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

#174 replace language container stuff with pec and slc pytest plugin #182

Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
90125c1
#174 Replaced Language Container Stuff with PEC
ckunki Sep 13, 2024
e225ece
Updated changes file
ckunki Sep 13, 2024
231ce11
poetry lock
ckunki Sep 13, 2024
b31d203
#174 Replaced Language Container Stuff with PEC
ckunki Sep 17, 2024
b9c7621
Fixed typeguard error
ckunki Sep 17, 2024
ce76e79
Removed typguard argument argname
ckunki Sep 17, 2024
d868c64
Fixed typeguard errors
ckunki Sep 17, 2024
9d2931b
Modified and renamed fixture to slc_builder_for_tests
ckunki Sep 17, 2024
2d7cb8a
Fixed import for Language_Container_Builder
ckunki Sep 17, 2024
4d8772f
#183 Fixed warning on tests with __init__ constructor
ckunki Sep 17, 2024
a264987
Fixed fixture create_container_deployer
ckunki Sep 17, 2024
76a1c2f
poetry lock test_package
ckunki Sep 18, 2024
bcb7a57
Added plugin pytest-exasol-slc
ckunki Sep 18, 2024
84d4eb4
disabled backend saas for pytest
ckunki Sep 18, 2024
580629a
Moved cls_builder to integration_tests/with_db/conftest.py
ckunki Sep 18, 2024
d787837
Fixed LanguageContainerBuilder
ckunki Sep 18, 2024
b41e217
updated pytest-exasol-backend to version 0.3.0
ckunki Sep 18, 2024
306fc3f
Replaced ITDE by pytest plugin exasol-backend
ckunki Sep 20, 2024
6f72d00
Cleanup
ckunki Sep 20, 2024
9bb5cef
fixed handing backend parameter to pytest
ckunki Sep 20, 2024
97458ea
Ensure upload SLC before calling _deploy_scripts
ckunki Sep 20, 2024
2d91514
Experimental fix for PYTSLC
ckunki Sep 23, 2024
6837def
Added imports
ckunki Sep 23, 2024
e900211
Added constant BFS_CONTAINER_DIRECTORY, temporarily
ckunki Sep 23, 2024
8cb8a7b
Fixed access to backend_aware_bucketfs_params
ckunki Sep 23, 2024
829c480
Fixed Build
ckunki Sep 23, 2024
b03f819
Ensure port is not empty
ckunki Sep 23, 2024
4170a3a
Fixed BucketFS URL
ckunki Sep 23, 2024
67e50b9
Added dependency to pytest-exasol-extension
ckunki Sep 24, 2024
6501ac1
Return name of bucketfs connection in fixture database_with_slc
ckunki Sep 24, 2024
9ba9727
Fixed tests once again
ckunki Sep 24, 2024
d93646f
as fixture
ckunki Sep 24, 2024
fd42667
fixed fixture
ckunki Sep 24, 2024
2790467
fixed fixture 2
ckunki Sep 24, 2024
695e46c
Removed SLC deployer and tests
ckunki Sep 24, 2024
15dd59a
Removed remaining references to old slc_deployer implementation
ckunki Sep 24, 2024
6f84880
Updated to PEC version 0.5.0
ckunki Sep 24, 2024
504a592
Removed temporary implementation of IncrementalSlcBuilder
ckunki Sep 24, 2024
d7ae37e
Prepare using pytest-exasol-slc 0.3.0 fixtures
ckunki Sep 24, 2024
fed4986
Fixed syntax error
ckunki Sep 24, 2024
3e662e4
Use pytest-exasol-slc 0.3.0 fixture deployed_slc
ckunki Sep 24, 2024
b1fac53
Cleanup
ckunki Sep 24, 2024
c72cbdf
Fixed test_scripts_deployer
ckunki Sep 24, 2024
4285491
Replaced test/utils/parameters.py
ckunki Sep 24, 2024
172be2e
Replaced method ScriptsDeployer.run
ckunki Sep 25, 2024
b16a92d
Added comments for cleanup
ckunki Sep 25, 2024
b1f03fa
Removed unused import
ckunki Sep 25, 2024
64d853b
Fixed review findings
ckunki Sep 25, 2024
fed53c8
Fixed slc.py
ckunki Sep 25, 2024
8191616
Fixed test
ckunki Sep 25, 2024
a30ab7a
Cleanup
ckunki Sep 25, 2024
a8cf3ce
Use ScriptsDeployer constructor in tests
ckunki Sep 26, 2024
92a090e
Reverted changes to run method of ScriptsDeployer
ckunki Sep 26, 2024
0242e26
pinned micromamba version to 1.5.10
ckunki Sep 26, 2024
3fb91d9
Fixed
ckunki Sep 26, 2024
d8e868c
Fixed call to micromamba
ckunki Sep 26, 2024
8c5c6d3
#184 Updated micromamba to version 2.0.0
ckunki Sep 26, 2024
fa64a89
#184 Updated micromamba to version 2.0.0
ckunki Sep 26, 2024
32e44ab
Cleaned up experiments for updating micromamba
ckunki Sep 26, 2024
3fc3678
Removed comment with question.
ckunki Sep 26, 2024
e8f57ba
Fixed Review findings.
ckunki Sep 30, 2024
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
8 changes: 1 addition & 7 deletions .github/workflows/tests-integration-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ jobs:
- name: Poetry install
run: poetry run -- nox -s run_in_dev_env -- poetry install

