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

feat: Add support for matrix globs. #61

Merged
merged 2 commits into from
Dec 14, 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fnmatch
import itertools
import os
import textwrap
Expand Down Expand Up @@ -300,10 +301,11 @@ def should_use_specific_entry(matrix_combo, specific_entry_matrix):
[matrices] list. This function validates the [matrices.matrix] value
against the provided `matrix_combo` to check if they are compatible.

A `specific_entry_matrix` is compatible with a `matrix_combo` if and only if
`specific_entry_matrix[key] == matrix_combo[key]` for every key defined in
`specific_entry_matrix`. A `matrix_combo` may contain additional keys not
specified by `specific_entry_matrix`.
A `specific_entry_matrix` is compatible with a `matrix_combo` if and only
if `specific_entry_matrix[key]` matches the glob pattern
`matrix_combo[key]` for every key defined in `specific_entry_matrix`. A
`matrix_combo` may contain additional keys not specified by
`specific_entry_matrix`.

Parameters
----------
Expand All @@ -321,7 +323,8 @@ def should_use_specific_entry(matrix_combo, specific_entry_matrix):
`matrix_combo` and False otherwise.
"""
return all(
matrix_combo.get(specific_key) == specific_value
specific_key in matrix_combo
and fnmatch.fnmatch(matrix_combo[specific_key], specific_value)
for specific_key, specific_value in specific_entry_matrix.items()
)

Expand Down
30 changes: 30 additions & 0 deletions tests/examples/matrix-glob/dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
files:
dev:
output: conda
conda_dir: output/actual
matrix:
cuda: ["10.0", "11.8", "12.0"]
includes:
- build
channels:
- rapidsai
- conda-forge
dependencies:
build:
common:
- output_types: [conda]
packages:
- clang-tools=11.1.0
specific:
- output_types: [conda]
matrices:
- matrix:
cuda: "11.*"
packages:
- cudatoolkit=11.*
- matrix:
cuda: "12.*"
packages:
- cuda-version=12.*
- matrix:
packages:
8 changes: 8 additions & 0 deletions tests/examples/matrix-glob/output/expected/dev_cuda-100.yaml
Original file line number Diff line number Diff line change
@@ -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:
- clang-tools=11.1.0
name: dev_cuda-100
9 changes: 9 additions & 0 deletions tests/examples/matrix-glob/output/expected/dev_cuda-118.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.*
name: dev_cuda-118
9 changes: 9 additions & 0 deletions tests/examples/matrix-glob/output/expected/dev_cuda-120.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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
- cuda-version=12.*
name: dev_cuda-120
Loading