From 7efaea5d8e6a946cf96ecf4de81119c072e76442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de> Date: Fri, 11 Nov 2022 13:30:24 +0100 Subject: [PATCH] With the inclusion of SZ in hdf5plugin the pytest checks are no longer needed. --- enstools/compression/analyzer/AnalysisOptions.py | 13 +++---------- setup.py | 1 + tests/test_analyzer.py | 3 +-- tests/test_cli.py | 4 +--- tests/test_compressor.py | 3 --- tests/test_emulate.py | 4 +--- tests/test_sz.py | 13 +------------ 7 files changed, 8 insertions(+), 33 deletions(-) diff --git a/enstools/compression/analyzer/AnalysisOptions.py b/enstools/compression/analyzer/AnalysisOptions.py index 99bb0ae..349b1b2 100644 --- a/enstools/compression/analyzer/AnalysisOptions.py +++ b/enstools/compression/analyzer/AnalysisOptions.py @@ -67,17 +67,10 @@ class AnalysisParameters: @property def compressors(self): - # Check library availability and select proper analysis_function - if check_libpressio_availability(): - if self.options.compressor is Compressors.NONE or self.options.compressor is Compressors.ALL: - return [Compressors.ZFP, Compressors.SZ] - else: - return [self.options.compressor] + if self.options.compressor is Compressors.NONE or self.options.compressor is Compressors.ALL: + return [Compressors.ZFP, Compressors.SZ] else: - if self.options.compressor is not Compressors.NONE: - assert self.options.compressor == Compressors.ZFP, "The only available option without libpressio is 'zfp'." - - return [Compressors.ZFP] + return [self.options.compressor] def get_compressor_mode_combinations(self): """ diff --git a/setup.py b/setup.py index ea274e6..d6da1ae 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ setup(name="enstools-compression", packages=find_enstools_packages(), install_requires=[ + "hdf5plugin @ git+https://github.com/orioltinto/hdf5plugin", "enstools>=2022.9.3", "enstools-encoding>=0.1.9", "zfpy", diff --git a/tests/test_analyzer.py b/tests/test_analyzer.py index c757c5f..070f746 100644 --- a/tests/test_analyzer.py +++ b/tests/test_analyzer.py @@ -2,7 +2,7 @@ from os.path import isfile, join import pytest -from enstools.encoding.api import check_sz_availability, check_libpressio_availability +from enstools.encoding.api import check_libpressio_availability from utils import file_size, wrapper, TestClass @@ -53,7 +53,6 @@ class TestAnalyzer(TestClass): raise AssertionError(f"The resulting compression ratio of {metrics[var][cr_label]:.2f}" f"x is not close enough to the target of {thresholds[cr_label]:.2f}") - @pytest.mark.skipif(not check_libpressio_availability(), reason="Requires libpressio") def test_sz_analyzer(self): from enstools.compression.api import analyze_files input_tempdir = self.input_directory_path diff --git a/tests/test_cli.py b/tests/test_cli.py index 048115a..2d2c071 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,7 +3,7 @@ Tests for the commandline interface. """ from os.path import isfile, join -from enstools.encoding.compressors.availability_checks import check_sz_availability, check_libpressio_availability +from enstools.encoding.compressors.availability_checks import check_libpressio_availability import pytest from utils import TestClass @@ -91,8 +91,6 @@ class TestCommandLineInterface(TestClass): mocker.patch("sys.argv", commands) enstools.compression.cli.main() - @pytest.mark.skipif(not check_sz_availability() and not check_libpressio_availability(), - reason="Requires SZ and libpressio") def test_analyze_with_sz_and_plugin(self, mocker): """ Test enstools-compressor analyze using a custom plugin. diff --git a/tests/test_compressor.py b/tests/test_compressor.py index 8d845fb..b0638f6 100644 --- a/tests/test_compressor.py +++ b/tests/test_compressor.py @@ -2,8 +2,6 @@ from os.path import isfile, join import pytest -from enstools.encoding.api import check_sz_availability - from utils import file_size, wrapper, TestClass folders = None @@ -76,7 +74,6 @@ class TestCompressor(TestClass): final_size = file_size(output_file_path) assert initial_size > final_size - @pytest.mark.skipif(not check_sz_availability(), reason="Requires SZ") def test_filters_availability(self): from enstools.encoding.api import check_filters_availability assert check_filters_availability() diff --git a/tests/test_emulate.py b/tests/test_emulate.py index 87fb972..5ab9f75 100644 --- a/tests/test_emulate.py +++ b/tests/test_emulate.py @@ -1,4 +1,4 @@ -from enstools.encoding.api import Compressors, CompressionModes, check_sz_availability, check_libpressio_availability +from enstools.encoding.api import Compressors, CompressionModes, check_libpressio_availability from utils import TestClass import numpy as np @@ -52,7 +52,6 @@ class TestEmulators: recovered_data = analysis_compressor.compress_and_decompress(data) print(f"Compression Ratio:{analysis_compressor.compression_ratio():.2f}") - @pytest.mark.skipif(not check_sz_availability(), reason="Requires SZ filter.") def test_FilterAnalysisCompressor_with_SZ(self): from enstools.compression.emulators import FilterEmulator settings = { @@ -83,7 +82,6 @@ class TestEmulate(TestClass): for compression_specification in compression_specifications: ds, _ = emulate_compression_on_dataset(ds, compression=compression_specification) - @pytest.mark.skipif(not check_sz_availability(), reason="Requires SZ filter.") def test_emulation_with_sz(self): from enstools.io import read from enstools.compression.emulation import emulate_compression_on_dataset diff --git a/tests/test_sz.py b/tests/test_sz.py index f2bdc6c..a2187df 100644 --- a/tests/test_sz.py +++ b/tests/test_sz.py @@ -2,7 +2,7 @@ from os.path import join import pytest -from enstools.encoding.api import check_sz_availability, check_libpressio_availability +from enstools.encoding.api import check_libpressio_availability from utils import wrapper, TestClass @@ -10,14 +10,6 @@ folders = None class TestSZ(TestClass): - @pytest.mark.skipif(check_sz_availability(), reason="Requires SZ not being available") - def test_sz_checker(self): - from enstools.encoding.errors import EnstoolsCompressionError - compression = "lossy,sz,pw_rel,0.1" - with pytest.raises(EnstoolsCompressionError): - wrapper(self, compression=compression) - - @pytest.mark.skipif(not check_libpressio_availability(), reason="Requires libpressio") def test_sz_analyzer(self): from enstools.compression.api import analyze_files # Check that the compression without specifying compression parameters works @@ -26,17 +18,14 @@ class TestSZ(TestClass): input_path = self.input_directory_path / ds analyze_files(file_paths=input_path, compressor="sz") - @pytest.mark.skipif(not check_sz_availability(), reason="Requires SZ") def test_compress_sz_pw_rel(self): compression = "lossy,sz,pw_rel,0.1" wrapper(self, compression=compression) - @pytest.mark.skipif(not check_sz_availability(), reason="Requires SZ") def test_compress_sz_abs(self): compression = "lossy,sz,abs,0.01" wrapper(self, compression=compression) - @pytest.mark.skipif(not check_sz_availability(), reason="Requires SZ") def test_compress_sz_rel(self): compression = "lossy,sz,rel,0.001" wrapper(self, compression=compression) -- GitLab