generated from kbase/kbase-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a208fa7
commit 7cfdc7b
Showing
7 changed files
with
82 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
This is the JupyterHub configuration file. It is used to configure the JupyterHub server. | ||
Refer to the JupyterHub documentation for more information: | ||
https://jupyterhub.readthedocs.io/en/latest/tutorial/getting-started/config-basics.html | ||
""" | ||
import os | ||
|
||
from jupyterhub_config.custom_spawner import VirtualEnvSpawner | ||
|
||
c = get_config() | ||
|
||
# Set the authenticator class | ||
# TODO: Change the authenticator class to a secure one (e.g. GitHubOAuthenticator) | ||
c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator' | ||
c.Authenticator.allowed_users = {'spark_user', 'test_user1', 'test_user2'} | ||
c.DummyAuthenticator.password = os.environ['JUPYTERHUB_ADMIN_PASSWORD'] | ||
|
||
c.Authenticator.admin_users = {'spark_user'} | ||
|
||
c.JupyterHub.spawner_class = VirtualEnvSpawner | ||
|
||
# Set the JupyterHub IP address and port | ||
c.JupyterHub.ip = '0.0.0.0' | ||
c.JupyterHub.port = int(os.getenv('NOTEBOOK_PORT')) | ||
|
||
c.JupyterHub.log_level = 'DEBUG' |
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,9 @@ | ||
#!/bin/bash | ||
|
||
USERNAME=${JUPYTERHUB_USER} | ||
|
||
echo "Starting Jupyter Notebook for user: $USERNAME" | ||
cd $JUPYTERHUB_USER_HOME/$USERNAME | ||
|
||
# Start the notebook server with current user | ||
exec jupyterhub-singleuser "$@" |
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,17 @@ | ||
from jupyterhub.spawner import SimpleLocalProcessSpawner | ||
|
||
|
||
class VirtualEnvSpawner(SimpleLocalProcessSpawner): | ||
""" | ||
A custom JupyterHub spawner that creates and manages a virtual environment | ||
for each user, configuring their workspace based on their admin status. | ||
""" | ||
|
||
def start(self): | ||
""" | ||
Start the JupyterHub server for the user. This method ensures that the | ||
user's directory and virtual environment are set up, configures environment | ||
variables, and sets the notebook directory before starting the server. | ||
""" | ||
|
||
return super().start() | ||
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 @@ | ||
from jupyterhub_config.custom_spawner import * |