Skip to content
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

Support for Notebook 7 and Jupyter Lab #11

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*~
/venv
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@

c = get_config()

# Root directory for notebook
c.ServerApp.root_dir='/'

### Password protection ###
# http://jupyter-notebook.readthedocs.io/en/latest/security.html
if os.environ.get('JUPYTER_NOTEBOOK_PASSWORD_DISABLED') != 'DangerZone!':
passwd = os.environ['JUPYTER_NOTEBOOK_PASSWORD']
c.NotebookApp.password = IPython.lib.passwd(passwd)
c.ServerApp.password = IPython.lib.passwd(passwd)
else:
c.NotebookApp.token = ''
c.NotebookApp.password = ''
c.ServerApp.token = ''
c.ServerApp.password = ''

### Make it so the default shell is bash & the prompt is not awful:
c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']}
c.ServerApp.terminado_settings = {'shell_command': ['/bin/bash']}

### PostresContentsManager ###
database_url = os.getenv('DATABASE_URL', None)
if database_url:
# Tell IPython to use PostgresContentsManager for all storage.
c.NotebookApp.contents_manager_class = pgcontents.PostgresContentsManager
c.ServerApp.contents_manager_class = pgcontents.PostgresContentsManager

# Set the url for the database used to store files. See
# http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html#postgresql
Expand All @@ -39,14 +42,6 @@
# Set a maximum file size, if desired.
#c.PostgresContentsManager.max_file_size_bytes = 1000000 # 1MB File cap

### CloudFoundry specific settings
vcap_application_json = os.getenv('VCAP_APPLICATION', None)
if vcap_application_json:
vcap_application = json.loads(vcap_application_json)
uri = vcap_application['uris'][0]
c.NotebookApp.allow_origin = 'https://{}'.format(uri)
c.NotebookApp.websocket_url = 'wss://{}:4443'.format(uri)

except Exception:
traceback.print_exc()
# if an exception occues, notebook normally would get started
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ The fastest & easiest way to get started is to choose option 1 below: automatic
First, click on this handy dandy button:
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Go through the form that the ^^ above button leads you to, and choose an app name & password. Then click the purple 'deploy app' button at the bottom of the form.
Go through the form that the ^^ above button leads you to, and choose an app name, password, and whether to run Jupyter notebook or Jupyter lab. Then click the purple 'deploy app' button at the bottom of the form.

It will take a couple of minutes for your app to deploy, and then you'll be able to click links to 1) manage your app, and 2) view your live, interactive jupyter notebook running on a heroku dyno (with persistant storage!).
It will take a couple of minutes for your app to deploy, and then you'll be able to click links to 1) manage your app, and 2) view your live, interactive jupyter application running on a heroku dyno (with persistant storage!).

Note: If you choose later to fork this repository, you can link your new repo to your heroku app afterwards.

Expand All @@ -31,6 +31,8 @@ To create a new app, run:
```
export APP_NAME=<your_app_name>
export JUPYTER_NOTEBOOK_PASSWORD=<your_jupyter_password>
# set to 'notebook' or 'lab' to choose which jupyter application to launch:
export JUPYTER_NOTEBOOK_OR_LAB=<notebook_or_lab>

# if you don't have git:
brew install git
Expand All @@ -46,6 +48,7 @@ heroku stack:set heroku-24 --app $APP_NAME

# Set your required config variable:
heroku config:set JUPYTER_NOTEBOOK_PASSWORD=$JUPYTER_NOTEBOOK_PASSWORD -a $APP_NAME
heroku congif:set JUPYTER_NOTEBOOK_OR_LAB=$JUPYTER_NOTEBOOK_OR_LAB -a $APP_NAME

# Specify the buildpacks it should use:
heroku buildpacks:add --index 1 heroku-community/apt -a $APP_NAME
Expand Down
7 changes: 7 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
}
],
"env": {
"JUPYTER_NOTEBOOK_OR_LAB": {
addisonwurtz marked this conversation as resolved.
Show resolved Hide resolved
"description": "Set to 'notebook' to launch Jupyter Notebook 7, 'lab' to launch Jupyter Lab.",
"value": "lab"
},
"JUPYTER_NOTEBOOK_PASSWORD": {
"description": "IMPORTANT! Set a secure password."
},
"JUPYTER_NOTEBOOK_ARGS": {
"description": "Add command line arguments here (optional)."
}
},
"addons": [
Expand Down
3 changes: 3 additions & 0 deletions notebooks/.ipynb_checkpoints/readme-checkpoint.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Files in this folder will not be stored. Restarting the app may result in data loss.

Is your ContentsManager configured correctly?
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ipython==7.32.0 # https://github.com/NetApp/netapp-dataops-toolkit/issues/13
# ipython==8.27.0 # fixed I think?
notebook==6.5.7 # latest 6.* version
git+https://github.com/quantopian/pgcontents.git # https://github.com/quantopian/pgcontents/issues/80
notebook>=7
#git+https://github.com/quantopian/pgcontents.git # https://github.com/quantopian/pgcontents/issues/80
git+https://github.com/addisonwurtz/pgcontents.git
# pgcontents==0.6
sqlalchemy[postgresql]==1.3 # https://stackoverflow.com/questions/62688256/sqlalchemy-exc-nosuchmoduleerror-cant-load-plugin-sqlalchemy-dialectspostgre
psycopg2-binary==2.9.9 # latest
alembic==1.13.2 # latest
jupyter_server==1.23.5 # https://github.com/jupyter/notebook/issues/6702
jupyter_server #==1.23.5 # https://github.com/jupyter/notebook/issues/6702
jupyterlab
git+https://github.com/ipython-contrib/jupyter_contrib_nbextensions.git
9 changes: 4 additions & 5 deletions start_jupyter
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ echo "Nbextensions configurator enabled"
# terminal interface a little prettier:
export PS1='\[\033[01;34m\]\w\[\033[00m\]\$'

echo "Starting Jupyter Notebook"
echo "Starting Jupyter ${JUPYTER_NOTEBOOK_OR_LAB}"
# NOTE: With allow_origin='*', anyone with the URL and password can potentially access your notebook,
# so be careful w/ the URL and password. Don't put sensitive data up here.
jupyter notebook \
--no-browser --no-mathjax --ip=0.0.0.0 --port=$PORT \
--NotebookApp.allow_origin='*' --NotebookApp.allow_credentials=True \
jupyter $JUPYTER_NOTEBOOK_OR_LAB \
addisonwurtz marked this conversation as resolved.
Show resolved Hide resolved
--no-browser --ip=0.0.0.0 --port=$PORT \
--ServerApp.allow_origin='*' --ServerApp.allow_credentials=True \
$JUPYTER_NOTEBOOK_ARGS \
notebooks