Skip to content

Commit 95ac53b

Browse files
author
Alan Christie
committed
fix: Schema permits hyphon in variable name (and adds a variables test)
1 parent 5ff511e commit 95ac53b

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

tests/test_decoder.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@
4343
)
4444
assert _DUPLICATE_WORKFLOW_VARIABLE_NAMES_WORKFLOW
4545

46+
_STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW_FILE: str = os.path.join(
47+
os.path.dirname(__file__),
48+
"workflow-definitions",
49+
"step-specification-variable-names.yaml",
50+
)
51+
with open(
52+
_STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW_FILE, "r", encoding="utf8"
53+
) as workflow_file:
54+
_STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW: Dict[str, Any] = yaml.safe_load(
55+
workflow_file
56+
)
57+
assert _STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW
58+
4659

4760
def test_validate_schema_for_minimal():
4861
# Arrange
@@ -110,6 +123,16 @@ def test_validate_schema_for_python_simple_molprops():
110123
assert error is None
111124

112125

126+
def test_validate_schema_for_step_specification_variable_names():
127+
# Arrange
128+
129+
# Act
130+
error = decoder.validate_schema(_STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW)
131+
132+
# Assert
133+
assert error is None
134+
135+
113136
def test_get_workflow_variables_for_smiple_python_molprops():
114137
# Arrange
115138

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
kind: DataManagerWorkflow
3+
kind-version: "2024.1"
4+
name: step-variables
5+
description: Test a lot of variables whose format is supported
6+
steps:
7+
- name: step-1
8+
specification:
9+
collection: a
10+
job: b
11+
version: '1.0.0'
12+
variables:
13+
_a: 1
14+
A-1: 2.0
15+
a_14_: A string
16+
A-Long_boolean_variable_Name: true

workflow/workflow-schema.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ definitions:
164164

165165
# A step specification variable
166166
# (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...
167+
# Typical variable syntax based on Python's definition of a variable
168+
# but with the inclusion of 'hyphen' within the variable.
169+
# The value of the variable (the object itself) is quite relaxed...
170170
# it simply needs to be a string, number (integer or float), or boolean.
171171
step-specification-variable:
172172
type: object
173173
additionalProperties: false
174174
patternProperties:
175-
'^[a-zA-Z]{1}[a-zA-Z0-9-_]{0,79}$':
175+
'^[a-zA-Z_]{1}[a-zA-Z0-9_-]{0,79}$':
176176
oneOf:
177177
- type: string
178178
- type: integer

0 commit comments

Comments
 (0)