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

build/pkgs/playwright: New package for screenshotting 3d graphics as png #38509

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

mkoeppe
Copy link

@mkoeppe mkoeppe commented Aug 14, 2024

After installing the package using sage -i playwright, we can now save threejs renders as png files. Upon first use, the chromium browser is installed automatically.

sage: g = polytopes.cube().plot()
sage: g.save('goo.png')

Relevant API:

The "webpdf" technology of nbconvert also currently uses playwright. https://github.com/jupyter/nbconvert/blob/main/pyproject.toml#L66

Discussion: https://groups.google.com/g/sage-devel/c/pj76chTb348

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Aug 14, 2024

Documentation preview for this PR (built with commit b320e53; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@mkoeppe mkoeppe added this to the sage-10.5 milestone Aug 15, 2024
@mkoeppe mkoeppe changed the title build/pkgs/playwright, playwright_chromium: New packages for screenshotting build/pkgs/playwright, playwright_chromium: New packages for screenshotting 3d graphics as png Aug 19, 2024
@kiwifb
Copy link
Member

kiwifb commented Aug 20, 2024

Yum python packages all the way. I was afraid of big bad nodejs. I have questions :)

  1. does it pop up a window while it is working or it is completely headless?
  2. can it use an installed browser or does it have to be a playwright packaged one? I can see why it could need a playwright packaged one, got a bit bitten by firefox snap in ubuntu 22.04 not working with selenium.

@mkoeppe
Copy link
Author

mkoeppe commented Aug 20, 2024

  • does it pop up a window while it is working or it is completely headless?

Here on macOS, I didn't see a window pop up. Haven't tested on Linux.

  • can it use an installed browser or does it have to be a playwright packaged one? I can see why it could need a playwright packaged one, got a bit bitten by firefox snap in ubuntu 22.04 not working with selenium.

I haven't seen any options to use browsers other than the ones it is providing. I'd also be quite skeptical about any solution that promised doing that.

@mkoeppe
Copy link
Author

mkoeppe commented Aug 20, 2024

nbconvert installs chromium at runtime.
https://github.com/jupyter/nbconvert/blob/55ff3e9ac1d892165bfb4352379672019b66ddff/nbconvert/exporters/webpdf.py#L86

We probably should do the same instead of my current solution of using the script package playwright_chromium

@mkoeppe
Copy link
Author

mkoeppe commented Aug 29, 2024

nbconvert installs chromium at runtime. https://github.com/jupyter/nbconvert/blob/55ff3e9ac1d892165bfb4352379672019b66ddff/nbconvert/exporters/webpdf.py#L86

We probably should do the same

Done now

@mkoeppe mkoeppe changed the title build/pkgs/playwright, playwright_chromium: New packages for screenshotting 3d graphics as png build/pkgs/playwright: New package for screenshotting 3d graphics as png Aug 29, 2024
@mkoeppe
Copy link
Author

mkoeppe commented Aug 29, 2024

Doesn't show in HTML documentation

@mkoeppe mkoeppe marked this pull request as draft August 29, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save threejs graphics using a screenshotting tool (playwright, selenium, ...)
2 participants