Skip to content

Kaleido 0.4 image export fails #223

@johannesloibl

Description

@johannesloibl

Hey,

just noticed some fails in my CICD that started occurring with the recent 0.4 version.
<0.4 works fine.

This is what i'm getting as error:

File "/home/runner/work/pharaoh-dev/pharaoh-dev/tests/unit/_example_assets/holoviews_plot.py", line 10, in <module>
    hv.save(model, filename="heatmap_holo_plotly.html")
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/pharaoh/assetlib/patches/_holoviews.py", line 84, in patched_hv_save
    plotly_fig.write_html(filename, **kwargs)
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/plotly/basedatatypes.py", line 3714, in write_html
    return pio.write_html(self, *args, **kwargs)
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/pharaoh/assetlib/patches/_plotly.py", line 156, in patched_px_write_html
    patched_px_write_image(**_kwargs)
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/pharaoh/assetlib/patches/_plotly.py", line 127, in patched_px_write_image
    vanilla_px_write_image(**params)
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 266, in write_image
    img_data = to_image(
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 143, in to_image
    img_bytes = scope.transform(
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/kaleido/scopes/plotly.py", line 233, in transform
    img = kaleido.to_image_block(spec, Path(self._tempfile.name).absolute(), self._topojson, self._mapbox_access_token, debug=debug, tmp_path=self._tmp_path)
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/kaleido/__init__.py", line 43, in to_image_block
    return asyncio.run(to_image(spec, f, topojson, mapbox_token, debug=debug, tmp_path=tmp_path))
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/runner/.local/share/hatch/env/virtual/pharaoh-report/3dSDsPqB/all.py3.10/lib/python3.10/site-packages/kaleido/__init__.py", line 129, in to_image
    response = await tab.send_command("Runtime.callFunctionOn", params=params)
choreographer.browser.BrowserClosedError: Command not completed because browser closed.

Python:
Fails for 3.9 to 3.12

System:

Current runner version: '2.320.0'
Operating System
  Ubuntu
  [2](https://github.com/Infineon/pharaoh-dev/actions/runs/11858025206/job/33048248018#step:1:2)2.04.5
  LTS
Runner Image
  Image: ubuntu-22.04
  Version: 20241112.1.0
  Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20241112.1/images/ubuntu/Ubuntu2204-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20241112.1
Runner Image Provisioner
  2.0.[3](https://github.com/Infineon/pharaoh-dev/actions/runs/11858025206/job/33048248018#step:1:3)84.1

I also have a Gitlab CI running, where this error also occurs but in a different form (also started with 0.4, so i assume it's related):

from plotly.io import to_json, to_image, write_image, write_html
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "/builds/global_projects/.../.hatch_data/env/virtual/all.py3.10/lib/python3.10/site-packages/_plotly_utils/importers.py", line 36, in __getattr__
    class_module = importlib.import_module(rel_module, parent_name)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/builds/global_projects/.../.hatch_data/env/virtual/all.py3.10/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 10, in <module>
    scope = PlotlyScope()
  File "/builds/global_projects/.../.hatch_data/env/virtual/all.py3.10/lib/python3.10/site-packages/kaleido/scopes/plotly.py", line 64, in __init__
    elif "snap" in path:
TypeError: argument of type 'NoneType' is not iterable

Metadata

Metadata

Assignees

Labels

TNGrelated to next-generation architecture

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions