Skip to content

Try using Kaleido v1 for image tests #7412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

emilykl
Copy link
Contributor

@emilykl emilykl commented Apr 30, 2025

No description provided.

@gvwilson gvwilson added P2 considered for next cycle infrastructure build process etc. labels May 8, 2025
@ayjayt
Copy link
Contributor

ayjayt commented May 29, 2025

Hi @emilykl, any interest in assigning me as well?

@emilykl
Copy link
Contributor Author

emilykl commented May 29, 2025

@ayjayt You're welcome to try on your own branch if you like -- I believe this task is blocked by plotly/plotly.py#5207 though which I'm still testing

@emilykl
Copy link
Contributor Author

emilykl commented May 30, 2025

@ayjayt There are two figures which are failing consistently with an error in Kaleido v1 -- could you investigate?

These are the two figures:

gl3d_streamtube_reversed_ranges
mathjax

(There are a few others which are failing intermittently but I think that's due to instability in the pipeline, not anything to do with Kaleido)

Here is an archive containing:

  1. The JSON figure representations for the failing figures
  2. A script which attempts to generate an image from each, and prints the traceback on failure.

failing_figures_kaleido_v1.zip

You'll need to pip install a few things in your environment to run the script:

python -m pip install "git+https://github.com/plotly/plotly.py.git@6837831"
python -m pip install "git+https://github.com/plotly/[email protected]#subdirectory=src/py"
python -m pip install numpy

Below is the output generated by running python generate_images.py from inside the root directory of the archive:

Error output
(make_baseline) (base) ekl@Emilys-MacBook-Air-2 failing_figures_kaleido_v1 % python generate_images.py
=============
=== Failed to generate image for gl3d_streamtube_reversed_ranges ===
=============
Traceback (most recent call last):
  File "generate_images.py", line 32, in <module>
    pio.write_image(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 509, in write_image
    img_data = to_image(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 379, in to_image
    img_bytes = kaleido.calc_fig_sync(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 145, in calc_fig_sync
    return _async_thread_run(calc_fig, args=args, kwargs=kwargs)
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 138, in _async_thread_run
    raise res
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 129, in run
    q.put(asyncio.run(func(*args, **kwargs)))
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 55, in calc_fig
    return await k.calc_fig(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/kaleido.py", line 319, in calc_fig
    spec, full_path = build_fig_spec(fig, path, opts)
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/_fig_tools.py", line 144, in build_fig_spec
    name = _next_filename(directory, prefix, ext)
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/_fig_tools.py", line 94, in _next_filename
    re_number = re.compile(r"^" + prefix + r"-(\d+)\." + ext + r"$")
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 598, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range _-2 at position 94
=============
=============
=== Failed to generate image for mathjax ===
=============
Traceback (most recent call last):
  File "generate_images.py", line 32, in <module>
    pio.write_image(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 509, in write_image
    img_data = to_image(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 379, in to_image
    img_bytes = kaleido.calc_fig_sync(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 145, in calc_fig_sync
    return _async_thread_run(calc_fig, args=args, kwargs=kwargs)
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 138, in _async_thread_run
    raise res
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 129, in run
    q.put(asyncio.run(func(*args, **kwargs)))
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/__init__.py", line 55, in calc_fig
    return await k.calc_fig(
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/kaleido.py", line 319, in calc_fig
    spec, full_path = build_fig_spec(fig, path, opts)
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/_fig_tools.py", line 144, in build_fig_spec
    name = _next_filename(directory, prefix, ext)
  File "/Users/ekl/code/plotly.js/venv/make_baseline/lib/python3.8/site-packages/kaleido/_fig_tools.py", line 94, in _next_filename
    re_number = re.compile(r"^" + prefix + r"-(\d+)\." + ext + r"$")
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 525, in _parse
    code = _escape(source, this, state)
  File "/Users/ekl/.local/share/uv/python/cpython-3.8.20-macos-aarch64-none/lib/python3.8/sre_parse.py", line 426, in _escape
    raise source.error("bad escape %s" % escape, len(escape))
re.error: bad escape \h at position 3
=============

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure build process etc. P2 considered for next cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants