Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #50 from RhodiumGroup/dev
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
delgadom authored Sep 7, 2018
2 parents 95524a9 + 539ac36 commit 24a25af
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion notebook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ COPY worker-template.yml /pre-home
COPY add_service_creds.py /pre-home
COPY run_sql_proxy.py /pre-home

COPY config.yml /pre-home
COPY config.yaml /pre-home
COPY worker-template.yml /pre-home


Expand Down
2 changes: 1 addition & 1 deletion notebook/config.yml → notebook/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ distributed:
limit: 5s

kubernetes:
worker-template-path: "/home/{NB_USER}/worker-template.yaml"
worker-template-path: "/home/{NB_USER}/worker-template.yml"
name: "dask-{JUPYTERHUB_USER}-{uuid}"
9 changes: 5 additions & 4 deletions notebook/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

set -x

echo "Copy files from pre-load directory into home"
cp --update -r -v /pre-home/. /home/jovyan

echo "Copy Dask configuration files from pre-load directory into home/.config"
mkdir -p /home/jovyan/.config/dask
cp --update -r -v /pre-home/config.yml /home/jovyan/.config/dask/
cp --update -r -v /pre-home/config.yaml /home/jovyan/.config/dask/
cp --update -r -v /pre-home/worker-template.yml /home/jovyan/.config/dask/
sudo rm /pre-home/config.yaml

echo "Copy files from pre-load directory into home"
cp --update -r -v /pre-home/. /home/jovyan

if [[ -e "/opt/app/environment.yml" ]]; then
echo "environment.yml found. Installing packages";
Expand Down
11 changes: 6 additions & 5 deletions notebook/run_sql_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
SQL_INSTANCE = {project}:{region}:{instance}=tcp:{port}
SQL_TOKEN_FILE = /path/to/credentials-file.json
modifying the `SQL_INSTANCE` and `SQL_TOKEN_FILE` values to match your server's
modifying the `SQL_INSTANCE` and `SQL_TOKEN` values to match your server's
configuration.
Then, run `python run_sql_proxy.py`. This will start an SQL proxy and will also
Expand All @@ -36,7 +36,8 @@ def get_sql_service_account_token(sql_token_file):

try:
with open(sql_token_file, 'r') as f:
return f.read()
return json.load(f)

except (OSError, IOError):
return

Expand Down Expand Up @@ -75,13 +76,13 @@ def __enter__(self):
for env in worker_template_modified['spec']['containers'][0]['env']:
if 'SQL_INSTANCE' in env['name']:
continue
elif 'SQL_TOKEN_FILE' in env['name']:
elif 'SQL_TOKEN' in env['name']:
continue
else:
env_vars.append(env)

env_vars.append(
{'name': 'SQL_TOKEN', 'value': sql_token})
{'name': 'SQL_TOKEN', 'value': json.dumps(sql_token)})

env_vars.append(
{'name': 'SQL_INSTANCE', 'value': sql_instance})
Expand Down Expand Up @@ -109,7 +110,7 @@ def maybe_start_sql_proxy(self, sql_instance, sql_token_file):

p.wait()


def return_worker_spec_to_original_state(self, *args):
if self.original_worker_template is None:
return
Expand Down

0 comments on commit 24a25af

Please sign in to comment.