forked from pl31/heroku-jupyter
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjupyterconfig.py
30 lines (24 loc) · 1.14 KB
/
jupyterconfig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import uuid
import IPython.lib
import pgcontents
c = get_config()
### Password protection ###
c.NotebookApp.password = IPython.lib.passwd(
os.getenv('JUPYTER_NOTEBOOK_PASSWORD', default=str(uuid.uuid4())))
### 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
# Set the url for the database used to store files. See
# http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html#postgresql
# for more info on db url formatting.
c.PostgresContentsManager.db_url = database_url
# PGContents associates each running notebook server with a user, allowing
# multiple users to connect to the same database without trampling each other's
# notebooks. By default, we use the result of result of getpass.getuser(), but
# a username can be specified manually like so:
c.PostgresContentsManager.user_id = 'heroku'
# Set a maximum file size, if desired.
#c.PostgresContentsManager.max_file_size_bytes = 1000000 # 1MB File cap