-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate start-notebook & start-singleuser to python #2006
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d1ff010
Migrate start-notebook.sh to bash
yuvipanda ed70463
Rename start-notebook.sh to start-notebook
yuvipanda 00e751e
Cleanup start-notebook a little
yuvipanda ea06768
Fix typo
yuvipanda 14a1e8c
Migrate start-singleuser as well
yuvipanda 40f37d7
Remove unused import
yuvipanda 3364294
Run symlink commands as root
yuvipanda bb98d5e
Combine repetitive RUN commands
yuvipanda 9e71839
Remove multiple args to env
yuvipanda 67302e3
Fix conditional inversion
yuvipanda 1804a8c
Fix how start-singleuser is exec'd
yuvipanda 527b756
Actually call jupyterhub-singleuser in start-singleuser
yuvipanda 9f7bdb3
Pass through any additional args we get
yuvipanda 37d5b15
Put .py suffix on the start-* scripts
yuvipanda 81c67ef
Add .sh shims for the start-* scripts
yuvipanda 219cf36
Document start-notebook.sh and start-singleuser.sh
yuvipanda d6519ac
Partially test start-notebook.sh
yuvipanda 99410dc
Reflow warning docs
yuvipanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
# Start up the notebook instance. | ||
|
||
exec start-notebook.sh "$@" | ||
exec start-notebook.py "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
import os | ||
import shlex | ||
import sys | ||
|
||
# If we are in a JupyterHub, we pass on to `start-singleuser.py` instead so it does the right thing | ||
if "JUPYTERHUB_API_TOKEN" in os.environ: | ||
print( | ||
"WARNING: using start-singleuser.py instead of start-notebook.py to start a server associated with JupyterHub." | ||
) | ||
command = ["/usr/local/bin/start-singleuser.py"] + sys.argv[1:] | ||
os.execvp(command[0], command) | ||
|
||
|
||
# Wrap everything in start.sh, no matter what | ||
command = ["/usr/local/bin/start.sh"] | ||
|
||
# If we want to survive restarts, tell that to start.sh | ||
if os.environ.get("RESTARTABLE") == "yes": | ||
command.append("run-one-constantly") | ||
|
||
# We always launch a jupyter subcommand from this script | ||
command.append("jupyter") | ||
|
||
# Launch the configured subcommand. Note that this should be a single string, so we don't split it | ||
# We default to lab | ||
jupyter_command = os.environ.get("DOCKER_STACKS_JUPYTER_CMD", "lab") | ||
command.append(jupyter_command) | ||
|
||
# Append any optional NOTEBOOK_ARGS we were passed in. This is supposed to be multiple args passed | ||
# on to the notebook command, so we split it correctly with shlex | ||
if "NOTEBOOK_ARGS" in os.environ: | ||
command += shlex.split(os.environ["NOTEBOOK_ARGS"]) | ||
|
||
# Pass through any other args we were passed on the commandline | ||
command += sys.argv[1:] | ||
|
||
# Execute the command! | ||
os.execvp(command[0], command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
#!/bin/bash | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
# Shim to emit warning and call start-notebook.py | ||
echo "WARNING: Use start-notebook.py instead" | ||
|
||
set -e | ||
|
||
# The Jupyter command to launch | ||
# JupyterLab by default | ||
DOCKER_STACKS_JUPYTER_CMD="${DOCKER_STACKS_JUPYTER_CMD:=lab}" | ||
|
||
if [[ -n "${JUPYTERHUB_API_TOKEN}" ]]; then | ||
echo "WARNING: using start-singleuser.sh instead of start-notebook.sh to start a server associated with JupyterHub." | ||
exec /usr/local/bin/start-singleuser.sh "$@" | ||
fi | ||
|
||
wrapper="" | ||
if [[ "${RESTARTABLE}" == "yes" ]]; then | ||
wrapper="run-one-constantly" | ||
fi | ||
|
||
# shellcheck disable=SC1091,SC2086 | ||
exec /usr/local/bin/start.sh ${wrapper} jupyter ${DOCKER_STACKS_JUPYTER_CMD} ${NOTEBOOK_ARGS} "$@" | ||
exec /usr/local/bin/start-notebook.py "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
import os | ||
import shlex | ||
import sys | ||
|
||
command = ["/usr/local/bin/start.sh", "jupyterhub-singleuser"] | ||
|
||
# set default ip to 0.0.0.0 | ||
if "--ip=" not in os.environ.get("NOTEBOOK_ARGS", ""): | ||
command.append("--ip=0.0.0.0") | ||
|
||
# Append any optional NOTEBOOK_ARGS we were passed in. This is supposed to be multiple args passed | ||
# on to the notebook command, so we split it correctly with shlex | ||
if "NOTEBOOK_ARGS" in os.environ: | ||
command += shlex.split(os.environ["NOTEBOOK_ARGS"]) | ||
|
||
# Pass any other args we have been passed through | ||
command += sys.argv[1:] | ||
|
||
# Execute the command! | ||
os.execvp(command[0], command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
#!/bin/bash | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
# Shim to emit warning and call start-singleuser.py | ||
echo "WARNING: Use start-singleuser.py instead" | ||
|
||
set -e | ||
|
||
# set default ip to 0.0.0.0 | ||
if [[ "${NOTEBOOK_ARGS} $*" != *"--ip="* ]]; then | ||
NOTEBOOK_ARGS="--ip=0.0.0.0 ${NOTEBOOK_ARGS}" | ||
fi | ||
|
||
# shellcheck disable=SC1091,SC2086 | ||
. /usr/local/bin/start.sh jupyterhub-singleuser ${NOTEBOOK_ARGS} "$@" | ||
exec /usr/local/bin/start-singleuser.py "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate it that you added comments to this file! I'm sure it will help future contributors to understand this file faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathbunnyru you're welcome :)