|
22 | 22 | from taskgraph.util.schema import Schema, validate_schema |
23 | 23 | from taskgraph.util.set_name import SET_NAME_MAP |
24 | 24 |
|
25 | | - |
26 | | -class FromDepsConfig(Schema): |
27 | | - # Limit dependencies to specified kinds (defaults to all kinds in |
28 | | - # `kind-dependencies`). |
29 | | - # |
30 | | - # The first kind in the list is the "primary" kind. The |
31 | | - # dependency of this kind will be used to derive the label |
32 | | - # and copy attributes (if `copy-attributes` is True). |
33 | | - kinds: Optional[list[str]] = None |
34 | | - # Set-name function (dynamic: validated at runtime against SET_NAME_MAP). |
35 | | - set_name: Optional[Union[bool, str, dict[str, object]]] = None |
36 | | - # Limit dependencies to tasks whose attributes match |
37 | | - # using :func:`~taskgraph.util.attributes.attrmatch`. |
38 | | - with_attributes: Optional[dict[str, Union[list, str]]] = None |
39 | | - # Group cross-kind dependencies using the given group-by |
40 | | - # function. One task will be created for each group. If not |
41 | | - # specified, the 'single' function will be used which creates |
42 | | - # a new task for each individual dependency. |
43 | | - group_by: Optional[Union[str, dict[str, object]]] = None |
44 | | - # If True, copy attributes from the dependency matching the |
45 | | - # first kind in the `kinds` list (whether specified explicitly |
46 | | - # or taken from `kind-dependencies`). |
47 | | - copy_attributes: Optional[bool] = None |
48 | | - # If true (the default), there must be only a single unique task |
49 | | - # for each kind in a dependency group. Setting this to false |
50 | | - # disables that requirement. |
51 | | - unique_kinds: Optional[bool] = None |
52 | | - # If present, a `fetches` entry will be added for each task |
53 | | - # dependency. Attributes of the upstream task may be used as |
54 | | - # substitution values in the `artifact` or `dest` values of the |
55 | | - # `fetches` entry. |
56 | | - fetches: Optional[dict[str, list[FetchesEntrySchema]]] = None |
57 | | - |
58 | | - |
59 | | -#: Schema for from_deps transforms |
60 | | -class FromDepsSchema(Schema, forbid_unknown_fields=False, kw_only=True): |
61 | | - from_deps: FromDepsConfig |
62 | | - |
63 | | - |
64 | | -FROM_DEPS_SCHEMA = FromDepsSchema |
| 25 | +FROM_DEPS_SCHEMA = Schema.from_dict( |
| 26 | + { |
| 27 | + "from-deps": Schema.from_dict( |
| 28 | + { |
| 29 | + # Limit dependencies to specified kinds (defaults to all kinds in |
| 30 | + # `kind-dependencies`). |
| 31 | + # |
| 32 | + # The first kind in the list is the "primary" kind. The |
| 33 | + # dependency of this kind will be used to derive the label |
| 34 | + # and copy attributes (if `copy-attributes` is True). |
| 35 | + "kinds": Optional[list[str]], |
| 36 | + # Set-name function (dynamic: validated at runtime against SET_NAME_MAP). |
| 37 | + "set-name": Optional[Union[bool, str, dict[str, object]]], |
| 38 | + # Limit dependencies to tasks whose attributes match |
| 39 | + # using :func:`~taskgraph.util.attributes.attrmatch`. |
| 40 | + "with-attributes": Optional[dict[str, Union[list, str]]], |
| 41 | + # Group cross-kind dependencies using the given group-by |
| 42 | + # function. One task will be created for each group. If not |
| 43 | + # specified, the 'single' function will be used which creates |
| 44 | + # a new task for each individual dependency. |
| 45 | + "group-by": Optional[Union[str, dict[str, object]]], |
| 46 | + # If True, copy attributes from the dependency matching the |
| 47 | + # first kind in the `kinds` list (whether specified explicitly |
| 48 | + # or taken from `kind-dependencies`). |
| 49 | + "copy-attributes": Optional[bool], |
| 50 | + # If true (the default), there must be only a single unique task |
| 51 | + # for each kind in a dependency group. Setting this to false |
| 52 | + # disables that requirement. |
| 53 | + "unique-kinds": Optional[bool], |
| 54 | + # If present, a `fetches` entry will be added for each task |
| 55 | + # dependency. Attributes of the upstream task may be used as |
| 56 | + # substitution values in the `artifact` or `dest` values of the |
| 57 | + # `fetches` entry. |
| 58 | + "fetches": Optional[dict[str, list[FetchesEntrySchema]]], |
| 59 | + }, |
| 60 | + ), |
| 61 | + }, |
| 62 | + name="FromDepsSchema", |
| 63 | + forbid_unknown_fields=False, |
| 64 | +) |
65 | 65 |
|
66 | 66 | transforms = TransformSequence() |
67 | 67 | transforms.add_validate(FROM_DEPS_SCHEMA) |
|
0 commit comments