[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow test schema #17128

Draft
wants to merge 14 commits into
base: dev
Choose a base branch
from
Prev Previous commit
Next Next commit
Model Job
  • Loading branch information
mvdbeek committed Jan 11, 2024
commit d36643c4bde351915f5f62a299fc8d24b25d238e
2 changes: 2 additions & 0 deletions lib/galaxy/tool_util/schemas/.xsdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<Config xmlns="http://pypi.org/project/xsdata" version="23.6">
<Extensions>
<Extension type="class" class=".*" import=".config.BaseSetting" prepend="false" applyIfDerived="true"/>
<Extension type="class" class="TestOutput$" import=".config.ClassFileField" prepend="false" applyIfDerived="true"/>
<Extension type="class" class="TestOutputCollection" import=".config.ClassCollectionField" prepend="false" applyIfDerived="true"/>
</Extensions>
</Config>
20 changes: 20 additions & 0 deletions lib/galaxy/tool_util/schemas/generated/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from dataclasses import (
dataclass,
field,
)
from typing import (
Literal,
Optional,
)

from pydantic import ConfigDict

alias_lookup = {
Expand All @@ -9,3 +18,14 @@ class BaseSetting:
__pydantic_config__ = ConfigDict(
extra="forbid", alias_generator=lambda field_name: alias_lookup.get(field_name, field_name)
)


@dataclass(kw_only=True)
class ClassFileField:
class_: Optional[Literal["File"]] = field(default="File", metadata={"alias": "class"})
path: Optional[str] = None


@dataclass(kw_only=True)
class ClassCollectionField:
class_: Optional[Literal["Collection"]] = field(default="Collection", metadata={"alias": "class"})
18 changes: 7 additions & 11 deletions lib/galaxy/tool_util/schemas/generated/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
Union,
)

from .config import BaseSetting
from .config import (
BaseSetting,
ClassCollectionField,
ClassFileField,
)


class ActionType(Enum):
Expand Down Expand Up @@ -4966,7 +4970,7 @@ class ConditionalWhen(BaseSetting):


@dataclass(kw_only=True)
class TestOutput(BaseSetting):
class TestOutput(BaseSetting, ClassFileField):
"""This tag set defines the variable that names the output dataset for the
functional test framework. The functional test framework will execute the tool
using the parameters defined in the ``&lt;param&gt;`` tag sets and generate a
Expand Down Expand Up @@ -5425,7 +5429,7 @@ class TestExtraFile(TestOutput, BaseSetting):


@dataclass(kw_only=True)
class TestOutputCollection(BaseSetting):
class TestOutputCollection(BaseSetting, ClassCollectionField):
"""Define tests for extra datasets and metadata corresponding to an output
collection.

Expand Down Expand Up @@ -5531,14 +5535,6 @@ class TestOutputCollection(BaseSetting):
"""

element: Union[List[TestOutput], TestOutput] = field(default_factory=list, metadata={"type": "Element"})
type_value: Optional[str] = field(
default=None,
metadata={
"name": "type",
"type": "Attribute",
"description": "Expected collection type (``list`` or ``paired``), nested collections are specified as colon separated list (the most common types are ``list``, ``paired``, ``list:paired``, or ``list:list``).",
},
)
count: Optional[int] = field(
default=None, metadata={"type": "Attribute", "description": "Number of elements in output collection."}
)
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/tool_util/schemas/postprocess_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
]
ATTRIBUTES_TO_DELETE = [
"TestOutputCollection.name",
"TestOutputCollection.type_value",
"TestOutput.element",
]

Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/tool_util/schemas/test_file_from_xsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
TestOutput,
TestOutputCollection as TestOutputCollection_,
)
from job import Job
from pydantic import (
BaseModel,
ConfigDict,
Expand All @@ -30,16 +31,17 @@ class TestOutputElement(TestOutput):
@dataclass
class TestOutputCollection(TestOutputCollection_):
element_tests: dict[str, TestOutputElement | TestOutput]
collection_type: str | None = None


AnyOutput = Union[TestOutputElement, TestOutput, TestOutputCollection] # noqa: F405
AnyOutput = Union[TestOutputElement, TestOutput, TestOutputCollection, str, int, float, bool] # noqa: F405


class Test(BaseModel):
model_config = extra_forbidden

doc: str
job: str
job: Job
outputs: dict[str, AnyOutput]


Expand Down
Loading