Skip to content

Commit 402e842

Browse files
committed
🚧 make outputdir option for streamlit optional, move to init
- outputdir only really makes sense for report generation, not execution: In the current implementation the report has to execute from the path it was generated from - should the static dir be change upon change of section_dir?
1 parent 11e90e0 commit 402e842

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/vuegen/report_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ def get_report(
108108
report_type=report_type,
109109
streamlit_autorun=streamlit_autorun,
110110
static_dir=static_files_dir,
111+
sections_dir=sections_dir,
111112
)
112-
st_report.generate_report(output_dir=sections_dir)
113-
st_report.run_report(output_dir=sections_dir)
113+
st_report.generate_report()
114+
st_report.run_report()
114115
else:
115116
# Check if Quarto is installed
116117
if shutil.which("quarto") is None and not hasattr(

src/vuegen/streamlit_reportview.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(
5050
report_type: r.ReportType,
5151
streamlit_autorun: bool = False,
5252
static_dir: str = STATIC_FILES_DIR,
53+
sections_dir: str = SECTIONS_DIR,
5354
):
5455
"""Initialize ReportView with the report and report type.
5556
@@ -86,8 +87,9 @@ def __init__(
8687
}
8788

8889
self.static_dir = static_dir
90+
self.section_dir = sections_dir
8991

90-
def generate_report(self, output_dir: str = SECTIONS_DIR) -> None:
92+
def generate_report(self, output_dir: str = None) -> None:
9193
"""
9294
Generates the Streamlit report and creates Python files for each section
9395
and its subsections and plots.
@@ -98,6 +100,10 @@ def generate_report(self, output_dir: str = SECTIONS_DIR) -> None:
98100
The folder where the generated report files will be saved
99101
(default is SECTIONS_DIR).
100102
"""
103+
if output_dir is not None:
104+
# ? does this imply changes to the static dir
105+
self.section_dir = Path(output_dir).resolve()
106+
output_dir = Path(self.section_dir)
101107
self.report.logger.debug(
102108
"Generating '%s' report in directory: '%s'", self.report_type, output_dir
103109
)
@@ -282,7 +288,7 @@ def generate_report(self, output_dir: str = SECTIONS_DIR) -> None:
282288
)
283289
raise
284290

285-
def run_report(self, output_dir: str = SECTIONS_DIR) -> None:
291+
def run_report(self, output_dir: str = None) -> None:
286292
"""
287293
Runs the generated Streamlit report.
288294
@@ -291,6 +297,9 @@ def run_report(self, output_dir: str = SECTIONS_DIR) -> None:
291297
output_dir : str, optional
292298
The folder where the report was generated (default is SECTIONS_DIR).
293299
"""
300+
if output_dir is not None:
301+
self.report.logger.warning("The output_dir parameter is deprecated.")
302+
output_dir = Path(self.section_dir)
294303
if self.streamlit_autorun:
295304
self.report.logger.info(
296305
"Running '%s' %s report.", self.report.title, self.report_type

0 commit comments

Comments
 (0)