From c8e438430477deb46b02ddb5164eb61a698b5fd9 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 18 Sep 2024 16:50:22 -0500 Subject: [PATCH 1/4] Fix matrix priority. --- .../_rapids_dependency_file_generator.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) 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 4fc186c..b201e36 100644 --- a/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py +++ b/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py @@ -389,7 +389,20 @@ def make_dependency_files( if file_type not in specific_entry.output_types: continue - found = False + # Ensure that all specific matrices are unique + num_matrices = len(specific_entry.matrices) + num_unique = len( + { + frozenset(specific_matrices_entry.matrix.items()) + for specific_matrices_entry in specific_entry.matrices + } + ) + if num_matrices != num_unique: + err = f"All matrix entries must be unique. Found duplicates in '{include}':" + for specific_matrices_entry in specific_entry.matrices: + err += f"\n - {specific_matrices_entry.matrix}" + raise ValueError(err) + fallback_entry = None for specific_matrices_entry in specific_entry.matrices: # An empty `specific_matrices_entry["matrix"]` is @@ -403,18 +416,12 @@ def make_dependency_files( continue if should_use_specific_entry(matrix_combo, specific_matrices_entry.matrix): - # Raise an error if multiple specific entries - # (not including the fallback_entry) match a - # requested matrix combination. - if found: - raise ValueError(f"Found multiple matches for matrix {matrix_combo}") - found = True # A package list may be empty as a way to # indicate that for some matrix elements no # packages should be installed. dependencies.extend(specific_matrices_entry.packages or []) - - if not found: + break + else: if fallback_entry: dependencies.extend(fallback_entry.packages) else: From d8763b6df08b41f25babc0b48c8ffd3e0a734561 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 20 Sep 2024 19:10:15 -0500 Subject: [PATCH 2/4] Add test for multiple matching matrices (first takes priority). --- .../dependencies.yaml | 27 +++++++++++++++++++ .../output/expected/all_cuda-115.yaml | 8 ++++++ .../output/expected/all_cuda-118.yaml | 8 ++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/examples/specific-fallback-multiple-matches/dependencies.yaml create mode 100644 tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-115.yaml create mode 100644 tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-118.yaml diff --git a/tests/examples/specific-fallback-multiple-matches/dependencies.yaml b/tests/examples/specific-fallback-multiple-matches/dependencies.yaml new file mode 100644 index 0000000..0d33b4f --- /dev/null +++ b/tests/examples/specific-fallback-multiple-matches/dependencies.yaml @@ -0,0 +1,27 @@ +files: + all: + output: conda + conda_dir: output/actual + matrix: + cuda: ["11.5", "11.8"] + includes: + - cudatoolkit +channels: + - rapidsai + - conda-forge +dependencies: + cudatoolkit: + specific: + - output_types: conda + matrices: + - matrix: + cuda: "11.5" + packages: + - cudatoolkit=11.5 + - matrix: + cuda: "11.*" + packages: + - cudatoolkit=11.* + - matrix: + packages: + - cudatoolkit diff --git a/tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-115.yaml b/tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-115.yaml new file mode 100644 index 0000000..f9ab85d --- /dev/null +++ b/tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-115.yaml @@ -0,0 +1,8 @@ +# 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: +- cudatoolkit=11.5 +name: all_cuda-115 diff --git a/tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-118.yaml b/tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-118.yaml new file mode 100644 index 0000000..f9f9290 --- /dev/null +++ b/tests/examples/specific-fallback-multiple-matches/output/expected/all_cuda-118.yaml @@ -0,0 +1,8 @@ +# 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: +- cudatoolkit=11.* +name: all_cuda-118 From c8e81c85c9d38ba27ad5872bd5be6447ac450b0a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 20 Sep 2024 19:14:25 -0500 Subject: [PATCH 3/4] Add tests of errors on duplicate matrix selectors. --- .../dependencies.yaml | 24 +++++++++++++++++++ .../output/expected/all_cuda-115.yaml | 8 +++++++ .../output/expected/all_cuda-118.yaml | 8 +++++++ tests/test_examples.py | 7 +++--- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 tests/examples/duplicate-specific-matrix-entries/dependencies.yaml create mode 100644 tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml create mode 100644 tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml diff --git a/tests/examples/duplicate-specific-matrix-entries/dependencies.yaml b/tests/examples/duplicate-specific-matrix-entries/dependencies.yaml new file mode 100644 index 0000000..54a262f --- /dev/null +++ b/tests/examples/duplicate-specific-matrix-entries/dependencies.yaml @@ -0,0 +1,24 @@ +files: + all: + output: conda + conda_dir: output/actual + matrix: + cuda: ["11.5", "11.8"] + includes: + - cudatoolkit +channels: + - rapidsai + - conda-forge +dependencies: + cudatoolkit: + specific: + - output_types: conda + matrices: + - matrix: + cuda: "11.5" + packages: + - cudatoolkit=11.5 + - matrix: + cuda: "11.5" + packages: + - cudatoolkit=11.5 diff --git a/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml b/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml new file mode 100644 index 0000000..f9ab85d --- /dev/null +++ b/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml @@ -0,0 +1,8 @@ +# 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: +- cudatoolkit=11.5 +name: all_cuda-115 diff --git a/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml b/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml new file mode 100644 index 0000000..f9f9290 --- /dev/null +++ b/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml @@ -0,0 +1,8 @@ +# 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: +- cudatoolkit=11.* +name: all_cuda-118 diff --git a/tests/test_examples.py b/tests/test_examples.py index c47ca35..2c5294d 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -14,11 +14,12 @@ # Erroneous examples raise runtime errors from the generator. _erroneous_examples = [ + "duplicate-specific-matrix-entries", "no-specific-match", - "pyproject_matrix_multi", - "pyproject_bad_key", "pyproject-no-extras", - "requirements-pip-dict" + "pyproject_bad_key", + "pyproject_matrix_multi", + "requirements-pip-dict", ] EXAMPLE_FILES = [ pth From 2224cb58396f7dd587c3b251baabab7ddd0a2878 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 20 Sep 2024 19:26:09 -0500 Subject: [PATCH 4/4] No output from erroneous test. --- .../output/expected/all_cuda-115.yaml | 8 -------- .../output/expected/all_cuda-118.yaml | 8 -------- 2 files changed, 16 deletions(-) delete mode 100644 tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml delete mode 100644 tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml diff --git a/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml b/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml deleted file mode 100644 index f9ab85d..0000000 --- a/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-115.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# 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: -- cudatoolkit=11.5 -name: all_cuda-115 diff --git a/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml b/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml deleted file mode 100644 index f9f9290..0000000 --- a/tests/examples/duplicate-specific-matrix-entries/output/expected/all_cuda-118.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# 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: -- cudatoolkit=11.* -name: all_cuda-118