diff --git a/doc/changes/changes_0.2.0.md b/doc/changes/changes_0.2.0.md index 61db454a..c8e0ce0f 100644 --- a/doc/changes/changes_0.2.0.md +++ b/doc/changes/changes_0.2.0.md @@ -18,5 +18,6 @@ Version: 0.2.0 ## Refactoring * #160: Implemented the PM's recommendations of 2024-01-24. +* #120: Passing the secret store object (sb_config) as a parameter to all functions that need it. ## Documentation diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/main_config.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/main_config.ipynb index 31ff07f2..8dfd0b95 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/main_config.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/main_config.ipynb @@ -75,7 +75,7 @@ "metadata": {}, "outputs": [], "source": [ - "display(get_db_selection_ui())" + "display(get_db_selection_ui(sb_config))" ] }, { @@ -95,7 +95,7 @@ "metadata": {}, "outputs": [], "source": [ - "display(get_db_config_ui())" + "display(get_db_config_ui(sb_config))" ] }, { @@ -117,7 +117,7 @@ "metadata": {}, "outputs": [], "source": [ - "display(get_start_docker_db_ui())" + "display(get_start_docker_db_ui(sb_config))" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/sme_init.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/sme_init.ipynb index 4629582a..cdaae5b9 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/sme_init.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/sme_init.ipynb @@ -58,7 +58,7 @@ "outputs": [], "source": [ "%run utils/sme_init_ui.ipynb\n", - "display(get_sme_config_ui())" + "display(get_sme_config_ui(sb_config))" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/utils/sme_init_ui.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/utils/sme_init_ui.ipynb index 0d64e5b9..80150909 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/utils/sme_init_ui.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/sagemaker/utils/sme_init_ui.ipynb @@ -35,20 +35,21 @@ "from enum import Enum\n", "import ipywidgets as widgets\n", "\n", + "from exasol.secret_store import Secrets\n", "from exasol.ai_lab_config import AILabConfig as CKey\n", "\n", "\n", - "def get_sme_config_ui() -> widgets.Widget:\n", + "def get_sme_config_ui(conf: Secrets) -> widgets.Widget:\n", "\n", " inputs = [\n", - " ('Access Key ID', widgets.Password(value=sb_config.get(CKey.aws_access_key_id)), CKey.aws_access_key_id),\n", - " ('Secret Access Key', widgets.Password(value=sb_config.get(CKey.aws_secret_access_key)), CKey.aws_secret_access_key),\n", - " ('Region', widgets.Text(value=sb_config.get(CKey.aws_region)), CKey.aws_region),\n", - " ('Sagemaker AWS Role', widgets.Text(value=sb_config.get(CKey.sme_aws_role)), CKey.sme_aws_role),\n", - " ('Sagemaker S3 Bucket', widgets.Text(value=sb_config.get(CKey.sme_aws_bucket)), CKey.sme_aws_bucket),\n", + " ('Access Key ID', widgets.Password(value=conf.get(CKey.aws_access_key_id)), CKey.aws_access_key_id),\n", + " ('Secret Access Key', widgets.Password(value=conf.get(CKey.aws_secret_access_key)), CKey.aws_secret_access_key),\n", + " ('Region', widgets.Text(value=conf.get(CKey.aws_region)), CKey.aws_region),\n", + " ('Sagemaker AWS Role', widgets.Text(value=conf.get(CKey.sme_aws_role)), CKey.sme_aws_role),\n", + " ('Sagemaker S3 Bucket', widgets.Text(value=conf.get(CKey.sme_aws_bucket)), CKey.sme_aws_bucket),\n", " ]\n", "\n", - " return get_generic_config_ui(sb_config, [inputs], ['Set AWS Credentials'])\n" + " return get_generic_config_ui(conf, [inputs], ['Set AWS Credentials'])\n" ] } ], diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/masked_modelling.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/masked_modelling.ipynb index 5fcf8690..e69e6d55 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/masked_modelling.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/masked_modelling.ipynb @@ -89,7 +89,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME)" + "load_huggingface_model(sb_config, MODEL_NAME)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/question_answering.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/question_answering.ipynb index 65deb0d3..4e0f8c50 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/question_answering.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/question_answering.ipynb @@ -89,7 +89,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME)" + "load_huggingface_model(sb_config, MODEL_NAME)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/sequence_classification.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/sequence_classification.ipynb index 5505ef16..eded5ffd 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/sequence_classification.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/sequence_classification.ipynb @@ -90,7 +90,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME, method='udf')" + "load_huggingface_model(sb_config, MODEL_NAME, method='udf')" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/te_init.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/te_init.ipynb index 04db483a..105d506e 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/te_init.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/te_init.ipynb @@ -46,7 +46,7 @@ "outputs": [], "source": [ "%run utils/te_init_ui.ipynb\n", - "display(get_te_config_ui())" + "display(get_te_config_ui(sb_config))" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/text_generation.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/text_generation.ipynb index 10c45745..b0531f47 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/text_generation.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/text_generation.ipynb @@ -71,7 +71,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME)" + "load_huggingface_model(sb_config, MODEL_NAME)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/token_classification.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/token_classification.ipynb index cfdfffc4..bbe07b44 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/token_classification.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/token_classification.ipynb @@ -89,7 +89,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME)" + "load_huggingface_model(sb_config, MODEL_NAME)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/translation.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/translation.ipynb index 8a3d9755..03caaaae 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/translation.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/translation.ipynb @@ -80,7 +80,6 @@ "execution_count": null, "id": "50a8cc23-bba5-4497-8947-9adc8c83a76c", "metadata": { - "editable": false, "slideshow": { "slide_type": "" }, @@ -91,7 +90,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME)" + "load_huggingface_model(sb_config, MODEL_NAME)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/model_retrieval.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/model_retrieval.ipynb index 685057ae..cae09791 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/model_retrieval.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/model_retrieval.ipynb @@ -36,12 +36,14 @@ "metadata": {}, "outputs": [], "source": [ - "def load_huggingface_model_udf(model_name: str) -> None:\n", + "from exasol.secret_store import Secrets\n", + "\n", + "\n", + "def load_huggingface_model_udf(conf: Secrets, model_name: str) -> None:\n", " \"\"\"\n", " Loads specified model into BucketFS using a UDF provided with the Transformer Extension.\n", - " There must be a global variable - sb_config - providing access to the secret store holding\n", - " the configuration data.\n", "\n", + " conf - Access to the secret store holding the configuration data.\n", " model_name - Name of the model at Huggingface hub, e.g. facebook/nllb-moe-54b.\n", " \"\"\"\n", "\n", @@ -50,16 +52,16 @@ " from exasol.ai_lab_config import AILabConfig as CKey\n", "\n", " sql = f\"\"\"\n", - " SELECT {sb_config.get(CKey.db_schema)}.TE_MODEL_DOWNLOADER_UDF(\n", + " SELECT {conf.get(CKey.db_schema)}.TE_MODEL_DOWNLOADER_UDF(\n", " '{model_name}',\n", - " '{sb_config.get(CKey.te_models_bfs_dir)}',\n", - " '{sb_config.get(CKey.te_bfs_connection)}',\n", - " '{sb_config.get(CKey.te_hf_connection)}'\n", + " '{conf.get(CKey.te_models_bfs_dir)}',\n", + " '{conf.get(CKey.te_bfs_connection)}',\n", + " '{conf.get(CKey.te_hf_connection)}'\n", " )\n", " \"\"\"\n", "\n", - " with open_pyexasol_connection(sb_config, compression=True) as conn:\n", - " conn.execute(query=get_activation_sql(sb_config))\n", + " with open_pyexasol_connection(conf, compression=True) as conn:\n", + " conn.execute(query=get_activation_sql(conf))\n", " conn.execute(query=sql)" ] }, @@ -80,12 +82,11 @@ "metadata": {}, "outputs": [], "source": [ - "def load_huggingface_model_cli(model_name: str, force_download: bool = False) -> None:\n", + "def load_huggingface_model_cli(conf: Secrets, model_name: str, force_download: bool = False) -> None:\n", " \"\"\"\n", " Loads specified model into BucketFS by saving it first to a local drive, as per the command-line interface.\n", - " There must be a global variable - sb_config - providing access to the secret store holding\n", - " the configuration data.\n", "\n", + " conf - Access to the secret store holding the configuration data.\n", " model_name - Name of the model at Huggingface hub, e.g. facebook/nllb-moe-54b.\n", " force_download - If True the model will be reloaded from the hub even if it has been cached before.\n", " \"\"\"\n", @@ -97,11 +98,11 @@ "\n", " # Make a name for the model sub-directory\n", " sub_dir = re.sub(r\"[/\\\\?%*:|\\\"<>\\x7F\\x00-\\x1F]\", \"-\", model_name)\n", - " models_dir = sb_config.get(CKey.te_models_cache_dir)\n", + " models_dir = conf.get(CKey.te_models_cache_dir)\n", " cache_dir = str(Path(models_dir) / sub_dir)\n", "\n", " # Upload it to the BucketFS\n", - " upload_model(sb_config, model_name=model_name, cache_dir=cache_dir, force_download=force_download)" + " upload_model(conf, model_name=model_name, cache_dir=cache_dir, force_download=force_download)" ] }, { @@ -121,10 +122,11 @@ "metadata": {}, "outputs": [], "source": [ - "def load_huggingface_model(model_name: str, method: str = 'cli', force_download: bool = False) -> None:\n", + "def load_huggingface_model(conf: Secrets, model_name: str, method: str = 'cli', force_download: bool = False) -> None:\n", " \"\"\"\n", " Loads specified model into BucketFS choosing one of the two available methods.\n", "\n", + " conf - Access to the secret store holding the configuration data.\n", " model_name - Name of the model at Huggingface hub, e.g. facebook/nllb-moe-54b.\n", " method - The recognized values are \"udf\" and \"cli\". If the parameter is not set then\n", " will look for method selection in the configuration. That failed the CLI method\n", @@ -134,9 +136,9 @@ "\n", " method = method.lower()\n", " if method == 'udf':\n", - " load_huggingface_model_udf(model_name)\n", + " load_huggingface_model_udf(conf, model_name)\n", " else:\n", - " load_huggingface_model_cli(model_name, force_download=force_download)" + " load_huggingface_model_cli(conf, model_name, force_download=force_download)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/te_init_ui.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/te_init_ui.ipynb index 08799345..5f0f98b8 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/te_init_ui.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/utils/te_init_ui.ipynb @@ -34,16 +34,17 @@ "source": [ "import ipywidgets as widgets\n", "\n", + "from exasol.secret_store import Secrets\n", "from exasol.ai_lab_config import AILabConfig as CKey\n", "\n", "\n", - "def get_te_config_ui() -> widgets.Widget:\n", + "def get_te_config_ui(conf: Secrets) -> widgets.Widget:\n", "\n", " inputs = [\n", " ('Access token', widgets.Password(value=sb_config.get(CKey.huggingface_token)), CKey.huggingface_token)\n", " ]\n", "\n", - " return get_generic_config_ui(sb_config, [inputs], ['Huggingface Access Parameters'])\n" + " return get_generic_config_ui(conf, [inputs], ['Huggingface Access Parameters'])\n" ] } ], diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/zero_shot_classification.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/zero_shot_classification.ipynb index ab6f064a..667ef7ba 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/zero_shot_classification.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/transformers/zero_shot_classification.ipynb @@ -89,7 +89,7 @@ "outputs": [], "source": [ "%run utils/model_retrieval.ipynb\n", - "load_huggingface_model(MODEL_NAME)" + "load_huggingface_model(sb_config, MODEL_NAME)" ] }, { diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/utils/main_config_ui.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/utils/main_config_ui.ipynb index 2ec592f3..752bdff9 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/utils/main_config_ui.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/utils/main_config_ui.ipynb @@ -35,6 +35,7 @@ "outputs": [], "source": [ "from typing import List\n", + "from exasol.secret_store import Secrets\n", "from exasol.ai_lab_config import AILabConfig as CKey\n", "import ipywidgets as widgets\n", "\n", @@ -51,17 +52,15 @@ " missing = 'Exasol Docker-DB is NOT CREATED'\n", "\n", "\n", - "def get_db_selection_ui() -> widgets.Widget:\n", + "def get_db_selection_ui(conf: Secrets) -> widgets.Widget:\n", " \"\"\"\n", " Creates a UI form for choosing between the Exasol Docker-DB and an external Exasol Database.\n", - "\n", - " A global variable `sb_config` should reference a configuration store object.\n", " \"\"\"\n", "\n", " ui_look = get_config_styles()\n", "\n", " db_options = ['Exasol Docker-DB', 'External Exasol Database']\n", - " db_choice = 0 if sb_config.get(CKey.use_itde, 'True') == 'True' else 1\n", + " db_choice = 0 if conf.get(CKey.use_itde, 'True') == 'True' else 1\n", " db_selector = widgets.RadioButtons(options=db_options, value=db_options[db_choice], \n", " layout=ui_look.input_layout, style=ui_look.input_style)\n", " select_btn = widgets.Button(description='Select', style=ui_look.button_style, layout=ui_look.button_layout)\n", @@ -69,7 +68,7 @@ "\n", "\n", " def select_database(btn):\n", - " sb_config.save(CKey.use_itde, str(db_selector.value == db_options[0]))\n", + " conf.save(CKey.use_itde, str(db_selector.value == db_options[0]))\n", " btn.icon = 'check'\n", "\n", " def on_value_change(change):\n", @@ -84,80 +83,76 @@ " return ui\n", "\n", "\n", - "def get_external_db_config_ui() -> widgets.Widget:\n", + "def get_external_db_config_ui(conf: Secrets) -> widgets.Widget:\n", " \"\"\"\n", " Creates a UI form for editing an external Exasol Database configuration.\n", - " \n", - " A global variable `sb_config` should reference a configuration store object.\n", " \"\"\"\n", "\n", " inputs = [\n", " [\n", - " ('Host Name', widgets.Text(value=sb_config.get(CKey.db_host_name, '127.0.0.1')), CKey.db_host_name),\n", - " ('Port', widgets.IntText(value=int(sb_config.get(CKey.db_port, '8888'))), CKey.db_port),\n", - " ('User Name', widgets.Text(value=sb_config.get(CKey.db_user)), CKey.db_user),\n", - " ('Password', widgets.Password(value=sb_config.get(CKey.db_password)), CKey.db_password),\n", - " ('Default Schema', widgets.Text(value=sb_config.get(CKey.db_schema, 'IDA')), CKey.db_schema),\n", - " ('Encrypted Comm.', widgets.Checkbox(value=sb_config.get(CKey.db_encryption, 'True') == 'True', indent=False),\n", + " ('Host Name', widgets.Text(value=conf.get(CKey.db_host_name, '127.0.0.1')), CKey.db_host_name),\n", + " ('Port', widgets.IntText(value=int(conf.get(CKey.db_port, '8888'))), CKey.db_port),\n", + " ('User Name', widgets.Text(value=conf.get(CKey.db_user)), CKey.db_user),\n", + " ('Password', widgets.Password(value=conf.get(CKey.db_password)), CKey.db_password),\n", + " ('Default Schema', widgets.Text(value=conf.get(CKey.db_schema, 'IDA')), CKey.db_schema),\n", + " ('Encrypted Comm.', widgets.Checkbox(value=conf.get(CKey.db_encryption, 'True') == 'True', indent=False),\n", " CKey.db_encryption)\n", " ],\n", " [\n", - " ('Host Name', widgets.Text(value=sb_config.get(CKey.bfs_host_name, '127.0.0.1')), CKey.bfs_host_name),\n", - " ('Port', widgets.IntText(value=int(sb_config.get(CKey.bfs_port, '6666'))), CKey.bfs_port),\n", - " ('User Name', widgets.Text(value=sb_config.get(CKey.bfs_user)), CKey.bfs_user),\n", - " ('Password', widgets.Password(value=sb_config.get(CKey.bfs_password)), CKey.bfs_password),\n", - " ('Service Name', widgets.Text(value=sb_config.get(CKey.bfs_service, 'bfsdefault')), CKey.bfs_service),\n", - " ('Bucket Name', widgets.Text(value=sb_config.get(CKey.bfs_bucket, 'default')), CKey.bfs_bucket),\n", - " ('Encrypted Comm.', widgets.Checkbox(value=sb_config.get(CKey.bfs_encryption, 'True') == 'True', indent=False),\n", + " ('Host Name', widgets.Text(value=conf.get(CKey.bfs_host_name, '127.0.0.1')), CKey.bfs_host_name),\n", + " ('Port', widgets.IntText(value=int(conf.get(CKey.bfs_port, '6666'))), CKey.bfs_port),\n", + " ('User Name', widgets.Text(value=conf.get(CKey.bfs_user)), CKey.bfs_user),\n", + " ('Password', widgets.Password(value=conf.get(CKey.bfs_password)), CKey.bfs_password),\n", + " ('Service Name', widgets.Text(value=conf.get(CKey.bfs_service, 'bfsdefault')), CKey.bfs_service),\n", + " ('Bucket Name', widgets.Text(value=conf.get(CKey.bfs_bucket, 'default')), CKey.bfs_bucket),\n", + " ('Encrypted Comm.', widgets.Checkbox(value=conf.get(CKey.bfs_encryption, 'True') == 'True', indent=False),\n", " CKey.bfs_encryption)\n", " ],\n", " [\n", - " ('Validate Certificate', widgets.Checkbox(value=sb_config.get(CKey.cert_vld, 'True') == 'True', indent=False),\n", + " ('Validate Certificate', widgets.Checkbox(value=conf.get(CKey.cert_vld, 'True') == 'True', indent=False),\n", " CKey.cert_vld),\n", - " ('Trusted CA File/Dir', widgets.Text(value=sb_config.get(CKey.trusted_ca)), CKey.trusted_ca),\n", - " ('Certificate File', widgets.Text(value=sb_config.get(CKey.client_cert)), CKey.client_cert),\n", - " ('Private Key File', widgets.Text(value=sb_config.get(CKey.client_key)), CKey.client_key)\n", + " ('Trusted CA File/Dir', widgets.Text(value=conf.get(CKey.trusted_ca)), CKey.trusted_ca),\n", + " ('Certificate File', widgets.Text(value=conf.get(CKey.client_cert)), CKey.client_cert),\n", + " ('Private Key File', widgets.Text(value=conf.get(CKey.client_key)), CKey.client_key)\n", " ]\n", " ]\n", "\n", " group_names = ['Database Connection', 'BucketFS Connection', 'TLS/SSL Configuration']\n", "\n", - " return get_generic_config_ui(sb_config, inputs, group_names)\n", + " return get_generic_config_ui(conf, inputs, group_names)\n", "\n", "\n", - "def get_docker_db_config_ui() -> widgets.Widget:\n", + "def get_docker_db_config_ui(conf: Secrets) -> widgets.Widget:\n", " \"\"\"\n", " Creates a UI form for editing the Exasol Docker-DB configuration.\n", - "\n", - " A global variable `sb_config` should reference a configuration store object.\n", " \"\"\"\n", "\n", " inputs = [\n", " [\n", - " ('Memory Size (GiB)', widgets.IntText(value=int(sb_config.get(CKey.mem_size, '2'))), CKey.mem_size),\n", - " ('Disk Size (GiB)', widgets.IntText(value=int(sb_config.get(CKey.disk_size, '2'))), CKey.disk_size),\n", - " ('Default Schema', widgets.Text(value=sb_config.get(CKey.db_schema, 'IDA')), CKey.db_schema)\n", + " ('Memory Size (GiB)', widgets.IntText(value=int(conf.get(CKey.mem_size, '2'))), CKey.mem_size),\n", + " ('Disk Size (GiB)', widgets.IntText(value=int(conf.get(CKey.disk_size, '2'))), CKey.disk_size),\n", + " ('Default Schema', widgets.Text(value=conf.get(CKey.db_schema, 'IDA')), CKey.db_schema)\n", " ]\n", " ]\n", "\n", " group_names = ['Database Configuration']\n", "\n", - " return get_generic_config_ui(sb_config, inputs, group_names)\n", + " return get_generic_config_ui(conf, inputs, group_names)\n", "\n", "\n", "\n", - "def get_db_config_ui() -> widgets.Widget:\n", + "def get_db_config_ui(conf: Secrets) -> widgets.Widget:\n", " \"\"\"\n", " Creates a db configuration UI, depending on the choice of the database.\n", " \"\"\"\n", "\n", - " if sb_config.get(CKey.use_itde, 'True') == 'True':\n", - " return get_docker_db_config_ui()\n", + " if conf.get(CKey.use_itde, 'True') == 'True':\n", + " return get_docker_db_config_ui(conf)\n", " else:\n", - " return get_external_db_config_ui()\n", + " return get_external_db_config_ui(conf)\n", "\n", "\n", - "def _get_docker_db_action_buttions(itde_exists: bool, itde_running: bool, \n", + "def _get_docker_db_action_buttions(conf: Secrets, itde_exists: bool, itde_running: bool, \n", " display_status: widgets.Widget) -> List[widgets.Button]:\n", " \"\"\"\n", " Creates one or two action buttons with the correspondent on_click functions for managing the\n", @@ -171,12 +166,12 @@ " try:\n", " # Need to check if the Exasol Docker-DB still exists and not running because\n", " # the situation might have changed while the the widgets were hanging around.\n", - " itde_exists_now, itde_running_now = is_itde_running(sb_config)\n", + " itde_exists_now, itde_running_now = is_itde_running(conf)\n", " if not itde_running_now:\n", " if itde_exists_now:\n", - " start_itde(sb_config)\n", + " start_itde(conf)\n", " else:\n", - " bring_itde_up(sb_config)\n", + " bring_itde_up(conf)\n", " # Indicate the successful completion.\n", " display_status.value = ITDEStatus.running.value\n", " btn.icon = 'check'\n", @@ -187,10 +182,10 @@ " try:\n", " # Need to check again if the Exasol Docker-DB exists or not because\n", " # the situation might have changed while the widgets were hanging around.\n", - " itde_exists_now, _ = is_itde_running(sb_config)\n", + " itde_exists_now, _ = is_itde_running(conf)\n", " if itde_exists_now:\n", - " take_itde_down(sb_config)\n", - " bring_itde_up(sb_config)\n", + " take_itde_down(conf)\n", + " bring_itde_up(conf)\n", " # Indicate the successful completion.\n", " display_status.value = ITDEStatus.running.value\n", " btn.icon = 'check'\n", @@ -213,22 +208,20 @@ " return [btn_start]\n", "\n", "\n", - "def get_start_docker_db_ui() -> widgets.Widget:\n", + "def get_start_docker_db_ui(conf: Secrets) -> widgets.Widget:\n", " \"\"\"\n", " A UI for starting or restarting the Exasol Docker-DB.\n", " It checks if an instance of the Exasol Docker-DB is already running or if it exists.\n", " In that case a warning is displayed.\n", - "\n", - " A global variable `sb_config` should reference a configuration store object.\n", " \"\"\"\n", "\n", - " if sb_config.get(CKey.use_itde) != 'True':\n", + " if conf.get(CKey.use_itde) != 'True':\n", " return None\n", "\n", " ui_look = get_config_styles()\n", "\n", " # Get the current status of the Exasol Docker-DB.\n", - " itde_exists, itde_running = is_itde_running(sb_config)\n", + " itde_exists, itde_running = is_itde_running(conf)\n", "\n", " # Display the status.\n", " header_lbl = widgets.Label(style=ui_look.header_style, layout=ui_look.header_layout)\n", @@ -249,7 +242,7 @@ " group_items.append(widgets.Box([warning_html], layout=ui_look.row_layout))\n", "\n", " # Create action buttons.\n", - " action_buttons = _get_docker_db_action_buttions(itde_exists, itde_running, header_lbl)\n", + " action_buttons = _get_docker_db_action_buttions(conf, itde_exists, itde_running, header_lbl)\n", " for btn in action_buttons:\n", " btn.style = ui_look.button_style\n", " btn.layout = ui_look.button_layout\n", @@ -260,20 +253,6 @@ " ui = widgets.Box(items, layout=ui_look.outer_layout)\n", " return ui\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e201faac-13f7-4562-857c-0e89f6cf1a0e", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "id": "e1482248-0f26-4975-8500-ba9cc95b6f5f", - "metadata": {}, - "source": [] } ], "metadata": {