Skip to content

Commit 4bf5f33

Browse files
committed
🐛 Fix: add try-except block to solve rel path error for static plots on CI tests
1 parent 8a4e393 commit 4bf5f33

File tree

2 files changed

+191
-1
lines changed

2 files changed

+191
-1
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
report:
2+
title: Basic Example Vuegen Demo Notebook
3+
description: 'A general description of the report.
4+
5+
'
6+
graphical_abstract: ''
7+
logo: ''
8+
sections:
9+
- title: ''
10+
description: Components added to homepage.
11+
components:
12+
- title: Description
13+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/description.md
14+
description: ''
15+
caption: ''
16+
component_type: markdown
17+
- title: Plots
18+
description: ''
19+
subsections:
20+
- title: Interactive Plots
21+
description: 'Optional description for section.
22+
23+
'
24+
components:
25+
- title: Top Species Plot By Biome Plotly
26+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/1_top_species_plot_by_biome_plotly.json
27+
description: ''
28+
caption: ''
29+
component_type: plot
30+
plot_type: plotly
31+
- title: Multiline Plot Altair
32+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/2_multiline_plot_altair.json
33+
description: ''
34+
caption: ''
35+
component_type: plot
36+
plot_type: altair
37+
- title: Pie Plot Countries Plotly
38+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/3_pie_plot_countries_plotly.json
39+
description: ''
40+
caption: ''
41+
component_type: plot
42+
plot_type: plotly
43+
- title: Pie Plots Biomes Plotly
44+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/4_pie_plots_biomes_plotly.json
45+
description: ''
46+
caption: ''
47+
component_type: plot
48+
plot_type: plotly
49+
- title: Saline Metagenomics Samples Map Altair
50+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/5_saline_metagenomics_samples_map_altair.json
51+
description: ''
52+
caption: ''
53+
component_type: plot
54+
plot_type: altair
55+
- title: Plotly Plot R
56+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/6_plotly_plot_R.json
57+
description: ''
58+
caption: ''
59+
component_type: plot
60+
plot_type: plotly
61+
- title: Description
62+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/description.md
63+
description: ''
64+
caption: ''
65+
component_type: markdown
66+
- title: Static Plots
67+
description: ''
68+
components:
69+
- title: Number Samples Per Study
70+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/1_number_samples_per_study.png
71+
description: ''
72+
caption: ''
73+
component_type: plot
74+
plot_type: static
75+
- title: Animal Metagenomics Samples Map
76+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/2_animal_metagenomics_samples_map.png
77+
description: ''
78+
caption: ''
79+
component_type: plot
80+
plot_type: static
81+
- title: Alpha Diversity Host Associated Samples
82+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/3_alpha_diversity_host_associated_samples.png
83+
description: ''
84+
caption: ''
85+
component_type: plot
86+
plot_type: static
87+
components: []
88+
- title: Dataframes
89+
description: ''
90+
subsections:
91+
- title: All Formats
92+
description: ''
93+
components:
94+
- title: Phyla Correlation Network Csv
95+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/1_phyla_correlation_network_csv.csv
96+
description: ''
97+
caption: ''
98+
component_type: dataframe
99+
file_format: csv
100+
delimiter: ','
101+
- title: Abundance Table Example Xls
102+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/2_abundance_table_example_xls.xls
103+
description: ''
104+
caption: ''
105+
component_type: dataframe
106+
file_format: xls
107+
- title: Sample Info Example Txt
108+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/3_sample_info_example_txt.txt
109+
description: ''
110+
caption: ''
111+
component_type: dataframe
112+
file_format: txt
113+
delimiter: \t
114+
- title: Sample Info Example Parquet
115+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/4_sample_info_example_parquet.parquet
116+
description: ''
117+
caption: ''
118+
component_type: dataframe
119+
file_format: parquet
120+
components: []
121+
- title: Networks
122+
description: ''
123+
subsections:
124+
- title: Interactive Networks
125+
description: 'Optional description for subsection.
126+
127+
'
128+
components:
129+
- title: Man Example
130+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/3_Networks/1_Interactive_networks/1_man_example.graphml
131+
description: ''
132+
caption: ''
133+
component_type: plot
134+
plot_type: interactive_network
135+
- title: Description
136+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/3_Networks/1_Interactive_networks/description.md
137+
description: ''
138+
caption: ''
139+
component_type: markdown
140+
- title: Static Networks
141+
description: ''
142+
components:
143+
- title: Phyla Correlation Network
144+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/3_Networks/2_Static_networks/1_phyla_correlation_network.png
145+
description: ''
146+
caption: ''
147+
component_type: plot
148+
plot_type: static
149+
components: []
150+
- title: Html
151+
description: ''
152+
subsections:
153+
- title: All Html
154+
description: ''
155+
components:
156+
- title: Plot
157+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/1_plot.html
158+
description: ''
159+
caption: ''
160+
component_type: html
161+
- title: Ckg Network
162+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/2_ckg_network.html
163+
description: ''
164+
caption: ''
165+
component_type: plot
166+
plot_type: interactive_network
167+
- title: Multiqc Report
168+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/3_multiqc_report.html
169+
description: ''
170+
caption: ''
171+
component_type: html
172+
components: []
173+
- title: Markdown
174+
description: ''
175+
subsections:
176+
- title: All Markdown
177+
description: ''
178+
components:
179+
- title: Readme
180+
file_path: /Users/asaru/Documents/DTU/MoNA/VueGen/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/5_Markdown/1_All_markdown/README.md
181+
description: ''
182+
caption: ''
183+
component_type: markdown
184+
components: []

src/vuegen/streamlit_reportview.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,14 @@ def _generate_plot_content(self, plot) -> List[str]:
585585
# Add content for the different plot types
586586
try:
587587
if plot.plot_type == r.PlotType.STATIC:
588+
try:
589+
plot_rel_path = Path(plot.file_path).relative_to(Path.cwd())
590+
except ValueError:
591+
plot_rel_path = (
592+
Path(plot.file_path).resolve().relative_to(Path.cwd().resolve())
593+
)
588594
plot_content.append(
589-
f"\nst.image('{Path(plot.file_path).relative_to(Path.cwd()).as_posix()}', caption='{plot.caption}', use_column_width=True)\n"
595+
f"\nst.image('{plot_rel_path.as_posix()}', caption='{plot.caption}', use_column_width=True)\n"
590596
)
591597
elif plot.plot_type == r.PlotType.PLOTLY:
592598
plot_content.append(self._generate_plot_code(plot))

0 commit comments

Comments
 (0)