rapidsai / dependency-file-generator

https://pypi.org/project/rapids-dependency-file-generator/
Apache License 2.0
15 stars 13 forks source link

idea: linting dependencies.yaml files via '--strict' #103

Open jameslamb opened 4 months ago

jameslamb commented 4 months ago

Description

I just manually updated a LOT of dependencies.yaml files across RAPIDS (https://github.com/rapidsai/build-planning/issues/31), and found myself looking for some things manually that should be possible to enforce with a linter.

This issue proposes adding a --strict argument to rapids-dependency-file-generator, which enforces more standardization across dependencies.yaml files.

Benefits of this work

Acceptance Criteria

Approach

I'm proposing that if a flag --strict is passed to rapids-dependency-file-generator, it check the content of the YAML file passed to --config and raise a non-0 exit code if any of a set of opt-in linting rules are violated.

I'll list some initial ideas I have here. I'm sure others will have more. For most of these, I have lightly-held opinions about which should be the preferred pattern, and care more that there be some preferred pattern and a tool to automatically enforce that preference.

# this
packages:
  - rmm-cu12

# not this
packages: [rmm-cu12]
# this
matrix:
  cuda: "12.*"

# not this:
matrix: {"cuda": "12.*"}
# this
- matrix: null
  packages: null

# not this
- matrix:
  packages:
# failing if this is never met by a corresponding '*cupy_cu12'
- matrix:
    cuda: "12.*"
   packages:
     - &cupy_cu12 cupy-cuda12x>=12.0.0

Notes

This proposal is inspired by mypy --strict (mypy docs).

And by conversations like this: https://github.com/rapidsai/rmm/pull/1627#discussion_r1690501031

jameslamb commented 4 months ago

Thinking more about this this morning.... all of the examples I gave are generic YAML-formatting things and not specific to rapids-dependency-file-generator. Maybe just yamllint or similar could be used to enforce those things if we wanted, with no changes to rapids-dependency-file-generator.