Skip to content

Commit 7d739b1

Browse files
committed
Add new field input_schema to the spec
1 parent 774cd9e commit 7d739b1

15 files changed

Lines changed: 57 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Support for Graph serialization and transparent handling of `Numpy arrays` in both JSON and
1313
YAML via pickling.
14+
- Add new field `inputs` to the spec
1415

1516
## [5.0.0rc1] - 2026-04-13
1617

doc/reference/specs.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ Graph attributes
4949
^^^^^^^^^^^^^^^^
5050
* *id* (optional): graph identifier unique to a database of graphs (Default: "notspecified")
5151
* *label* (optional): non-unique label to be used when identifying a graph for human consumption
52-
* *schema_version* (optional): the schema version of this graph representation (Default: "1.0")
52+
* *schema_version* (optional): the schema version of this graph representation (Default: "1.2")
53+
* *inputs* (optional): inputs of the workflow itself. Must be a JSON schema representing a subset of the node inputs.
5354
* *requirements* (optional): a list of projects that should be present in the Python environment for the
5455
graph to be executed.
5556
* *input_nodes* (optional): nodes that are expected to be used as link targets when the graph

pyproject.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ classifiers = [
1717
]
1818
requires-python = ">=3.8"
1919
dependencies = [
20-
"numpy >=1.15",
21-
"networkx >=2",
22-
"silx >=1",
23-
"pyyaml >=5.1",
24-
"h5py >=2.8",
25-
"packaging",
2620
"ewoksutils >=1.9.1",
21+
"h5py >=2.8",
2722
"importlib_metadata;python_version < '3.9'",
23+
"jsonschema",
24+
"networkx >=2",
25+
"numpy >=1.15",
26+
"packaging",
2827
"pydantic >= 2",
28+
"pyyaml >=5.1",
29+
"silx >=1",
2930
"typing_extensions;python_version < '3.11'",
3031
]
3132

src/ewokscore/graph/schema/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from .metadata import SchemaMetadata
1010
from .update import from_v1_0_to_v1_1
11+
from .update import from_v1_1_to_v1_2
1112
from .update import v0_update
1213

1314
_VERSIONS = None
@@ -21,7 +22,8 @@ def get_versions() -> Dict[Version, SchemaMetadata]:
2122
_VERSIONS = {
2223
parse_version("0.0"): SchemaMetadata(("0.0", "0.0.1"), v0_update),
2324
parse_version("1.0"): SchemaMetadata(("0.1.0-rc", None), from_v1_0_to_v1_1),
24-
parse_version("1.1"): SchemaMetadata(("0.1.0-rc", None), None),
25+
parse_version("1.1"): SchemaMetadata(("0.1.0-rc", None), from_v1_1_to_v1_2),
26+
parse_version("1.2"): SchemaMetadata(("0.1.0-rc1", None), None),
2527
}
2628
return _VERSIONS
2729

src/ewokscore/graph/schema/model.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
from typing import Any
3+
from typing import Dict
34
from typing import Hashable
45
from typing import Literal
56
from typing import Optional
@@ -17,8 +18,11 @@
1718
from typing import Self
1819

1920

21+
from jsonschema import Draft7Validator
2022
from pydantic import BaseModel
2123
from pydantic import Field
24+
from pydantic import ValidationError
25+
from pydantic import field_validator
2226
from pydantic import model_validator
2327

2428
from . import LATEST_VERSION
@@ -123,6 +127,16 @@ class EwoksGraphAttributes(BaseModel):
123127
requirements: Sequence[str] = []
124128
input_nodes: Sequence[EwoksNodeAlias] = []
125129
output_nodes: Sequence[EwoksNodeAlias] = []
130+
inputs: Dict[str, Any] = {}
131+
132+
@field_validator("inputs")
133+
@classmethod
134+
def validate_schema(cls, v):
135+
try:
136+
Draft7Validator.check_schema(v)
137+
except ValidationError:
138+
raise
139+
return v
126140

127141

128142
class EwoksGraph(BaseModel):

src/ewokscore/graph/schema/update.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ def v0_update(graph: networkx.DiGraph) -> None:
99
def from_v1_0_to_v1_1(graph: networkx.DiGraph) -> None:
1010
"""This version does not have the requirements field."""
1111
graph.graph["schema_version"] = "1.1"
12+
13+
14+
def from_v1_1_to_v1_2(graph: networkx.DiGraph) -> None:
15+
"""This version does not have the inputs field."""
16+
graph.graph["schema_version"] = "1.2"

src/ewokscore/tests/examples/graphs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def wrapper():
3434
attrs = g.setdefault("graph", dict())
3535
assert attrs.get("id") == name
3636
assert attrs.get("label") == name
37-
assert attrs.get("schema_version") == "1.1"
37+
assert attrs.get("schema_version") == "1.2"
3838
return g, result
3939

4040
if _ALL_GRAPHS is None:

src/ewokscore/tests/examples/graphs/acyclic1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def acyclic1():
133133
},
134134
]
135135
}
136-
graph = {"id": "acyclic1", "label": "acyclic1", "schema_version": "1.1", "ows": ows}
136+
graph = {"id": "acyclic1", "label": "acyclic1", "schema_version": "1.2", "ows": ows}
137137

138138
taskgraph = {"graph": graph, "links": links, "nodes": nodes}
139139

src/ewokscore/tests/examples/graphs/acyclic2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@graph
55
def acyclic2():
6-
graph = {"id": "acyclic2", "label": "acyclic2", "schema_version": "1.1"}
6+
graph = {"id": "acyclic2", "label": "acyclic2", "schema_version": "1.2"}
77

88
task = "ewokscore.tests.examples.tasks.errorsumtask.ErrorSumTask"
99
nodes = [

src/ewokscore/tests/examples/graphs/acyclic3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
@graph
66
def acyclic3():
7-
graph = {"id": "acyclic3", "label": "acyclic3", "schema_version": "1.1"}
7+
graph = {"id": "acyclic3", "label": "acyclic3", "schema_version": "1.2"}
88

99
task = "ewokscore.tests.examples.tasks.sumtask.SumTask"
1010
nodes = [

0 commit comments

Comments
 (0)