Skip to content

Commit 5ff511e

Browse files
author
Alan Christie
committed
feat: Step specification now an object (not a string)
1 parent 58d100c commit 5ff511e

11 files changed

+103
-122
lines changed

tests/workflow-definitions/duplicate-step-names.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ kind-version: "2024.1"
44
name: duplicate-step-names
55
steps:
66
- name: step-1
7-
specification: >-
8-
{}
7+
specification:
8+
collection: a
9+
job: b
10+
version: '1.0.0'
911
- name: step-1
10-
specification: >-
11-
{}
12+
specification:
13+
collection: a
14+
job: b
15+
version: '2.0.0'

tests/workflow-definitions/duplicate-workflow-variable-names.yaml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ variables:
1717
steps:
1818
- name: step1
1919
description: Add column 1
20-
specification: >-
21-
{
22-
"collection": "workflow-engine-unit-test-jobs",
23-
"job": "rdkit-molprops",
24-
"version": "1.0.0",
25-
"variables": {
26-
"name": "col1",
27-
"value": 123
28-
}
29-
}
20+
specification:
21+
collection: workflow-engine-unit-test-jobs
22+
job: rdkit-molprops
23+
version: "1.0.0"
24+
variables:
25+
name: "col1"
26+
value: 123
3027
inputs:
3128
- input: inputFile
3229
from:
@@ -37,16 +34,13 @@ steps:
3734

3835
- name: step2
3936
description: Add column 2
40-
specification: >-
41-
{
42-
"collection": "workflow-engine-unit-test-jobs",
43-
"job": "cluster-butina",
44-
"version":"1.0.0",
45-
"variables": {
46-
"name":"col2",
47-
"value":"999"
48-
}
49-
}
37+
specification:
38+
collection: workflow-engine-unit-test-jobs
39+
job: cluster-butina
40+
version: "1.0.0"
41+
variables:
42+
name: "col2"
43+
value: "999"
5044
inputs:
5145
- input: inputFile
5246
from:

tests/workflow-definitions/example-nop-fail.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ description: >-
66
A workflow with one step that fails
77
steps:
88
- name: step-1
9-
specification: >-
10-
{
11-
"collection": "workflow-engine-unit-test-jobs",
12-
"job": "nop-fail",
13-
"version": "1.0.0"
14-
}
9+
specification:
10+
collection: workflow-engine-unit-test-jobs
11+
job: nop-fail
12+
version: "1.0.0"

tests/workflow-definitions/example-smiles-to-file.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ description: >-
77
The step takes an input string and the Job creates a file from it.
88
steps:
99
- name: step-1
10-
specification: >-
11-
{
12-
"collection": "workflow-engine-unit-test-jobs",
13-
"job": "smiles-to-file",
14-
"version": "1.0.0"
15-
}
10+
specification:
11+
collection: workflow-engine-unit-test-jobs
12+
job: smiles-to-file
13+
version: "1.0.0"

tests/workflow-definitions/example-two-step-nop.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ description: >-
77
The steps do nothing, take no arguments, and simply return success.
88
steps:
99
- name: step-1
10-
specification: >-
11-
{
12-
"collection": "workflow-engine-unit-test-jobs",
13-
"job": "nop",
14-
"version": "1.0.0"
15-
}
10+
specification:
11+
collection: workflow-engine-unit-test-jobs
12+
job: nop
13+
version: "1.0.0"
1614
- name: step-2
17-
specification: >-
18-
{
19-
"collection": "workflow-engine-unit-test-jobs",
20-
"job": "nop",
21-
"version": "1.0.0"
22-
}
15+
specification:
16+
collection: workflow-engine-unit-test-jobs
17+
job: nop
18+
version: "1.0.0"

tests/workflow-definitions/minimal.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ kind-version: "2024.1"
44
name: workflow-minimal
55
steps:
66
- name: step-1
7-
specification: >-
8-
{}
7+
specification:
8+
collection: a
9+
job: b
10+
version: "1.0.0"

tests/workflow-definitions/shortcut-example-1.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@ description: The shortcut example 1 workflow
66
steps:
77
- name: example-1-step-1
88
description: The first step
9-
specification: >-
10-
{
11-
"collection": "workflow-engine-unit-test-jobs",
12-
"job": "shortcut-example-1-process-a",
13-
"version": "1.0.0"
14-
}
9+
specification:
10+
collection: workflow-engine-unit-test-jobs
11+
job: shortcut-example-1-process-a
12+
version: "1.0.0"
1513
outputs:
1614
- output: 'outputFile'
1715
as: 'a.sdf'
1816
- name: example-1-step-2
1917
description: The first step
20-
specification: >-
21-
{
22-
"collection": "workflow-engine-unit-test-jobs",
23-
"job": "shortcut-example-1-process-b",
24-
"version": "1.0.0"
25-
}
18+
specification:
19+
collection: workflow-engine-unit-test-jobs
20+
job: shortcut-example-1-process-b
21+
version: "1.0.0"
2622
inputs:
2723
- input: 'inputFile'
2824
from:

