Skip to content

Commit

Permalink
Adding regression tests for new metadata fields
Browse files Browse the repository at this point in the history
  • Loading branch information
NatPRoach committed Jul 14, 2022
1 parent f904e79 commit e7c613c
Show file tree
Hide file tree
Showing 9 changed files with 774 additions and 6 deletions.
4 changes: 1 addition & 3 deletions conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,6 @@ def _solve_for_arch(


def convert_structured_metadata_yaml(in_path: pathlib.Path) -> Dict[str, Any]:
import yaml

with in_path.open("r") as infile:
metadata = yaml.safe_load(infile)
return metadata
Expand All @@ -758,7 +756,7 @@ def update_metadata(to_change: Dict[str, Any], change_source: Dict[str, Any]) ->
for key in change_source:
if key in to_change:
logger.warning(
f"Custom metadata field {key} provided twice overwriting value "
f"Custom metadata field {key} provided twice, overwriting value "
+ f"{to_change[key]} with {change_source[key]}"
)
to_change.update(change_source)
Expand Down
2 changes: 0 additions & 2 deletions conda_lock/src_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ def create(cls, src_file: pathlib.Path) -> "InputMeta":

@staticmethod
def get_input_md5(src_file: pathlib.Path) -> str:
import hashlib

hasher = hashlib.md5()
with src_file.open("r") as infile:
hasher.update(infile.read().encode("utf-8"))
Expand Down
4 changes: 3 additions & 1 deletion conda_lock/src_parser/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def write_section(text: str) -> None:
yaml.dump(
{
"version": Lockfile.version,
**json.loads(content.json(by_alias=True, exclude_unset=True)),
**json.loads(
content.json(by_alias=True, exclude_unset=True, exclude_none=True)
),
},
f,
)
192 changes: 192 additions & 0 deletions tests/test-custom-metadata/conda-lock.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# This lock file was generated by conda-lock (https://github.com/conda-incubator/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.lock
# To update a single package to the latest version compatible with the version constraints in the source:
# conda-lock lock --lockfile conda-lock.lock --update PACKAGE
# To re-solve the entire environment, e.g. after changing a version constraint in the source file:
# conda-lock -f /Users/c13371nroach/Documents/repos/conda-lock/tests/zlib/environment.yml --lockfile conda-lock.lock
metadata:
channels:
- url: conda-forge
used_env_vars: []
- url: defaults
used_env_vars: []
content_hash:
linux-64: 1173e3c96ce20d063a5701b325b76deb97394f891af270af4ee0cb7cc1f6e838
osx-64: d01c1f5433f30bdbcd3bdad8d9b096774ab55f1210c094acdc61a35b32b28d67
win-64: 310b23581083bfb983927c40d3bdc86162192d7b26ffd7bffc385f627c155697
custom_metadata:
json_example_metadata: json_test
yaml_example_metadata: yaml_test
platforms:
- linux-64
- osx-64
- win-64
sources:
- /Users/c13371nroach/Documents/repos/conda-lock/tests/zlib/environment.yml
package:
- category: main
dependencies: {}
hash:
md5: d7c89558ba9fa0495403155b64376d81
sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726
manager: conda
name: _libgcc_mutex
optional: false
platform: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2
version: '0.1'
- category: main
dependencies:
_libgcc_mutex: 0.1 conda_forge
hash:
md5: f013cf7749536ce43d82afbffdf499ab
sha256: 499fab15d3897a7bf7a1d82dd44c76dad1ceeaec0b71e348e77fb8a753ff898d
manager: conda
name: libgomp
optional: false
platform: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/libgomp-12.1.0-h8d9b700_16.tar.bz2
version: 12.1.0
- category: main
dependencies:
_libgcc_mutex: 0.1 conda_forge
libgomp: '>=7.5.0'
hash:
md5: 73aaf86a425cc6e73fcf236a5a46396d
sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22
manager: conda
name: _openmp_mutex
optional: false
platform: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2
version: '4.5'
- category: main
dependencies:
_libgcc_mutex: 0.1 conda_forge
_openmp_mutex: '>=4.5'
hash:
md5: 4f05bc9844f7c101e6e147dab3c88d5c
sha256: 2fde3d9f0199bf4f5447b35d3fd74d058c17ef2b6c68815eb1b469f2aec138b9
manager: conda
name: libgcc-ng
optional: false
platform: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-12.1.0-h8d9b700_16.tar.bz2
version: 12.1.0
- category: main
dependencies:
libgcc-ng: '>=12'
hash:
md5: 8302381297332ea50532cf2c67961080
sha256: 38cf13bff23409683f2da6b0ee156d964f40e6c3dabcee626e0a118e37ab02e4
manager: conda
name: libzlib
optional: false
platform: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.2.12-h166bdaf_2.tar.bz2
version: 1.2.12
- category: main
dependencies:
libgcc-ng: '>=12'
libzlib: 1.2.12 h166bdaf_2
hash:
md5: 4533821485cde83ab12ff3d8bda83768
sha256: 084342e7f0d2feeca6eb0f194f0a82ac75217730745e6c9033016ed015283bcc
manager: conda
name: zlib
optional: false
platform: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/zlib-1.2.12-h166bdaf_2.tar.bz2
version: 1.2.12
- category: main
dependencies: {}
hash:
md5: 1d676bbaa2599f22121dd5bbea455c2e
sha256: 14fe466192d4af8fbfaf60bb102a3590e39e00ed8c9ef15c9392a7848ab3f39d
manager: conda
name: libzlib
optional: false
platform: osx-64
url: https://conda.anaconda.org/conda-forge/osx-64/libzlib-1.2.12-hfe4f2af_2.tar.bz2
version: 1.2.12
- category: main
dependencies:
libzlib: 1.2.12 hfe4f2af_2
hash:
md5: fe7ebd3b35b8f26f6a7d0af481a21721
sha256: 8f455dcebeae224fdb422ba8f90d33e61298dc088139227e25eb4ee20a3ea35f
manager: conda
name: zlib
optional: false
platform: osx-64
url: https://conda.anaconda.org/conda-forge/osx-64/zlib-1.2.12-hfe4f2af_2.tar.bz2
version: 1.2.12
- category: main
dependencies: {}
hash:
md5: 6d666b6ea8251231ff508062d1e41f9c
sha256: e5a8634df6ee84745dfe27f40ace7b6e45646a4b7bc7dbeb1efe1bb6128e44b9
manager: conda
name: ucrt
optional: false
platform: win-64
url: https://conda.anaconda.org/conda-forge/win-64/ucrt-10.0.20348.0-h57928b3_0.tar.bz2
version: 10.0.20348.0
- category: main
dependencies:
ucrt: '>=10.0.20348.0'
hash:
md5: 33d07ebe91062743eabc9e53a60d18e1
sha256: f2efbbe3465a34b195edd218d5572c998d94c5964d4e495c3d7f95c8bb5fcaac
manager: conda
name: vs2015_runtime
optional: false
platform: win-64
url: https://conda.anaconda.org/conda-forge/win-64/vs2015_runtime-14.29.30037-h902a5da_6.tar.bz2
version: 14.29.30037
- category: main
dependencies:
vs2015_runtime: '>=14.28.29325'
hash:
md5: c2aecbc9b00ba6f352e27d3d61fd31fb
sha256: c6e7d2b9ceafe2cc302fb8fce1dfcc46b49c5333757424a34294bffdfb5569be
manager: conda
name: vc
optional: false
platform: win-64
url: https://conda.anaconda.org/conda-forge/win-64/vc-14.2-hb210afc_6.tar.bz2
version: '14.2'
- category: main
dependencies:
vc: '>=14.1,<15'
vs2015_runtime: '>=14.16.27033'
hash:
md5: 74585107cf2f18b31aa84375fcb24215
sha256: e88ff9ab754e58a76162532e9d671637870a1dec9387fdda63a7841fc6a3b4c0
manager: conda
name: libzlib
optional: false
platform: win-64
url: https://conda.anaconda.org/conda-forge/win-64/libzlib-1.2.12-h8ffe710_2.tar.bz2
version: 1.2.12
- category: main
dependencies:
libzlib: 1.2.12 h8ffe710_2
vc: '>=14.1,<15'
vs2015_runtime: '>=14.16.27033'
hash:
md5: d6f4eeb62da2ad90c31082cc7178776a
sha256: a1a4c6997ba96debd345d5d3fdf6109340ce4bf08c25d86e3db33b08e371937d
manager: conda
name: zlib
optional: false
platform: win-64
url: https://conda.anaconda.org/conda-forge/win-64/zlib-1.2.12-h8ffe710_2.tar.bz2
version: 1.2.12
version: 1
1 change: 1 addition & 0 deletions tests/test-custom-metadata/custom_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"json_example_metadata": "json_test"}
1 change: 1 addition & 0 deletions tests/test-custom-metadata/custom_metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yaml_example_metadata: yaml_test
Loading

0 comments on commit e7c613c

Please sign in to comment.