- name: Build language container
run: poetry run -- nox -s build_language_container

- name: Start test environment
run: poetry run -- nox -s start_integration_test_environment

- name: Run Python integration tests with db
run: poetry run -- nox -s run_python_integration_tests_with_db
run: poetry run -- nox -s run_python_integration_tests_with_db -- -- --setup-show --backend=onprem
ckunki marked this conversation as resolved.
Show resolved Hide resolved
env:
PYTEST_ADDOPTS: '-o log_cli=true -o log_cli_level=INFO ${{ steps.pytest-markers.outputs.slow-tests }}'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ doc/_build

# emacs
TAGS

# locally build script language container files
.slc
20 changes: 20 additions & 0 deletions doc/changes/changes_0.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,27 @@ Code name:
* #95: Remove setup.py
* #114: Refactored BackgroundPeerState and introduced parameter objects
* #173: Introduced Python Toolbox
* #174: Replaced Language Container Stuff with PEC and SLC plugin
* #183: Fixed warning on tests with `__init__` constructor
* #184: Updated micromamba to the latest version 2.0.0

### Documentation

* #9: Added README file

## Dependency Updates

Compared to `main` branch this release updates the following dependencies:

### File `pyproject.toml`

* Updated dependency `exasol-bucketfs:0.8.0` to `0.13.0`
* Updated dependency `pyexasol:0.25.2` to `0.27.0`
* Updated dependency `typeguard:2.13.3` to `4.3.0`
* Updated dependency `exasol-integration-test-docker-environment:3.1.0` to `3.2.0`
* Updated dependency `polyfactory:2.16.2` to `2.17.0`
* Added dependency `exasol-python-extension-common:0.6.0`
* Added dependency `exasol-script-languages-container-tool:1.0.0`
* Added dependency `pytest-exasol-slc:0.3.0`
* Added dependency `pytest-exasol-backend:0.3.0`
* Added dependency `pytest-exasol-extension:0.1.0`
25 changes: 19 additions & 6 deletions exasol_advanced_analytics_framework/deploy.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import logging
import click
from exasol_advanced_analytics_framework.deployment. \
language_container_deployer_cli import language_container_deployer_main
from exasol_advanced_analytics_framework.deployment. \
scripts_deployer_cli import scripts_deployer_main
from exasol_advanced_analytics_framework.slc import (
SLC_FILE_NAME,
SLC_URL_FORMATTER,
)
from exasol_advanced_analytics_framework.deployment import (
scripts_deployer_cli,
language_container_deployer_cli,
)
from exasol.python_extension_common.deployment.language_container_deployer_cli import (
language_container_deployer_main,
slc_parameter_formatters,
CustomizableParameters,
)


@click.group()
def main():
pass


main.add_command(scripts_deployer_main)
main.add_command(language_container_deployer_main)
slc_parameter_formatters.set_formatter(CustomizableParameters.container_url, SLC_URL_FORMATTER)
slc_parameter_formatters.set_formatter(CustomizableParameters.container_name, SLC_FILE_NAME)

main.add_command(scripts_deployer_cli.scripts_deployer_main)
main.add_command(language_container_deployer_cli.language_container_deployer_main)


