1313import msgspec
1414
1515from .util .python_path import find_object
16- from .util .schema import validate_schema
16+ from .util .schema import Schema , validate_schema
1717from .util .vcs import get_repository
1818from .util .yaml import load_yaml
1919
2626]
2727
2828
29- class WorkerAlias (msgspec . Struct , kw_only = True , rename = "kebab" ):
29+ class WorkerAlias (Schema ):
3030 """Worker alias configuration."""
3131
3232 provisioner : Union [str , dict ]
@@ -35,32 +35,38 @@ class WorkerAlias(msgspec.Struct, kw_only=True, rename="kebab"):
3535 worker_type : Union [str , dict ] # Can be keyed-by, maps from "worker-type"
3636
3737
38- class Workers (msgspec . Struct , kw_only = True ):
38+ class Workers (Schema , rename = None ):
3939 """Workers configuration."""
4040
4141 aliases : Dict [str , WorkerAlias ]
4242
4343
44- class Repository (msgspec . Struct , kw_only = True , rename = "kebab" ):
44+ class Repository (Schema ):
4545 """Repository configuration."""
4646
47+ # Required fields first
4748 name : str
49+
50+ # Optional fields
4851 project_regex : Optional [str ] = None # Maps from "project-regex"
4952 ssh_secret_name : Optional [str ] = None # Maps from "ssh-secret-name"
5053 # Allow extra fields for flexibility
5154 __extras__ : Dict [str , Any ] = msgspec .field (default_factory = dict )
5255
5356
54- class RunConfig (msgspec . Struct , kw_only = True , rename = "kebab" ):
57+ class RunConfig (Schema ):
5558 """Run transforms configuration."""
5659
5760 use_caches : Optional [Union [bool , List [str ]]] = None # Maps from "use-caches"
5861
5962
60- class TaskGraphConfig (msgspec . Struct , kw_only = True , rename = "kebab" ):
63+ class TaskGraphConfig (Schema ):
6164 """Taskgraph specific configuration."""
6265
66+ # Required fields first
6367 repositories : Dict [str , Repository ]
68+
69+ # Optional fields
6470 register : Optional [str ] = None
6571 decision_parameters : Optional [str ] = None # Maps from "decision-parameters"
6672 cached_task_prefix : Optional [str ] = None # Maps from "cached-task-prefix"
@@ -69,17 +75,18 @@ class TaskGraphConfig(msgspec.Struct, kw_only=True, rename="kebab"):
6975 run : Optional [RunConfig ] = None
7076
7177
72- class GraphConfigSchema (
73- msgspec .Struct , kw_only = True , omit_defaults = True , rename = "kebab"
74- ):
78+ class GraphConfigSchema (Schema ):
7579 """Main graph configuration schema."""
7680
81+ # Required fields first
7782 trust_domain : str # Maps from "trust-domain"
7883 task_priority : Union [
7984 TaskPriority , dict
8085 ] # Maps from "task-priority", can be keyed-by
8186 workers : Workers
8287 taskgraph : TaskGraphConfig
88+
89+ # Optional fields
8390 docker_image_kind : Optional [str ] = None # Maps from "docker-image-kind"
8491 task_deadline_after : Optional [Union [str , dict ]] = (
8592 None # Maps from "task-deadline-after", can be keyed-by
@@ -161,9 +168,7 @@ def kinds_dir(self):
161168def validate_graph_config (config ):
162169 """Validate graph configuration using msgspec."""
163170 # With rename="kebab", msgspec handles the conversion automatically
164- validate_schema (
165- GraphConfigSchema , config , "Invalid graph configuration:" , use_msgspec = True
166- )
171+ validate_schema (GraphConfigSchema , config , "Invalid graph configuration:" )
167172
168173
169174def load_graph_config (root_dir ):
0 commit comments