tests/workflow-definitions/simple-python-molprops.yaml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ variables:
1717
steps:
1818
- name: step1
1919
description: Add column 1
20-
specification: >-
21-
{
22-
"collection": "workflow-engine-unit-test-jobs",
23-
"job": "rdkit-molprops",
24-
"version": "1.0.0",
25-
"variables": {
26-
"name": "col1",
27-
"value": 123
28-
}
29-
}
20+
specification:
21+
collection: workflow-engine-unit-test-jobs
22+
job: rdkit-molprops
23+
version: "1.0.0"
24+
variables:
25+
name: "col1"
26+
value: 123
3027
inputs:
3128
- input: inputFile
3229
from:
@@ -37,16 +34,13 @@ steps:
3734

3835
- name: step2
3936
description: Add column 2
40-
specification: >-
41-
{
42-
"collection": "workflow-engine-unit-test-jobs",
43-
"job": "cluster-butina",
44-
"version":"1.0.0",
45-
"variables": {
46-
"name":"col2",
47-
"value":"999"
48-
}
49-
}
37+
specification:
38+
collection: workflow-engine-unit-test-jobs
39+
job: cluster-butina
40+
version: "1.0.0"
41+
variables:
42+
name: "col2"
43+
value: "999"
5044
inputs:
5145
- input: inputFile
5246
from:

workflow/workflow-schema.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,42 @@ definitions:
161161
- output
162162
- as
163163

164+
165+
# A step specification variable
166+
# (there must be at least one if a variables block is defined).
167+
# Typical variable syntax - must start with a letter
168+
# and only contain letters, numbers, hyphen or underbar.
169+
# The value of the object is quite relaxed...
170+
# it simply needs to be a string, number (integer or float), or boolean.
171+
step-specification-variable:
172+
type: object
173+
additionalProperties: false
174+
patternProperties:
175+
'^[a-zA-Z]{1}[a-zA-Z0-9-_]{0,79}$':
176+
oneOf:
177+
- type: string
178+
- type: integer
179+
- type: boolean
180+
minProperties: 1
181+
182+
# Step specification
183+
step-specification:
184+
type: object
185+
additionalProperties: false
186+
properties:
187+
collection:
188+
type: string
189+
job:
190+
type: string
191+
version:
192+
type: string
193+
variables:
194+
$ref: "#/definitions/step-specification-variable"
195+
required:
196+
- collection
197+
- job
198+
- version
199+
164200
# Steps (in a workflow)
165201
step:
166202
type: object
@@ -172,8 +208,7 @@ definitions:
172208
type: string
173209
description: A description of the step
174210
specification:
175-
type: string
176-
description: The Data Manager Job Specification, a JSON string
211+
$ref: '#/definitions/step-specification'
177212
inputs:
178213
type: array
179214
items:

workflow/workflow_engine.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
is executed, and it uses thew InstanceLauncher to launch the Job (a Pod) for each step.
2323
"""
2424

25-
import json
2625
import logging
2726
import sys
2827
from typing import Any, Dict, Optional
@@ -295,7 +294,7 @@ def _validate_step_command(
295294
# the keys "collection", "job", and "version". Here we assume that
296295
# the workflow definition has passed the RUN-level validation
297296
# which means we can get these values.
298-
step_spec: dict[str, Any] = json.loads(step["specification"])
297+
step_spec: dict[str, Any] = step["specification"]
299298
job_collection: str = step_spec["collection"]
300299
job_job: str = step_spec["job"]
301300
job_version: str = step_spec["version"]
@@ -466,7 +465,7 @@ def _launch(
466465
debug=rwf.get("debug"),
467466
launching_user_name=rwf["running_user"],
468467
launching_user_api_token=rwf["running_user_api_token"],
469-
specification=json.loads(step["specification"]),
468+
specification=step["specification"],
470469
specification_variables=variables,
471470
running_workflow_id=rwf_id,
472471
running_workflow_step_id=rwfs_id,

0 commit comments

Comments
 (0)