Skip to content

Commit f1ee067

Browse files
vharshsatyamz
authored andcommitted
Fix warnings in running jupyter instance due to undefined environment variables (#1)
* Fix warnings due to undefined environment variables * Adds auto-commit and file download facility
1 parent 44aaeff commit f1ee067

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

jupyter_notebook_config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
github_user_name = os.getenv("GITHUB_USERNAME")
88
user_email = os.getenv("USER_EMAIL")
99
user_token = os.getenv("GITHUB_TOKEN")
10-
branch_name = uuid.uuid4().hex + '-'+ github_user_name
10+
if github_user_name:
11+
global branch_name
12+
branch_name = uuid.uuid4().hex + '-' + github_user_name
1113

1214
# Configuration file for jupyter-notebook.
1315

@@ -599,9 +601,11 @@ def gitconfig(user_name, user_email, user_token, branch_name):
599601
out, err, retcode = _system('git remote set-url origin ' + final_url)
600602
out, err, retcode = _system('git checkout -b ' + branch_name)
601603

602-
gitconfig(user_name, user_email, user_token, branch_name)
603604

604-
c.FileContentsManager.post_save_hook = save
605+
# Only create a post-save hook if required env vars are set
606+
if user_name and github_user_name and user_email and user_token:
607+
gitconfig(user_name, user_email, user_token, branch_name)
608+
c.FileContentsManager.post_save_hook = save
605609

606610
##
607611
#c.FileContentsManager.root_dir = ''
@@ -648,4 +652,4 @@ def gitconfig(user_name, user_email, user_token, branch_name):
648652
## Whitelist of allowed kernel names.
649653
#
650654
# By default, all installed kernels are allowed.
651-
#c.KernelSpecManager.whitelist = set()
655+
#c.KernelSpecManager.whitelist = set()

launch.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
echo "Fetching notebooks from" $GIT_REPO
44

55
git clone $GIT_REPO /home/notebooks
6+
cp jupyter_notebook_config.py /home/notebooks/
7+
cp openebs_utils.py /home/notebooks/
68

79
echo "Running Notebook"
8-
/opt/conda/bin/jupyter notebook --ip='*' --notebook-dir=/home --port=8888 --no-browser
10+
/opt/conda/bin/jupyter notebook --ip='*' --notebook-dir=/home --port=8888 --no-browser

0 commit comments

Comments
 (0)