app

Module: binderhub.app

The binderhub application

BinderHub

class binderhub.app.BinderHub(**kwargs)

An Application for starting a builder.

config c.BinderHub.about_message = Unicode('')

Additional message to display on the about page.

Will be directly inserted into the about page’s source so you can use raw HTML.

config c.BinderHub.appendix = Unicode('')

Appendix to pass to repo2docker

A multi-line string of Docker directives to run. Since the build context cannot be affected, ADD will typically not be useful.

This should be a Python string template. It will be formatted with at least the following names available:

  • binder_url: the shareable URL for the current image (e.g. for sharing links to the current Binder)
  • repo_url: the repository URL used to build the image
config c.BinderHub.auth_enabled = Bool(False)

If JupyterHub authentication enabled, require user to login (don’t create temporary users during launch) and start the new server for the logged in user.

config c.BinderHub.base_url = Unicode('/')

The base URL of the entire application

config c.BinderHub.build_cleanup_interval = Int(60)

Interval (in seconds) for how often stopped build pods will be deleted.

config c.BinderHub.build_docker_host = Unicode('/var/run/docker.sock')

The docker URL repo2docker should use to build the images.

Currently, only paths are supported, and they are expected to be available on all the hosts.

config c.BinderHub.build_image = Unicode('jupyter/repo2docker:0.8.0')

The repo2docker image to be used for doing builds

config c.BinderHub.build_max_age = Int(14400)

Maximum age of builds

Builds that are still running longer than this will be killed.

config c.BinderHub.build_memory_limit = ByteSpecification(0)

Max amount of memory allocated for each image build process.

0 sets no limit.

This is used as both the memory limit & request for the pod that is spawned to do the building, even though the pod itself will not be using that much memory since the docker building is happening outside the pod. However, it makes kubernetes aware of the resources being used, and lets it schedule more intelligently.

config c.BinderHub.build_namespace = Unicode('default')

Kubernetes namespace to spawn build pods in.

Note that the push_secret must refer to a secret in this namespace.

config c.BinderHub.build_node_selector = Dict()

Select the node where build pod runs on.

config c.BinderHub.builder_required = Bool(True)

If binderhub should try to continue to run without a working build infrastructure.

Build infrastructure is kubernetes cluster + docker. This is useful for pure HTML/CSS/JS local development.

config c.BinderHub.concurrent_build_limit = Int(32)

The number of concurrent builds to allow.

config c.BinderHub.config_file = Unicode('binderhub_config.py')

Config file to load.

If a relative path is provided, it is taken relative to current directory

config c.BinderHub.debug = Bool(False)

Turn on debugging.

config c.BinderHub.executor_threads = Int(5)

The number of threads to use for blocking calls

Should generaly be a small number because we don’t care about high concurrency here, just not blocking the webserver. This executor is not used for long-running tasks (e.g. builds).

config c.BinderHub.extra_footer_scripts = Dict()

Extra bits of JavaScript that should be loaded in footer of each page.

Only the values are set up as scripts. Keys are used only for sorting.

Omit the <script> tag. This should be primarily used for analytics code.

config c.BinderHub.extra_static_path = Unicode('')

Path to search for extra static files.

config c.BinderHub.extra_static_url_prefix = Unicode('/extra_static/')

Url prefix to serve extra static files.

config c.BinderHub.google_analytics_code = Unicode(None)

The Google Analytics code to use on the main page.

Note that we’ll respect Do Not Track settings, despite the fact that GA does not. We will not load the GA scripts on browsers with DNT enabled.

config c.BinderHub.google_analytics_domain = Unicode('auto')

The Google Analytics domain to use on the main page.

By default this is set to ‘auto’, which sets it up for current domain and all subdomains. This can be set to a more restrictive domain here for better privacy

config c.BinderHub.hub_api_token = Unicode('')

API token for talking to the JupyterHub API

config c.BinderHub.hub_url = Unicode('')

The base URL of the JupyterHub instance where users will run.

e.g. https://hub.mybinder.org/

config c.BinderHub.image_prefix = Unicode('')

Prefix for all built docker images.

If you are pushing to gcr.io, this would start with:
gcr.io/<your-project-name>/

Set according to whatever registry you are pushing to.

Defaults to “”, which is probably not what you want :)

config c.BinderHub.log_datefmt = Unicode('%Y-%m-%d %H:%M:%S')

The date format used by logging formatters for %(asctime)s

config c.BinderHub.log_format = Unicode('[%(name)s]%(highlevel)s %(message)s')

The Logging format template

config c.BinderHub.log_level = Enum(30)

Set the log level by value or name.

config c.BinderHub.log_tail_lines = Int(100)

Limit number of log lines to show when connecting to an already running build.

config c.BinderHub.per_repo_quota = Int(0)

Maximum number of concurrent users running from a given repo.

Limits the amount of Binder that can be consumed by a single repo.

0 (default) means no quotas.

config c.BinderHub.port = Int(8585)

Port for the builder to listen on.

config c.BinderHub.push_secret = Unicode('binder-push-secret')

A kubernetes secret object that provides credentials for pushing built images.

config c.BinderHub.repo_providers = Dict()

List of Repo Providers to register and try

config c.BinderHub.template_path = Unicode('')

Path to search for custom jinja templates, before using the default templates.

config c.BinderHub.template_variables = Dict()

Extra variables to supply to jinja templates when rendering.

config c.BinderHub.tornado_settings = Dict()

additional settings to pass through to tornado.

can include things like additional headers, etc.

config c.BinderHub.use_named_servers = Bool(False)

Use named servers when authentication is enabled.

config c.BinderHub.use_registry = Bool(True)

Set to true to push images to a registry & check for images in registry.

