From 1aa2b632d85ffc819dfaa50bdd2a0a2ab55b5d1a Mon Sep 17 00:00:00 2001 From: mibe Date: Thu, 6 Jun 2024 17:41:23 +0100 Subject: [PATCH] #114 Calling the language container deployer correctly --- .../sagemaker_extension_wrapper.py | 60 +++++++++++------- .../transformers_extension_wrapper.py | 62 +++++++++++-------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/exasol/nb_connector/sagemaker_extension_wrapper.py b/exasol/nb_connector/sagemaker_extension_wrapper.py index a3a8e25..9109704 100644 --- a/exasol/nb_connector/sagemaker_extension_wrapper.py +++ b/exasol/nb_connector/sagemaker_extension_wrapper.py @@ -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, @@ -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. @@ -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) diff --git a/exasol/nb_connector/transformers_extension_wrapper.py b/exasol/nb_connector/transformers_extension_wrapper.py index e1f09cf..2148fbc 100644 --- a/exasol/nb_connector/transformers_extension_wrapper.py +++ b/exasol/nb_connector/transformers_extension_wrapper.py @@ -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, @@ -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. @@ -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)