From 75776eb6448c13289ffcbcd4210f3f3111235fd0 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Sun, 10 Dec 2023 14:40:43 +0100 Subject: [PATCH] Add missing compression to plugins --- .../quetz_current_repodata/main.py | 5 +++++ .../quetz_repodata_patching/main.py | 3 +++ .../tests/test_main.py | 20 +++++++++++++++---- .../quetz_repodata_zchunk/tests/test_main.py | 5 ++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/plugins/quetz_current_repodata/quetz_current_repodata/main.py b/plugins/quetz_current_repodata/quetz_current_repodata/main.py index f00c7ef1..36c57faa 100644 --- a/plugins/quetz_current_repodata/quetz_current_repodata/main.py +++ b/plugins/quetz_current_repodata/quetz_current_repodata/main.py @@ -4,8 +4,12 @@ from conda_index.index import _build_current_repodata import quetz +from quetz.config import Config from quetz.utils import add_temp_static_file +config = Config() +compression = config.get_compression_config() + @quetz.hookimpl def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages): @@ -25,4 +29,5 @@ def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages) "current_repodata.json", tempdir, files, + compression, ) diff --git a/plugins/quetz_repodata_patching/quetz_repodata_patching/main.py b/plugins/quetz_repodata_patching/quetz_repodata_patching/main.py index 4ed2e43f..8e01a28b 100644 --- a/plugins/quetz_repodata_patching/quetz_repodata_patching/main.py +++ b/plugins/quetz_repodata_patching/quetz_repodata_patching/main.py @@ -15,6 +15,7 @@ config = Config() pkgstore = config.get_package_store() +compression = config.get_compression_config() def update_dict(packages, instructions): @@ -147,6 +148,7 @@ def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages) "repodata_from_packages.json", tempdir, files, + compression=compression, ) patch_repodata(repodata, patch_instructions) @@ -162,4 +164,5 @@ def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages) "repodata.json", tempdir, files, + compression=compression, ) diff --git a/plugins/quetz_repodata_patching/tests/test_main.py b/plugins/quetz_repodata_patching/tests/test_main.py index defb3261..3c9b1a0a 100644 --- a/plugins/quetz_repodata_patching/tests/test_main.py +++ b/plugins/quetz_repodata_patching/tests/test_main.py @@ -288,6 +288,7 @@ def test_post_package_indexing( channel_name, package_repodata_patches, db, + config, package_file_name, repodata_stem, compressed_repodata, @@ -301,7 +302,9 @@ def get_db(): yield db with mock.patch("quetz_repodata_patching.main.get_db_manager", get_db): - indexing.update_indexes(dao, pkgstore, channel_name) + indexing.update_indexes( + dao, pkgstore, channel_name, compression=config.get_compression_config() + ) ext = "json.bz2" if compressed_repodata else "json" open_ = bz2.open if compressed_repodata else open @@ -372,6 +375,7 @@ def test_index_html( package_file_name, dao, db, + config, remove_instructions, ): @contextmanager @@ -379,7 +383,9 @@ def get_db(): yield db with mock.patch("quetz_repodata_patching.main.get_db_manager", get_db): - indexing.update_indexes(dao, pkgstore, channel_name) + indexing.update_indexes( + dao, pkgstore, channel_name, compression=config.get_compression_config() + ) index_path = os.path.join( pkgstore.channels_dir, @@ -412,6 +418,7 @@ def test_patches_for_subdir( package_repodata_patches, dao, db, + config, package_subdir, patches_subdir, ): @@ -420,7 +427,9 @@ def get_db(): yield db with mock.patch("quetz_repodata_patching.main.get_db_manager", get_db): - indexing.update_indexes(dao, pkgstore, channel_name) + indexing.update_indexes( + dao, pkgstore, channel_name, compression=config.get_compression_config() + ) index_path = os.path.join( pkgstore.channels_dir, @@ -466,13 +475,16 @@ def test_no_repodata_patches_package( package_file_name, dao, db, + config, ): @contextmanager def get_db(): yield db with mock.patch("quetz_repodata_patching.main.get_db_manager", get_db): - indexing.update_indexes(dao, pkgstore, channel_name) + indexing.update_indexes( + dao, pkgstore, channel_name, compression=config.get_compression_config() + ) index_path = os.path.join( pkgstore.channels_dir, diff --git a/plugins/quetz_repodata_zchunk/tests/test_main.py b/plugins/quetz_repodata_zchunk/tests/test_main.py index 364abdae..5664a467 100644 --- a/plugins/quetz_repodata_zchunk/tests/test_main.py +++ b/plugins/quetz_repodata_zchunk/tests/test_main.py @@ -112,8 +112,11 @@ def test_repodata_zchunk( package_file_name, dao, db, + config, ): - indexing.update_indexes(dao, pkgstore, channel_name) + indexing.update_indexes( + dao, pkgstore, channel_name, compression=config.get_compression_config() + ) index_path = os.path.join( pkgstore.channels_dir,