Skip to content

Commit 882f22a

Browse files
authored
Merge pull request #22566 from jmchilton/wf_test_job_schema
Tighten the workflow test schema
2 parents a17f9d8 + a1baeef commit 882f22a

66 files changed

Lines changed: 2909 additions & 1405 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/src/api/schema/schema.ts

Lines changed: 930 additions & 688 deletions
Large diffs are not rendered by default.

lib/galaxy/tool_util/cwl/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ def replacement_directory(value: Dict[str, Any]) -> Dict[str, Any]:
305305
file_path = value.get("location", None) or value.get("path", None)
306306
if file_path is None:
307307
return value
308-
if not os.path.isabs(file_path):
309-
file_path = os.path.join(test_data_directory, file_path)
308+
file_path = abs_path_or_uri(file_path, test_data_directory, resolve_data=resolve_data)
310309

311310
file_type = value.get("filetype", None) or value.get("format", None) or "directory"
312311

lib/galaxy/tool_util/verify/asserts/tabular.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def assert_has_n_columns(
5151
5252
For instance, ``<has_n_columns n="3"/>``. The assertion tests only the first line.
5353
Number of columns can optionally also be specified with ``delta``. Alternatively the
54-
range of expected occurences can be specified by ``min`` and/or ``max``.
54+
range of expected occurrences can be specified by ``min`` and/or ``max``.
5555
5656
Optionally a column separator (``sep``, default is ``\t``) `and comment character(s)
5757
can be specified (``comment``, default is empty string). The first non-comment

lib/galaxy/tool_util/verify/asserts/text.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def assert_has_text(
4646
lambda o, t: o.find(t) >= 0,
4747
lambda o, t: len(re.findall(re.escape(t), o)),
4848
"{expected} text '{text}' in output ('{output}')",
49-
"{expected} {n}+-{delta} occurences of '{text}' in output ('{output}')",
50-
"{expected} that the number of occurences of '{text}' in output is in [{min}:{max}] ('{output}')",
49+
"{expected} {n}+-{delta} occurrences of '{text}' in output ('{output}')",
50+
"{expected} that the number of occurrences of '{text}' in output is in [{min}:{max}] ('{output}')",
5151
)
5252

5353

@@ -123,8 +123,8 @@ def assert_has_text_matching(
123123
) -> None:
124124
"""Asserts the specified output contains text matching the
125125
regular expression specified by the argument expression.
126-
If n is given the assertion checks for exacly n (nonoverlapping)
127-
occurences.
126+
If n is given the assertion checks for exactly n (nonoverlapping)
127+
occurrences.
128128
"""
129129
_assert_presence_number(
130130
output,
@@ -153,7 +153,7 @@ def assert_has_line_matching(
153153
) -> None:
154154
"""Asserts the specified output contains a line matching the
155155
regular expression specified by the argument expression. If n is given
156-
the assertion checks for exactly n occurences."""
156+
the assertion checks for exactly n occurrences."""
157157
_assert_presence_number(
158158
output,
159159
expression,

lib/galaxy/tool_util/verify/asserts/xml.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def assert_has_n_elements_with_path(
9696
```
9797
9898
Alternatively to ``n`` and ``delta`` also the ``min`` and ``max`` attributes
99-
can be used to specify the range of the expected number of occurences.
99+
can be used to specify the range of the expected number of occurrences.
100100
With ``negate`` the result of the assertion can be inverted.
101101
"""
102102
assert_xml_element(output, path, n=n, delta=delta, min=min, max=max, negate=negate)
@@ -222,7 +222,7 @@ def assert_xml_element(
222222
) -> None:
223223
"""Assert if the XML file contains element(s) or tag(s) with the specified
224224
[XPath-like ``path``](https://lxml.de/xpathxslt.html). If ``n`` and ``delta``
225-
or ``min`` and ``max`` are given also the number of occurences is checked.
225+
or ``min`` and ``max`` are given also the number of occurrences is checked.
226226
227227
```xml
228228
<assert_contents>
@@ -232,7 +232,7 @@ def assert_xml_element(
232232
</assert_contents>
233233
```
234234
235-
With ``negate="true"`` the outcome of the assertions wrt the precence and number
235+
With ``negate="true"`` the outcome of the assertions wrt the presence and number
236236
of ``path`` can be negated. If there are any sub assertions then check them against
237237
238238
- the content of the attribute ``attribute``
@@ -247,7 +247,7 @@ def assert_xml_element(
247247
```
248248
249249
Sub-assertions are not subject to the ``negate`` attribute of ``xml_element``.
250-
If ``all`` is ``true`` then the sub assertions are checked for all occurences.
250+
If ``all`` is ``true`` then the sub assertions are checked for all occurrences.
251251
252252
Note that all other XML assertions can be expressed by this assertion (Galaxy
253253
also implements the other assertions by calling this one).
@@ -269,7 +269,7 @@ def assert_xml_element(
269269
lambda x, p: len(x.findall(p)),
270270
"{expected} path '{text}' in xml",
271271
"{expected} {n}+-{delta} occurrences of path '{text}' in xml",
272-
"{expected} that the number of occurences of path '{text}' in xml is in [{min}:{max}]",
272+
"{expected} that the number of occurrences of path '{text}' in xml is in [{min}:{max}]",
273273
)
274274

275275
# check sub-assertions

lib/galaxy/tool_util/verify/codegen.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from galaxy.tool_util.verify.asserts._types import AssertionParameter as AssertionParameterAnnotation
2828
from galaxy.util.commands import shell
2929

30-
models_path = os.path.join(os.path.dirname(__file__), "assertion_models.py")
30+
models_path = os.path.join(os.path.dirname(__file__), "..", "..", "tool_util_models", "assertions.py")
3131
galaxy_xsd_path = os.path.join(os.path.dirname(__file__), "..", "xsd", "galaxy.xsd")
3232

3333
Children = Literal["allowed", "required", "forbidden"]
@@ -114,17 +114,19 @@ def check_non_negative_if_int(v: typing.Any):
114114
115115
class base_{{assertion.name}}_model(AssertionModel):
116116
'''base model for {{assertion.name}} describing attributes.'''
117+
model_config = ConfigDict(extra="forbid", title="base_{{assertion.name}}_model")
117118
{% for parameter in assertion.parameters %}
118119
{% if not parameter.is_deprecated %}
119120
{{ parameter.name }}: {{ parameter.type_str }} = Field(
120121
{{ parameter.field_default_str }},
122+
title="{{ parameter.title }}",
121123
description={{ assertion.name }}_{{ parameter.name }}_description,
122124
)
123125
{% endif %}
124126
{% endfor %}
125127
{% if assertion.children in ["required", "allowed"] %}
126-
children: typing.Optional["assertion_list"] = None
127-
asserts: typing.Optional["assertion_list"] = None
128+
children: typing.Optional["assertion_list"] = Field(None, title="Children")
129+
asserts: typing.Optional["assertion_list"] = Field(None, title="Asserts")
128130
129131
{% if assertion.children == "required" %}
130132
@model_validator(mode='before')
@@ -139,17 +141,19 @@ def validate_children(self, data: typing.Any):
139141
140142
class base_{{assertion.name}}_model_relaxed(AssertionModel):
141143
'''base model for {{assertion.name}} describing attributes.'''
144+
model_config = ConfigDict(extra="forbid", title="base_{{assertion.name}}_model_relaxed")
142145
{% for parameter in assertion.parameters %}
143146
{% if not parameter.is_deprecated %}
144147
{{ parameter.name }}: {{ parameter.lax_type_str }} = Field(
145148
{{ parameter.field_default_str }},
149+
title="{{ parameter.title }}",
146150
description={{ assertion.name }}_{{ parameter.name }}_description,
147151
)
148152
{% endif %}
149153
{% endfor %}
150154
{% if assertion.children in ["required", "allowed"] %}
151-
children: typing.Optional["assertion_list"] = None
152-
asserts: typing.Optional["assertion_list"] = None
155+
children: typing.Optional["assertion_list"] = Field(None, title="Children")
156+
asserts: typing.Optional["assertion_list"] = Field(None, title="Asserts")
153157
154158
{% if assertion.children == "required" %}
155159
@model_validator(mode='before')
@@ -164,15 +168,18 @@ def validate_children(self, data: typing.Any):
164168
165169
class {{assertion.name}}_model(base_{{assertion.name}}_model):
166170
r\"\"\"{{ assertion.docstring }}\"\"\"
167-
that: Literal["{{assertion.name}}"] = "{{assertion.name}}"
171+
model_config = ConfigDict(extra="forbid", title="{{ assertion.title }}")
172+
that: Literal["{{assertion.name}}"] = Field("{{assertion.name}}", title="That")
168173
169174
class {{assertion.name}}_model_nested(AssertionModel):
170175
r\"\"\"Nested version of this assertion model.\"\"\"
171-
{{assertion.name}}: base_{{assertion.name}}_model
176+
model_config = ConfigDict(extra="forbid", title="{{ assertion.title }} (Nested)")
177+
{{assertion.name}}: base_{{assertion.name}}_model = Field(..., title="{{ assertion.title }}")
172178
173179
class {{assertion.name}}_model_relaxed(base_{{assertion.name}}_model_relaxed):
174180
r\"\"\"{{ assertion.docstring }}\"\"\"
175-
that: Literal["{{assertion.name}}"] = "{{assertion.name}}"
181+
model_config = ConfigDict(extra="forbid", title="{{ assertion.title }} (Relaxed)")
182+
that: Literal["{{assertion.name}}"] = Field("{{assertion.name}}", title="That")
176183
{% endfor %}
177184
178185
any_assertion_model_flat = Annotated[typing.Union[
@@ -193,15 +200,19 @@ class {{assertion.name}}_model_relaxed(base_{{assertion.name}}_model_relaxed):
193200
{% endfor %}
194201
], Field(discriminator="that")]
195202
196-
assertion_list = RootModel[typing.List[typing.Union[any_assertion_model_flat, any_assertion_model_nested]]]
203+
class assertion_list(RootModel[typing.List[typing.Union[any_assertion_model_flat, any_assertion_model_nested]]]):
204+
model_config = ConfigDict(title="assertion_list")
205+
197206
198207
# used to model what the XML conversion should look like - not meant to be consumed outside of
199208
# of Galaxy internals / linting.
200-
relaxed_assertion_list = RootModel[typing.List[any_assertion_model_flat_relaxed]]
209+
class relaxed_assertion_list(RootModel[typing.List[any_assertion_model_flat_relaxed]]):
210+
model_config = ConfigDict(title="relaxed_assertion_list")
201211
202212
class assertion_dict(AssertionModel):
213+
model_config = ConfigDict(extra="forbid", title="assertion_dict")
203214
{% for assertion in assertions %}
204-
{{assertion.name}}: typing.Optional[base_{{assertion.name}}_model] = None
215+
{{assertion.name}}: typing.Optional[base_{{assertion.name}}_model] = Field(None, title="{{ assertion.title }}")
205216
{% endfor %}
206217
207218
@@ -338,6 +349,10 @@ def __init__(self, name: str, type: str, default_value):
338349
self.type = type
339350
self.default_value = default_value
340351

352+
@property
353+
def title(self) -> str:
354+
return " ".join(w.capitalize() for w in self.name.split("_"))
355+
341356
@property
342357
def description(self) -> str:
343358
type = self.type
@@ -490,6 +505,10 @@ def __init__(
490505
self.children = children
491506
self.module_and_function = module_and_function
492507

508+
@property
509+
def title(self) -> str:
510+
return "Assert " + " ".join(w.capitalize() for w in self.name.split("_"))
511+
493512

494513
def arg_parser() -> argparse.ArgumentParser:
495514
parser = argparse.ArgumentParser(description=DESCRIPTION)

lib/galaxy/tool_util/xsd/galaxy.xsd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,7 @@ $attribute_list::5]]></xs:documentation>
25322532
<xs:annotation>
25332533
<xs:documentation xml:lang="en"><![CDATA[Asserts the specified output contains a line matching the
25342534
regular expression specified by the argument expression. If n is given
2535-
the assertion checks for exactly n occurences.
2535+
the assertion checks for exactly n occurrences.
25362536
25372537
$attribute_list::5]]></xs:documentation>
25382538
</xs:annotation>
@@ -2653,8 +2653,8 @@ $attribute_list::5]]></xs:documentation>
26532653
<xs:annotation>
26542654
<xs:documentation xml:lang="en"><![CDATA[Asserts the specified output contains text matching the
26552655
regular expression specified by the argument expression.
2656-
If n is given the assertion checks for exacly n (nonoverlapping)
2657-
occurences.
2656+
If n is given the assertion checks for exactly n (nonoverlapping)
2657+
occurrences.
26582658
26592659
$attribute_list::5]]></xs:documentation>
26602660
</xs:annotation>
@@ -2715,7 +2715,7 @@ number (``n``) of columns.
27152715
27162716
For instance, ``<has_n_columns n="3"/>``. The assertion tests only the first line.
27172717
Number of columns can optionally also be specified with ``delta``. Alternatively the
2718-
range of expected occurences can be specified by ``min`` and/or ``max``.
2718+
range of expected occurrences can be specified by ``min`` and/or ``max``.
27192719
27202720
Optionally a column separator (``sep``, default is `` ``) `and comment character(s)
27212721
can be specified (``comment``, default is empty string). The first non-comment
@@ -2991,7 +2991,7 @@ For example:
29912991
```
29922992
29932993
Alternatively to ``n`` and ``delta`` also the ``min`` and ``max`` attributes
2994-
can be used to specify the range of the expected number of occurences.
2994+
can be used to specify the range of the expected number of occurrences.
29952995
With ``negate`` the result of the assertion can be inverted.
29962996
29972997
$attribute_list::5]]></xs:documentation>
@@ -3043,7 +3043,7 @@ $attribute_list::5]]></xs:documentation>
30433043
<xs:annotation>
30443044
<xs:documentation xml:lang="en"><![CDATA[Assert if the XML file contains element(s) or tag(s) with the specified
30453045
[XPath-like ``path``](https://lxml.de/xpathxslt.html). If ``n`` and ``delta``
3046-
or ``min`` and ``max`` are given also the number of occurences is checked.
3046+
or ``min`` and ``max`` are given also the number of occurrences is checked.
30473047
30483048
```xml
30493049
<assert_contents>
@@ -3053,7 +3053,7 @@ or ``min`` and ``max`` are given also the number of occurences is checked.
30533053
</assert_contents>
30543054
```
30553055
3056-
With ``negate="true"`` the outcome of the assertions wrt the precence and number
3056+
With ``negate="true"`` the outcome of the assertions wrt the presence and number
30573057
of ``path`` can be negated. If there are any sub assertions then check them against
30583058
30593059
- the content of the attribute ``attribute``
@@ -3068,7 +3068,7 @@ of ``path`` can be negated. If there are any sub assertions then check them agai
30683068
```
30693069
30703070
Sub-assertions are not subject to the ``negate`` attribute of ``xml_element``.
3071-
If ``all`` is ``true`` then the sub assertions are checked for all occurences.
3071+
If ``all`` is ``true`` then the sub assertions are checked for all occurrences.
30723072
30733073
Note that all other XML assertions can be expressed by this assertion (Galaxy
30743074
also implements the other assertions by calling this one).

0 commit comments

Comments
 (0)