diff --git a/packages/python/plotly/plotly/io/_sg_scraper.py b/packages/python/plotly/plotly/io/_sg_scraper.py index 3f514a57ca8..bec587d0ff6 100644 --- a/packages/python/plotly/plotly/io/_sg_scraper.py +++ b/packages/python/plotly/plotly/io/_sg_scraper.py @@ -42,13 +42,11 @@ def plotly_sg_scraper(block, block_vars, gallery_conf, **kwargs): Notes ----- - Add this function to the image scrapers + Add this function to the image scrapers """ - examples_dirs = gallery_conf["examples_dirs"] - if isinstance(examples_dirs, (list, tuple)): - examples_dirs = examples_dirs[0] - pngs = sorted(glob(os.path.join(examples_dirs, "*.png"))) - htmls = sorted(glob(os.path.join(examples_dirs, "*.html"))) + examples_dir = os.path.dirname(block_vars["src_file"]) + pngs = sorted(glob(os.path.join(examples_dir, "*.png"))) + htmls = sorted(glob(os.path.join(examples_dir, "*.html"))) image_path_iterator = block_vars["image_path_iterator"] image_names = list() seen = set() diff --git a/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py b/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py index 837943ab45b..63eb1e2fc65 100644 --- a/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py +++ b/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py @@ -52,7 +52,10 @@ def test_scraper(): tempdir = tempfile.mkdtemp() gallery_conf = {"src_dir": tempdir, "examples_dirs": here} names = iter(["0", "1", "2"]) - block_vars = {"image_path_iterator": names} + block_vars = { + "image_path_iterator": names, + "src_file": os.path.join(here, "plot_example.py"), + } execute_plotly_example() res = plotly_sg_scraper(block, block_vars, gallery_conf) shutil.rmtree(tempdir)