Skip to content

Commit e52d8f3

Browse files
committed
🐛 get rid of absolute path (missed in #136)
- update tests - make altair plot path relative to qmd file
1 parent 1da57eb commit e52d8f3

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/vuegen/quarto_reportview.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def generate_report(self, output_dir: Optional[Path] = None) -> None:
8585
Will overwrite value set on initialization of QuartoReportView.
8686
"""
8787
if output_dir is not None:
88-
self.output_dir = Path(output_dir).resolve().absolute()
88+
self.output_dir = Path(output_dir).resolve()
8989

9090
self.report.logger.debug(
9191
f"Generating '{self.report_type}' report in directory: '{self.output_dir}'"
@@ -543,7 +543,7 @@ def _generate_plot_content(self, plot) -> List[str]:
543543
# ? should that be in the output folder
544544
static_plot_path = (
545545
Path(self.static_dir) / f"{plot.title.replace(' ', '_')}.png"
546-
).absolute()
546+
).resolve()
547547
self.report.logger.debug(f"Static plot path: {static_plot_path}")
548548
else:
549549
html_plot_file = (
@@ -569,7 +569,7 @@ def _generate_plot_content(self, plot) -> List[str]:
569569
plot_content.append(self._generate_plot_code(plot))
570570
if self.is_report_static:
571571
plot_content.append(
572-
f"""fig_altair.save("{static_plot_path.as_posix()}")\n```\n"""
572+
f"""fig_altair.save("{static_plot_path.relative_to(self.output_dir).as_posix()}")\n```\n"""
573573
)
574574
plot_content.append(self._generate_image_content(static_plot_path))
575575
else:

tests/report_examples/Basic_example_vuegen_demo_notebook/docx/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ plot_json_str = json.dumps(plot_json)
7272
# Create the plotly plot
7373
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
7474
75-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/docx/quarto_report/static/Multiline_Plot_Altair.png")
75+
fig_altair.save("static/Multiline_Plot_Altair.png")
7676
```
7777

7878
![](static/Multiline_Plot_Altair.png){fig-alt= width=90%}
@@ -143,7 +143,7 @@ plot_json_str = json.dumps(plot_json)
143143
# Create the plotly plot
144144
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
145145
146-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/docx/quarto_report/static/Saline_Metagenomics_Samples_Map_Altair.png")
146+
fig_altair.save("static/Saline_Metagenomics_Samples_Map_Altair.png")
147147
```
148148

149149
![](static/Saline_Metagenomics_Samples_Map_Altair.png){fig-alt= width=90%}

tests/report_examples/Basic_example_vuegen_demo_notebook/odt/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ plot_json_str = json.dumps(plot_json)
7272
# Create the plotly plot
7373
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
7474
75-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/odt/quarto_report/static/Multiline_Plot_Altair.png")
75+
fig_altair.save("static/Multiline_Plot_Altair.png")
7676
```
7777

7878
![](static/Multiline_Plot_Altair.png){fig-alt= width=90%}
@@ -143,7 +143,7 @@ plot_json_str = json.dumps(plot_json)
143143
# Create the plotly plot
144144
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
145145
146-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/odt/quarto_report/static/Saline_Metagenomics_Samples_Map_Altair.png")
146+
fig_altair.save("static/Saline_Metagenomics_Samples_Map_Altair.png")
147147
```
148148

149149
![](static/Saline_Metagenomics_Samples_Map_Altair.png){fig-alt= width=90%}

tests/report_examples/Basic_example_vuegen_demo_notebook/pdf/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ plot_json_str = json.dumps(plot_json)
8282
# Create the plotly plot
8383
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
8484
85-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/pdf/quarto_report/static/Multiline_Plot_Altair.png")
85+
fig_altair.save("static/Multiline_Plot_Altair.png")
8686
```
8787

8888
![](static/Multiline_Plot_Altair.png){fig-alt= width=90%}
@@ -153,7 +153,7 @@ plot_json_str = json.dumps(plot_json)
153153
# Create the plotly plot
154154
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
155155
156-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/pdf/quarto_report/static/Saline_Metagenomics_Samples_Map_Altair.png")
156+
fig_altair.save("static/Saline_Metagenomics_Samples_Map_Altair.png")
157157
```
158158

159159
![](static/Saline_Metagenomics_Samples_Map_Altair.png){fig-alt= width=90%}

tests/report_examples/Basic_example_vuegen_demo_notebook/pptx/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ plot_json_str = json.dumps(plot_json)
7373
# Create the plotly plot
7474
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
7575
76-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/pptx/quarto_report/static/Multiline_Plot_Altair.png")
76+
fig_altair.save("static/Multiline_Plot_Altair.png")
7777
```
7878

7979
![](static/Multiline_Plot_Altair.png){fig-alt= width=90%}
@@ -144,7 +144,7 @@ plot_json_str = json.dumps(plot_json)
144144
# Create the plotly plot
145145
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
146146
147-
fig_altair.save("/Users/heweb/Documents/repos/vuegen/tests/report_examples/Basic_example_vuegen_demo_notebook/pptx/quarto_report/static/Saline_Metagenomics_Samples_Map_Altair.png")
147+
fig_altair.save("static/Saline_Metagenomics_Samples_Map_Altair.png")
148148
```
149149

150150
![](static/Saline_Metagenomics_Samples_Map_Altair.png){fig-alt= width=90%}

0 commit comments

Comments
 (0)