Skip to content

Commit 67f141f

Browse files
authored
#277: Added option to export slc to uncompressed tar (#278)
fixes #277
1 parent 32dd03d commit 67f141f

30 files changed

+622
-144
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
python-version: ${{ matrix.python-version }}
4848
poetry-version: 2.1.2
4949

50+
- name: Run Unit tests
51+
run: poetry run nox -s test:unit
52+
5053
- name: Run lint
5154
run: poetry run nox -s lint:code
5255

exasol/slc/api/deploy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
from exasol.slc.internal.tasks.upload.deploy_containers import DeployContainers
2525
from exasol.slc.internal.tasks.upload.deploy_info import toDeployResult
26+
from exasol.slc.models.compression_strategy import (
27+
CompressionStrategy,
28+
defaultCompressionStrategy,
29+
)
2630
from exasol.slc.models.deploy_result import DeployResult
2731

2832

@@ -61,6 +65,7 @@ def deploy(
6165
task_dependencies_dot_file: Optional[str] = None,
6266
log_level: Optional[str] = None,
6367
use_job_specific_log_file: bool = True,
68+
compression_strategy: CompressionStrategy = defaultCompressionStrategy(),
6469
) -> Dict[str, Dict[str, DeployResult]]:
6570
"""
6671
This command uploads the whole script-language-container package of the flavor to the database.
@@ -118,6 +123,7 @@ def root_task_generator() -> DependencyLoggerBaseTask:
118123
bucketfs_name=bucketfs_name,
119124
ssl_cert_path=ssl_cert_path,
120125
use_ssl_cert_validation=use_ssl_cert_validation,
126+
compression_strategy=compression_strategy,
121127
)
122128

123129
deploy_infos = run_task(

exasol/slc/api/export.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
)
2222

2323
from exasol.slc.internal.tasks.export.export_containers import ExportContainers
24+
from exasol.slc.models.compression_strategy import (
25+
CompressionStrategy,
26+
defaultCompressionStrategy,
27+
)
2428
from exasol.slc.models.export_container_result import ExportContainerResult
2529

2630

@@ -51,6 +55,7 @@ def export(
5155
log_level: Optional[str] = None,
5256
use_job_specific_log_file: bool = True,
5357
cleanup_docker_images: bool = False,
58+
compression_strategy: CompressionStrategy = defaultCompressionStrategy(),
5459
) -> ExportContainerResult:
5560
"""
5661
This command exports the whole script-language-container package of the flavor,
@@ -93,6 +98,7 @@ def root_task_generator() -> DependencyLoggerBaseTask:
9398
export_path=export_path,
9499
release_name=release_name,
95100
cleanup_docker_images=cleanup_docker_images,
101+
compression_strategy=compression_strategy,
96102
)
97103

