Configuration Options

class yarnspawner.YarnSpawner(**kwargs)

A spawner for starting singleuser instances in a YARN container.

config c.YarnSpawner.args = List('')

Extra arguments to be passed to the single-user server.

Some spawners allow shell-style expansion here, allowing you to use environment variables here. Most, including the default, do not. Consult the documentation for your spawner to verify!

config c.YarnSpawner.cmd = Command('')

The command used for starting the singleuser server.

config c.YarnSpawner.consecutive_failure_limit = Int(0)

Maximum number of consecutive failures to allow before shutting down JupyterHub.

This helps JupyterHub recover from a certain class of problem preventing launch in contexts where the Hub is automatically restarted (e.g. systemd, docker, kubernetes).

A limit of 0 means no limit and consecutive failures will not be tracked.

config c.YarnSpawner.cpu_guarantee = Float(None)

Minimum number of cpu-cores a single-user notebook server is guaranteed to have available.

If this value is set to 0.5, allows use of 50% of one CPU. If this value is set to 2, allows use of up to 2 CPUs.

This is a configuration setting. Your spawner must implement support for the limit to work. The default spawner, LocalProcessSpawner, does not implement this support. A custom spawner must add support for this setting for it to be enforced.

config c.YarnSpawner.cpu_limit = Int(1)

Maximum number of cpu-cores a singleuser notebook server is allowed to use. Unlike other spawners, this must be an integer amount >= 1.

config c.YarnSpawner.debug = Bool(False)

Enable debug-logging of the single-user server

config c.YarnSpawner.default_url = Unicode('')

The URL the single-user server should start in.

{username} will be expanded to the user’s username

Example uses:

  • You can set notebook_dir to / and default_url to /tree/home/{username} to allow people to navigate the whole filesystem from their notebook server, but still start in their home directory.
  • Start with /notebooks instead of /tree if default_url points to a notebook instead of a directory.
  • You can set this to /lab to have JupyterLab start by default, rather than Jupyter Notebook.
config c.YarnSpawner.disable_user_config = Bool(False)

Disable per-user configuration of single-user servers.

When starting the user’s single-user server, any config file found in the user’s $HOME directory will be ignored.

Note: a user could circumvent this if the user modifies their Python environment, such as when they have their own conda environments / virtualenvs / containers.

config c.YarnSpawner.env_keep = List('')

Whitelist of environment variables for the single-user server to inherit from the JupyterHub process.

This whitelist is used to ensure that sensitive information in the JupyterHub process’s environment (such as CONFIGPROXY_AUTH_TOKEN) is not passed to the single-user server’s process.

config c.YarnSpawner.environment = Dict('')

Extra environment variables to set for the single-user server’s process.

Environment variables that end up in the single-user server’s process come from 3 sources:
  • This environment configurable
  • The JupyterHub process’ environment variables that are whitelisted in env_keep
  • Variables to establish contact between the single-user notebook and the hub (such as JUPYTERHUB_API_TOKEN)

The environment configurable should be set by JupyterHub administrators to add installation specific environment variables. It is a dict where the key is the name of the environment variable, and the value can be a string or a callable. If it is a callable, it will be called with one parameter (the spawner instance), and should return a string fairly quickly (no blocking operations please!).

Note that the spawner class’ interface is not guaranteed to be exactly same across upgrades, so if you are using the callable take care to verify it continues to work after upgrades!

config c.YarnSpawner.epilogue = Unicode('')

Script to run after singleuser server ends.

config c.YarnSpawner.http_timeout = Int(30)

Timeout (in seconds) before giving up on a spawned HTTP server

Once a server has successfully been spawned, this is the amount of time we wait before assuming that the server is unable to accept connections.

config c.YarnSpawner.ip = Unicode('')

The IP address (or hostname) the singleuser server should listen on.

config c.YarnSpawner.keytab = Unicode(None)

Path to kerberos keytab for JupyterHub user

config c.YarnSpawner.localize_files = Dict('')

Extra files to distribute to the singleuser server container.

