plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
MIT License
374 stars 36 forks source link

Likely Javascript Error #225

Open ayjayt opened 2 hours ago

ayjayt commented 2 hours ago

I also have a daily GHA failing this AM, due to picking up Kaleido 0.4.1. I've "fixed" it by pinning to 0.2.1.

File /opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotly/basedatatypes.py:3835, in BaseFigure.write_image(self, *args, **kwargs)
   3775 """
   3776 Convert a figure to a static image and write it to a file or writeable
   3777 object
   (...)
   3831 None
   3832 """
   3833 import plotly.io as pio
-> 3835 return pio.write_image(self, *args, **kwargs)

File /opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotly/io/_kaleido.py:296, in write_image(fig, file, format, scale, width, height, validate, engine)
    286         raise ValueError(
    287             """
    288 The 'file' argument '{file}' is not a string, pathlib.Path object, or file descriptor.
   (...)
    291             )
    292         )
    293     else:
    294         # We previously succeeded in interpreting `file` as a pathlib object.
    295         # Now we can use `write_bytes()`.
--> 296         path.write_bytes(img_data)

File /opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/pathlib.py:[106](https://github.com/hudcostreets/nj-crashes/actions/runs/11858949522/job/33050751493#step:19:107)6, in Path.write_bytes(self, data)
   1062 """
   1063 Open the file in bytes mode, write to it, and close the file.
   1064 """
   1065 # type-check for the buffer interface before truncating the file
-> 1066 view = memoryview(data)
   1067 with self.open(mode='wb') as f:
   1068     return f.write(view)

TypeError: memoryview: a bytes-like object is required, not 'NoneType'

Apologies if this should be its own issue, the error msg looks slightly similar to the last one above (something is None where it shouldn't be).

Originally posted by @ryan-williams in #223

ayjayt commented 2 hours ago

Hi @ryan-williams, sorry for your error.

The other issue is likely a matter of installing or running chrome/chromium (we no longer include it by default- its huge and updates too frequently), but I think your error may be different.

If you'd like me to help you debug it and/or send a fix to Kaleido, please set env var KALEIDO_DEBUG=true and run it again- although looking at your GHA, it may very well be that you need to add a line about installing chrome/ium.

I'm not 100% sure what the best way to install chrome is through GHA- we're doing it through snap (apt install) but there may be a faster method by curling from a google server.