Skip to content

Commit

Permalink
#114 Calling the language container deployer correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Jun 6, 2024
1 parent 78bccb2 commit 1aa2b63
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 49 deletions.
60 changes: 36 additions & 24 deletions exasol/nb_connector/sagemaker_extension_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from exasol.nb_connector.connections import (
open_pyexasol_connection,
get_backend
)
from exasol.nb_connector.extension_wrapper_common import (
encapsulate_aws_credentials,
Expand All @@ -15,7 +16,7 @@
get_activation_sql
)
from exasol.nb_connector.secret_store import Secrets
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey, StorageBackend

# Root directory in a BucketFS bucket where all stuff of the Sagemaker
# Extension, including its language container, will be uploaded.
Expand Down Expand Up @@ -60,29 +61,40 @@ def deploy_language_container(conf: Secrets,
The language alias of the extension's language container.
"""

deployer = SmeLanguageContainerDeployer.create(
dsn=get_optional_external_host(conf),
db_user=conf.get(CKey.db_user),
db_password=conf.get(CKey.db_password),
bucketfs_name=conf.get(CKey.bfs_service),
bucketfs_host=conf.get(CKey.bfs_host_name, conf.get(CKey.db_host_name)),
bucketfs_port=get_optional_bfs_port(conf),
bucketfs_user=conf.get(CKey.bfs_user),
bucketfs_password=conf.get(CKey.bfs_password),
bucketfs_use_https=str_to_bool(conf, CKey.bfs_encryption, True),
bucket=conf.get(CKey.bfs_bucket),
saas_url=conf.get(CKey.saas_url),
saas_account_id=conf.get(CKey.saas_account_id),
saas_database_id=conf.get(CKey.saas_database_id),
saas_database_name=conf.get(CKey.saas_database_name),
saas_token=conf.get(CKey.saas_token),
path_in_bucket=PATH_IN_BUCKET,
language_alias=language_alias,
use_ssl_cert_validation=str_to_bool(conf, CKey.cert_vld, True),
ssl_trusted_ca=conf.get(CKey.trusted_ca),
ssl_client_certificate=conf.get(CKey.client_cert),
ssl_private_key=conf.get(CKey.client_key),
)
backend = get_backend(conf)
if backend == StorageBackend.onprem:
deployer = SmeLanguageContainerDeployer.create(
dsn=get_optional_external_host(conf),
db_user=conf.get(CKey.db_user),
db_password=conf.get(CKey.db_password),
bucketfs_name=conf.get(CKey.bfs_service),
bucketfs_host=conf.get(CKey.bfs_host_name, conf.get(CKey.db_host_name)),
bucketfs_port=get_optional_bfs_port(conf),
bucketfs_user=conf.get(CKey.bfs_user),
bucketfs_password=conf.get(CKey.bfs_password),
bucketfs_use_https=str_to_bool(conf, CKey.bfs_encryption, True),
bucket=conf.get(CKey.bfs_bucket),
path_in_bucket=PATH_IN_BUCKET,
language_alias=language_alias,
use_ssl_cert_validation=str_to_bool(conf, CKey.cert_vld, True),
ssl_trusted_ca=conf.get(CKey.trusted_ca),
ssl_client_certificate=conf.get(CKey.client_cert),
ssl_private_key=conf.get(CKey.client_key),
)
else:
deployer = SmeLanguageContainerDeployer.create(
saas_url=conf.get(CKey.saas_url),
saas_account_id=conf.get(CKey.saas_account_id),
saas_database_id=conf.get(CKey.saas_database_id),
saas_database_name=conf.get(CKey.saas_database_name),
saas_token=conf.get(CKey.saas_token),
path_in_bucket=PATH_IN_BUCKET,
language_alias=language_alias,
use_ssl_cert_validation=str_to_bool(conf, CKey.cert_vld, True),
ssl_trusted_ca=conf.get(CKey.trusted_ca),
ssl_client_certificate=conf.get(CKey.client_cert),
ssl_private_key=conf.get(CKey.client_key),
)

# Install the language container.
deployer.download_from_github_and_run(version, False)
Expand Down
62 changes: 37 additions & 25 deletions exasol/nb_connector/transformers_extension_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from exasol_transformers_extension.deployment.te_language_container_deployer import TeLanguageContainerDeployer # type: ignore

from exasol.nb_connector.connections import (
open_pyexasol_connection
open_pyexasol_connection,
get_backend
)
from exasol.nb_connector.extension_wrapper_common import (
encapsulate_bucketfs_credentials,
Expand All @@ -16,7 +17,7 @@
get_activation_sql
)
from exasol.nb_connector.secret_store import Secrets
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey, StorageBackend

# Root directory in a BucketFS bucket where all stuff of the Transformers
# Extension, including its language container, will be uploaded.
Expand Down Expand Up @@ -72,29 +73,40 @@ def deploy_language_container(conf: Secrets,
The language alias of the extension's language container.
"""

deployer = TeLanguageContainerDeployer.create(
dsn=get_optional_external_host(conf),
db_user=conf.get(CKey.db_user),
db_password=conf.get(CKey.db_password),
bucketfs_name=conf.get(CKey.bfs_service),
bucketfs_host=conf.get(CKey.bfs_host_name, conf.get(CKey.db_host_name)),
bucketfs_port=get_optional_bfs_port(conf),
bucketfs_user=conf.get(CKey.bfs_user),
bucketfs_password=conf.get(CKey.bfs_password),
bucketfs_use_https=str_to_bool(conf, CKey.bfs_encryption, True),
bucket=conf.get(CKey.bfs_bucket),
saas_url=conf.get(CKey.saas_url),
saas_account_id=conf.get(CKey.saas_account_id),
saas_database_id=conf.get(CKey.saas_database_id),
saas_database_name=conf.get(CKey.saas_database_name),
saas_token=conf.get(CKey.saas_token),
path_in_bucket=PATH_IN_BUCKET,
language_alias=language_alias,
use_ssl_cert_validation=str_to_bool(conf, CKey.cert_vld, True),
ssl_trusted_ca=conf.get(CKey.trusted_ca),
ssl_client_certificate=conf.get(CKey.client_cert),
ssl_private_key=conf.get(CKey.client_key)
)
backend = get_backend(conf)
if backend == StorageBackend.onprem:
deployer = TeLanguageContainerDeployer.create(
dsn=get_optional_external_host(conf),
db_user=conf.get(CKey.db_user),
db_password=conf.get(CKey.db_password),
bucketfs_name=conf.get(CKey.bfs_service),
bucketfs_host=conf.get(CKey.bfs_host_name, conf.get(CKey.db_host_name)),
bucketfs_port=get_optional_bfs_port(conf),
bucketfs_user=conf.get(CKey.bfs_user),
bucketfs_password=conf.get(CKey.bfs_password),
bucketfs_use_https=str_to_bool(conf, CKey.bfs_encryption, True),
bucket=conf.get(CKey.bfs_bucket),
path_in_bucket=PATH_IN_BUCKET,
language_alias=language_alias,
use_ssl_cert_validation=str_to_bool(conf, CKey.cert_vld, True),
ssl_trusted_ca=conf.get(CKey.trusted_ca),
ssl_client_certificate=conf.get(CKey.client_cert),
ssl_private_key=conf.get(CKey.client_key)
)
else:
deployer = TeLanguageContainerDeployer.create(
saas_url=conf.get(CKey.saas_url),
saas_account_id=conf.get(CKey.saas_account_id),
saas_database_id=conf.get(CKey.saas_database_id),
saas_database_name=conf.get(CKey.saas_database_name),
saas_token=conf.get(CKey.saas_token),
path_in_bucket=PATH_IN_BUCKET,
language_alias=language_alias,
use_ssl_cert_validation=str_to_bool(conf, CKey.cert_vld, True),
ssl_trusted_ca=conf.get(CKey.trusted_ca),
ssl_client_certificate=conf.get(CKey.client_cert),
ssl_private_key=conf.get(CKey.client_key)
)

# Install the language container.
deployer.download_from_github_and_run(version, False)
Expand Down

0 comments on commit 1aa2b63

Please sign in to comment.