#241 Add macOS-specific fixes and tests for Kaleido compatibility#289
Conversation
Introduce macOS-specific arguments for Kaleido to address issue plotly#323. Add new tests to validate image generation (e.g., PNG, JPEG, SVG, PDF) on macOS, ensuring proper functionality. This improves cross-platform support and resolves inconsistencies in the Kaleido backend. issue: plotly#241
Cleaned up unnecessary blank lines and adjusted minor formatting issues to improve code readability and maintain consistency. No functional changes were made.
Introduced a macOS-specific `create_test_surface` function in `plotly_kaleido` and adjusted test-related imports in `plotly`. Ensures compatibility with macOS while keeping non-macOS logic intact.
Reorganized and added conditional imports to improve clarity and maintain consistent functionality across platforms. This ensures the required dependencies are properly included, particularly handling the macOS-specific conditions.
Reorganized imports in the tests module to improve clarity and maintain consistency. Non-standard library imports are now grouped separately, following a logical and readable structure.
|
Hi @joaquinbejar , Thank you for the PR! Interesting find!
I have only one commet regarding the PR. I see that you have added new unittests. Any particular reason why you chose to do that and not reuse the existing ones? Do you mind if I merge your tests with the previous ones ( I see you have added some nice extra asserts)? |
|
HI @andrei-ng Sure, that makes sense! I added the new tests because the failure reliably showed up with a Surface trace, while the existing tests use only Scatter. I wanted to prove the fix on the exact setup that was breaking. Feel totally free to merge my extra assertions into the existing test file (or replace it entirely) — I just separated them to keep the repro crystal-clear. Thanks for the review! |
OK, understood. Thank you for clarifying! I will remove the old unittests in favour of yours and merge it afterwards. |
- keep only the kaleido unittests added in PR #289 in favor of previous ones Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
- keep only the kaleido unittests added in PR #289 in favor of previous ones Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
- keep only the kaleido unittests added in PR #289 in favor of previous ones Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
Hi 👋,
This PR fixes #241 by omitting
--disable-gpuon macOS + arm64.spec.json:
{"format":"png","width":800,"height":600,"scale":1.0,"data":{"config":{},"data":[{"name":"Surface","type":"surface","x":[1.0,2.0,3.0],"y":[4.0,5.0,6.0],"z":[[1.0,2.0,3.0],[4.0,5.0,6.0],[7.0,8.0,9.0]]}],"layout":{}}}{"code": 0, "message": "Success", "result": null, "version": "0.2.1"} {"code":525,"message":"error creating static canvas/context for image server","pdfBgColor":null,"format":"png","result":null,"width":800,"height":600,"scale":1}so we never get any image data. The fix is still to omit
--disable-gpu, but I wanted to be precise in the description.What the patch changes
--disable-gpuflag is removed on macOS; everything else remains untouched.write_imagenow succeeds and the tests pass.Link to upstream discussion
plotly/Kaleido#323
Let me know if you’d prefer the macOS check to be
target_arch = "aarch64"only (i.e. keep the flag for Intel Macs). Happy to adjust!— Joaquín