Skip to content

Commit 14bab30

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 5c7c13d + 72fdec4 commit 14bab30

File tree

9 files changed

+82
-39
lines changed

9 files changed

+82
-39
lines changed

.github/workflows/report.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
path: ./artifacts
3030

3131
- name: Copy Artifacts into Root Folder
32+
if: ${{ (hashFiles('./artifacts/.coverage/.coverage') != '') && (hashFiles('./artifacts/.lint.txt/.lint.txt') != '')}}
3233
working-directory: ./artifacts
3334
run: |
3435
cp .coverage/.coverage ../
@@ -44,6 +45,7 @@ jobs:
4445
path: metrics.json
4546

4647
- name: Generate GitHub Summary
48+
if: ${{ (hashFiles('./artifacts/.coverage/.coverage') != '') && (hashFiles('./artifacts/.lint.txt/.lint.txt') != '')}}
4749
run: |
4850
echo -e "# Summary\n" >> $GITHUB_STEP_SUMMARY
4951
poetry run nox -s report -- -- --format markdown >> $GITHUB_STEP_SUMMARY

doc/changes/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 📝 Changes
22

33
* [unreleased](unreleased.md)
4+
* [0.5.0](changes_0.5.0.md)
45
* [0.4.0](changes_0.4.0.md)
56
* [0.3.1](changes_0.3.1.md)
67
* [0.3.0](changes_0.3.0.md)
@@ -12,6 +13,7 @@
1213
hidden:
1314
---
1415
unreleased
16+
changes_0.5.0
1517
changes_0.4.0
1618
changes_0.3.1
1719
changes_0.3.0

doc/changes/changes_0.5.0.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# 0.5.0 - 2024-09-19
2+
3+
This release prepares validation of Script Language Containers (SLC) uploaded to BucketFS as a file archive, e.g. with extension `tar.gz`.
4+
5+
Validation is implemented by
6+
* activating the uploaded SLC,
7+
* running a UDF inside it,
8+
* and making the UDF check for a specific file having been extracted from the SLC archive to be available on each node of the databasecluster.
9+
10+
Addtionally this release refactors the existing CLI tests for the `LanguageContainerDeployer` which were integration tests involving the whole chain from the CLI down to the API, starting a database and uploading and activating SLCs.
11+
12+
The existing integration tests have been split into
13+
* either unit tests just verifiying that the CLI options are passed to the API
14+
* or ordinary integration tests not using the CLI.
15+
16+
This enables faster and more robust tests for the pure CLI-related features, faster turnaounds during development, and separation of concerns.
17+
18+
## Features
19+
20+
* #50: Created new implementation `ExtractValidator` for validating extraction of
21+
* #49: Integrated new `ExtractValidator` into `LanguageContainerDeployer`
22+
23+
# Refactoring
24+
25+
* #51: Split CLI integration tests
26+
27+
## Bug Fixing
28+
29+
* #60: Fix handling pip requirements when creating an SLC

doc/changes/unreleased.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
11
# Unreleased
2-
3-
This release prepares validation of Script Language Containers (SLC) uploaded to BucketFS as a file archive, e.g. with extension `tar.gz`.
4-
5-
Validation is implemented by
6-
* activating the uploaded SLC,
7-
* running a UDF inside it,
8-
* and making the UDF check for a specific file having been extracted from the SLC archive to be available on each node of the databasecluster.
9-
10-
Addtionally this release refactors the existing CLI tests for the `LanguageContainerDeployer` which were integration tests involving the whole chain from the CLI down to the API, starting a database and uploading and activating SLCs.
11-
12-
The existing integration tests have been split into
13-
* either unit tests just verifiying that the CLI options are passed to the API
14-
* or ordinary integration tests not using the CLI.
15-
16-
This enables faster and more robust tests for the pure CLI-related features, faster turnaounds during development, and separation of concerns.
17-
18-
## Features
19-
20-
* #50: Created new implementation `ExtractValidator` for validating extraction of
21-
* #49: Integrated new `ExtractValidator` into `LanguageContainerDeployer`
22-
23-
# Refactoring
24-
25-
* #51: Split CLI integration tests

exasol/python_extension_common/deployment/language_container/flavor_base/build_steps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from pathlib import Path
2-
from typing import Dict
3-
1+
# pylint: disable=import-error
42
from exasol_script_languages_container_tool.lib.tasks.build.docker_flavor_image_task import DockerFlavorAnalyzeImageTask # type: ignore
53

64

@@ -14,6 +12,7 @@ def requires_tasks(self):
1412
def get_path_in_flavor(self):
1513
return "flavor_base"
1614

15+
1716
class AnalyzeRelease(DockerFlavorAnalyzeImageTask):
1817
def get_build_step(self) -> str:
1918
return "release"

exasol/python_extension_common/deployment/language_container_builder.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pathlib import Path
77
from importlib import resources
88

