-
Notifications
You must be signed in to change notification settings - Fork 38
Customizing Chromium Flags
Kaleido is based on chromium, and it can be configured by the various chromium command line flags (https://peter.sh/experiments/chromium-command-line-switches/). Our aim is to choose a default set of flags that will work in as many contexts as possible, but there may be cases where you need to customize these flags to get things working in a specific context (e.g. https://github.com/plotly/Kaleido/issues/45).
As of version 0.1.0, the default chromium flags used by a scope can be determined by examining the chromium_args
property of the scope.
from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope()
scope.chromium_args
('--disable-gpu', '--allow-file-access-from-files', '--disable-breakpad', '--disable-dev-shm-usage', '--no-sandbox')
You can override these flags by providing a tuple of flags as the chromium_args
constructor argument...
from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope(chromium_args=("--no-sandbox",))
scope.chromium_args
('--no-sandbox',)
or by assigning a new tuple of flags to the chromium_args
attribute of a scope that has already been constructed.
from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope()
scope.chromium_args = ("--no-sandbox",)
scope.chromium_args
('--no-sandbox',)
You can use attribute assignment method to add a flag to the existing defaults
from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope()
scope.chromium_args += ("--single-process",)
scope.chromium_args
('--disable-gpu', '--allow-file-access-from-files', '--disable-breakpad', '--disable-dev-shm-usage', '--no-sandbox', '--single-process')
Or you can use it to remove a flag from the existing defaults
from kaleido.scopes.plotly import PlotlyScope
scope = PlotlyScope()
scope.chromium_args = tuple([arg for arg in scope.chromium_args if arg != "--no-sandbox"])
scope.chromium_args
('--disable-gpu', '--allow-file-access-from-files', '--disable-breakpad', '--disable-dev-shm-usage')
You can use the attribute assignment method to customize the chromium arguments of the default Kaleido Scope
that is used by plotly.py.
For example, to add the --single-process
flag to this set of default flags
import plotly.io as pio
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')