This is a mapping from local-name to resource. Resource paths can be local, or in HDFS (prefix with hdfs://... if so). If an archive (.tar.gz or .zip), the resource will be unarchived as directory local-name. For finer control, resources can also be specified as skein.File objects, or their dict equivalents.

This can be used to distribute conda/virtual environments by configuring the following:

c.YarnSpawner.localize_files = {
    'environment': {
        'source': 'hdfs:///path/to/archived/environment.tar.gz',
        'visibility': 'public'
c.YarnSpawner.prologue = 'source environment/bin/activate'

These archives are usually created using either conda-pack or venv-pack. For more information on distributing files, see

config c.YarnSpawner.mem_guarantee = ByteSpecification(None)

Minimum number of bytes a single-user notebook server is guaranteed to have available.

Allows the following suffixes:
  • K -> Kilobytes
  • M -> Megabytes
  • G -> Gigabytes
  • T -> Terabytes

This is a configuration setting. Your spawner must implement support for the limit to work. The default spawner, LocalProcessSpawner, does not implement this support. A custom spawner must add support for this setting for it to be enforced.

config c.YarnSpawner.mem_limit = ByteSpecification('2 G')

Maximum number of bytes a singleuser notebook server is allowed to use. Allows the following suffixes:

  • K -> Kibibytes
  • M -> Mebibytes
  • G -> Gibibytes
  • T -> Tebibytes
config c.YarnSpawner.notebook_dir = Unicode('')

Path to the notebook directory for the single-user server.

The user sees a file listing of this directory when the notebook interface is started. The current interface does not easily allow browsing beyond the subdirectories in this directory’s tree.

~ will be expanded to the home directory of the user, and {username} will be replaced with the name of the user.

Note that this does not prevent users from accessing files outside of this path! They can do so with many other means.

config c.YarnSpawner.options_form = Union('')

An HTML form for options a user can specify on launching their server.

The surrounding <form> element and the submit button are already provided.

For example:

Set your key:
<input name="key" val="default_key"></input>
Choose a letter:
<select name="letter" multiple="true">
  <option value="A">The letter A</option>
  <option value="B">The letter B</option>

The data from this form submission will be passed on to your spawner in self.user_options

Instead of a form snippet string, this could also be a callable that takes as one parameter the current spawner instance and returns a string. The callable will be called asynchronously if it returns a future, rather than a str. Note that the interface of the spawner class is not deemed stable across versions, so using this functionality might cause your JupyterHub upgrades to break.

config c.YarnSpawner.poll_interval = Int(30)

Interval (in seconds) on which to poll the spawner for single-user server’s status.

At every poll interval, each spawner’s .poll method is called, which checks if the single-user server is still running. If it isn’t running, then JupyterHub modifies its own state accordingly and removes appropriate routes from the configurable proxy.

config c.YarnSpawner.port = Int(0)

The port for single-user servers to listen on.

Defaults to 0, which uses a randomly allocated port number each time.

If set to a non-zero value, all Spawners will use the same port, which only makes sense if each server is on a different address, e.g. in containers.

New in version 0.7.

config c.YarnSpawner.post_stop_hook = Any(None)

An optional hook function that you can implement to do work after the spawner stops.

This can be set independent of any concrete spawner implementation.

config c.YarnSpawner.pre_spawn_hook = Any(None)

An optional hook function that you can implement to do some bootstrapping work before the spawner starts. For example, create a directory for your user or load initial content.

This can be set independent of any concrete spawner implementation.

This maybe a coroutine.


from subprocess import check_call
def my_hook(spawner):
    username =
    check_call(['./examples/bootstrap-script/', username])

c.Spawner.pre_spawn_hook = my_hook
config c.YarnSpawner.principal = Unicode(None)

Kerberos principal for JupyterHub user

config c.YarnSpawner.prologue = Unicode('')

Script to run before singleuser server starts.

config c.YarnSpawner.queue = Unicode('default')

The YARN queue to submit applications under

config c.YarnSpawner.script_template = Unicode('{prologue}\n{singleuser_command}\n{epilogue}')

Template for application script.

Filled in by calling script_template.format(**variables). Variables include the following attributes of this class:

  • prologue
  • singleuser_command
  • epilogue
config c.YarnSpawner.ssl_alt_names = List('')

List of SSL alt names

May be set in config if all spawners should have the same value(s), or set at runtime by Spawner that know their names.

config c.YarnSpawner.ssl_alt_names_include_local = Bool(True)

Whether to include DNS:localhost, IP: in alt names

config c.YarnSpawner.start_timeout = Int(300)

Timeout (in seconds) before giving up on starting of singleuser server.