9+
# pylint: disable=import-error
910
from exasol_integration_test_docker_environment.lib.docker.images.image_info import ImageInfo # type: ignore
1011
from exasol_script_languages_container_tool.lib import api # type: ignore
1112
from exasol_script_languages_container_tool.lib.tasks.export.export_containers import ExportContainerResult # type: ignore
@@ -94,9 +95,17 @@ def write_file(self, file_name: str | Path, content: str) -> None:
9495
file_path.write_text(content)
9596

9697
@property
97-
def flavor_base(self):
98+
def flavor_base(self) -> Path:
9899
return self.flavor_path / "flavor_base"
99100

101+
@property
102+
def requirements_file(self) -> Path:
103+
return self.flavor_base / "dependencies" / "requirements.txt"
104+
105+
@property
106+
def wheel_target(self) -> Path:
107+
return self.flavor_base / "release" / "dist"
108+
100109
def prepare_flavor(self, project_directory: str | Path,
101110
requirement_filter: Callable[[str], bool] | None = None):
102111
"""
@@ -144,19 +153,22 @@ def _set_language_alias(self) -> None:
144153
def _add_requirements_to_flavor(self, project_directory: str | Path,
145154
requirement_filter: Callable[[str], bool] | None):
146155
"""
147-
Create the project's requirements.txt.
156+
Adds project's requirements to the requirements.txt file. Creates this file
157+
if it doesn't exist.
148158
"""
149159
assert self._root_path is not None
150-
dist_path = self._root_path / "requirements.txt"
151160
requirements_bytes = subprocess.check_output(["poetry", "export",
152-
"--without-hashes", "--without-urls",
153-
"--output", f'{dist_path}'],
161+
"--without-hashes", "--without-urls"],
154162
cwd=str(project_directory))
155163
requirements = requirements_bytes.decode("UTF-8")
156164
if requirement_filter is not None:
157165
requirements = "\n".join(filter(requirement_filter, requirements.splitlines()))
158-
requirements_file = self.flavor_base / "dependencies" / "requirements.txt"
159-
requirements_file.write_text(requirements)
166+
# Make sure the content ends with a new line, so that other requirements can be
167+
# added at the end of it.
168+
if not requirements.endswith('\n'):
169+
requirements += '\n'
170+
with self.requirements_file.open(mode='a') as f:
171+
return f.write(requirements)
160172

161173
def _add_wheel_to_flavor(self, project_directory: str | Path):
162174
"""
@@ -176,6 +188,5 @@ def _add_wheel_to_flavor(self, project_directory: str | Path):
176188
raise RuntimeError(f"Did not find exactly one wheel file in dist directory {dist_path}. "
177189
f"Found the following wheels: {wheels}")
178190
wheel = wheels[0]
179-
wheel_target = self.flavor_base / "release" / "dist"
180-
wheel_target.mkdir(parents=True, exist_ok=True)
181-
shutil.copyfile(wheel, wheel_target / wheel.name)
191+
self.wheel_target.mkdir(parents=True, exist_ok=True)
192+
shutil.copyfile(wheel, self.wheel_target / wheel.name)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "exasol-python-extension-common"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
description = "A collection of common utilities for Exasol extensions."
55
packages = [ {include = "exasol"}, ]
66
authors = ["Mikhail Beck <[email protected]>"]

test/integration/test_language_container_builder.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@
1616
)
1717

1818

19+
def test_prepare_flavor(tmp_path):
20+
project_directory = find_path_backwards("pyproject.toml", __file__).parent
21+
22+
with LanguageContainerBuilder('test_container', TEST_LANGUAGE_ALIAS) as container_builder:
23+
container_builder.prepare_flavor(project_directory)
24+
assert container_builder.requirements_file.exists()
25+
assert container_builder.requirements_file.stat().st_size > 0
26+
assert container_builder.wheel_target.exists()
27+
assert container_builder.wheel_target.is_dir()
28+
assert any(container_builder.wheel_target.iterdir())
29+
30+
31+
def test_prepare_flavor_extra(tmp_path):
32+
"""Tests that requirements from multiple projects can be added together"""
33+
project_directory = find_path_backwards("pyproject.toml", __file__).parent
34+
dummy_req = 'xyz\n'
35+
with LanguageContainerBuilder('test_container', TEST_LANGUAGE_ALIAS) as container_builder:
36+
container_builder.requirements_file.write_text(dummy_req)
37+
container_builder.prepare_flavor(project_directory)
38+
assert container_builder.requirements_file.exists()
39+
assert container_builder.requirements_file.stat().st_size > len(dummy_req)
40+
assert container_builder.requirements_file.read_text().startswith(dummy_req)
41+
42+
1943
def test_language_container_builder(itde: config.TestConfig,
2044
connection_factory: Callable[[config.Exasol], ExaConnection],
2145
tmp_path):

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
# Do not edit this file manually!
66
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
77
MAJOR = 0
8-
MINOR = 4
8+
MINOR = 5
99
PATCH = 0
1010
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"

0 commit comments

Comments
 (0)