if __name__ == '__main__':
logging.basicConfig(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ def deploy_scripts(self) -> None:
@classmethod
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preferred passing the pyexasol_connection instead of the individual parameters dsn, user and password as the tests are using the fixture pyexasol_connection anyway and extracting the former individual parameters seemed cumbersome to me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the pyexasol Connection you have the constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor does not call save_aaf_query_loop_lua_script(), nor scripts_deployer.deploy_scripts().
So in the end I still prefer changing the signature.
Alternatively we could use a different name and keep the old method.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For explanation, the run is specifically for the CLI and for nothing else. Other code should call deploy_scripts directly and should use an already generated Lua script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found 3 places calling ScriptsDeployer.run():

The current implementation of the run() method is

if develop:
    save_aaf_query_loop_lua_script()
scripts_deployer = cls(language_alias, schema, pyexasol_conn)
scripts_deployer.deploy_scripts()

As P2 and P3 both are using flag develop=True I will use the following code in order to use the constructor:

save_aaf_query_loop_lua_script()
ScriptsDeployer(language_alias, db_schema_name, pyexasol_connection).deploy_scripts()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be ok for now. We could also think about moving the save_aaf_query_loop_lua_script call into its own fixture

def run(cls, dsn: str, user: str, password: str,
schema: str, language_alias: str, develop: bool):

if develop:
save_aaf_query_loop_lua_script()

pyexasol_conn = pyexasol.connect(dsn=dsn, user=user, password=password)
scripts_deployer = cls(language_alias, schema, pyexasol_conn)
scripts_deployer.deploy_scripts()
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@
from exasol_advanced_analytics_framework.deployment import utils
from exasol_advanced_analytics_framework.deployment.scripts_deployer import \
ScriptsDeployer

from exasol_advanced_analytics_framework.slc import LANGUAGE_ALIAS

@click.command(name="scripts")
@click.option('--dsn', type=str, required=True)
@click.option('--user', type=str, required=True)
@click.option('--pass', 'pwd', type=str)
@click.option('--schema', type=str, required=True)
@click.option('--language-alias', type=str, default="PYTHON3_AAF")
@click.option('--language-alias', type=str, default=LANGUAGE_ALIAS)
@click.option('--develop', type=bool, is_flag=True)
def scripts_deployer_main(
dsn: str, user: str, pwd: str, schema: str,
language_alias: str, develop: bool):
password = utils.get_password(
pwd, user, utils.DB_PASSWORD_ENVIRONMENT_VARIABLE, "DB Password")

# pyexasol_conn = pyexasol.connect(dsn=dsn, user=user, password=password)
ckunki marked this conversation as resolved.
Show resolved Hide resolved
ScriptsDeployer.run(
dsn=dsn,
user=user,
password=password,
schema=schema,
language_alias=language_alias,
develop=develop
develop=develop,
)
# ScriptsDeployer.run(
# pyexasol_conn,
# schema=schema,
# language_alias=language_alias,
# develop=develop
# )
ckunki marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == '__main__':
Expand Down
18 changes: 18 additions & 0 deletions exasol_advanced_analytics_framework/slc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from contextlib import contextmanager
from exasol.python_extension_common.deployment.language_container_builder import (
LanguageContainerBuilder,
find_path_backwards
)

LANGUAGE_ALIAS = "PYTHON3_AAF"
SLC_NAME = "exasol_advanced_analytics_framework_container"
SLC_FILE_NAME = SLC_NAME + ".tar.gz"
SLC_URL_FORMATTER = "https://github.com/exasol/advanced_analytics_framework/releases/download/{version}/" + SLC_NAME


@contextmanager
def custom_slc_builder() -> LanguageContainerBuilder:
project_directory = find_path_backwards("pyproject.toml", __file__).parent
with LanguageContainerBuilder(SLC_NAME) as builder:
builder.prepare_flavor(project_directory)
yield builder
2 changes: 1 addition & 1 deletion exasol_data_science_utils_python/schema/column_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ColumnName(ExasolIdentifierImpl):
@typechecked
def __init__(self, name: str, table_like_name: TableLikeName = None):
def __init__(self, name: str, table_like_name: TableLikeName|None = None):
super().__init__(name)
self._table_like_name = table_like_name

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from dataclasses import fields

import typeguard

from typeguard import TypeCheckError

def check_dataclass_types(datacls):
for field in fields(datacls):
typeguard.check_type(value=datacls.__dict__[field.name],
expected_type=field.type,
argname=field.name)
try:
typeguard.check_type(value=datacls.__dict__[field.name],
expected_type=field.type)
except TypeCheckError as e:
raise TypeCheckError(f"Field '{field.name}' has wrong type: {e}")
14 changes: 11 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import os
from pathlib import Path
from exasol_advanced_analytics_framework.slc import custom_slc_builder
from datetime import datetime

import nox
from nox import Session
Expand Down Expand Up @@ -108,11 +110,17 @@ def start_integration_test_environment(session: Session):

@nox.session(python=False)
def build_language_container(session: Session):
script_path = ROOT_DIR / "build_language_container.sh"
session.run(str(script_path))
export_path = ROOT_DIR / ".slc"
with custom_slc_builder() as builder:
builder.export(export_path)


@nox.session(python=False)
def run_python_integration_tests_with_db(session: Session):
integration_test_directory = INTEGRATION_TEST_DIRECTORY / "with_db"
_run_in_dev_env_poetry_call(session, "pytest", str(integration_test_directory))
_run_in_dev_env_poetry_call(
session,
"pytest",
str(integration_test_directory),
*session.posargs,
)
Loading