Skip to content

Commit 32a3b68

Browse files
author
Alan Christie
committed
feat: Extended schema for 'example 1' (step inputs & outputs)
1 parent ac1c213 commit 32a3b68

File tree

4 files changed

+100
-2
lines changed

4 files changed

+100
-2
lines changed

tests/test_decoder_minimal.py renamed to tests/test_decoder.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88

99
from workflow import decoder
1010

11+
# Pre-load some example workflows...
1112
_MINIMAL_WORKFLOW_FILE: str = os.path.join(
1213
os.path.dirname(__file__), "workflow-definitions", "minimal.yaml"
1314
)
1415
with open(_MINIMAL_WORKFLOW_FILE, "r", encoding="utf8") as workflow_file:
15-
_MINIMAL_WORKFLOW: Dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
16+
_MINIMAL_WORKFLOW: Dict[str, Any] = yaml.safe_load(workflow_file)
1617
assert _MINIMAL_WORKFLOW
1718

19+
_SHORTCUT_EXAMPLE_1_WORKFLOW_FILE: str = os.path.join(
20+
os.path.dirname(__file__), "workflow-definitions", "shortcut-example-1.yaml"
21+
)
22+
with open(_SHORTCUT_EXAMPLE_1_WORKFLOW_FILE, "r", encoding="utf8") as workflow_file:
23+
_SHORTCUT_EXAMPLE_1_WORKFLOW: Dict[str, Any] = yaml.safe_load(workflow_file)
24+
assert _SHORTCUT_EXAMPLE_1_WORKFLOW
25+
1826

1927
def test_validate_minimal():
2028
# Arrange
@@ -60,3 +68,13 @@ def test_validate_name_with_spaces():
6068
assert (
6169
error == "'workflow with spaces' does not match '^[a-z][a-z0-9-]{,63}(?<!-)$'"
6270
)
71+
72+
73+
def test_validate_shortcut_example_1():
74+
# Arrange
75+
76+
# Act
77+
error = decoder.validate_schema(_SHORTCUT_EXAMPLE_1_WORKFLOW)
78+
79+
# Assert
80+
assert error is None

tests/test_workflow_validator.py

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

77
pytestmark = pytest.mark.unit
88

9-
from tests.test_decoder_minimal import _MINIMAL_WORKFLOW
9+
from tests.test_decoder import _MINIMAL_WORKFLOW
1010
from workflow.workflow_validator import ValidationLevel, WorkflowValidator
1111

1212

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
kind: DataManagerWorkflow
3+
kind-version: "2024.1"
4+
name: experimental-workflow
5+
description: An experimental workflow
6+
steps:
7+
- name: step-1
8+
description: The first step
9+
specification: '{"collection":"im-test","job":"process-a","version":"1.0.0", "variables":{"x": 7}}'
10+
outputs:
11+
- output: 'outputFile'
12+
as: 'a.sdf'
13+
- name: step-2
14+
specification: '{"collection":"im-test","job":"process-b","version":"1.0.0", "variables":{"y": 22}}'
15+
inputs:
16+
- input: 'inputFile'
17+
from:
18+
step: step-1
19+
output: 'outputFile'
20+
outputs:
21+
- output: 'outputFile'
22+
as: 'b.sdf'

workflow/workflow-schema.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,54 @@ definitions:
4242
rfc1035-label-name:
4343
type: string
4444
pattern: ^[a-z][a-z0-9-]{,63}(?<!-)$
45+
description: >-
46+
A value compatible with Kubernetes variables
47+
to allow it to be used ins Pod Label
48+
49+
variable-name:
50+
type: string
51+
pattern: ^[a-zA-Z_][a-zA-Z0-9_]{,63}$
52+
description: >-
53+
A Job/Step variable name, as used in the Data Manager Job Specification
54+
55+
# Declaration of a step from anotehr step
56+
from-step-output:
57+
type: object
58+
additionalProperties: false
59+
properties:
60+
step:
61+
$ref: '#/definitions/rfc1035-label-name'
62+
output:
63+
$ref: '#/definitions/variable-name'
64+
required:
65+
- step
66+
- output
67+
68+
# A Step input (from an output of a prior step)
69+
step-input-from-step:
70+
type: object
71+
additionalProperties: false
72+
properties:
73+
input:
74+
$ref: '#/definitions/variable-name'
75+
from:
76+
$ref: '#/definitions/from-step-output'
77+
required:
78+
- input
79+
80+
# A Step output (with an 'as' - a declared value)
81+
step-output-as:
82+
type: object
83+
additionalProperties: false
84+
properties:
85+
output:
86+
$ref: '#/definitions/variable-name'
87+
as:
88+
type: string
89+
description: The value to set the variable to
90+
required:
91+
- output
92+
- as
4593

4694
step:
4795
type: object
@@ -54,6 +102,16 @@ definitions:
54102
specification:
55103
type: string
56104
description: The Data Manager Job Specification, a JSON string
105+
inputs:
106+
type: array
107+
items:
108+
oneOf:
109+
- $ref: "#/definitions/step-input-from-step"
110+
outputs:
111+
type: array
112+
items:
113+
oneOf:
114+
- $ref: "#/definitions/step-output-as"
57115
required:
58116
- name
59117
- specification

0 commit comments

Comments
 (0)