-
Notifications
You must be signed in to change notification settings - Fork 1
Add new fields workflow_input_schema and workflow_output_schema to the spec
#475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import sys | ||
| from typing import Dict | ||
| from typing import List | ||
| from typing import Literal | ||
| from typing import Optional | ||
| from typing import Union | ||
|
|
||
| from jsonschema import Draft202012Validator | ||
| from pydantic import BaseModel | ||
| from pydantic import Field | ||
| from pydantic import model_validator | ||
|
|
||
| if sys.version_info < (3, 11): | ||
| from typing_extensions import Self | ||
| else: | ||
| from typing import Self | ||
|
|
||
|
|
||
| class _Target(BaseModel): | ||
| name: str | ||
| id: Union[str, int, None] = None | ||
| label: Optional[str] = None | ||
| task_identifier: Optional[str] = None | ||
| all: bool = False | ||
|
|
||
|
|
||
| class _Property(BaseModel, extra="allow"): | ||
|
woutdenolf marked this conversation as resolved.
|
||
| x_ewoks_targets: List[_Target] = Field(default_factory=list) | ||
|
|
||
|
|
||
| class EwoksParameterSchema(BaseModel, extra="forbid"): | ||
| schema_url: Literal["https://json-schema.org/draft/2020-12/schema"] = Field( | ||
| default="https://json-schema.org/draft/2020-12/schema", | ||
| alias="$schema", | ||
| ) | ||
|
|
||
| type: Literal["object"] = "object" | ||
|
|
||
| properties: Dict[str, _Property] | ||
| required: List[str] = Field(default_factory=list) | ||
|
woutdenolf marked this conversation as resolved.
|
||
|
|
||
| additionalProperties: Literal[False] = False | ||
|
|
||
| @model_validator(mode="after") | ||
| def validate_json_schema(self) -> Self: | ||
| schema_dict = self.model_dump(by_alias=True) | ||
|
|
||
| # validates that the structure is a valid JSON Schema | ||
| Draft202012Validator.check_schema(schema_dict) | ||
|
|
||
| return self | ||
|
|
||
| @model_validator(mode="after") | ||
| def validate_required(self) -> Self: | ||
| missing = set(self.required) - self.properties.keys() | ||
| if missing: | ||
| raise ValueError( | ||
| f"'required' contains unknown properties: {sorted(missing)}" | ||
| ) | ||
| return self | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| from . import graph | ||
|
|
||
|
|
||
| @graph | ||
| def with_schema(): | ||
| graph = { | ||
| "id": "with_schema", | ||
| "label": "with_schema", | ||
| "schema_version": "1.3", | ||
| "workflow_input_schema": { | ||
| "properties": { | ||
| "a": { | ||
| "type": "number", | ||
| "x_ewoks_targets": [{"name": "a", "id": "task1a"}], | ||
| }, | ||
| "b": { | ||
| "type": "number", | ||
| "default": 0, | ||
| "x_ewoks_targets": [{"name": "b", "id": "task1b"}], | ||
| }, | ||
| }, | ||
| "required": ["a"], | ||
| }, | ||
| "workflow_output_schema": { | ||
| "properties": { | ||
| "result_sum": { | ||
| "type": "number", | ||
| "x_ewoks_targets": [{"name": "result", "id": "task"}], | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| nodes = [ | ||
| { | ||
| "id": "task1a", | ||
| "task_type": "class", | ||
| "task_identifier": "ewokscore.tests.examples.tasks.sumlist.SumList", | ||
| "default_inputs": [{"name": "list", "value": [0, 1, 2]}], | ||
| }, | ||
| { | ||
| "id": "task1b", | ||
| "task_type": "class", | ||
| "task_identifier": "ewokscore.tests.examples.tasks.sumtask.SumTask", | ||
| "default_inputs": [{"name": "a", "value": 10}], | ||
| }, | ||
| { | ||
| "id": "task2", | ||
| "task_type": "class", | ||
| "task_identifier": "ewokscore.tests.examples.tasks.sumtask.SumTask", | ||
| }, | ||
| ] | ||
|
|
||
| links = [ | ||
| { | ||
| "source": "task1a", | ||
| "target": "task2", | ||
| "data_mapping": [{"source_output": "sum", "target_input": "a"}], | ||
| }, | ||
| { | ||
| "source": "task1b", | ||
| "target": "task2", | ||
| "data_mapping": [{"source_output": "result", "target_input": "b"}], | ||
| }, | ||
| ] | ||
|
|
||
| taskgraph = {"graph": graph, "links": links, "nodes": nodes} | ||
|
|
||
| expected_results = { | ||
| "task1a": {"sum": 3}, | ||
| "task1b": {"result": 10}, | ||
| "task2": {"result": 13}, | ||
| } | ||
|
|
||
| return taskgraph, expected_results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.