98104
return run_task(

exasol/slc/api/run_db_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
from exasol.slc.internal.tasks.test.test_container_content import (
3636
build_test_container_content,
3737
)
38+
from exasol.slc.models.compression_strategy import (
39+
CompressionStrategy,
40+
defaultCompressionStrategy,
41+
)
3842
from exasol.slc.models.test_result import AllTestsResult
3943

4044

@@ -97,6 +101,7 @@ def run_db_test(
97101
task_dependencies_dot_file: Optional[str] = None,
98102
log_level: Optional[str] = None,
99103
use_job_specific_log_file: bool = True,
104+
compression_strategy: CompressionStrategy = defaultCompressionStrategy(),
100105
) -> AllTestsResult:
101106
"""
102107
This command runs the integration tests in local docker-db.
@@ -146,6 +151,8 @@ def run_db_test(
146151
raise api_errors.MissingArgumentError("external_exasol_db_port")
147152
if external_exasol_bucketfs_port is None:
148153
raise api_errors.MissingArgumentError("external_exasol_bucketfs_port")
154+
if external_exasol_ssh_port is None:
155+
raise api_errors.MissingArgumentError("external_exasol_ssh_port")
149156

150157
def root_task_generator() -> DependencyLoggerBaseTask:
151158
return generate_root_task(
@@ -190,6 +197,7 @@ def root_task_generator() -> DependencyLoggerBaseTask:
190197
create_certificates=create_certificates,
191198
additional_db_parameter=additional_db_parameter,
192199
test_container_content=build_test_container_content(test_container_folder),
200+
compression_strategy=compression_strategy,
193201
)
194202

195203
return run_task(

exasol/slc/api/upload.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
)
2525

2626
from exasol.slc.internal.tasks.upload.upload_containers import UploadContainers
27+
from exasol.slc.models.compression_strategy import (
28+
CompressionStrategy,
29+
defaultCompressionStrategy,
30+
)
2731

2832

2933
@cli_function
@@ -61,6 +65,7 @@ def upload(
6165
use_job_specific_log_file: bool = True,
6266
ssl_cert_path: str = "",
6367
use_ssl_cert_validation: bool = True,
68+
compression_strategy: CompressionStrategy = defaultCompressionStrategy(),
6469
) -> luigi.LocalTarget:
6570
warnings.warn(
6671
"The 'upload' function is deprecated, use 'deploy' instead", DeprecationWarning
@@ -113,6 +118,7 @@ def root_task_generator() -> DependencyLoggerBaseTask:
113118
bucketfs_name=bucketfs_name,
114119
ssl_cert_path=ssl_cert_path,
115120
use_ssl_cert_validation=use_ssl_cert_validation,
121+
compression_strategy=compression_strategy,
116122
)
117123

118124
return run_task(

exasol/slc/internal/tasks/export/export_container_base_task.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from exasol.slc.internal.tasks.export.remove_cached_export_file_task import (
2727
RemoveCachedExportTask,
2828
)
29+
from exasol.slc.models.compression_strategy import CompressionStrategy
2930
from exasol.slc.models.export_info import ExportInfo
3031

3132

@@ -112,6 +113,16 @@ def _create_export_info(
112113
)
113114
return export_info
114115

116+
def _get_export_file_extension(self) -> str:
117+
if self.compression_strategy == CompressionStrategy.GZIP:
118+
return ".tar.gz"
119+
elif self.compression_strategy == CompressionStrategy.NONE:
120+
return ".tar"
121+
else:
122+
raise ValueError(
123+
f"Unsupported compression_strategy: {self.compression_strategy}"
124+
)
125+
115126
def _get_cache_file_path(
116127
self,
117128
image_info_of_release_image: ImageInfo,
@@ -120,5 +131,7 @@ def _get_cache_file_path(
120131
release_image_name = image_info_of_release_image.get_target_complete_name()
121132
export_path = Path(export_directory_future.get_output()).absolute()
122133
release_complete_name = f"""{image_info_of_release_image.target_tag}-{image_info_of_release_image.hash}"""
123-
cache_file = Path(export_path, release_complete_name + ".tar.gz").absolute()
134+
cache_file = Path(
135+
export_path, release_complete_name + self._get_export_file_extension()
136+
).absolute()
124137
return str(cache_file), release_complete_name, release_image_name

exasol/slc/internal/tasks/export/export_container_parameters.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
from typing import Optional, Tuple
22

33
import luigi
4-
from luigi import Config
4+
5+
from exasol.slc.models.compression_strategy import (
6+
CompressionStrategy,
7+
defaultCompressionStrategy,
8+
)
59

610
CHECKSUM_ALGORITHM = "sha512sum"
711

812

9-
class ExportContainerParameterBase(Config):
13+
class ExportContainerOptionsParameter:
14+
compression_strategy: CompressionStrategy = luigi.EnumParameter(enum=CompressionStrategy, default=defaultCompressionStrategy()) # type: ignore
15+
16+
17+
class ExportContainerParameterBase(ExportContainerOptionsParameter):
1018
export_path: Optional[str] = luigi.OptionalParameter(None) # type: ignore
1119
release_name: Optional[str] = luigi.OptionalParameter(None) # type: ignore
1220
cleanup_docker_images: bool = luigi.BoolParameter(False) # type: ignore

exasol/slc/internal/tasks/export/export_container_to_cache_task.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
CHECKSUM_ALGORITHM,
3737
ExportContainerParameter,
3838
)
39+
from exasol.slc.models.compression_strategy import CompressionStrategy
3940

4041

4142
class CheckCacheFileTask(DependencyLoggerBaseTask):
@@ -170,11 +171,17 @@ def _pack_release_file(
170171
) -> None:
171172
self.logger.info("Pack container file %s", release_file)
172173
extract_content = " ".join(f"'{file}'" for file in os.listdir(extract_dir))
173-
if not str(release_file).endswith("tar.gz"):
174+
if str(release_file).endswith("tar.gz"):
175+
tmp_release_file = release_file.with_suffix(
176+
""
177+
) # cut off ".gz" from ".tar.gz"
178+
elif str(release_file).endswith("tar"):
179+
tmp_release_file = release_file
180+
else:
174181
raise ValueError(
175-
f"Unexpected release file: '{release_file}'. Expected suffix 'tar.gz'."
182+
f"Unexpected release file: '{release_file}'. Expected suffix: 'tar.gz' or 'tar'."
176183
)
177-
tmp_release_file = release_file.with_suffix("") # cut off ".gz" from ".tar.gz"
184+
178185
command = (
179186
f"""tar -C '{extract_dir}' -vcf '{tmp_release_file}' {extract_content}"""
180187
)
@@ -195,12 +202,19 @@ def _pack_release_file(
195202
log_path.joinpath("pack_release_file.log"),
196203
)
197204
shutil.rmtree(extract_dir)
198-
command = f"""gzip {tmp_release_file}"""
199-
self.run_command(
200-
command,
201-
f"Creating '{release_file}'",
202-
log_path.joinpath("pack_release_file.log"),
203-
)
205+
if self.compression_strategy == CompressionStrategy.GZIP:
206+
command = f"""gzip {tmp_release_file}"""
207+
self.run_command(
208+
command,
209+
f"Creating '{release_file}'",
210+
log_path.joinpath("pack_release_file.log"),
211+
)
212+
elif self.compression_strategy == CompressionStrategy.NONE:
213+
pass
214+
else:
215+
raise ValueError(
216+
f"Unexpected compression_strategy: {self.compression_strategy}"
217+
)
204218

205219
@staticmethod
206220
def _modify_extracted_container(extract_dir: str) -> None:

exasol/slc/internal/tasks/export/export_container_to_file_task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from exasol.slc.internal.tasks.export.export_container_to_cache_task import (
2121
ExportContainerToCacheTask,
2222
)
23+
from exasol.slc.internal.utils.file_utilities import detect_container_file_extension
2324

2425

2526
class ExportContainerToFileInfo(Info):
@@ -66,9 +67,8 @@ def _copy_cache_file_to_output_path(
6667
suffix = f"""_{self.release_name}"""
6768
else:
6869
suffix = ""
69-
file_name = (
70-
f"""{self.get_flavor_name()}_{self.release_goal}{suffix}.tar.gz"""
71-
)
70+
file_extension = detect_container_file_extension(cache_file.name)
71+
file_name = f"""{self.get_flavor_name()}_{self.release_goal}{suffix}{file_extension}"""
7272
output_file = Path(str(self.export_path), file_name)
7373
output_checksum_file = Path(
7474
str(self.export_path), file_name + "." + CHECKSUM_ALGORITHM

exasol/slc/internal/tasks/test/test_container.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
SpawnTestEnvironmentParameter,
1414
)
1515

16+
from exasol.slc.internal.tasks.export.export_container_parameters import (
17+
ExportContainerOptionsParameter,
18+
)
1619
from exasol.slc.internal.tasks.test.run_db_tests_parameter import (
1720
GeneralRunDBTestParameter,
1821
RunDBTestsInTestConfigParameter,
@@ -30,7 +33,9 @@
3033

3134

3235
class TestContainerParameter(
33-
RunDBTestsInTestConfigParameter, GeneralRunDBTestParameter
36+
RunDBTestsInTestConfigParameter,
37+
GeneralRunDBTestParameter,
38+
ExportContainerOptionsParameter,
3439
):
3540
release_goals: Tuple[str, ...] = luigi.ListParameter(["release"]) # type: ignore
3641
languages: Tuple[Optional[str], ...] = luigi.ListParameter([None]) # type: ignore

0 commit comments

Comments
 (0)