feat: add project base path and template path handling in report generation
- Introduced PROJECT_BASE_PATH constant for consistent project directory reference. - Updated Reports class to require template_path for loading HTML templates. - Modified DataManagerRepository to pass the new template_path when generating reports.
This commit is contained in:
@@ -68,7 +68,7 @@ class Reports:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, reference_data: Any, current_data: Any, target_name: str, base_path: str | None = None
|
||||
self, reference_data: Any, current_data: Any, target_name: str, base_path: str | None = None, template_path: str | None = None
|
||||
) -> None:
|
||||
"""
|
||||
Initializes an instance of the AigReport class.
|
||||
@@ -87,6 +87,7 @@ class Reports:
|
||||
self.target_name = target_name
|
||||
self.set_color_options(primary_color='#0F4C81', secondary_color='#001E60')
|
||||
self.base_path = base_path
|
||||
self.template_path = template_path
|
||||
|
||||
def add_data_quality_section(self, columns: list[str] | None = None, run: bool = True) -> None:
|
||||
"""
|
||||
@@ -238,6 +239,9 @@ class Reports:
|
||||
if not self.base_path:
|
||||
raise ValueError('base_path is required to save all sections HTML')
|
||||
|
||||
if not self.template_path:
|
||||
raise ValueError('template_path is required to save all sections HTML')
|
||||
|
||||
# Ensure output directory exists
|
||||
output_dir = os.path.dirname(report_path)
|
||||
if output_dir and not os.path.exists(output_dir):
|
||||
@@ -248,7 +252,7 @@ class Reports:
|
||||
print(f"Base path: {self.base_path}")
|
||||
|
||||
# Load main HTML template
|
||||
main_html_path = os.path.join(self.base_path, 'header.html')
|
||||
main_html_path = os.path.join(self.template_path, 'header.html')
|
||||
main_html = load_html_from_file(main_html_path)
|
||||
|
||||
# Load content from data_drift.html, data_quality.html, and regression.html
|
||||
|
||||
Reference in New Issue
Block a user