Skip to content
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

Issues with parenthesis in kaleido installation path #209

Open
mmarras opened this issue Oct 23, 2024 · 12 comments
Open

Issues with parenthesis in kaleido installation path #209

mmarras opened this issue Oct 23, 2024 · 12 comments
Assignees
Labels
active bug something broken P2 needed for current cycle TNG related to next-generation architecture

Comments

@mmarras
Copy link

mmarras commented Oct 23, 2024

Hello,

I am using plotly's fig.write_image() (plotly 5.24.1) [fig.write_html() works fine]

I am on a work machine, windows 10 enterprise and am boxed in and can only install to my user folder, so that's where I have miniconda installed. However my user folder has a parenthesis in it which likely clashes with some internal shell/batch scripting. Changing the location of the output file to "c:\temp" is still promting the same error.

'c:\Users\MArras' is not recognized as an internal or external command,
operable program or batch file.

Note here that my user folder is: c:\Users\MArras(NL)\ and not c:\Users\MArras

here is the full error dump:

---------------------------------------------------------------------------
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File c:\Users\MArras(NL)\datamore\misc\intensity_pressure\intensity_pressure.py:91
     77 fig = plot_results_with_buttons(
     78     data_dict,
     79     image=crop_image_by_vector(roi_color_full_img, mask),
   (...)
     86     calib_min="5 bar",
     87 )
     88 # Show the figure
     89 # fig.show()
     90 # fig.write_html(pdf.parent / f"{pdf.stem}.html")
