Skip to content

Commit 2981488

Browse files
committed
Clarify input type aliases; move input_parameter_class out of generated file
Schema docs distinguish normalized gxformat2 spellings (data, collection, string, int, float, boolean) from compatibility aliases (File, data_input, data_collection, data_collection_input, text, integer). Updates GalaxyType, WorkflowDataParameter, WorkflowIntegerParameter, WorkflowTextParameter, and the optional/default field docs. Closes #200. input_parameter_class and _INPUT_TYPE_TO_CLASS were hand-edited into the generated gxformat2/schema/gxformat2.py in 1a2d9ed; any rerun of build_schema.sh wiped them. Moved to gxformat2/schema/_input_parameter.py (hand-written, regen-safe). Consumers in normalized/_format2.py and normalized/_conversion.py updated. Regenerated gxformat2/schema/v19_09.py, gxformat2.py, gxformat2_strict.py to pick up the doc changes.
1 parent 2b5ef33 commit 2981488

7 files changed

Lines changed: 181 additions & 101 deletions

File tree

gxformat2/normalized/_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
FrameComment,
4545
FreehandComment,
4646
GalaxyWorkflow,
47-
input_parameter_class,
4847
MarkdownComment,
4948
Report,
5049
)
50+
from ..schema._input_parameter import input_parameter_class
5151
from ..schema.gxformat2 import StepPosition as Format2StepPosition
5252
from ..schema.gxformat2 import (
5353
TextComment,

gxformat2/normalized/_format2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
FrameComment,
2626
FreehandComment,
2727
GalaxyWorkflow,
28-
input_parameter_class,
2928
MarkdownComment,
3029
Report,
3130
StepPosition,
@@ -38,6 +37,7 @@
3837
WorkflowStepOutput,
3938
WorkflowStepType,
4039
)
40+
from gxformat2.schema._input_parameter import input_parameter_class
4141
from gxformat2.schema.gxformat2_strict import GalaxyWorkflow as StrictGalaxyWorkflow
4242
from gxformat2.yaml import ordered_load_path
4343

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""Hand-written helper for resolving Format2 input ``type`` strings to the
2+
corresponding pydantic model class.
3+
4+
The discriminator map mirrors ``pydantic:discriminator_map`` on
5+
``Process.inputs`` in ``schema/v19_09/Process.yml``. Keep the two in sync.
6+
7+
Lives outside the generated modules in this package so ``build_schema.sh``
8+
regeneration does not clobber it.
9+
"""
10+
11+
from .gxformat2 import (
12+
BaseInputParameter,
13+
WorkflowBooleanParameter,
14+
WorkflowCollectionParameter,
15+
WorkflowDataParameter,
16+
WorkflowFloatParameter,
17+
WorkflowIntegerParameter,
18+
WorkflowTextParameter,
19+
)
20+
21+
_INPUT_TYPE_TO_CLASS: dict[str, type[BaseInputParameter]] = {
22+
"data": WorkflowDataParameter,
23+
"File": WorkflowDataParameter,
24+
"data_input": WorkflowDataParameter,
25+
"collection": WorkflowCollectionParameter,
26+
"data_collection": WorkflowCollectionParameter,
27+
"data_collection_input": WorkflowCollectionParameter,
28+
"integer": WorkflowIntegerParameter,
29+
"int": WorkflowIntegerParameter,
30+
"text": WorkflowTextParameter,
31+
"string": WorkflowTextParameter,
32+
"float": WorkflowFloatParameter,
33+
"boolean": WorkflowBooleanParameter,
34+
"color": WorkflowTextParameter,
35+
}
36+
37+
38+
def input_parameter_class(type_value: str | None) -> type[BaseInputParameter]:
39+
"""Return the specific input parameter class for a Format2 type string.
40+
41+
Falls back to WorkflowDataParameter for unknown or None types.
42+
"""
43+
if type_value is None:
44+
return WorkflowDataParameter
45+
return _INPUT_TYPE_TO_CLASS.get(type_value, WorkflowDataParameter)

gxformat2/schema/gxformat2.py

Lines changed: 66 additions & 67 deletions
Large diffs are not rendered by default.

gxformat2/schema/gxformat2_strict.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ class PrimitiveType(str, Enum):
3838

3939

4040
class GalaxyType(str, Enum):
41-
"""Extends primitive types with the native Galaxy concepts such datasets and collections.
42-
integer: an alias for int type - matches syntax used by Galaxy tools
43-
text: an alias for string type - matches syntax used by Galaxy tools
44-
File: an alias for data - there are subtle differences between a plain file, the CWL concept of 'File', and the Galaxy concept of a dataset - this may have subtly difference semantics in the future
45-
data: a Galaxy dataset
46-
collection: a Galaxy dataset collection"""
41+
"""Extends primitive types with the native Galaxy concepts such as datasets and collections.
42+
Normalized gxformat2 workflow input declaration spellings are ``data``, ``collection``, ``string``, ``int``, ``float``, and ``boolean``. Other spellings are accepted as compatibility aliases on import but normalized gxformat2 output emits the normalized spellings.
43+
data: one Galaxy dataset input. Native Galaxy ``data_input`` converts to this spelling.
44+
File: accepted alias for ``data``, but normalized gxformat2 output emits ``data``. Note: workflow **test job** YAML uses ``type: File`` to mean 'stage this file as test input data', which is a separate concept from workflow input declaration.
45+
collection: one Galaxy dataset collection input. Native Galaxy ``data_collection_input`` converts to this spelling.
46+
string: normalized gxformat2 spelling for native Galaxy text workflow parameters.
47+
text: accepted alias for ``string`` because native Galaxy parameter state and Galaxy tool XML terminology use ``text``.
48+
int: normalized gxformat2 spelling for native Galaxy integer workflow parameters.
49+
integer: accepted alias for ``int`` because native Galaxy parameter state and Galaxy tool XML terminology use ``integer``."""
4750

4851
null = "null"
4952
boolean = "boolean"
@@ -202,7 +205,7 @@ class BaseInputParameter(InputParameter, HasStepPosition):
202205
id: None | str = Field(default=None, description="The unique identifier for this object.")
203206
label: None | str = Field(default=None, description="A short, human-readable label of this object.")
204207
doc: None | str | list[str] = Field(default=None, description="A documentation string for this object, or an array of strings which should be concatenated.")
205-
optional: bool | None = Field(default=None, description="If set to true, `WorkflowInputParameter` is not required to submit the workflow.")
208+
optional: bool | None = Field(default=None, description="Controls whether Galaxy allows invocation of the workflow without a user-supplied value for this input. If ``true``, the input may be omitted at invocation time. ``optional`` and ``default`` are in...")
206209

207210
class BaseDataParameter(BaseInputParameter):
208211
model_config = ConfigDict(populate_by_name=True, extra="forbid")
@@ -215,7 +218,10 @@ class BaseDataParameter(BaseInputParameter):
215218
format: None | list[str] = Field(default=None, description="Specify datatype extensions for valid input datasets.")
216219

217220
class WorkflowDataParameter(BaseDataParameter):
218-
"""A data input parameter for a Galaxy workflow - represents a dataset."""
221+
"""A data input parameter for a Galaxy workflow. Represents one Galaxy dataset.
222+
Normalized gxformat2 output uses ``type: data``. ``type: File`` is accepted as
223+
an alias, but should not be confused with workflow test job syntax where
224+
``type: File`` means stage a file as test input data."""
219225

220226
model_config = ConfigDict(populate_by_name=True, extra="forbid")
221227

@@ -224,7 +230,7 @@ class WorkflowDataParameter(BaseDataParameter):
224230
doc: None | str | list[str] = Field(default=None, description="A documentation string for this object, or an array of strings which should be concatenated.")
225231
default: None | Any = Field(default=None, description="The default value to use for this parameter if the parameter is missing from the input object, or if the value of the parameter in the input object is `null`. Default values are applied before eva...")
226232
position: None | StepPosition = Field(default=None)
227-
optional: bool | None = Field(default=None, description="If set to true, `WorkflowInputParameter` is not required to submit the workflow.")
233+
optional: bool | None = Field(default=None, description="Controls whether Galaxy allows invocation of the workflow without a user-supplied value for this input. If ``true``, the input may be omitted at invocation time. ``optional`` and ``default`` are in...")
228234
type_: Literal["data", "File"] | None = Field(default=None, alias="type", description="Specify valid types of data that may be assigned to this parameter.")
229235

230236
class WorkflowCollectionParameter(BaseDataParameter):
@@ -237,7 +243,7 @@ class WorkflowCollectionParameter(BaseDataParameter):
237243
doc: None | str | list[str] = Field(default=None, description="A documentation string for this object, or an array of strings which should be concatenated.")
238244
default: None | Any = Field(default=None, description="The default value to use for this parameter if the parameter is missing from the input object, or if the value of the parameter in the input object is `null`. Default values are applied before eva...")
239245
position: None | StepPosition = Field(default=None)
240-
optional: bool | None = Field(default=None, description="If set to true, `WorkflowInputParameter` is not required to submit the workflow.")
246+
optional: bool | None = Field(default=None, description="Controls whether Galaxy allows invocation of the workflow without a user-supplied value for this input. If ``true``, the input may be omitted at invocation time. ``optional`` and ``default`` are in...")
241247
type_: Literal["collection"] = Field(default="collection", alias="type", description="Must be ``collection``.")
242248
collection_type: None | str = Field(default=None, description="Collection type (defaults to `list` if `type` is `collection`). Nested collection types are separated with colons, e.g. `list:list:paired`.")
243249

@@ -248,7 +254,9 @@ class MinMax(BaseModel):
248254
max: int | float | None = Field(default=None, description="Maximum allowed value (inclusive).")
249255

250256
class WorkflowIntegerParameter(BaseInputParameter, MinMax):
251-
"""An integer input parameter for a Galaxy workflow."""
257+
"""A scalar integer workflow parameter. Normalized gxformat2 output uses
258+
``type: int``. ``type: integer`` is accepted for compatibility with native
259+
Galaxy parameter state and Galaxy tool XML terminology."""
252260

253261
model_config = ConfigDict(populate_by_name=True, extra="forbid")
254262

@@ -272,7 +280,9 @@ class WorkflowFloatParameter(BaseInputParameter, MinMax):
272280
type_: Literal["float"] = Field(default="float", alias="type", description="Must be ``float``.")
273281

274282
class WorkflowTextParameter(BaseInputParameter):
275-
"""A text input parameter for a Galaxy workflow."""
283+
"""A scalar text workflow parameter. Normalized gxformat2 output uses
284+
``type: string``. ``type: text`` is accepted for compatibility with native
285+
Galaxy parameter state and Galaxy tool XML terminology."""
276286

277287
model_config = ConfigDict(populate_by_name=True, extra="forbid")
278288

@@ -307,7 +317,7 @@ class WorkflowInputParameter(BaseDataParameter, MinMax):
307317
doc: None | str | list[str] = Field(default=None, description="A documentation string for this object, or an array of strings which should be concatenated.")
308318
default: None | Any = Field(default=None, description="The default value to use for this parameter if the parameter is missing from the input object, or if the value of the parameter in the input object is `null`. Default values are applied before eva...")
309319
position: None | StepPosition = Field(default=None)
310-
optional: bool | None = Field(default=None, description="If set to true, `WorkflowInputParameter` is not required to submit the workflow.")
320+
optional: bool | None = Field(default=None, description="Controls whether Galaxy allows invocation of the workflow without a user-supplied value for this input. If ``true``, the input may be omitted at invocation time. ``optional`` and ``default`` are in...")
311321
type_: GalaxyType | None | list[GalaxyType] = Field(default=None, alias="type", description="Specify valid types of data that may be assigned to this parameter.")
312322
collection_type: None | str = Field(default=None, description="Collection type (defaults to `list` if `type` is `collection`). Nested collection types are separated with colons, e.g. `list:list:paired`.")
313323

gxformat2/schema/v19_09.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,7 +3569,10 @@ def save(
35693569

35703570
class WorkflowDataParameter(BaseDataParameter):
35713571
"""
3572-
A data input parameter for a Galaxy workflow - represents a dataset.
3572+
A data input parameter for a Galaxy workflow. Represents one Galaxy dataset.
3573+
Normalized gxformat2 output uses ``type: data``. ``type: File`` is accepted as
3574+
an alias, but should not be confused with workflow test job syntax where
3575+
``type: File`` means stage a file as test input data.
35733576

