From 8d572f6b638e3a002b4201c92a9d6036fd71c614 Mon Sep 17 00:00:00 2001 From: Torsten Kilias Date: Fri, 5 Jan 2024 07:52:21 +0100 Subject: [PATCH 1/4] Add get_language_activation to LanguageActivationLevel --- .../deployment/language_container_deployer.py | 5 ++++ .../test_language_container_deployer.py | 28 ++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/exasol_transformers_extension/deployment/language_container_deployer.py b/exasol_transformers_extension/deployment/language_container_deployer.py index 7a52063c..c21aeb0b 100644 --- a/exasol_transformers_extension/deployment/language_container_deployer.py +++ b/exasol_transformers_extension/deployment/language_container_deployer.py @@ -213,6 +213,11 @@ def _update_previous_language_settings(self, alter_type: LanguageActivationLevel path_in_udf, prev_lang_aliases) return new_definitions_str + def get_language_activation(self, bucket_file_path: str): + path_in_udf = self._bucketfs_location.generate_bucket_udf_path(bucket_file_path) + result = self._generate_new_language_settings(path_in_udf=path_in_udf, prev_lang_aliases=[]) + return result + def _generate_new_language_settings(self, path_in_udf: PurePosixPath, prev_lang_aliases: List[str]) -> str: other_definitions = [ diff --git a/tests/unit_tests/deployment/test_language_container_deployer.py b/tests/unit_tests/deployment/test_language_container_deployer.py index 58f7e1b1..3b4359d8 100644 --- a/tests/unit_tests/deployment/test_language_container_deployer.py +++ b/tests/unit_tests/deployment/test_language_container_deployer.py @@ -3,9 +3,11 @@ ######################################################### from pathlib import Path, PurePosixPath from unittest.mock import create_autospec, MagicMock, patch + import pytest -from pyexasol import ExaConnection from exasol_bucketfs_utils_python.bucketfs_location import BucketFSLocation +from pyexasol import ExaConnection + from exasol_transformers_extension.deployment.language_container_deployer import ( LanguageContainerDeployer, LanguageActivationLevel) @@ -77,14 +79,13 @@ def test_slc_deployer_activate(container_deployer, container_file_name, containe @patch('exasol_transformers_extension.deployment.language_container_deployer.get_language_settings') def test_slc_deployer_generate_activation_command(mock_lang_settings, container_deployer, language_alias, container_file_name, container_bfs_path): - mock_lang_settings.return_value = 'R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3' alter_type = LanguageActivationLevel.Session expected_command = f"ALTER {alter_type.value.upper()} SET SCRIPT_LANGUAGES='" \ - "R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3 " \ - f"{language_alias}=localzmq+protobuf:///{container_bfs_path}?" \ - f"lang=python#/buckets/{container_bfs_path}/exaudf/exaudfclient_py3';" + "R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3 " \ + f"{language_alias}=localzmq+protobuf:///{container_bfs_path}?" \ + f"lang=python#/buckets/{container_bfs_path}/exaudf/exaudfclient_py3';" command = container_deployer.generate_activation_command(container_file_name, alter_type) assert command == expected_command @@ -93,7 +94,6 @@ def test_slc_deployer_generate_activation_command(mock_lang_settings, container_ @patch('exasol_transformers_extension.deployment.language_container_deployer.get_language_settings') def test_slc_deployer_generate_activation_command_override(mock_lang_settings, container_deployer, language_alias, container_file_name, container_bfs_path): - current_bfs_path = 'bfsdefault/default/container_abc' mock_lang_settings.return_value = \ 'R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3 ' \ @@ -102,9 +102,9 @@ def test_slc_deployer_generate_activation_command_override(mock_lang_settings, c alter_type = LanguageActivationLevel.Session expected_command = f"ALTER {alter_type.value.upper()} SET SCRIPT_LANGUAGES='" \ - "R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3 " \ - f"{language_alias}=localzmq+protobuf:///{container_bfs_path}?" \ - f"lang=python#/buckets/{container_bfs_path}/exaudf/exaudfclient_py3';" + "R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3 " \ + f"{language_alias}=localzmq+protobuf:///{container_bfs_path}?" \ + f"lang=python#/buckets/{container_bfs_path}/exaudf/exaudfclient_py3';" command = container_deployer.generate_activation_command(container_file_name, alter_type, allow_override=True) assert command == expected_command @@ -113,7 +113,6 @@ def test_slc_deployer_generate_activation_command_override(mock_lang_settings, c @patch('exasol_transformers_extension.deployment.language_container_deployer.get_language_settings') def test_slc_deployer_generate_activation_command_failure(mock_lang_settings, container_deployer, language_alias, container_file_name): - current_bfs_path = 'bfsdefault/default/container_abc' mock_lang_settings.return_value = \ 'R=builtin_r JAVA=builtin_java PYTHON3=builtin_python3 ' \ @@ -123,3 +122,12 @@ def test_slc_deployer_generate_activation_command_failure(mock_lang_settings, co with pytest.raises(RuntimeError): container_deployer.generate_activation_command(container_file_name, LanguageActivationLevel.Session, allow_override=False) + + +def test_slc_deployer_get_language_activation(container_deployer, language_alias, + container_file_name, container_bfs_path): + expected_command = f"{language_alias}=localzmq+protobuf:///{container_bfs_path}?" \ + f"lang=python#/buckets/{container_bfs_path}/exaudf/exaudfclient_py3" + + command = container_deployer.get_language_activation(container_file_name) + assert command == expected_command From ceb42452fdae64a19bb3c36af51f1746a4d5ea7c Mon Sep 17 00:00:00 2001 From: Torsten Kilias Date: Fri, 5 Jan 2024 08:11:44 +0100 Subject: [PATCH 2/4] Rename get_language_activation to get_language_definition --- .../deployment/language_container_deployer.py | 7 ++++++- .../deployment/test_language_container_deployer.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/exasol_transformers_extension/deployment/language_container_deployer.py b/exasol_transformers_extension/deployment/language_container_deployer.py index c21aeb0b..d3d3170f 100644 --- a/exasol_transformers_extension/deployment/language_container_deployer.py +++ b/exasol_transformers_extension/deployment/language_container_deployer.py @@ -213,7 +213,12 @@ def _update_previous_language_settings(self, alter_type: LanguageActivationLevel path_in_udf, prev_lang_aliases) return new_definitions_str - def get_language_activation(self, bucket_file_path: str): + def get_language_definition(self, bucket_file_path: str): + """ + Generate a language definition (ALIAS=URL) for the specified bucket file path. + + bucket_file_path - Path within the designated bucket where the container is uploaded. + """ path_in_udf = self._bucketfs_location.generate_bucket_udf_path(bucket_file_path) result = self._generate_new_language_settings(path_in_udf=path_in_udf, prev_lang_aliases=[]) return result diff --git a/tests/unit_tests/deployment/test_language_container_deployer.py b/tests/unit_tests/deployment/test_language_container_deployer.py index 3b4359d8..746c442b 100644 --- a/tests/unit_tests/deployment/test_language_container_deployer.py +++ b/tests/unit_tests/deployment/test_language_container_deployer.py @@ -124,10 +124,10 @@ def test_slc_deployer_generate_activation_command_failure(mock_lang_settings, co allow_override=False) -def test_slc_deployer_get_language_activation(container_deployer, language_alias, +def test_slc_deployer_get_language_definition(container_deployer, language_alias, container_file_name, container_bfs_path): expected_command = f"{language_alias}=localzmq+protobuf:///{container_bfs_path}?" \ f"lang=python#/buckets/{container_bfs_path}/exaudf/exaudfclient_py3" - command = container_deployer.get_language_activation(container_file_name) + command = container_deployer.get_language_definition(container_file_name) assert command == expected_command From 7e088f5a3ac0ff153e622a40bd4c8fbf5cc11b1c Mon Sep 17 00:00:00 2001 From: Torsten Kilias Date: Fri, 5 Jan 2024 08:23:08 +0100 Subject: [PATCH 3/4] Update changelog --- doc/changes/changes_0.8.0.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/changes/changes_0.8.0.md b/doc/changes/changes_0.8.0.md index 751d219a..60a0d872 100644 --- a/doc/changes/changes_0.8.0.md +++ b/doc/changes/changes_0.8.0.md @@ -1,15 +1,15 @@ -# Transformers Extension 0.8.0, T.B.D +# Transformers Extension 0.8.0, 2024-01-05 -Code name: T.B.D +Code name: Get Language Definition in LanguageContainerDeployer ## Summary -T.B.D +This release added the get_language_definition function to the LanguageContainerDeployer. ### Features - - n/a + - #174: Added get_language_definition to the language container deployer ### Bug Fixes @@ -24,5 +24,6 @@ T.B.D - n/a ### Security + - Update paramiko version to 3.4.0 - Updated transformers to 4.36.2 \ No newline at end of file From 12437e6b2db3854570d98f1b97f023af2580c314 Mon Sep 17 00:00:00 2001 From: Torsten Kilias Date: Fri, 5 Jan 2024 08:26:25 +0100 Subject: [PATCH 4/4] [CodeBuild]