Skip to content

Commit

Permalink
Add missing compression to plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
beenje committed Jun 5, 2024
1 parent d712010 commit 75776eb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions plugins/quetz_current_repodata/quetz_current_repodata/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -25,4 +29,5 @@ def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages)
"current_repodata.json",
tempdir,
files,
compression,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

config = Config()
pkgstore = config.get_package_store()
compression = config.get_compression_config()


def update_dict(packages, instructions):
Expand Down Expand Up @@ -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)
Expand All @@ -162,4 +164,5 @@ def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages)
"repodata.json",
tempdir,
files,
compression=compression,
)
20 changes: 16 additions & 4 deletions plugins/quetz_repodata_patching/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def test_post_package_indexing(
channel_name,
package_repodata_patches,
db,
config,
package_file_name,
repodata_stem,
compressed_repodata,
Expand All @@ -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
Expand Down Expand Up @@ -372,14 +375,17 @@ def test_index_html(
package_file_name,
dao,
db,
config,
remove_instructions,
):
@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,
Expand Down Expand Up @@ -412,6 +418,7 @@ def test_patches_for_subdir(
package_repodata_patches,
dao,
db,
config,
package_subdir,
patches_subdir,
):
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion plugins/quetz_repodata_zchunk/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 75776eb

Please sign in to comment.