35743577
"""
35753578

@@ -4957,7 +4960,9 @@ def save(
49574960

49584961
class WorkflowIntegerParameter(BaseInputParameter, MinMax):
49594962
"""
4960-
An integer input parameter for a Galaxy workflow.
4963+
A scalar integer workflow parameter. Normalized gxformat2 output uses
4964+
``type: int``. ``type: integer`` is accepted for compatibility with native
4965+
Galaxy parameter state and Galaxy tool XML terminology.
49614966

49624967
"""
49634968

@@ -6191,7 +6196,9 @@ def save(
61916196

61926197
class WorkflowTextParameter(BaseInputParameter):
61936198
"""
6194-
A text input parameter for a Galaxy workflow.
6199+
A scalar text workflow parameter. Normalized gxformat2 output uses
6200+
``type: string``. ``type: text`` is accepted for compatibility with native
6201+
Galaxy parameter state and Galaxy tool XML terminology.
61956202

61966203
"""
61976204

@@ -15376,12 +15383,15 @@ def save(
1537615383
"GalaxyType",
1537715384
)
1537815385
"""
15379-
Extends primitive types with the native Galaxy concepts such datasets and collections.
15380-
integer: an alias for int type - matches syntax used by Galaxy tools
15381-
text: an alias for string type - matches syntax used by Galaxy tools
15382-
File: an alias for data - there are subtle differences between a plain file, the CWL concept of 'File', and the Galaxy concept of a dataset - this may have subtly difference semantics in the future
15383-
data: a Galaxy dataset
15384-
collection: a Galaxy dataset collection
15386+
Extends primitive types with the native Galaxy concepts such as datasets and collections.
15387+
Normalized gxformat2 workflow input declaration spellings are ``data``, ``collection``, ``string``, ``int``, ``float``, and ``boolean``. Other spellings are accepted as compatibility aliases on import but normalized gxformat2 output emits the normalized spellings.
15388+
data: one Galaxy dataset input. Native Galaxy ``data_input`` converts to this spelling.
15389+
File: accepted alias for ``data``, but normalized gxformat2 output emits ``data``. Note: workflow **test job** YAML uses ``type: File`` to mean 'stage this file as test input data', which is a separate concept from workflow input declaration.
15390+
collection: one Galaxy dataset collection input. Native Galaxy ``data_collection_input`` converts to this spelling.
15391+
string: normalized gxformat2 spelling for native Galaxy text workflow parameters.
15392+
text: accepted alias for ``string`` because native Galaxy parameter state and Galaxy tool XML terminology use ``text``.
15393+
int: normalized gxformat2 spelling for native Galaxy integer workflow parameters.
15394+
integer: accepted alias for ``int`` because native Galaxy parameter state and Galaxy tool XML terminology use ``integer``.
1538515395
"""
1538615396
WorkflowStepTypeLoader = _EnumLoader(
1538715397
(

schema/v19_09/workflow.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ $graph:
3737
- data
3838
- collection
3939
doc:
40-
- "Extends primitive types with the native Galaxy concepts such datasets and collections."
41-
- "integer: an alias for int type - matches syntax used by Galaxy tools"
42-
- "text: an alias for string type - matches syntax used by Galaxy tools"
43-
- "File: an alias for data - there are subtle differences between a plain file, the CWL concept of 'File', and the Galaxy concept of a dataset - this may have subtly difference semantics in the future"
44-
- "data: a Galaxy dataset"
45-
- "collection: a Galaxy dataset collection"
40+
- "Extends primitive types with the native Galaxy concepts such as datasets and collections."
41+
- "Normalized gxformat2 workflow input declaration spellings are ``data``, ``collection``, ``string``, ``int``, ``float``, and ``boolean``. Other spellings are accepted as compatibility aliases on import but normalized gxformat2 output emits the normalized spellings."
42+
- "data: one Galaxy dataset input. Native Galaxy ``data_input`` converts to this spelling."
43+
- "File: accepted alias for ``data``, but normalized gxformat2 output emits ``data``. Note: workflow **test job** YAML uses ``type: File`` to mean 'stage this file as test input data', which is a separate concept from workflow input declaration."
44+
- "collection: one Galaxy dataset collection input. Native Galaxy ``data_collection_input`` converts to this spelling."
45+
- "string: normalized gxformat2 spelling for native Galaxy text workflow parameters."
46+
- "text: accepted alias for ``string`` because native Galaxy parameter state and Galaxy tool XML terminology use ``text``."
47+
- "int: normalized gxformat2 spelling for native Galaxy integer workflow parameters."
48+
- "integer: accepted alias for ``int`` because native Galaxy parameter state and Galaxy tool XML terminology use ``integer``."
4649

4750

4851
- name: WorkflowStepType
@@ -73,7 +76,13 @@ $graph:
7376
- "null"
7477
default: false
7578
doc: |
76-
If set to true, `WorkflowInputParameter` is not required to submit the workflow.
79+
Controls whether Galaxy allows invocation of the workflow without a
80+
user-supplied value for this input. If ``true``, the input may be omitted
81+
at invocation time. ``optional`` and ``default`` are independent: a
82+
required input (``optional: false``) may still declare a ``default``,
83+
and an optional input may have no ``default``. ``default`` supplies a
84+
value when the invocation input is missing or ``null``; ``optional``
85+
controls whether the missing case is even permitted.
7786
7887
- name: BaseDataParameter
7988
type: record
@@ -93,7 +102,10 @@ $graph:
93102
- BaseDataParameter
94103
docParent: "#GalaxyWorkflow"
95104
doc: |
96-
A data input parameter for a Galaxy workflow - represents a dataset.
105+
A data input parameter for a Galaxy workflow. Represents one Galaxy dataset.
106+
Normalized gxformat2 output uses ``type: data``. ``type: File`` is accepted as
107+
an alias, but should not be confused with workflow test job syntax where
108+
``type: File`` means stage a file as test input data.
97109
fields:
98110
- name: type
99111
type:
@@ -169,7 +181,9 @@ $graph:
169181
- MinMax
170182
docParent: "#GalaxyWorkflow"
171183
doc: |
172-
An integer input parameter for a Galaxy workflow.
184+
A scalar integer workflow parameter. Normalized gxformat2 output uses
185+
``type: int``. ``type: integer`` is accepted for compatibility with native
186+
Galaxy parameter state and Galaxy tool XML terminology.
173187
fields:
174188
- name: type
175189
type: string
@@ -208,7 +222,9 @@ $graph:
208222
- BaseInputParameter
209223
docParent: "#GalaxyWorkflow"
210224
doc: |
211-
A text input parameter for a Galaxy workflow.
225+
A scalar text workflow parameter. Normalized gxformat2 output uses
226+
``type: string``. ``type: text`` is accepted for compatibility with native
227+
Galaxy parameter state and Galaxy tool XML terminology.
212228
fields:
213229
- name: type
214230
type: string

0 commit comments

Comments
 (0)