Skip to content

Commit de56725

Browse files
committed
Add pre-commit
1 parent a4f2bd9 commit de56725

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# pre-commit is a tool to perform a predefined set of tasks manually and/or
2+
# automatically before git commits are made.
3+
#
4+
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
5+
#
6+
# Common tasks
7+
#
8+
# - Run on all files: pre-commit run --all-files
9+
# - Register git hooks: pre-commit install --install-hooks
10+
#
11+
repos:
12+
# Autoformat: Python code
13+
- repo: https://github.com/psf/black
14+
rev: 22.8.0
15+
hooks:
16+
- id: black
17+
args:
18+
- --target-version=py38
19+
- --target-version=py39
20+
- --target-version=py310
21+
22+
# Autoformat: markdown, yaml
23+
- repo: https://github.com/pre-commit/mirrors-prettier
24+
rev: v2.7.1
25+
hooks:
26+
- id: prettier

README.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,45 @@
1212
**jupyterhub-deploy-docker** provides a reference
1313
deployment of [JupyterHub](https://github.com/jupyter/jupyterhub), a
1414
multi-user [Jupyter Notebook](http://jupyter.org/) environment, on a
15-
**single host** using [Docker](https://docs.docker.com).
15+
**single host** using [Docker](https://docs.docker.com).
1616

1717
Possible **use cases** include:
1818

19-
* Creating a JupyterHub demo environment that you can spin up relatively
19+
- Creating a JupyterHub demo environment that you can spin up relatively
2020
quickly.
21-
* Providing a multi-user Jupyter Notebook environment for small classes,
21+
- Providing a multi-user Jupyter Notebook environment for small classes,
2222
teams, or departments.
2323

2424
## Disclaimer
2525

26-
This deployment is **NOT** intended for a production environment.
27-
It is a reference implementation that does not meet traditional
28-
requirements in terms of availability nor scalability.
26+
This deployment is **NOT** intended for a production environment.
27+
It is a reference implementation that does not meet traditional
28+
requirements in terms of availability nor scalability.
2929

3030
If you are looking for a more robust solution to host JupyterHub, or
3131
you require scaling beyond a single host, please check out the
3232
excellent [zero-to-jupyterhub-k8s](https://github.com/jupyterhub/zero-to-jupyterhub-k8s)
3333
project.
3434

35-
3635
## Technical Overview
3736

3837
Key components of this reference deployment are:
3938

40-
* **Host**: Runs the [JupyterHub components](https://jupyterhub.readthedocs.org/en/latest/getting-started.html#overview)
39+
- **Host**: Runs the [JupyterHub components](https://jupyterhub.readthedocs.org/en/latest/getting-started.html#overview)
4140
in a Docker container on the host.
4241

43-
* **Authenticator**: Uses [Native Authenticator](https://github.com/jupyterhub/nativeauthenticator) to authenticate users.
42+
- **Authenticator**: Uses [Native Authenticator](https://github.com/jupyterhub/nativeauthenticator) to authenticate users.
4443

45-
* **Spawner**:Uses [DockerSpawner](https://github.com/jupyter/dockerspawner)
44+
- **Spawner**:Uses [DockerSpawner](https://github.com/jupyter/dockerspawner)
4645
to spawn single-user Jupyter Notebook servers in separate Docker
4746
containers on the same host.
4847

49-
* **Persistence of Hub data**: Persists JupyterHub data in a Docker
48+
- **Persistence of Hub data**: Persists JupyterHub data in a Docker
5049
volume on the host.
5150

52-
* **Persistence of user notebook directories**: Persists user notebook
51+
- **Persistence of user notebook directories**: Persists user notebook
5352
directories in Docker volumes on the host.
5453

55-
5654
## Prerequisites
5755

5856
### Docker
@@ -62,7 +60,6 @@ This deployment uses Docker, via [Docker Compose](https://docs.docker.com/compos
6260
1. Use [Docker's installation instructions](https://docs.docker.com/engine/installation/)
6361
to set up Docker for your environment.
6462

65-
6663
## Authenticator setup
6764

6865
This deployment uses [JupyterHub Native Authenticator](https://native-authenticator.readthedocs.io/en/latest/) to authenticate users.
@@ -79,7 +76,6 @@ This deployment uses [JupyterHub Native Authenticator](https://native-authentica
7976
docker-compose build
8077
```
8178

82-
8379
## Customisation: Jupyter Notebook Image
8480

8581
You can configure JupyterHub to spawn Notebook servers from any Docker image, as
@@ -90,12 +86,12 @@ To specify which Notebook image to spawn for users, you set the value of the
9086
`DOCKER_NOTEBOOK_IMAGE` environment variable to the desired container image.
9187

9288
Whether you build a custom Notebook image or pull an image from a public or
93-
private Docker registry, the image must reside on the host.
89+
private Docker registry, the image must reside on the host.
9490

9591
If the Notebook image does not exist on host, Docker will attempt to pull the
96-
image the first time a user attempts to start his or her server. In such cases,
92+
image the first time a user attempts to start his or her server. In such cases,
9793
JupyterHub may timeout if the image being pulled is large, so it is better to
98-
pull the image to the host before running JupyterHub.
94+
pull the image to the host before running JupyterHub.
9995

10096
This deployment defaults to the
10197
[jupyter/minimal-notebook](https://hub.docker.com/r/jupyter/minimal-notebook/)
@@ -136,7 +132,7 @@ docker-compose down
136132

137133
### How can I view the logs for JupyterHub or users' Notebook servers?
138134

139-
Use `docker logs <container>`. For example, to view the logs of the `jupyterhub` container
135+
Use `docker logs <container>`. For example, to view the logs of the `jupyterhub` container
140136

141137
```bash
142138
docker logs jupyterhub
@@ -175,7 +171,7 @@ kernels.
175171

176172
### How can I backup a user's notebook directory?
177173

178-
There are multiple ways to [backup and restore](https://docs.docker.com/engine/userguide/containers/dockervolumes/#backup-restore-or-migrate-data-volumes) data in Docker containers.
174+
There are multiple ways to [backup and restore](https://docs.docker.com/engine/userguide/containers/dockervolumes/#backup-restore-or-migrate-data-volumes) data in Docker containers.
179175

180176
Suppose you have the following running containers:
181177

@@ -195,7 +191,7 @@ In this deployment, the user's notebook directories (`/home/jovyan/work`) are ba
195191
[{jtyberg /var/lib/docker/volumes/jtyberg/_data /home/jovyan/work local rw true rprivate}]
196192
```
197193

198-
We can backup the user's notebook directory by running a separate container that mounts the user's volume and creates a tarball of the directory.
194+
We can backup the user's notebook directory by running a separate container that mounts the user's volume and creates a tarball of the directory.
199195

200196
```bash
201197
docker run --rm \

jupyterhub_config.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@
1111
# configuration parameter.
1212

1313
# Spawn single-user servers as Docker containers
14-
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
14+
c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"
1515

1616
# Spawn containers from this image
17-
c.DockerSpawner.image = os.environ['DOCKER_NOTEBOOK_IMAGE']
17+
c.DockerSpawner.image = os.environ["DOCKER_NOTEBOOK_IMAGE"]
1818

1919
# JupyterHub requires a single-user instance of the Notebook server, so we
2020
# default to using the `start-singleuser.sh` script included in the
2121
# jupyter/docker-stacks *-notebook images as the Docker run command when
2222
# spawning containers. Optionally, you can override the Docker run command
2323
# using the DOCKER_SPAWN_CMD environment variable.
24-
spawn_cmd = os.environ.get('DOCKER_SPAWN_CMD', "start-singleuser.sh")
24+
spawn_cmd = os.environ.get("DOCKER_SPAWN_CMD", "start-singleuser.sh")
2525
c.DockerSpawner.cmd = spawn_cmd
2626

2727
# Connect containers to this Docker network
28-
network_name = os.environ['DOCKER_NETWORK_NAME']
28+
network_name = os.environ["DOCKER_NETWORK_NAME"]
2929
c.DockerSpawner.use_internal_ip = True
3030
c.DockerSpawner.network_name = network_name
3131

3232
# Explicitly set notebook directory because we'll be mounting a volume to it.
3333
# Most jupyter/docker-stacks *-notebook images run the Notebook server as
3434
# user `jovyan`, and set the notebook directory to `/home/jovyan/work`.
3535
# We follow the same convention.
36-
notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work'
36+
notebook_dir = os.environ.get("DOCKER_NOTEBOOK_DIR") or "/home/jovyan/work"
3737
c.DockerSpawner.notebook_dir = notebook_dir
3838

3939
# Mount the real user's Docker volume on the host to the notebook user's
4040
# notebook directory in the container
41-
c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }
41+
c.DockerSpawner.volumes = {"jupyterhub-user-{username}": notebook_dir}
4242

4343
# Remove containers once they are stopped
4444
c.DockerSpawner.remove = True
@@ -47,17 +47,17 @@
4747
c.DockerSpawner.debug = True
4848

4949
# User containers will access hub by container name on the Docker network
50-
c.JupyterHub.hub_ip = 'jupyterhub'
50+
c.JupyterHub.hub_ip = "jupyterhub"
5151
c.JupyterHub.hub_port = 8080
5252

5353
# Persist hub data on volume mounted inside container
54-
c.JupyterHub.cookie_secret_file = '/data/jupyterhub_cookie_secret'
54+
c.JupyterHub.cookie_secret_file = "/data/jupyterhub_cookie_secret"
5555
c.JupyterHub.db_url = "sqlite:////data/jupyterhub.sqlite"
5656

5757
# Authenticate users with Native Authenticator
58-
c.JupyterHub.authenticator_class = 'nativeauthenticator.NativeAuthenticator'
58+
c.JupyterHub.authenticator_class = "nativeauthenticator.NativeAuthenticator"
5959

6060
# Allowed admins
61-
admin = os.environ.get('JUPYTERHUB_ADMIN')
61+
admin = os.environ.get("JUPYTERHUB_ADMIN")
6262
if admin:
6363
c.Authenticator.admin_users = [admin]

0 commit comments

Comments
 (0)