Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor build_language_container #129

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional
from pathlib import Path
from exasol.python_extension_common.deployment.language_container_deployer import LanguageContainerDeployer
import exasol.bucketfs as bfs


class SmeLanguageContainerDeployer(LanguageContainerDeployer):
Expand All @@ -17,6 +18,10 @@ def download_from_github_and_run(self, version: str,
alter_system=alter_system, allow_override=allow_override,
wait_for_completion=wait_for_completion)

@property
def bfs_path(self) -> bfs.path.PathLike:
return self._bucketfs_path

def run(self, container_file: Optional[Path] = None,
bucket_file_path: Optional[str] = None,
alter_system: bool = True,
Expand Down
30 changes: 20 additions & 10 deletions tests/ci_tests/fixtures/build_language_container_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import pytest
import subprocess
from typing import Tuple
from pathlib import Path
import pyexasol
import exasol_bucketfs_utils_python.upload as bfsupload
from exasol_bucketfs_utils_python.bucket_config import BucketConfig
from exasol_bucketfs_utils_python.bucketfs_config import BucketFSConfig
from exasol_bucketfs_utils_python.bucketfs_connection_config import \
BucketFSConnectionConfig

from tests.ci_tests.utils.parameters import db_params
from exasol_sagemaker_extension.deployment.sme_language_container_deployer import SmeLanguageContainerDeployer

from tests.ci_tests.utils.parameters import db_params, get_bfs_root_path


def find_script(script_name: str):
Expand All @@ -27,7 +31,7 @@ def find_script(script_name: str):


@pytest.fixture(scope="session")
def language_container():
def language_container() -> Tuple[Path, str]:
script_dir = find_script("build_language_container.sh")
completed_process = subprocess.run(
[script_dir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand All @@ -46,11 +50,7 @@ def language_container():
container_path = \
[line for line in lines if line.startswith(container_path_selector)][0]
container_path = container_path[len(container_path_selector):]

return {
"container_path": container_path,
"alter_session": alter_session
}
return Path(container_path), alter_session


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -86,6 +86,16 @@ def upload_language_container(language_container, db_conn):


@pytest.fixture(scope="session")
def register_language_container(upload_language_container, db_conn):
alter_session = upload_language_container
db_conn.execute(f"ALTER SYSTEM SET SCRIPT_LANGUAGES='{alter_session}'")
def container_deployer(language_container, db_conn: pyexasol.ExaConnection) -> SmeLanguageContainerDeployer:
deployer = SmeLanguageContainerDeployer(
pyexasol_connection=db_conn,
language_alias='PYTHON3_TEST',
bucketfs_path=get_bfs_root_path(),
)
return deployer


@pytest.fixture(scope="session")
def register_language_container(language_container, container_deployer: SmeLanguageContainerDeployer, db_conn):
container_path, _ = language_container
container_deployer.run(container_path, alter_system=True)
15 changes: 15 additions & 0 deletions tests/ci_tests/utils/parameters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from collections import namedtuple
import exasol.bucketfs as bfs


POLLING_INTERVAL = 5 * 60 # seconds
TIMEOUT = 90 * 60 # seconds
Expand Down Expand Up @@ -41,3 +43,16 @@ def get_db_params():


db_params = get_db_params()


def get_bfs_root_path() -> bfs.path.PathLike:
root_path = bfs.path.build_path(
backend="onprem",
url=f"http://{db_params.host}:{db_params.port}",
username="w",
password="write",
bucket_name="bfsdefault",
verify=False,
)

return root_path
Loading