Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up a test which keeps timing out #533

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions tests/test-update-filter-platform/conda-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This lock file was generated by conda-lock (https://github.com/conda/conda-lock). DO NOT EDIT!
#
# A "lock file" contains a concrete list of package versions (with checksums) to be installed. Unlike
# e.g. `conda env create`, the resulting environment will not change as new package versions become
# available, unless you explicitly update the lock file.
#
# Install this environment as "YOURENV" with:
# conda-lock install -n YOURENV --file conda-lock.yml
# To update a single package to the latest version compatible with the version constraints in the source:
# conda-lock lock --lockfile conda-lock.yml --update PACKAGE
# To re-solve the entire environment, e.g. after changing a version constraint in the source file:
# conda-lock -f environment-preupdate.yml --lockfile conda-lock.yml
version: 1
metadata:
content_hash:
linux-64: 74b9b82333bad461da874bac86ac55f9ac26d57510234e36571d0a0f43fb9c2d
osx-64: 3374c9a110308beb184dfdf37a58250fecb0b6e79ef06a55858a955ba7668ad9
channels:
- url: conda-forge
used_env_vars: []
platforms:
- linux-64
- osx-64
sources:
- environment-preupdate.yml
package:
- name: zlib
version: 1.2.8
manager: conda
platform: linux-64
dependencies: {}
url: https://conda.anaconda.org/conda-forge/linux-64/zlib-1.2.8-3.tar.bz2
hash:
md5: 6b3dbbf50432b3e2a271b5e46877bcfc
sha256: 85fcb6906b8686fe6341db89b4e6fc2631ad69ee6eab2f4823bfd64ae0b20ac8
category: main
optional: false
- name: zlib
version: 1.2.8
manager: conda
platform: osx-64
dependencies: {}
url: https://conda.anaconda.org/conda-forge/osx-64/zlib-1.2.8-3.tar.bz2
hash:
md5: 03b6fcc7a5e1a471e74049665e1c06b0
sha256: d175728c3972c4baf2bdbdd9d7580ba3349b8861e7150d41034319496f99a804
category: main
optional: false
39 changes: 28 additions & 11 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,13 +1173,16 @@ def update_environment(tmp_path: Path) -> Path:


@pytest.fixture
def update_environment_filter_platform(tmp_path: Path) -> Tuple[Path, Path]:
def update_environment_filter_platform(tmp_path: Path) -> Tuple[Path, Path, Path]:
test_dir = clone_test_dir("test-update-filter-platform", tmp_path)

return (
files = (
test_dir / "conda-lock.yml",
test_dir / "environment-preupdate.yml",
test_dir / "environment-postupdate.yml",
)
for file in files:
assert file.exists()
return files


@pytest.fixture
Expand Down Expand Up @@ -1250,22 +1253,36 @@ def test_run_lock_with_update(
@pytest.mark.timeout(120)
def test_run_lock_with_update_filter_platform(
monkeypatch: "pytest.MonkeyPatch",
update_environment_filter_platform: Tuple[Path, Path],
update_environment_filter_platform: Tuple[Path, Path, Path],
conda_exe: str,
):
"""Test that when updating for one platform, other platforms are not updated."""
pre_env = update_environment_filter_platform[0]
post_env = update_environment_filter_platform[1]
environment_dir = pre_env.parent
lockfile_path, pre_env, post_env = update_environment_filter_platform
environment_dir = lockfile_path.parent
monkeypatch.chdir(environment_dir)

run_lock([pre_env], conda_exe=conda_exe)
run_lock([post_env], conda_exe=conda_exe, update=["zlib"], platforms=["linux-64"])
# # We have pre-generated the lockfile for the pre_env file to save time.
# # Run 'conda-lock -f environment-preupdate.yml' or
# run_lock([pre_env], lockfile_path=lockfile_path, conda_exe=conda_exe)

pre_lock = {
(p.name, p.platform): p for p in parse_conda_lock_file(lockfile_path).package
}
# The pre_env file has zlib 1.2.8 for all platforms.
assert pre_lock[("zlib", "linux-64")].version == "1.2.8"
assert pre_lock[("zlib", "osx-64")].version == "1.2.8"

run_lock(
[post_env],
lockfile_path=lockfile_path,
conda_exe=conda_exe,
update=["zlib"],
platforms=["linux-64"],
)
post_lock = {
(p.name, p.platform): p
for p in parse_conda_lock_file(environment_dir / DEFAULT_LOCKFILE_NAME).package
(p.name, p.platform): p for p in parse_conda_lock_file(lockfile_path).package
}
# The post_env file updates zlib to 1.2.13, but we only ran the update for linux-64.
assert post_lock[("zlib", "linux-64")].version == "1.2.13"
assert post_lock[("zlib", "osx-64")].version == "1.2.8"

Expand Down