Skip to content

Commit b836118

Browse files
feat: added support for msgspec schemas now called Schema along with refactoring volutpous schemas to now be called LegacySchema
1 parent 773f5d2 commit b836118

File tree

22 files changed

+277
-91
lines changed

22 files changed

+277
-91
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies = [
2525
"cookiecutter~=2.1",
2626
"json-e>=2.7",
2727
"mozilla-repo-urls",
28+
"msgspec>=0.19.0",
2829
"PyYAML>=5.3.1",
2930
"redo>=2.0",
3031
"requests>=2.25",

src/taskgraph/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
from .util.caches import CACHES
1515
from .util.python_path import find_object
16-
from .util.schema import Schema, optionally_keyed_by, validate_schema
16+
from .util.schema import LegacySchema, optionally_keyed_by, validate_schema
1717
from .util.vcs import get_repository
1818
from .util.yaml import load_yaml
1919

2020
logger = logging.getLogger(__name__)
2121

2222

2323
#: Schema for the graph config
24-
graph_config_schema = Schema(
24+
graph_config_schema = LegacySchema(
2525
{
2626
# The trust-domain for this graph.
2727
# (See https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/taskgraph.html#taskgraph-trust-domain) # noqa

src/taskgraph/decision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from taskgraph.taskgraph import TaskGraph
2121
from taskgraph.util import json
2222
from taskgraph.util.python_path import find_object
23-
from taskgraph.util.schema import Schema, validate_schema
23+
from taskgraph.util.schema import LegacySchema, validate_schema
2424
from taskgraph.util.vcs import get_repository
2525
from taskgraph.util.yaml import load_yaml
2626

@@ -40,7 +40,7 @@
4040

4141

4242
#: Schema for try_task_config.json version 2
43-
try_task_config_schema_v2 = Schema(
43+
try_task_config_schema_v2 = LegacySchema(
4444
{
4545
Optional("parameters"): {str: object},
4646
}

src/taskgraph/transforms/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from ..config import GraphConfig
1414
from ..parameters import Parameters
15-
from ..util.schema import Schema, validate_schema
15+
from ..util.schema import LegacySchema, validate_schema
1616

1717

1818
@dataclass(frozen=True)
@@ -138,7 +138,7 @@ def add_validate(self, schema):
138138

139139
@dataclass
140140
class ValidateSchema:
141-
schema: Schema
141+
schema: LegacySchema
142142

143143
def __call__(self, config, tasks):
144144
for task in tasks:

src/taskgraph/transforms/chunking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from voluptuous import ALLOW_EXTRA, Optional, Required
88

99
from taskgraph.transforms.base import TransformSequence
10-
from taskgraph.util.schema import Schema
10+
from taskgraph.util.schema import LegacySchema
1111
from taskgraph.util.templates import substitute
1212

1313
#: Schema for chunking transforms
14-
CHUNK_SCHEMA = Schema(
14+
CHUNK_SCHEMA = LegacySchema(
1515
{
1616
# Optional, so it can be used for a subset of tasks in a kind
1717
Optional(

src/taskgraph/transforms/docker_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from taskgraph.transforms.base import TransformSequence
1414
from taskgraph.util import json
1515
from taskgraph.util.docker import create_context_tar, generate_context_hash
16-
from taskgraph.util.schema import Schema
16+
from taskgraph.util.schema import LegacySchema
1717

1818
from .task import task_description_schema
1919

@@ -32,7 +32,7 @@
3232
transforms = TransformSequence()
3333

3434
#: Schema for docker_image transforms
35-
docker_image_schema = Schema(
35+
docker_image_schema = LegacySchema(
3636
{
3737
Required(
3838
"name",

src/taskgraph/transforms/fetch.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
from ..util import path
2020
from ..util.cached_tasks import add_optimization
21-
from ..util.schema import Schema, validate_schema
21+
from ..util.schema import LegacySchema, validate_schema
2222
from ..util.treeherder import join_symbol
2323
from .base import TransformSequence
2424

2525
CACHE_TYPE = "content.v1"
2626

2727
#: Schema for fetch transforms
28-
FETCH_SCHEMA = Schema(
28+
FETCH_SCHEMA = LegacySchema(
2929
{
3030
Required(
3131
"name",
@@ -87,12 +87,12 @@
8787

8888
@dataclass(frozen=True)
8989
class FetchBuilder:
90-
schema: Schema
90+
schema: LegacySchema
9191
builder: Callable
9292

9393

9494
def fetch_builder(name, schema):
95-
schema = Schema({Required("type"): name}).extend(schema)
95+
schema = LegacySchema({Required("type"): name}).extend(schema)
9696

9797
def wrap(func):
9898
fetch_builders[name] = FetchBuilder(schema, func) # type: ignore

src/taskgraph/transforms/from_deps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
from taskgraph.transforms.run import fetches_schema
2121
from taskgraph.util.attributes import attrmatch
2222
from taskgraph.util.dependencies import GROUP_BY_MAP, get_dependencies
23-
from taskgraph.util.schema import Schema, validate_schema
23+
from taskgraph.util.schema import LegacySchema, validate_schema
2424
from taskgraph.util.set_name import SET_NAME_MAP
2525

2626
#: Schema for from_deps transforms
27-
FROM_DEPS_SCHEMA = Schema(
27+
FROM_DEPS_SCHEMA = LegacySchema(
2828
{
2929
Required("from-deps"): {
3030
Optional(

src/taskgraph/transforms/matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from voluptuous import ALLOW_EXTRA, Extra, Optional, Required
1414

1515
from taskgraph.transforms.base import TransformSequence
16-
from taskgraph.util.schema import Schema
16+
from taskgraph.util.schema import LegacySchema
1717
from taskgraph.util.templates import substitute_task_fields
1818

1919
#: Schema for matrix transforms
20-
MATRIX_SCHEMA = Schema(
20+
MATRIX_SCHEMA = LegacySchema(
2121
{
2222
Required("name"): str,
2323
Optional("matrix"): {

src/taskgraph/transforms/notify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from voluptuous import ALLOW_EXTRA, Any, Exclusive, Optional, Required
1212

1313
from taskgraph.transforms.base import TransformSequence
14-
from taskgraph.util.schema import Schema, optionally_keyed_by, resolve_keyed_by
14+
from taskgraph.util.schema import LegacySchema, optionally_keyed_by, resolve_keyed_by
1515

1616
_status_type = Any(
1717
"on-completed",
@@ -55,7 +55,7 @@
5555
"""Map each type to its primary key that will be used in the route."""
5656

5757
#: Schema for notify transforms
58-
NOTIFY_SCHEMA = Schema(
58+
NOTIFY_SCHEMA = LegacySchema(
5959
{
6060
Exclusive("notify", "config"): {
6161
Required("recipients"): [Any(*_recipients)],

0 commit comments

Comments
 (0)