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

Add support for custom chromium commandline arguments #53

Merged
merged 5 commits into from
Oct 23, 2020

Conversation

jonmmease
Copy link
Collaborator

Closes #45

This PR adds support for fully customizing the chromium flags used by the kaleido process. It also adds --disable-dev-shm-usage to the list of default arguments. This is helpful in certain docker configurations with limited /dev/shm size and it is also the default for puppeteer.

The default arguments are returned by the default_chromium_args class method. e.g.

from kaleido.scopes.plotly import PlotlyScope
PlotlyScope.default_chromium_args()
('--disable-gpu',
 '--allow-file-access-from-files',
 '--disable-breakpad',
 '--disable-dev-shm-usage',
 '--no-sandbox')

A custom tuple/list of arguments can be provided using the chromium_args argument in the scope constructor, and a tuple of the active chromium arguments can be accessed using the chromium_args property

from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope(chromium_args=["--disable-gpu", "--single-process"])
scope.chromium_args
('--disable-gpu', '--single-process')

For an already constructed scope (as in the case of the scope that plotly.py constructs at plotly.io.kaleido.scope), the arguments can be set using the property setter. This will automatically shut down any running kaleido process so that the arguments are in
effect the next time a transform is applied.

For example, to add the --single-process argument to the list of defaults for use by plotly.py:

import plotly.io as pio
pio.kaleido.scope.chromium_args = pio.kaleido.scope.chromium_args + ("--single-process",)
pio.kaleido.scope.chromium_args
('--disable-gpu',
 '--allow-file-access-from-files',
 '--disable-breakpad',
 '--disable-dev-shm-usage',
 '--no-sandbox',
 '--single-process')

cc @aschmied

@jonmmease jonmmease added this to the 0.1.0 milestone Oct 2, 2020
@aschmied
Copy link

🎉

@peterli110
Copy link

how to use this branch with pipenv?
I've tried with kaleido = {git = "https://github.com/plotly/Kaleido.git", editable = true, ref = "chromium_args", subdirectory = "repos/kaleido/py"}
but it throws an error on setup.py:line 26 that _version.py is not exist

@jonmmease jonmmease merged commit 32d2b03 into master Oct 23, 2020
@jonmmease
Copy link
Collaborator Author

There isn't a convenient way to install kaleido from a branch due to the need to compile Chromium. I'll publish a new alpha version with these changes to PyPI later today.

@jonmmease jonmmease deleted the chromium_args branch October 23, 2020 09:14
@jonmmease
Copy link
Collaborator Author

These changes are now released in 0.1.0a3 on PyPI (https://pypi.org/project/kaleido/0.1.0a3/). The final release probably won't happen until early November, so please let us know if you run any (especially new) issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support passing arbitrary Chromium arguments to the kaleido binary
3 participants