diff --git a/notebook/Dockerfile b/notebook/Dockerfile index 98b5754..211bf68 100644 --- a/notebook/Dockerfile +++ b/notebook/Dockerfile @@ -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 diff --git a/notebook/config.yml b/notebook/config.yaml similarity index 73% rename from notebook/config.yml rename to notebook/config.yaml index ed5a46c..2b88bc1 100644 --- a/notebook/config.yml +++ b/notebook/config.yaml @@ -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}" \ No newline at end of file diff --git a/notebook/prepare.sh b/notebook/prepare.sh index e85b341..0608e34 100644 --- a/notebook/prepare.sh +++ b/notebook/prepare.sh @@ -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"; diff --git a/notebook/run_sql_proxy.py b/notebook/run_sql_proxy.py index 64dd81c..7450e01 100644 --- a/notebook/run_sql_proxy.py +++ b/notebook/run_sql_proxy.py @@ -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 @@ -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 @@ -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}) @@ -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