From 5d1a63d506def15ed17611facb9cf5014838395e Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 5 Dec 2023 20:02:55 +0100 Subject: [PATCH] Model Job --- lib/galaxy/tool_util/schemas/.xsdata.xml | 2 + .../tool_util/schemas/generated/config.py | 20 + .../tool_util/schemas/generated/galaxy.py | 18 +- .../tool_util/schemas/postprocess_schema.py | 1 + .../tool_util/schemas/test_file_from_xsd.py | 6 +- .../tool_util/schemas/test_file_schema.json | 785 +++++++++++++++++- lib/galaxy_test/api/test_tools_upload.py | 1 + 7 files changed, 806 insertions(+), 27 deletions(-) diff --git a/lib/galaxy/tool_util/schemas/.xsdata.xml b/lib/galaxy/tool_util/schemas/.xsdata.xml index d757e331310b..1019afbd1dba 100644 --- a/lib/galaxy/tool_util/schemas/.xsdata.xml +++ b/lib/galaxy/tool_util/schemas/.xsdata.xml @@ -2,5 +2,7 @@ + + diff --git a/lib/galaxy/tool_util/schemas/generated/config.py b/lib/galaxy/tool_util/schemas/generated/config.py index e04f30745b20..65247646cce1 100644 --- a/lib/galaxy/tool_util/schemas/generated/config.py +++ b/lib/galaxy/tool_util/schemas/generated/config.py @@ -1,3 +1,12 @@ +from dataclasses import ( + dataclass, + field, +) +from typing import ( + Literal, + Optional, +) + from pydantic import ConfigDict alias_lookup = { @@ -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"}) diff --git a/lib/galaxy/tool_util/schemas/generated/galaxy.py b/lib/galaxy/tool_util/schemas/generated/galaxy.py index e3a20ed18c0a..d5cff7f59465 100644 --- a/lib/galaxy/tool_util/schemas/generated/galaxy.py +++ b/lib/galaxy/tool_util/schemas/generated/galaxy.py @@ -10,7 +10,11 @@ Union, ) -from .config import BaseSetting +from .config import ( + BaseSetting, + ClassCollectionField, + ClassFileField, +) class ActionType(Enum): @@ -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 ``<param>`` tag sets and generate a @@ -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. @@ -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."} ) diff --git a/lib/galaxy/tool_util/schemas/postprocess_schema.py b/lib/galaxy/tool_util/schemas/postprocess_schema.py index 2019bddba996..3e5cd1450730 100644 --- a/lib/galaxy/tool_util/schemas/postprocess_schema.py +++ b/lib/galaxy/tool_util/schemas/postprocess_schema.py @@ -33,6 +33,7 @@ ] ATTRIBUTES_TO_DELETE = [ "TestOutputCollection.name", + "TestOutputCollection.type_value", "TestOutput.element", ] diff --git a/lib/galaxy/tool_util/schemas/test_file_from_xsd.py b/lib/galaxy/tool_util/schemas/test_file_from_xsd.py index ffba30ea07a9..188543ddbdd6 100644 --- a/lib/galaxy/tool_util/schemas/test_file_from_xsd.py +++ b/lib/galaxy/tool_util/schemas/test_file_from_xsd.py @@ -13,6 +13,7 @@ TestOutput, TestOutputCollection as TestOutputCollection_, ) +from job import Job from pydantic import ( BaseModel, ConfigDict, @@ -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] diff --git a/lib/galaxy/tool_util/schemas/test_file_schema.json b/lib/galaxy/tool_util/schemas/test_file_schema.json index 31eee6ffa2dc..3a35ceeeba57 100644 --- a/lib/galaxy/tool_util/schemas/test_file_schema.json +++ b/lib/galaxy/tool_util/schemas/test_file_schema.json @@ -1443,6 +1443,645 @@ "title": "AssertXmlelement", "type": "object" }, + "Collection": { + "properties": { + "class": { + "const": "Collection", + "title": "Class" + }, + "collection_type": { + "default": "list", + "title": "Collection Type", + "type": "string" + }, + "elements": { + "items": { + "anyOf": [ + { + "$ref": "#/$defs/CollectionElement" + }, + { + "$ref": "#/$defs/LocationFileElement" + }, + { + "$ref": "#/$defs/PathFileElement" + } + ] + }, + "title": "Elements", + "type": "array" + } + }, + "required": [ + "class", + "elements" + ], + "title": "Collection", + "type": "object" + }, + "CollectionElement": { + "properties": { + "class": { + "const": "Collection", + "title": "Class" + }, + "identifier": { + "title": "Identifier", + "type": "string" + }, + "elements": { + "items": { + "anyOf": [ + { + "$ref": "#/$defs/CollectionElement" + }, + { + "$ref": "#/$defs/LocationFileElement" + }, + { + "$ref": "#/$defs/PathFileElement" + } + ] + }, + "title": "Elements", + "type": "array" + }, + "type": { + "default": "list", + "title": "Type", + "type": "string" + } + }, + "required": [ + "class", + "identifier", + "elements" + ], + "title": "CollectionElement", + "type": "object" + }, + "Job": { + "additionalProperties": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "$ref": "#/$defs/Collection" + }, + { + "$ref": "#/$defs/LocationFile" + }, + { + "$ref": "#/$defs/PathFile" + }, + { + "type": "null" + } + ] + }, + "title": "Job", + "type": "object" + }, + "LocationFile": { + "additionalProperties": false, + "properties": { + "class": { + "const": "File", + "title": "Class" + }, + "filetype": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Filetype" + }, + "dbkey": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Dbkey" + }, + "decompress": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": false, + "title": "Decompress" + }, + "to_posix_line": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "To Posix Line" + }, + "space_to_tab": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Space To Tab" + }, + "deferred": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Deferred" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Name" + }, + "info": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Info" + }, + "tags": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Tags" + }, + "location": { + "title": "Location", + "type": "string" + } + }, + "required": [ + "class", + "location" + ], + "title": "LocationFile", + "type": "object" + }, + "LocationFileElement": { + "additionalProperties": false, + "properties": { + "class": { + "const": "File", + "title": "Class" + }, + "filetype": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Filetype" + }, + "dbkey": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Dbkey" + }, + "decompress": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": false, + "title": "Decompress" + }, + "to_posix_line": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "To Posix Line" + }, + "space_to_tab": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Space To Tab" + }, + "deferred": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Deferred" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Name" + }, + "info": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Info" + }, + "tags": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Tags" + }, + "identifier": { + "title": "Identifier", + "type": "string" + }, + "location": { + "title": "Location", + "type": "string" + } + }, + "required": [ + "class", + "identifier", + "location" + ], + "title": "LocationFileElement", + "type": "object" + }, + "PathFile": { + "additionalProperties": false, + "properties": { + "class": { + "const": "File", + "title": "Class" + }, + "filetype": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Filetype" + }, + "dbkey": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Dbkey" + }, + "decompress": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": false, + "title": "Decompress" + }, + "to_posix_line": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "To Posix Line" + }, + "space_to_tab": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Space To Tab" + }, + "deferred": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Deferred" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Name" + }, + "info": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Info" + }, + "tags": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Tags" + }, + "path": { + "title": "Path", + "type": "string" + } + }, + "required": [ + "class", + "path" + ], + "title": "PathFile", + "type": "object" + }, + "PathFileElement": { + "additionalProperties": false, + "properties": { + "class": { + "const": "File", + "title": "Class" + }, + "filetype": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Filetype" + }, + "dbkey": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Dbkey" + }, + "decompress": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": false, + "title": "Decompress" + }, + "to_posix_line": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "To Posix Line" + }, + "space_to_tab": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Space To Tab" + }, + "deferred": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Deferred" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Name" + }, + "info": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Info" + }, + "tags": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Tags" + }, + "identifier": { + "title": "Identifier", + "type": "string" + }, + "path": { + "title": "Path", + "type": "string" + } + }, + "required": [ + "class", + "identifier", + "path" + ], + "title": "PathFileElement", + "type": "object" + }, "PermissiveBooleanValue": { "enum": [ "0", @@ -1465,8 +2104,7 @@ "type": "string" }, "job": { - "title": "Job", - "type": "string" + "$ref": "#/$defs/Job" }, "outputs": { "additionalProperties": { @@ -1479,6 +2117,18 @@ }, { "$ref": "#/$defs/TestOutputCollection" + }, + { + "type": "string" + }, + { + "type": "integer" + }, + { + "type": "number" + }, + { + "type": "boolean" } ] }, @@ -1805,6 +2455,30 @@ "TestDiscoveredDataset": { "additionalProperties": false, "properties": { + "class": { + "anyOf": [ + { + "const": "File" + }, + { + "type": "null" + } + ], + "default": "File", + "title": "Class" + }, + "path": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Path" + }, "discovered_dataset": { "items": { "$ref": "#/$defs/TestDiscoveredDataset" @@ -2053,6 +2727,30 @@ "TestExtraFile": { "additionalProperties": false, "properties": { + "class": { + "anyOf": [ + { + "const": "File" + }, + { + "type": "null" + } + ], + "default": "File", + "title": "Class" + }, + "path": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Path" + }, "discovered_dataset": { "items": { "$ref": "#/$defs/TestDiscoveredDataset" @@ -2301,6 +2999,30 @@ "TestOutput": { "additionalProperties": false, "properties": { + "class": { + "anyOf": [ + { + "const": "File" + }, + { + "type": "null" + } + ], + "default": "File", + "title": "Class" + }, + "path": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Path" + }, "discovered_dataset": { "items": { "$ref": "#/$defs/TestDiscoveredDataset" @@ -2550,32 +3272,43 @@ "title": "Element Tests", "type": "object" }, - "element": { + "collection_type": { "anyOf": [ { - "items": { - "$ref": "#/$defs/TestOutput" - }, - "type": "array" + "type": "string" }, { - "$ref": "#/$defs/TestOutput" + "type": "null" } ], - "title": "Element" + "default": null, + "title": "Collection Type" }, - "type_value": { + "class": { "anyOf": [ { - "type": "string" + "const": "Collection" }, { "type": "null" } ], - "default": null, - "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``).", - "title": "Type Value" + "default": "Collection", + "title": "Class" + }, + "element": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/TestOutput" + }, + "type": "array" + }, + { + "$ref": "#/$defs/TestOutput" + } + ], + "title": "Element" }, "count": { "anyOf": [ @@ -2626,6 +3359,30 @@ "title": "Element Tests", "type": "object" }, + "class": { + "anyOf": [ + { + "const": "File" + }, + { + "type": "null" + } + ], + "default": "File", + "title": "Class" + }, + "path": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Path" + }, "discovered_dataset": { "items": { "$ref": "#/$defs/TestDiscoveredDataset" diff --git a/lib/galaxy_test/api/test_tools_upload.py b/lib/galaxy_test/api/test_tools_upload.py index 51df9ab4adcd..ef35eecf6de7 100644 --- a/lib/galaxy_test/api/test_tools_upload.py +++ b/lib/galaxy_test/api/test_tools_upload.py @@ -990,6 +990,7 @@ def upload_file(url, path, api_key, history_id): # Upload a file to a tus server. uploader = my_client.uploader(path, metadata=metadata) uploader.upload() + assert uploader.url return uploader.url.rsplit("/", 1)[1] with self.dataset_populator.test_history() as history_id: