Skip to content

Commit c6d088e

Browse files
committed
🐛 Fix code to load images from URLs in streamlit reports
1 parent c4a58e8 commit c6d088e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/vuegen/streamlit_reportview.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,11 @@ def _generate_plot_content(self, plot) -> List[str]:
648648
# Add content for the different plot types
649649
try:
650650
if plot.plot_type == r.PlotType.STATIC:
651-
# Use .as_posix() only if the plot_file_path is a Path object
652-
# so, if the file_path is a URL, it will not cause an error
653-
plot_file_path = (
654-
plot.file_path.as_posix()
655-
if isinstance(plot.file_path, Path)
656-
else plot.file_path
657-
)
651+
# If the file path is a URL, keep the file path as is
652+
if is_url(plot.file_path):
653+
plot_file_path = plot.file_path
654+
else: # If it's a local file
655+
plot_file_path = get_relative_file_path(plot.file_path).as_posix()
658656
plot_content.append(
659657
f"\nst.image('{plot_file_path}', "
660658
f" caption='{plot.caption}', use_column_width=True)\n"

0 commit comments

Comments
 (0)