Skip to content

Commit

Permalink
Add partially auto-generated test file schema
Browse files Browse the repository at this point in the history
To generate dataclasses in generated/galaxy from xsd:

```
pip install 'xsdata[cli]'
cd lib/galaxy/tool_util/schemas
xsdata ../xsd/galaxy.xsd --unnest-classes --kw-only --docstring-style Accessible --ignore-patterns --max-line-length 10000
```

Fix up tool test schema for workflow particularities (and xsdata
odditites)
```
python postprocess_schema.py
```

To generate json schema (requires pydantic 2.0 to deal with recursive
data classes):
```
python test_file_from_xsd.py > test_file_schema.json
```

To validate a workflow test file with check-jsonschema
```
check-jsonschema --traceback-mode full --schemafile test_file_schema.json sra-manifest-to-concatenated-fastqs-tests.yml
```

TODO:
  - jobs is not modeled
  - element / element_tests needs work
  - special handling for primitive workflow parameter output values
  - de-RST-ify description fields
  • Loading branch information
mvdbeek committed Dec 4, 2023
1 parent 84b48a8 commit d13c928
Show file tree
Hide file tree
Showing 7 changed files with 9,785 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/galaxy/tool_util/schemas/.xsdata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Config xmlns="http://pypi.org/project/xsdata" version="23.6">
<Extensions>
<Extension type="class" class=".*" import=".config.BaseSetting" prepend="false" applyIfDerived="true"/>
</Extensions>
</Config>
305 changes: 305 additions & 0 deletions lib/galaxy/tool_util/schemas/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
from generated.galaxy import (
Action,
Actions,
ActionsConditional,
ActionsConditionalFilter,
ActionsConditionalFilterType,
ActionsConditionalWhen,
ActionsOption,
ActionsOptionType,
ActionType,
AssertAttributeIs,
AssertAttributeMatches,
AssertElementText,
AssertElementTextIs,
AssertElementTextMatches,
AssertHasArchiveMember,
AssertHasElementWithPath,
AssertHasH5Attribute,
AssertHasH5Keys,
AssertHasJsonPropertyWithText,
AssertHasJsonPropertyWithValue,
AssertHasLine,
AssertHasLineMatching,
AssertHasNcolumns,
AssertHasNelementsWithPath,
AssertHasNlines,
AssertHasSize,
AssertHasText,
AssertHasTextMatching,
AssertIsValidXml,
AssertNotHasText,
AssertXmlelement,
ChangeFormat,
ChangeFormatWhen,
Citation,
Citations,
CitationType,
Code,
CodeHook,
Column,
Command,
CompareType,
Conditional,
ConditionalWhen,
ConfigFile,
ConfigFiles,
ConfigFileSources,
ConfigInputs,
Container,
ContainerType,
Creator,
DetectErrorType,
DisplayType,
EdamOperations,
EdamTopics,
EntryPoint,
EntryPointPort,
EntryPoints,
EntryPointUrl,
EnvironmentVariable,
EnvironmentVariableInject,
EnvironmentVariables,
ExitCode,
Expression,
ExpressionType,
Filter,
FilterType,
HierarchyType,
Inputs,
InputType,
LevelType,
Macros,
MethodType,
Options,
Organization,
Output,
OutputCollection,
OutputCollectionDiscoverDatasets,
OutputData,
OutputDiscoverDatasets,
Outputs,
Parallelism,
Param,
ParamConversion,
ParamDefault,
ParamDefaultCollection,
ParamDefaultElement,
ParamDrillDownOption,
ParamOptions,
ParamSelectOption,
ParamType,
PermissiveBooleanValue,
Person,
Regex,
Repeat,
RequestParameter,
RequestParameterAppend,
RequestParameterAppendValue,
RequestParameterGalaxyNameType,
RequestParameterTranslation,
RequestParameterValueTranslation,
RequestParameterValueTranslationValue,
RequiredFileExclude,
RequiredFileInclude,
RequiredFileReferenceType,
RequiredFiles,
Requirement,
Requirements,
RequirementType,
Resource,
ResourceType,
Sanitizer,
SanitizerMapping,
SanitizerMappingAdd,
SanitizerMappingRemove,
SanitizerValid,
SanitizerValidAdd,
SanitizerValidRemove,
Section,
SourceType,
Stdio,
TargetType,
Test,
TestAssertions,
TestCollection,
TestCompositeData,
TestConditional,
TestDiscoveredDataset,
TestExtraFile,
TestOutput,
TestOutputCollection,
TestOutputCompareType,
TestOutputMetadata,
TestParam,
TestParamMetadata,
TestRepeat,
Tests,
TestSection,
Tool,
ToolAction,
ToolTypeType,
TracksterAction,
TracksterConf,
Uihints,
UrlmethodType,
Validator,
ValidatorType,
VersionCommand,
Xref,
Xrefs,
XrefType,
)

