Skip to content

Commit

Permalink
#133 Fixed a couple of defects
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Sep 4, 2024
1 parent e3a8525 commit 9b7c372
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
6 changes: 6 additions & 0 deletions doc/changes/changes_0.3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
## Features

* #131: Let the itde_manager use an instance of the DockerDB provided externally.

## Bugfixes

* #133: Fixed the following defects:
- Using the `allow_override` option when deploying a language container.
- Storing internal bucket-fs host and port in a bucket-fs connection object.
2 changes: 2 additions & 0 deletions exasol/nb_connector/ai_lab_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class AILabConfig(Enum):
client_key = auto()
bfs_host_name = auto()
bfs_port = auto()
bfs_internal_host_name = auto()
bfs_internal_port = auto()
bfs_service = auto()
bfs_bucket = auto()
bfs_user = auto()
Expand Down
8 changes: 6 additions & 2 deletions exasol/nb_connector/extension_wrapper_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,13 @@ def to_json_str(**kwargs) -> str:

backend = get_backend(conf)
if backend == StorageBackend.onprem:
host = conf.get(CKey.bfs_host_name, conf.get(CKey.db_host_name))
# Here we are using the internal bucket-fs host and port, falling back
# to the external parameters if the former are not specified.
host = conf.get(CKey.bfs_internal_host_name,
conf.get(CKey.bfs_host_name, conf.get(CKey.db_host_name)))
port = conf.get(CKey.bfs_internal_port, conf.get(CKey.bfs_port))
protocol = "https" if str_to_bool(conf, CKey.bfs_encryption, True) else "http"
url = f"{protocol}://{host}:{conf.get(CKey.bfs_port)}"
url = f"{protocol}://{host}:{port}"
verify: Optional[bool] = (False if conf.get(CKey.trusted_ca)
else optional_str_to_bool(conf.get(CKey.cert_vld)))
conn_to = to_json_str(backend=bfs.path.StorageBackend.onprem.name,
Expand Down
18 changes: 14 additions & 4 deletions exasol/nb_connector/sagemaker_extension_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

def deploy_language_container(conf: Secrets,
version: str,
language_alias: str) -> None:
language_alias: str,
allow_override: bool) -> None:
"""
Calls the Sagemaker Extension's language container deployment API.
Downloads the specified released version of the extension from the GitHub
Expand All @@ -56,6 +57,8 @@ def deploy_language_container(conf: Secrets,
Sagemaker Extension version.
language_alias:
The language alias of the extension's language container.
allow_override:
If True allows overriding the language definition.
"""

deployer = SmeLanguageContainerDeployer.create( # pylint: disable=unexpected-keyword-arg
Expand All @@ -65,7 +68,8 @@ def deploy_language_container(conf: Secrets,
)

# Install the language container.
deployer.download_from_github_and_run(version, False)
deployer.download_from_github_and_run(version, alter_system=False,
allow_override=allow_override)

# Save the activation SQL in the secret store.
language_def = deployer.get_language_definition(deployer.SLC_NAME)
Expand Down Expand Up @@ -99,7 +103,8 @@ def initialize_sme_extension(conf: Secrets,
language_alias: str = LANGUAGE_ALIAS,
run_deploy_container: bool = True,
run_deploy_scripts: bool = True,
run_encapsulate_aws_credentials: bool = True) -> None:
run_encapsulate_aws_credentials: bool = True,
allow_override: bool = True) -> None:
"""
Performs all necessary operations to get the Sagemaker Extension
up and running. See the "Getting Started" and "Setup" sections of the
Expand All @@ -122,13 +127,18 @@ def initialize_sme_extension(conf: Secrets,
run_encapsulate_aws_credentials:
If set to False will skip the creation of the database connection
object encapsulating the AWS credentials.
allow_override:
If True allows overriding the language definition. Otherwise, if
the database already has a language definition for the specified
language alias, an attempt to deploy the container will result
in a RuntimeError.
"""

# Make the connection object name
aws_conn_name = "_".join([AWS_CONNECTION_PREFIX, str(conf.get(CKey.db_user))])

if run_deploy_container:
deploy_language_container(conf, version, language_alias)
deploy_language_container(conf, version, language_alias, allow_override)

# Create the required objects in the database
if run_deploy_scripts:
Expand Down
19 changes: 15 additions & 4 deletions exasol/nb_connector/transformers_extension_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

def deploy_language_container(conf: Secrets,
version: str,
language_alias: str) -> None:
language_alias: str,
allow_override: bool) -> None:
"""
Calls the Transformers Extension's language container deployment API.
Downloads the specified released version of the extension from the GitHub
Expand All @@ -62,12 +63,15 @@ def deploy_language_container(conf: Secrets,
Parameters:
conf:
The secret store. The store must contain the DB connection parameters
and the parameters of the BucketFS service.
version:
Transformers Extension version.
language_alias:
The language alias of the extension's language container.
allow_override:
If True allows overriding the language definition.
"""

deployer = TeLanguageContainerDeployer.create(
Expand All @@ -77,7 +81,8 @@ def deploy_language_container(conf: Secrets,
)

# Install the language container.
deployer.download_from_github_and_run(version, False)
deployer.download_from_github_and_run(version, alter_system=False,
allow_override=allow_override)

# Save the activation SQL in the secret store.
language_def = deployer.get_language_definition(deployer.SLC_NAME)
Expand Down Expand Up @@ -113,7 +118,8 @@ def initialize_te_extension(conf: Secrets,
run_deploy_container: bool = True,
run_deploy_scripts: bool = True,
run_encapsulate_bfs_credentials: bool = True,
run_encapsulate_hf_token: bool = True) -> None:
run_encapsulate_hf_token: bool = True,
allow_override: bool = True) -> None:
"""
Performs all necessary operations to get the Transformers Extension
up and running. See the "Getting Started" and "Setup" sections of the
Expand All @@ -139,6 +145,11 @@ def initialize_te_extension(conf: Secrets,
run_encapsulate_hf_token:
If set to False will skip the creation of the database connection
object encapsulating the Huggingface token.
allow_override:
If True allows overriding the language definition. Otherwise, if
the database already has a language definition for the specified
language alias, an attempt to deploy the container will result
in a RuntimeError.
"""

# Make the connection object names
Expand All @@ -148,7 +159,7 @@ def initialize_te_extension(conf: Secrets,
hf_conn_name = "_".join([HF_CONNECTION_PREFIX, db_user]) if token else ""

if run_deploy_container:
deploy_language_container(conf, version, language_alias)
deploy_language_container(conf, version, language_alias, allow_override)

# Create the required objects in the database
if run_deploy_scripts:
Expand Down

0 comments on commit 9b7c372

Please sign in to comment.