Set to false to use only local docker images. Useful when running in a single node.

config c.BinderHub.about_message = Unicode('')

Additional message to display on the about page.

Will be directly inserted into the about page’s source so you can use raw HTML.

static add_url_prefix(prefix, handlers)

add a url prefix to handlers

config c.BinderHub.appendix = Unicode('')

Appendix to pass to repo2docker

A multi-line string of Docker directives to run. Since the build context cannot be affected, ADD will typically not be useful.

This should be a Python string template. It will be formatted with at least the following names available:

  • binder_url: the shareable URL for the current image (e.g. for sharing links to the current Binder)
  • repo_url: the repository URL used to build the image
config c.BinderHub.auth_enabled = Bool(False)

If JupyterHub authentication enabled, require user to login (don’t create temporary users during launch) and start the new server for the logged in user.

config c.BinderHub.base_url = Unicode('/')

The base URL of the entire application

config c.BinderHub.build_cleanup_interval = Int(60)

Interval (in seconds) for how often stopped build pods will be deleted.

config c.BinderHub.build_docker_host = Unicode('/var/run/docker.sock')

The docker URL repo2docker should use to build the images.

Currently, only paths are supported, and they are expected to be available on all the hosts.

config c.BinderHub.build_image = Unicode('jupyter/repo2docker:0.8.0')

The repo2docker image to be used for doing builds

config c.BinderHub.build_max_age = Int(14400)

Maximum age of builds

Builds that are still running longer than this will be killed.

config c.BinderHub.build_memory_limit = ByteSpecification(0)

Max amount of memory allocated for each image build process.

0 sets no limit.

This is used as both the memory limit & request for the pod that is spawned to do the building, even though the pod itself will not be using that much memory since the docker building is happening outside the pod. However, it makes kubernetes aware of the resources being used, and lets it schedule more intelligently.

config c.BinderHub.build_namespace = Unicode('default')

Kubernetes namespace to spawn build pods in.

Note that the push_secret must refer to a secret in this namespace.

config c.BinderHub.build_node_selector = Dict()

Select the node where build pod runs on.

config c.BinderHub.builder_required = Bool(True)

If binderhub should try to continue to run without a working build infrastructure.

Build infrastructure is kubernetes cluster + docker. This is useful for pure HTML/CSS/JS local development.

config c.BinderHub.concurrent_build_limit = Int(32)

The number of concurrent builds to allow.

config c.BinderHub.config_file = Unicode('binderhub_config.py')

Config file to load.

If a relative path is provided, it is taken relative to current directory

config c.BinderHub.debug = Bool(False)

Turn on debugging.

config c.BinderHub.executor_threads = Int(5)

The number of threads to use for blocking calls

Should generaly be a small number because we don’t care about high concurrency here, just not blocking the webserver. This executor is not used for long-running tasks (e.g. builds).

config c.BinderHub.extra_footer_scripts = Dict()

Extra bits of JavaScript that should be loaded in footer of each page.

Only the values are set up as scripts. Keys are used only for sorting.

Omit the <script> tag. This should be primarily used for analytics code.

config c.BinderHub.extra_static_path = Unicode('')

Path to search for extra static files.

config c.BinderHub.extra_static_url_prefix = Unicode('/extra_static/')

Url prefix to serve extra static files.

config c.BinderHub.google_analytics_code = Unicode(None)

The Google Analytics code to use on the main page.

Note that we’ll respect Do Not Track settings, despite the fact that GA does not. We will not load the GA scripts on browsers with DNT enabled.

config c.BinderHub.google_analytics_domain = Unicode('auto')

The Google Analytics domain to use on the main page.

By default this is set to ‘auto’, which sets it up for current domain and all subdomains. This can be set to a more restrictive domain here for better privacy

config c.BinderHub.hub_api_token = Unicode('')

API token for talking to the JupyterHub API

config c.BinderHub.hub_url = Unicode('')

The base URL of the JupyterHub instance where users will run.

e.g. https://hub.mybinder.org/

config c.BinderHub.image_prefix = Unicode('')

Prefix for all built docker images.

If you are pushing to gcr.io, this would start with:
gcr.io/<your-project-name>/

Set according to whatever registry you are pushing to.

Defaults to “”, which is probably not what you want :)

initialize(*args, **kwargs)

Load configuration settings.

config c.BinderHub.log_tail_lines = Int(100)

Limit number of log lines to show when connecting to an already running build.

config c.BinderHub.per_repo_quota = Int(0)

Maximum number of concurrent users running from a given repo.

Limits the amount of Binder that can be consumed by a single repo.

0 (default) means no quotas.

config c.BinderHub.port = Int(8585)

Port for the builder to listen on.

config c.BinderHub.push_secret = Unicode('binder-push-secret')

A kubernetes secret object that provides credentials for pushing built images.

config c.BinderHub.repo_providers = Dict()

List of Repo Providers to register and try

start(run_loop=True)

Start the app mainloop.

Override in subclasses.

config c.BinderHub.template_path = Unicode('')

Path to search for custom jinja templates, before using the default templates.

config c.BinderHub.template_variables = Dict()

Extra variables to supply to jinja templates when rendering.

config c.BinderHub.tornado_settings = Dict()

additional settings to pass through to tornado.

can include things like additional headers, etc.

config c.BinderHub.use_named_servers = Bool(False)

Use named servers when authentication is enabled.

config c.BinderHub.use_registry = Bool(True)

Set to true to push images to a registry & check for images in registry.

Set to false to use only local docker images. Useful when running in a single node.

watch_build_pods()

Watch build pods

Every build_cleanup_interval: - delete stopped build pods - delete running build pods older than build_max_age