__all__ = [
"Action",
"ActionType",
"Actions",
"ActionsConditional",
"ActionsConditionalFilter",
"ActionsConditionalFilterType",
"ActionsConditionalWhen",
"ActionsOption",
"ActionsOptionType",
"AssertAttributeIs",
"AssertAttributeMatches",
"AssertElementText",
"AssertElementTextIs",
"AssertElementTextMatches",
"AssertHasArchiveMember",
"AssertHasElementWithPath",
"AssertHasH5Attribute",
"AssertHasH5Keys",
"AssertHasJsonPropertyWithText",
"AssertHasJsonPropertyWithValue",
"AssertHasLine",
"AssertHasLineMatching",
"AssertHasNcolumns",
"AssertHasNelementsWithPath",
"AssertHasNlines",
"AssertHasSize",
"AssertHasText",
"AssertHasTextMatching",
"AssertIsValidXml",
"AssertNotHasText",
"AssertXmlelement",
"ChangeFormat",
"ChangeFormatWhen",
"Citation",
"CitationType",
"Citations",
"Code",
"CodeHook",
"Column",
"Command",
"CompareType",
"Conditional",
"ConditionalWhen",
"ConfigFile",
"ConfigFileSources",
"ConfigFiles",
"ConfigInputs",
"Container",
"ContainerType",
"Creator",
"DetectErrorType",
"DisplayType",
"EdamOperations",
"EdamTopics",
"EntryPoint",
"EntryPointPort",
"EntryPointUrl",
"EntryPoints",
"EnvironmentVariable",
"EnvironmentVariableInject",
"EnvironmentVariables",
"ExitCode",
"Expression",
"ExpressionType",
"Filter",
"FilterType",
"HierarchyType",
"InputType",
"Inputs",
"LevelType",
"Macros",
"MethodType",
"Options",
"Organization",
"Output",
"OutputCollection",
"OutputCollectionDiscoverDatasets",
"OutputData",
"OutputDiscoverDatasets",
"Outputs",
"Parallelism",
"Param",
"ParamConversion",
"ParamDefault",
"ParamDefaultCollection",
"ParamDefaultElement",
"ParamDrillDownOption",
"ParamOptions",
"ParamSelectOption",
"ParamType",
"PermissiveBooleanValue",
"Person",
"Regex",
"Repeat",
"RequestParameter",
"RequestParameterAppend",
"RequestParameterAppendValue",
"RequestParameterGalaxyNameType",
"RequestParameterTranslation",
"RequestParameterValueTranslation",
"RequestParameterValueTranslationValue",
"RequiredFileExclude",
"RequiredFileInclude",
"RequiredFileReferenceType",
"RequiredFiles",
"Requirement",
"RequirementType",
"Requirements",
"Resource",
"ResourceType",
"Sanitizer",
"SanitizerMapping",
"SanitizerMappingAdd",
"SanitizerMappingRemove",
"SanitizerValid",
"SanitizerValidAdd",
"SanitizerValidRemove",
"Section",
"SourceType",
"Stdio",
"TargetType",
"Test",
"TestAssertions",
"TestCollection",
"TestCompositeData",
"TestConditional",
"TestDiscoveredDataset",
"TestExtraFile",
"TestOutput",
"TestOutputCollection",
"TestOutputCompareType",
"TestOutputMetadata",
"TestParam",
"TestParamMetadata",
"TestRepeat",
"TestSection",
"Tests",
"ToolAction",
"ToolTypeType",
"TracksterAction",
"TracksterConf",
"Uihints",
"UrlmethodType",
"Validator",
"ValidatorType",
"VersionCommand",
"Tool",
"Xref",
"XrefType",
"Xrefs",
]
12 changes: 12 additions & 0 deletions lib/galaxy/tool_util/schemas/generated/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pydantic import ConfigDict

alias_lookup = {
"assert_contents": "asserts",
"element": "element_tests",
}


class BaseSetting:
__pydantic_config__ = ConfigDict(
extra="forbid", alias_generator=lambda field_name: alias_lookup.get(field_name, field_name)
)
Loading

0 comments on commit d13c928

Please sign in to comment.