6.1. app

6.1.1. Module: binderhub.app

The binderhub application

6.1.2. BinderHub

class binderhub.app.BinderHub(**kwargs)

An Application for starting a builder.

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.base_url = Unicode('/')

The base URL of the entire application

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_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 docker_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_image_spec = Unicode('jupyter/repo2docker:687788f')

The builder image to be used for doing builds

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.docker_auth_host = Unicode('')

Docker authentication host.

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

Prefix for all built docker images.

If you are pushing to gcr.io, you would have this be:
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.docker_push_secret = Unicode('docker-push-secret')

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

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

Docker registry host.

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

Url to request docker registry authentication token.

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_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.github_auth_token = Unicode(None)

GitHub OAuth token to use for talking to the GitHub API.

Might get throttled otherwise!

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.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.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_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.

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.base_url = Unicode('/')

The base URL of the entire application

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_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 docker_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_image_spec = Unicode('jupyter/repo2docker:687788f')

The builder image to be used for doing builds

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.docker_auth_host = Unicode('')

Docker authentication host.

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

Prefix for all built docker images.

If you are pushing to gcr.io, you would have this be:
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.docker_push_secret = Unicode('docker-push-secret')

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

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

Docker registry host.

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

Url to request docker registry authentication token.

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_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.github_auth_token = Unicode(None)

GitHub OAuth token to use for talking to the GitHub API.

Might get throttled otherwise!

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/

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.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_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.