From f3d982a3d0ef123ef7b791cdfc4e303183ad17af Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Sat, 7 Dec 2024 22:15:48 -0600 Subject: [PATCH] Allow null matrix entries. --- .../_rapids_dependency_file_generator.py | 4 +- .../schema.json | 5 +- .../matrix-null-item/dependencies.yaml | 59 +++++++++++++++++++ .../expected/dev_cuda-115_arch-arm64.yaml | 10 ++++ .../dev_cuda-115_arch-arm64_py-38.yaml | 12 ++++ .../expected/dev_cuda-115_arch-x86_64.yaml | 10 ++++ .../dev_cuda-115_arch-x86_64_py-38.yaml | 11 ++++ 7 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 tests/examples/matrix-null-item/dependencies.yaml create mode 100644 tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64.yaml create mode 100644 tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64_py-38.yaml create mode 100644 tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64.yaml create mode 100644 tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64_py-38.yaml diff --git a/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py b/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py index 5d378a47..c01c63e2 100644 --- a/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py +++ b/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py @@ -243,7 +243,7 @@ def get_filename(file_type: _config.Output, file_key: str, matrix_combo: dict[st file_type_prefix = "" file_ext = "" file_name_prefix = file_key - suffix = "_".join([f"{k}-{v}" for k, v in matrix_combo.items()]) + suffix = "_".join([f"{k}-{v}" for k, v in matrix_combo.items() if v]) if file_type == _config.Output.CONDA: file_ext = ".yaml" elif file_type == _config.Output.REQUIREMENTS: @@ -322,7 +322,7 @@ def should_use_specific_entry(matrix_combo: dict[str, str], specific_entry_matri `matrix_combo` and False otherwise. """ return all( - specific_key in matrix_combo and fnmatch.fnmatch(matrix_combo[specific_key], specific_value) + matrix_combo.get(specific_key) and fnmatch.fnmatch(matrix_combo[specific_key], specific_value) for specific_key, specific_value in specific_entry_matrix.items() ) diff --git a/src/rapids_dependency_file_generator/schema.json b/src/rapids_dependency_file_generator/schema.json index 8ce3eb1a..c307c556 100644 --- a/src/rapids_dependency_file_generator/schema.json +++ b/src/rapids_dependency_file_generator/schema.json @@ -87,7 +87,10 @@ "patternProperties": { ".*": { "type": "array", - "items": {"type": "string"} + "items": {"oneOf": [ + {"type": "string"}, + {"type": "null"} + ]} } } }, diff --git a/tests/examples/matrix-null-item/dependencies.yaml b/tests/examples/matrix-null-item/dependencies.yaml new file mode 100644 index 00000000..b8e9789e --- /dev/null +++ b/tests/examples/matrix-null-item/dependencies.yaml @@ -0,0 +1,59 @@ +files: + dev: + output: conda + conda_dir: output/actual + matrix: + cuda: ["11.5"] + arch: [x86_64, arm64] + py: ["3.8", null] + includes: + - build +channels: + - rapidsai + - conda-forge +dependencies: + build: + common: + - output_types: [conda] + packages: + - clang-tools=11.1.0 + - spdlog>=1.8.5,<1.9 + specific: + - output_types: [conda] + matrices: + - matrix: + cuda: "11.5" + packages: + - cudatoolkit=11.5 + - matrix: + cuda: "11.6" + packages: + - cudatoolkit=11.6 + - output_types: [conda] + matrices: + - matrix: + arch: x86_64 + py: "3.9" + packages: + - some_amd64_39_build_dep + - matrix: + packages: + - output_types: [conda] + matrices: + - matrix: + arch: arm64 + cuda: "11.5" + py: "3.8" + packages: + - super_specific_dep + - matrix: + packages: + - output_types: [conda] + matrices: + - matrix: + cuda: "11.5" + py: "3.8" + packages: + - some_115_38_build_dep + - matrix: + packages: diff --git a/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64.yaml b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64.yaml new file mode 100644 index 00000000..9eb4167a --- /dev/null +++ b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64.yaml @@ -0,0 +1,10 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- conda-forge +dependencies: +- clang-tools=11.1.0 +- cudatoolkit=11.5 +- spdlog>=1.8.5,<1.9 +name: dev_cuda-115_arch-arm64 diff --git a/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64_py-38.yaml b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64_py-38.yaml new file mode 100644 index 00000000..913c1b2f --- /dev/null +++ b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-arm64_py-38.yaml @@ -0,0 +1,12 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- conda-forge +dependencies: +- clang-tools=11.1.0 +- cudatoolkit=11.5 +- some_115_38_build_dep +- spdlog>=1.8.5,<1.9 +- super_specific_dep +name: dev_cuda-115_arch-arm64_py-38 diff --git a/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64.yaml b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64.yaml new file mode 100644 index 00000000..c28187e0 --- /dev/null +++ b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64.yaml @@ -0,0 +1,10 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- conda-forge +dependencies: +- clang-tools=11.1.0 +- cudatoolkit=11.5 +- spdlog>=1.8.5,<1.9 +name: dev_cuda-115_arch-x86_64 diff --git a/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64_py-38.yaml b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64_py-38.yaml new file mode 100644 index 00000000..a90d5000 --- /dev/null +++ b/tests/examples/matrix-null-item/output/expected/dev_cuda-115_arch-x86_64_py-38.yaml @@ -0,0 +1,11 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- conda-forge +dependencies: +- clang-tools=11.1.0 +- cudatoolkit=11.5 +- some_115_38_build_dep +- spdlog>=1.8.5,<1.9 +name: dev_cuda-115_arch-x86_64_py-38