---> 91 fig.write_image(Path(r"C:\temp") / f"{pdf.stem}.png")

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\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 c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\plotly\io\_kaleido.py:266, in write_image(fig, file, format, scale, width, height, validate, engine)
    250             raise ValueError(
    251                 """
    252 Cannot infer image type from output path '{file}'.
   (...)
    260                 )
    261             )
    263     # Request image
    264     # -------------
    265     # Do this first so we don't create a file if image conversion fails
--> 266     img_data = to_image(
    267         fig,
    268         format=format,
    269         scale=scale,
    270         width=width,
    271         height=height,
    272         validate=validate,
    273         engine=engine,
    274     )
    276     # Open file
    277     # ---------
    278     if path is None:
    279         # We previously failed to make sense of `file` as a pathlib object.
    280         # Attempt to write to `file` as an open file descriptor.

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\plotly\io\_kaleido.py:143, in to_image(fig, format, width, height, scale, validate, engine)
    140 # Validate figure
    141 # ---------------
    142 fig_dict = validate_coerce_fig_to_dict(fig, validate)
--> 143 img_bytes = scope.transform(
    144     fig_dict, format=format, width=width, height=height, scale=scale
    145 )
    147 return img_bytes

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\kaleido\scopes\plotly.py:153, in PlotlyScope.transform(self, figure, format, width, height, scale)
    142     raise ValueError(
    143         "Invalid format '{original_format}'.\n"
    144         "    Supported formats: {supported_formats_str}"
   (...)
    148         )
    149     )
    151 # Transform in using _perform_transform rather than superclass so we can access the full
    152 # response dict, including error codes.
--> 153 response = self._perform_transform(
    154     figure, format=format, width=width, height=height, scale=scale
    155 )
    157 # Check for export error, later can customize error messages for plotly Python users
    158 code = response.get("code", 0)

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\kaleido\scopes\base.py:293, in BaseScope._perform_transform(self, data, **kwargs)
    284 """
    285 Transform input data using the current scope, returning dict response with error code
    286 whether successful or not.
   (...)
    290 :return: Dict of response from Kaleido executable, whether successful or not
    291 """
    292 # Ensure that kaleido subprocess is running
--> 293 self._ensure_kaleido()
    295 # Perform export
    296 export_spec = self._json_dumps(dict(kwargs, data=data)).encode('utf-8')

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\kaleido\scopes\base.py:198, in BaseScope._ensure_kaleido(self)
    193 if not startup_response_string:
    194     message = (
    195         "Failed to start Kaleido subprocess. Error stream:\n\n" +
    196         self._get_decoded_std_error()
    197     )
--> 198     raise ValueError(message)
    199 else:
    200     startup_response = json.loads(startup_response_string)

ValueError: Failed to start Kaleido subprocess. Error stream:

'c:\Users\MArras' is not recognized as an internal or external command,
operable program or batch file.
@ayjayt
Copy link
Collaborator

ayjayt commented Oct 24, 2024

Hi @mmarras

Will you do me a favor and re-install kaleido with
pip install --pre kaleido

This will install the yet-to-be-release rewrite of kaleido, and this problem may disappear. Fair warning, it is alpha so it may throw a different error.

Either way I think I can help get this resolved today. Thanks!

@mmarras
Copy link
Author

mmarras commented Oct 24, 2024

Different error indeed:

RuntimeError: Kaleido doesn't support asyncio + the old kaleido API yet.

@ayjayt
Copy link
Collaborator

ayjayt commented Oct 24, 2024

That is very useful, thank you, I'll get back to you in a couple hours

@gvwilson gvwilson added bug something broken P2 needed for current cycle TNG related to next-generation architecture labels Oct 24, 2024
@ayjayt
Copy link
Collaborator

ayjayt commented Oct 24, 2024

@mmarras for context, plotly had to rewrite kaleido because the original strategy was no longer tenable, and I just had you install the new release.

it's in internal testing right now-

I've just fixed the

RuntimeError: Kaleido doesn't support asyncio + the old kaleido API yet.

but I can't speak for what might happen afterwards..

The rewrite requires chrome or chromium installed on the system- the old version bundled it but its huge now and that doesn't work. (let me know if that's a problem)

You can install the development branch directly with:
python3 -m pip install git+https://github.com/plotly/kaleido@devtools/main#subdirectory=src/py

or if you don't mind waiting, I will @ you when a new --pre is pushed to pypi!

Thank you so much for your patience and help!

@mmarras
Copy link
Author

mmarras commented Oct 24, 2024

No more error message, but also no image generation. Keeps being busy indefinitely. Chrome 70 is on the system as a managed installation.

@ayjayt
Copy link
Collaborator

ayjayt commented Oct 24, 2024

Hi @mmarras, I really apologize about all this...

I've submitted another commit to that branch to allow verbose (very) debugging output, and it can be enabled if the image is written as:

from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope(debug=True)
with open(str(Path(r"C:\temp") / f"{pdf.stem}.png)"), "wb") as f:
         f.write(scope.transform(fig, format="png"))

I copied your original post to make that.

I would need that debugging output to help further, and any additional information about the system.

Thank you so much,

@mmarras
Copy link
Author

mmarras commented Oct 31, 2024

Hi sorry, for getting back to this just now.

The folders (browser_path, user_data_dir) are correct, accessible and contain data but it stops right there after 2s of processing it just hangs.

Got running loop, threading
Calling thread start
Calling to_image in thread
DEBUG REPORT:
BROWSER_PATH: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
USER_DATA_DIR: C:\Users\MARRAS~1\AppData\Local\Temp\tmpz65us1nn
We are in a selector event loop, use loop_hack
read_jsons (blocking):
write_json:
write_json: {"id": 0, "method": "Target.getTargets"}
Starting watchdog
wrote_json.
{"id":0,"result":{"targetInfos":[]}}

@ayjayt
Copy link
Collaborator

ayjayt commented Oct 31, 2024

Hi @mmarras, there are quite a few bugfixes and updates coming out probably EOD today (maybe tomorrow morning), so your issue might get fixed there... also coming with improved debug. I'll ping you when it's ready!

@ayjayt
Copy link
Collaborator

ayjayt commented Nov 4, 2024

Hi @mmarras, so there is a new release candidate on pypi for kaleido. (must pass --pre to pip to install it)

It includes several bug fixes, several hang fixes, and the option for increasing debug output.

It is currently going through rounds of alpha testing internally, and I'm sure will be even more stable once that is finished.

I appreciate your patience on these issues!

@ayjayt
Copy link
Collaborator

ayjayt commented Nov 15, 2024

New version is now main version- many bogs were squashed since this issue started. I wonder if there is an update?

@gvwilson
Copy link
Collaborator

@mmarras can you please let us know if v1.0.0rc0 fixes your problems?

@mmarras
Copy link
Author

mmarras commented Dec 7, 2024

Successfully installed async-timeout-5.0.1 choreographer-0.99.7 kaleido-1.0.0rc0 simplejson-3.19.3

I can report error persist, i.e. still hangs idefinitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active bug something broken P2 needed for current cycle TNG related to next-generation architecture
Projects
None yet
Development

No branches or pull requests

3 participants