Skip to content

Commit

Permalink
Initial commit of the SageMaker notebooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Nov 6, 2023
1 parent d040a56 commit 1972ebb
Show file tree
Hide file tree
Showing 11 changed files with 1,430 additions and 0 deletions.
99 changes: 99 additions & 0 deletions doc/tutorials/access_store_ui.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "60a822de-01a8-484f-8810-a5126384a393",
"metadata": {},
"source": [
"# Configuration Access\n",
"\n",
"<b>This notebook is not supposed to be used on its own.<b>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e542d21f-e082-494a-b00a-661abcc5bd12",
"metadata": {},
"outputs": [],
"source": [
"def get_access_store_ui(root_dir: str = '.'):\n",
" \n",
" from pathlib import Path\n",
" import ipywidgets as widgets\n",
" from exasol.secret_store import Secrets as Secrets_\n",
" \n",
" # A fix for the secret store to make its interface more in line with the dict.\n",
" class Secrets(Secrets_):\n",
" \n",
" def get(self, key: str, default_value: str=None) -> str:\n",
" value = super().get(key)\n",
" return default_value if value is None else value\n",
"\n",
" def __getattr__(self, key):\n",
" value = self.get(key)\n",
" if value is None:\n",
" raise AttributeError(f'{key} value is not defined')\n",
" return value\n",
"\n",
" # Try to find the file name and the password in the shared store.\n",
" # Create global variables only temporarily.\n",
" %store -r\n",
" if 'sb_store_file' in globals():\n",
" global sb_store_file\n",
" sb_store_file_ = sb_store_file\n",
" del sb_store_file\n",
" else:\n",
" sb_store_file_ = 'dss_config.sqlite'\n",
" if 'sb_password' in globals():\n",
" global sb_password\n",
" sb_password_ = sb_password\n",
" del sb_password\n",
" else:\n",
" sb_password_ = ''\n",
"\n",
" style = {'description_width': '120px'}\n",
" inputs = {\n",
" 'file': widgets.Text(description='Config. File Name', value=sb_store_file_, style=style),\n",
" 'password': widgets.Password(description='Config. Password', value=sb_password_, style=style),\n",
" 'ok': widgets.Button(description='OK')\n",
" }\n",
"\n",
" def open_or_create_config_store(btn):\n",
" global sb_config, sb_store_file, sb_password\n",
" sb_store_file = inputs['file'].value\n",
" sb_password = inputs['password'].value\n",
" sb_config = Secrets(Path(root_dir) / sb_store_file, sb_password)\n",
" # Save the file and password in the shared store.\n",
" %store sb_store_file sb_password\n",
" del sb_store_file, sb_password\n",
" \n",
" inputs['ok'].on_click(open_or_create_config_store)\n",
" \n",
" ui = widgets.VBox(list(inputs.values()))\n",
" return ui"
]
}
],
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 1972ebb

Please sign in to comment.