Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/rapids_dependency_file_generator/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
default_conda_dir = "conda/environments"
default_requirements_dir = "python"
default_pyproject_dir = "python"

default_dependency_file_path = "dependencies.yaml"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import typing
from collections.abc import Generator
from dataclasses import dataclass
from pathlib import Path

import tomlkit
import yaml
Expand Down Expand Up @@ -213,6 +214,54 @@ def make_dependency_file(
return file_contents


def make_conda_build_config_file(
*,
config_file: os.PathLike,
output_dir: os.PathLike,
matrix: dict[str, list[str]],
) -> str:
"""Generate the contents of a conda_build_config.yaml file.

This function aggregates matrix values from the dependencies.yaml file and
formats them in the conda-build config format.

Parameters
----------
config_file : PathLike
The full path to the dependencies.yaml file.
output_dir : PathLike
The path to the directory where the conda_build_config.yaml file will be written.
matrix : dict[str, list[str]]
The matrix of specific parameters to use when generating.

Returns
-------
str
The contents of the conda_build_config.yaml file.
"""
relative_path_to_config_file = os.path.relpath(config_file, output_dir)
file_contents = textwrap.dedent(
f"""\
{HEADER}
# To make changes, edit {relative_path_to_config_file} and run `{cli_name}`.
# This file contains matrix values aggregated from dependencies.yaml
"""
)

# Convert matrix values to conda-build config format
conda_build_config = {}
for key, values in matrix.items():
# Rename "py" key to "python" for conda-build compatibility
if key == "py":
conda_build_config["python"] = values
else:
conda_build_config[key] = values

file_contents += yaml.dump(conda_build_config, default_flow_style=False)

return file_contents


def get_filename(file_type: _config.Output, file_key: str, matrix_combo: dict[str, str]):
"""Get the name of the file to which to write a generated dependency set.

Expand Down Expand Up @@ -256,6 +305,7 @@ def get_filename(file_type: _config.Output, file_key: str, matrix_combo: dict[st
# need to have that exact name and are never prefixed.
file_name_prefix = "pyproject"
suffix = ""

filename = "_".join(filter(None, (file_type_prefix, file_name_prefix, suffix))).replace(".", "")
return filename + file_ext

Expand Down Expand Up @@ -289,6 +339,7 @@ def get_output_dir(*, file_type: _config.Output, config_file_path: os.PathLike,
path.append(file_config.requirements_dir)
elif file_type == _config.Output.PYPROJECT:
path.append(file_config.pyproject_dir)

return os.path.join(*path)


Expand Down Expand Up @@ -417,6 +468,25 @@ def make_dependency_files(
if _config.Output.PYPROJECT in file_types_to_generate and len(calculated_grid) > 1:
raise ValueError("Pyproject outputs can't have more than one matrix output")
for file_type in file_types_to_generate:
# Generate conda_build_config.yaml if this is a conda output type
if file_type == _config.Output.CONDA and not to_stdout:
conda_build_config_name = "conda_build_config.yaml"
output_dir = get_output_dir(
file_type=file_type,
config_file_path=parsed_config.path,
file_config=file_config,
)
conda_build_config_contents = make_conda_build_config_file(
config_file=parsed_config.path,
output_dir=output_dir,
matrix=file_matrix,
)

os.makedirs(output_dir, exist_ok=True)
conda_build_config_path = Path(output_dir) / conda_build_config_name
with open(conda_build_config_path, "w") as f:
f.write(conda_build_config_contents)

for matrix_combo in calculated_grid:
dependencies = []

Expand Down
41 changes: 41 additions & 0 deletions tests/examples/conda-build-config/dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
files:
build:
output: [conda]
conda_dir: output/actual
matrix:
cuda: ["11.5", "11.6"]
arch: [x86_64, arm64]
py: ["3.9", "3.10"]
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:
py: "3.9"
packages:
- python=3.9
- matrix:
py: "3.10"
packages:
- python=3.10
Original file line number Diff line number Diff line change
@@ -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
- python=3.10
- spdlog>=1.8.5,<1.9
name: build_cuda-115_arch-arm64_py-310
Original file line number Diff line number Diff line change
@@ -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
- python=3.9
- spdlog>=1.8.5,<1.9
name: build_cuda-115_arch-arm64_py-39
Original file line number Diff line number Diff line change
@@ -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
- python=3.10
- spdlog>=1.8.5,<1.9
name: build_cuda-115_arch-x86_64_py-310
Original file line number Diff line number Diff line change
@@ -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
- python=3.9
- spdlog>=1.8.5,<1.9
name: build_cuda-115_arch-x86_64_py-39
Original file line number Diff line number Diff line change
@@ -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.6
- python=3.10
- spdlog>=1.8.5,<1.9
name: build_cuda-116_arch-arm64_py-310
Original file line number Diff line number Diff line change
@@ -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.6
- python=3.9
- spdlog>=1.8.5,<1.9
name: build_cuda-116_arch-arm64_py-39
Original file line number Diff line number Diff line change
@@ -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.6
- python=3.10
- spdlog>=1.8.5,<1.9
name: build_cuda-116_arch-x86_64_py-310
Original file line number Diff line number Diff line change
@@ -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.6
- python=3.9
- spdlog>=1.8.5,<1.9
name: build_cuda-116_arch-x86_64_py-39
Original file line number Diff line number Diff line change
@@ -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`.
# This file contains matrix values aggregated from dependencies.yaml
arch:
- x86_64
- arm64
cuda:
- '11.5'
- '11.6'
python:
- '3.9'
- '3.10'
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`.
# This file contains matrix values aggregated from dependencies.yaml
arch:
- x86_64
cuda:
- '11.5'
- '11.6'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
cuda:
- '11.5'
- '11.6'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
cuda:
- '10.0'
- '11.8'
- '12.0'
Original file line number Diff line number Diff line change
@@ -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`.
# This file contains matrix values aggregated from dependencies.yaml
arch:
- x86_64
- arm64
cuda:
- '11.5'
python:
- '3.8'
- null
12 changes: 12 additions & 0 deletions tests/examples/matrix/output/expected/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -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`.
# This file contains matrix values aggregated from dependencies.yaml
arch:
- x86_64
- arm64
cuda:
- '11.5'
- '11.6'
python:
- '3.8'
- '3.9'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
cuda:
- '11.8'
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`.
# This file contains matrix values aggregated from dependencies.yaml
arch:
- x86_64
cuda:
- '11.5'
- '11.6'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
cuda:
- '11.5'
- '11.8'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
cuda:
- '11.5'
- '11.8'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is generated by `rapids-dependency-file-generator`.
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
# This file contains matrix values aggregated from dependencies.yaml
cuda:
- '11.5'
- '11.8'
Loading
Loading