Skip to content

Commit d085915

Browse files
author
Alan Christie
committed
feat: Initial workflow options support (schema)
1 parent 0886e2d commit d085915

File tree

4 files changed

+121
-4
lines changed

4 files changed

+121
-4
lines changed

tests/test_decoder.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@
5656
)
5757
assert _STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW
5858

59+
_WORKFLOW_OPTIONS_WORKFLOW_FILE: str = os.path.join(
60+
os.path.dirname(__file__),
61+
"workflow-definitions",
62+
"workflow-options.yaml",
63+
)
64+
with open(_WORKFLOW_OPTIONS_WORKFLOW_FILE, "r", encoding="utf8") as workflow_file:
65+
_WORKFLOW_OPTIONS: Dict[str, Any] = yaml.safe_load(workflow_file)
66+
assert _WORKFLOW_OPTIONS
67+
5968

6069
def test_validate_schema_for_minimal():
6170
# Arrange
@@ -133,6 +142,16 @@ def test_validate_schema_for_step_specification_variable_names():
133142
assert error is None
134143

135144

145+
def test_validate_schema_for_workflow_options():
146+
# Arrange
147+
148+
# Act
149+
error = decoder.validate_schema(_WORKFLOW_OPTIONS)
150+
151+
# Assert
152+
assert error is None
153+
154+
136155
def test_get_workflow_variables_for_smiple_python_molprops():
137156
# Arrange
138157

tests/workflow-definitions/step-specification-variable-names.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ steps:
1010
job: b
1111
version: '1.0.0'
1212
variables:
13-
_a: 1
14-
A-1: 2.0
13+
a: 1
14+
A_1: 2.0
1515
a_14_: A string
16-
A-Long_boolean_variable_Name: true
16+
A_Long_boolean_variableName: true
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
kind: DataManagerWorkflow
3+
kind-version: "2024.1"
4+
name: workflow-options
5+
description: Illustrate the use of workflow options
6+
variables:
7+
options:
8+
- name: variableWithoutDefault
9+
as:
10+
- option: variable1
11+
step: step-1
12+
- option: variable2
13+
step: step-2
14+
- name: variableWithIntegerDefault
15+
default: 7
16+
as:
17+
- option: variable3
18+
step: step-1
19+
- name: variableWithIntegerDefaultAndRange
20+
default: 7
21+
minimum: 1
22+
maximum: 8
23+
as:
24+
- option: variable4
25+
step: step-1
26+
- name: variableWithFloatDefault
27+
default: 1.0
28+
as:
29+
- option: variable5
30+
step: step-1
31+
- name: variableWithBooleanDefault
32+
default: true
33+
as:
34+
- option: variable6
35+
step: step-1
36+
- name: variableWithStringDefault
37+
default: Hello, World!
38+
as:
39+
- option: variable7
40+
step: step-1
41+
steps:
42+
- name: step-1
43+
specification:
44+
collection: a
45+
job: b
46+
version: '1.0.0'
47+
- name: step-2
48+
specification:
49+
collection: a
50+
job: b
51+
version: '1.0.0'

workflow/workflow-schema.yaml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ properties:
2929
$ref: "#/definitions/step"
3030
variables:
3131
type: object
32+
additionalProperties: false
3233
properties:
3334
inputs:
3435
type: array
@@ -38,6 +39,10 @@ properties:
3839
type: array
3940
items:
4041
$ref: "#/definitions/workflow-output-parameter"
42+
options:
43+
type: array
44+
items:
45+
$ref: "#/definitions/workflow-option-parameter"
4146
required:
4247
- kind
4348
- kind-version
@@ -100,6 +105,20 @@ definitions:
100105
- name
101106
- as
102107

108+
# Declaration of a value from a workflow input (variable)
109+
as-step-option:
110+
type: object
111+
additionalProperties: false
112+
properties:
113+
option:
114+
$ref: '#/definitions/template-variable-name'
115+
step:
116+
$ref: '#/definitions/rfc1035-label-name'
117+
required:
118+
- option
119+
- step
120+
121+
103122
# Declaration of a value from a workflow input (variable)
104123
from-workflow-input:
105124
type: object
@@ -123,6 +142,34 @@ definitions:
123142
- step
124143
- output
125144

145+
# A workflow option used as a step option
146+
workflow-option-parameter:
147+
type: object
148+
additionalProperties: false
149+
properties:
150+
name:
151+
$ref: '#/definitions/template-variable-name'
152+
description:
153+
type: string
154+
default:
155+
oneOf:
156+
- type: string
157+
- type: number
158+
- type: boolean
159+
minimum:
160+
oneOf:
161+
- type: number
162+
maximum:
163+
oneOf:
164+
- type: number
165+
as:
166+
type: array
167+
items:
168+
$ref: '#/definitions/as-step-option'
169+
required:
170+
- name
171+
- as
172+
126173
# A Step input (from an output of a prior step)
127174
step-input-from-step:
128175
type: object
@@ -172,7 +219,7 @@ definitions:
172219
type: object
173220
additionalProperties: false
174221
patternProperties:
175-
'^[a-zA-Z_]{1}[a-zA-Z0-9_-]{0,79}$':
222+
'^[a-zA-Z]{1}[a-zA-Z0-9_]{0,79}$':
176223
oneOf:
177224
- type: string
178225
- type: integer

0 commit comments

Comments
 (0)