-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added mechanisms for mapping secondary data folder and individual sec…
…rets files
- Loading branch information
Showing
7 changed files
with
346 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# Project | ||
.secrets | ||
archive | ||
todo | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3c697b0f-4fa4-4dd0-a86b-90b5ed0fbaaa", | ||
"metadata": {}, | ||
"source": [ | ||
"# Example: Accessing API tokens and credentials\n", | ||
"\n", | ||
"## Starting Jupyter\n", | ||
"\n", | ||
"Start Jupyter with\n", | ||
"\n", | ||
"```bash\n", | ||
"./run_notebook.sh --add-secret ~/.my_access_tokens/TESTTOKEN1 FOO --add-secret ~/.my_access_tokens/TESTTOKEN2 BAR\n", | ||
"```\n", | ||
"\n", | ||
"The two **files** \n", | ||
"\n", | ||
"`~/.my_access_tokens/TESTTOKEN1`\n", | ||
"\n", | ||
"and\n", | ||
"\n", | ||
"`~/.my_access_tokens/TESTTOKEN2`\n", | ||
"\n", | ||
"must exist on the host systems!\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "91d1053e-31d8-43a0-9c53-819f9f15f7cc", | ||
"metadata": {}, | ||
"source": [ | ||
"## Accessing the contents of the secrets from a notebook" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "11af385e-37bf-4d72-adce-2e0e9caa8489", | ||
"metadata": {}, | ||
"source": [ | ||
"### With shell commands" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "92b59d9d-6bc2-40ca-afb7-abb7903f7dc8", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"SUPERSECRET_TOKEN1\n", | ||
"API_TOKEN_FOR_ACME\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"!cat /mnt/secrets/FOO\n", | ||
"!cat /mnt/secrets/BAR" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "67300fec-69df-42af-b962-5eab6799cd0b", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"total 16\n", | ||
"drwxr-xr-x 2 root root 4096 May 10 11:43 .\n", | ||
"drwxr-xr-x 1 root root 4096 May 10 11:43 ..\n", | ||
"-rw-r--r-- 1 root root 19 May 10 11:32 BAR\n", | ||
"-rw-r--r-- 1 root root 19 May 10 11:32 FOO\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"!ls -la /mnt/secrets/" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "29b93823-53ea-4dc8-98bc-077440b8b54a", | ||
"metadata": {}, | ||
"source": [ | ||
"### Python" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "cde13d39-2d0a-4cba-992d-2e9e06511d4d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"SUPERSECRET_TOKEN1\n", | ||
"API_TOKEN_FOR_ACME\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"SECRET_1_PATH = \"/mnt/secrets/FOO\"\n", | ||
"SECRET_2_PATH = \"/mnt/secrets/BAR\"\n", | ||
"\n", | ||
"with open(SECRET_1_PATH, \"r\") as file:\n", | ||
" SECRET_TOKEN = file.read().strip()\n", | ||
"\n", | ||
"with open(SECRET_2_PATH, \"r\") as file:\n", | ||
" API_KEY_ACME = file.read().strip()\n", | ||
"\n", | ||
"print(SECRET_TOKEN)\n", | ||
"print(API_KEY_ACME)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.