diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 29b4adbc..c8706edd 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -74,7 +74,7 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: - fail_ci_if_error: true + fail_ci_if_error: false tox-style: name: CI linters via Tox diff --git a/Makefile b/Makefile index 1e565aa9..23b62578 100644 --- a/Makefile +++ b/Makefile @@ -194,21 +194,25 @@ flake8: FORCE src/cwl_utils/parser/cwl_v1_0.py: FORCE schema-salad-tool --codegen python \ --codegen-parser-info "org.w3id.cwl.v1_0" \ - https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml \ + --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" \ + https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml \ > $@ src/cwl_utils/parser/cwl_v1_1.py: FORCE schema-salad-tool --codegen python \ --codegen-parser-info "org.w3id.cwl.v1_1" \ - https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml \ + --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" \ + https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml \ > $@ src/cwl_utils/parser/cwl_v1_2.py: FORCE schema-salad-tool --codegen python \ --codegen-parser-info "org.w3id.cwl.v1_2" \ - https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml \ + --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" \ + https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/CommonWorkflowLanguage.yml \ > $@ + regen_parsers: src/cwl_utils/parser/cwl_v1_*.py FORCE: diff --git a/README.rst b/README.rst index 204a1f87..1748ce52 100644 --- a/README.rst +++ b/README.rst @@ -173,13 +173,13 @@ Regenerate parsers To regenerate install the ``schema_salad`` package and run: ``cwl_utils/parser/cwl_v1_0.py`` was created via -``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_0" > cwl_utils/parser/cwl_v1_0.py`` +``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" --codegen-parser-info "org.w3id.cwl.v1_0" > src/cwl_utils/parser/cwl_v1_0.py`` ``cwl_utils/parser/cwl_v1_1.py`` was created via -``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_1" > cwl_utils/parser/cwl_v1_1.py`` +``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" --codegen-parser-info "org.w3id.cwl.v1_1" > src/cwl_utils/parser/cwl_v1_1.py`` ``cwl_utils/parser/cwl_v1_2.py`` was created via -``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_2" > cwl_utils/parser/cwl_v1_2.py`` +``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/CommonWorkflowLanguage.yml --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" --codegen-parser-info "org.w3id.cwl.v1_2" > src/cwl_utils/parser/cwl_v1_2.py`` Release ~~~~~~~ diff --git a/pyproject.toml b/pyproject.toml index 5212d444..cb9e0dc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dependencies = [ "packaging", "rdflib", "requests", - "schema-salad >= 8.8.20250205075315,<9", + "schema-salad @ git+https://github.com/common-workflow-language/schema_salad.git@refs/pull/993/head", "ruamel.yaml >= 0.17.6, < 0.20", "typing_extensions >= 4.10.0", ] @@ -71,6 +71,9 @@ cwl-pack = "cwl_utils.pack_cli:main" cwl-normalizer = "cwl_utils.normalizer:main" cwl-inputs-schema-gen = "cwl_utils.inputs_schema_gen:main" +[tool.hatch.metadata] +allow-direct-references = true + [tool.pytest.ini_options] addopts = "-rsx -n auto --pyargs cwl_utils.tests" @@ -135,3 +138,4 @@ ignore = [ [tool.bandit] exclude_dirs = ["src/cwl_utils/tests"] +skips = ["B101"] diff --git a/src/cwl_utils/cite_extract.py b/src/cwl_utils/cite_extract.py index d35081d5..099aacd6 100755 --- a/src/cwl_utils/cite_extract.py +++ b/src/cwl_utils/cite_extract.py @@ -33,7 +33,7 @@ def main() -> int: def extract_software_reqs( - process: cwl.Process, + process: cwl.Process | cwl.WorkflowStep, ) -> Iterator[cwl.SoftwareRequirement]: """Return an iterator over any SoftwareRequirements found in the given process.""" if process.requirements: @@ -67,7 +67,7 @@ def get_process_from_step(step: cwl.WorkflowStep) -> cwl.Process: """Return the process for this step, loading it if needed.""" if isinstance(step.run, str): return cast(cwl.Process, cwl.load_document_by_uri(step.run)) - return cast(cwl.Process, step.run) + return step.run def traverse_workflow(workflow: cwl.Workflow) -> Iterator[cwl.SoftwareRequirement]: diff --git a/src/cwl_utils/cwl_v1_0_expression_refactor.py b/src/cwl_utils/cwl_v1_0_expression_refactor.py index 1446319a..82ebb151 100755 --- a/src/cwl_utils/cwl_v1_0_expression_refactor.py +++ b/src/cwl_utils/cwl_v1_0_expression_refactor.py @@ -11,6 +11,8 @@ from typing import Any, cast from ruamel import yaml +from schema_salad.metaschema import ArraySchema, RecordSchema +from schema_salad.runtime import LoadingOptions, save from schema_salad.sourceline import SourceLine from schema_salad.utils import json_dumps @@ -18,6 +20,18 @@ import cwl_utils.parser.cwl_v1_0_utils as utils from cwl_utils.errors import JavascriptException, WorkflowException from cwl_utils.expression import do_eval, interpolate +from cwl_utils.parser.cwl_v1_0_utils import ( + AnyTypeSchema, + BasicCommandInputTypeSchemas, + BasicCommandOutputTypeSchemas, + BasicInputTypeSchemas, + BasicOutputTypeSchemas, + CommandInputTypeSchemas, + CommandOutputTypeSchemas, + InputTypeSchemas, + OutputTypeSchemas, +) +from cwl_utils.parser.utils import param_for_source_id from cwl_utils.types import ( CWLDirectoryType, CWLFileType, @@ -26,6 +40,7 @@ CWLParameterContext, CWLRuntimeParameterContext, is_file_or_directory, + is_sequence, ) @@ -41,7 +56,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool stdout_path = process.stdout if not stdout_path: stdout_path = hashlib.sha1( # nosec - json_dumps(cwl.save(process)).encode("utf-8") + json_dumps(save(process)).encode("utf-8") ).hexdigest() result.stdout = stdout_path result.outputs[index].type_ = "File" @@ -56,33 +71,64 @@ def escape_expression_field(contents: str) -> str: return contents.replace("${", "$/{").replace("$(", "$/(") -def clean_type_ids( - cwltype: cwl.ArraySchema | cwl.InputRecordSchema, -) -> cwl.ArraySchema | cwl.InputRecordSchema: - """Simplify type identifiers.""" - result = copy.deepcopy(cwltype) - if isinstance(result, cwl.ArraySchema): - if isinstance(result.items, MutableSequence): - for item in result.items: +def _clean_type_ids( + cwltype: InputTypeSchemas | CommandOutputTypeSchemas, +) -> None: + if isinstance(cwltype, ArraySchema): + if is_sequence(cwltype.items): + for item in cwltype.items: if hasattr(item, "id"): item.id = item.id.split("#")[-1] - elif isinstance(result.items, cwl.InputRecordSchema): - if result.items.name: - result.items.name = result.items.name.split("/")[-1] - if result.items.fields: - for field in result.items.fields: + elif isinstance(cwltype.items, RecordSchema): + if ( + isinstance( + cwltype.items, + (cwl.InputRecordSchema, cwl.CommandOutputRecordSchema), + ) + and cwltype.items.name + ): + cwltype.items.name = cwltype.items.name.split("/")[-1] + if cwltype.items.fields: + for field in cwltype.items.fields: field.name = field.name.split("/")[-1] - elif isinstance(result, cwl.InputRecordSchema): - if result.name: - result.name = result.name.split("/")[-1] - if result.fields: - for field in result.fields: + elif isinstance(cwltype, RecordSchema): + if cwltype.fields: + for field in cwltype.fields: field.name = field.name.split("/")[-1] + + +def clean_type_ids( + cwltype: AnyTypeSchema, +) -> AnyTypeSchema: + """Simplify type identifiers.""" + result = copy.deepcopy(cwltype) + if is_sequence(result): + for item in result: + _clean_type_ids(item) + else: + _clean_type_ids(result) return result +def _has_expression(string: str) -> bool: + if "${" in string: + return True + if "$(" in string: + return True + return False + + +def has_expression(field: str | Sequence[str]) -> bool: + if is_sequence(field): + for entry in field: + if _has_expression(entry): + return True + return False + return _has_expression(field) + + def get_expression( - string: str, inputs: CWLObjectType, self: CWLOutputType | None + string: Any, inputs: CWLObjectType, self: CWLOutputType | None ) -> str | None: """ Find and return a normalized CWL expression, if any. @@ -137,6 +183,142 @@ def get_expression( return None +def _plain_input_schema_to_clt_input_schema( + input_type: BasicInputTypeSchemas, +) -> BasicCommandInputTypeSchemas: + match input_type: + case cwl.InputArraySchema(): + return cwl.CommandInputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputEnumSchema(): + return cwl.CommandInputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputRecordSchema(): + return cwl.CommandInputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_input_schema_to_clt_input_schema( + input_type: InputTypeSchemas, +) -> CommandInputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_input_schema_to_clt_input_schema(input_type_item) + for input_type_item in input_type + ] + if input_type is None: + return None + return _plain_input_schema_to_clt_input_schema(input_type) + + +def _plain_input_schema_to_plain_output_schema( + input_type: BasicInputTypeSchemas, +) -> BasicOutputTypeSchemas: + match input_type: + case cwl.InputArraySchema(): + return cwl.OutputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputEnumSchema(): + return cwl.OutputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputRecordSchema(): + return cwl.OutputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_input_schema_to_plain_output_schema( + input_type: InputTypeSchemas, +) -> OutputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_input_schema_to_plain_output_schema(input_type_item) + for input_type_item in input_type + ] + if input_type is None: + return None + return _plain_input_schema_to_plain_output_schema(input_type) + + +def _plain_output_type_to_clt_output_type( + output_type: BasicOutputTypeSchemas, +) -> BasicCommandOutputTypeSchemas: + match output_type: + case cwl.OutputArraySchema(): + return cwl.CommandOutputArraySchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case cwl.OutputEnumSchema(): + return cwl.CommandOutputEnumSchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case cwl.OutputRecordSchema(): + return cwl.CommandOutputRecordSchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case str(): + return output_type + raise WorkflowException(f"Unexpected ExpressionTool output type: {output_type}.") + + +def plain_output_type_to_clt_output_type( + output_type: OutputTypeSchemas, +) -> CommandOutputTypeSchemas: + if is_sequence(output_type): + return [ + _plain_output_type_to_clt_output_type(output_type_item) + for output_type_item in output_type + ] + if output_type is None: + return None + return _plain_output_type_to_clt_output_type(output_type) + + +def parameter_to_plain_input_paramater( + parameter: cwl.InputParameter | cwl.OutputParameter, +) -> cwl.InputParameter: + return cwl.InputParameter.fromDoc( + parameter.save(), parameter.loadingOptions.baseuri, parameter.loadingOptions + ) + + +def parameters_to_plain_input_paramaters( + parameters: Sequence[ + cwl.InputParameter | cwl.CommandInputParameter | cwl.CommandOutputParameter + ], +) -> Sequence[cwl.InputParameter]: + return [parameter_to_plain_input_paramater(parameter) for parameter in parameters] + + def etool_to_cltool( etool: cwl.ExpressionTool, expressionLib: list[str] | None = None ) -> cwl.CommandLineTool: @@ -152,7 +334,7 @@ def etool_to_cltool( doc=inp.doc, format=inp.format, default=inp.default, - type_=inp.type_, + type_=plain_input_schema_to_clt_input_schema(inp.type_), extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -167,7 +349,7 @@ def etool_to_cltool( streamable=outp.streamable, doc=outp.doc, format=outp.format, - type_=outp.type_, + type_=plain_output_type_to_clt_output_type(outp.type_), extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -329,53 +511,50 @@ def generate_etool_from_expr( | cwl.CommandInputParameter | list[cwl.InputParameter | cwl.CommandInputParameter] ) = None, # if the "self" input should be a different type than the "result" output - extra_processes: None | ( - Sequence[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] - ) = None, + extra_processes: None | Sequence[cwl.Process | cwl.WorkflowStep] = None, ) -> cwl.ExpressionTool: """Convert a CWL Expression into an ExpressionTool.""" - inputs = yaml.comments.CommentedSeq() + inputs: list[cwl.InputParameter] = [] if not no_inputs: - if not self_type: + if self_type is None: self_type = target - if isinstance(self_type, list): - new_type: ( - list[cwl.ArraySchema | cwl.InputRecordSchema] - | cwl.ArraySchema - | cwl.InputRecordSchema - ) = [clean_type_ids(t.type_) for t in self_type if t.type_] - elif self_type.type_: - new_type = clean_type_ids(self_type.type_) + assert self_type is not None + new_type: InputTypeSchemas + if is_sequence(self_type): + new_type_list: MutableSequence[BasicInputTypeSchemas] = [] + for entry in self_type: + clean_type = clean_type_ids(entry.type_) + if is_sequence(clean_type): + new_type_list.extend(clean_type) + elif clean_type is None: + pass + else: + new_type_list.append(clean_type) + new_type = new_type_list else: - raise WorkflowException(f"Don't know how to make type from {self_type!r}.") + new_type = clean_type_ids(self_type.type_) inputs.append( cwl.InputParameter( id="self", - label=self_type.label if not isinstance(self_type, list) else None, + label=self_type.label if not is_sequence(self_type) else None, secondaryFiles=( - self_type.secondaryFiles - if not isinstance(self_type, list) - else None + self_type.secondaryFiles if not is_sequence(self_type) else None ), streamable=( - self_type.streamable if not isinstance(self_type, list) else None + self_type.streamable if not is_sequence(self_type) else None ), - doc=self_type.doc if not isinstance(self_type, list) else None, - format=self_type.format if not isinstance(self_type, list) else None, + doc=self_type.doc if not is_sequence(self_type) else None, + format=(self_type.format if not is_sequence(self_type) else None), type_=new_type, extension_fields=( - self_type.extension_fields - if not isinstance(self_type, list) - else None + self_type.extension_fields if not is_sequence(self_type) else None ), loadingOptions=( - self_type.loadingOptions - if not isinstance(self_type, list) - else None + self_type.loadingOptions if not is_sequence(self_type) else None ), ) ) - outputs = yaml.comments.CommentedSeq() + outputs: list[cwl.ExpressionToolOutputParameter] = [] outputs.append( cwl.ExpressionToolOutputParameter( id="result", @@ -383,8 +562,8 @@ def generate_etool_from_expr( secondaryFiles=target.secondaryFiles, streamable=target.streamable, doc=target.doc, - format=target.format, - type_=target.type_, + format=target.format[0] if target.format else None, + type_=plain_input_schema_to_plain_output_schema(target.type_), extension_fields=target.extension_fields, loadingOptions=target.loadingOptions, ) @@ -412,19 +591,20 @@ def generate_etool_from_expr( ) -def get_input_for_id( - name: str, tool: cwl.CommandLineTool | cwl.Workflow -) -> cwl.CommandInputParameter | None: +def get_input_for_id(name: str, tool: cwl.Process) -> cwl.CommandInputParameter | None: """Determine the CommandInputParameter for the given input name.""" name = name.split("/")[-1] for inp in cast(list[cwl.CommandInputParameter], tool.inputs): if inp.id and inp.id.split("#")[-1].split("/")[-1] == name: - return inp + return cwl.CommandInputParameter.fromDoc( + inp.save(), inp.loadingOptions.baseuri, inp.loadingOptions + ) if isinstance(tool, cwl.Workflow) and "/" in name: stepname, stem = name.split("/", 1) for step in tool.steps: if step.id == stepname: + assert not isinstance(step.run, str) result = get_input_for_id(stem, step.run) if result: return result @@ -432,9 +612,7 @@ def get_input_for_id( def find_expressionLib( - processes: Sequence[ - cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool | cwl.WorkflowStep - ], + processes: Sequence[cwl.Process | cwl.WorkflowStep], ) -> list[str] | None: """ Return the expressionLib from the highest priority InlineJavascriptRequirement. @@ -457,24 +635,18 @@ def replace_expr_with_etool( target: cwl.CommandInputParameter | cwl.InputParameter, source: str | list[Any] | None, replace_etool: bool = False, - extra_process: None | ( - cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool - ) = None, + extra_process: cwl.Process | cwl.WorkflowStep | None = None, source_type: cwl.CommandInputParameter | None = None, ) -> None: """Modify the given workflow, replacing the expr with an standalone ExpressionTool.""" - extra_processes: list[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] = [ - workflow - ] + extra_processes: list[cwl.Process | cwl.WorkflowStep] = [workflow] if extra_process: extra_processes.append(extra_process) etool: cwl.ExpressionTool = generate_etool_from_expr( expr, target, source is None, source_type, extra_processes ) if replace_etool: - processes: list[cwl.WorkflowStep | cwl.Workflow | cwl.CommandLineTool] = [ - workflow - ] + processes: list[cwl.Process | cwl.WorkflowStep] = [workflow] if extra_process: processes.append(extra_process) final_tool: cwl.ExpressionTool | cwl.CommandLineTool = etool_to_cltool( @@ -485,14 +657,16 @@ def replace_expr_with_etool( inps = [] if source: inps.append(cwl.WorkflowStepInput(id="self", source=source)) - workflow.steps.append( + new_steps: list[cwl.WorkflowStep] = [ cwl.WorkflowStep( id=name, in_=inps, out=[cwl.WorkflowStepOutput("result")], run=final_tool, ) - ) + ] + new_steps.extend(workflow.steps) + workflow.steps = new_steps def replace_wf_input_ref_with_step_output( @@ -522,27 +696,28 @@ def replace_wf_input_ref_with_step_output( def empty_inputs( - process_or_step: ( - cwl.CommandLineTool | cwl.WorkflowStep | cwl.ExpressionTool | cwl.Workflow - ), + process_or_step: cwl.Process | cwl.WorkflowStep, parent: cwl.Workflow | None = None, ) -> dict[str, Any]: """Produce a mock input object for the given inputs.""" result = {} if isinstance(process_or_step, cwl.Process): - for param in process_or_step.inputs: - result[param.id.split("#")[-1]] = example_input(param.type_) + for param1 in process_or_step.inputs: + result[param1.id.split("#")[-1]] = example_input(param1.type_) else: - for param in process_or_step.in_: - param_id = param.id.split("/")[-1] - if param.source is None and param.valueFrom: - result[param_id] = example_input("string") - elif param.source is None and param.default: - result[param_id] = param.default - else: + for param2 in process_or_step.in_: + param2_id = param2.id.split("/")[-1] + if param2.source is None and param2.valueFrom: + result[param2_id] = example_input("string") + elif param2.source is None and param2.default: + result[param2_id] = param2.default + elif param2.source is not None: with suppress(WorkflowException): - result[param_id] = example_input( - utils.type_for_source(process_or_step.run, param.source, parent) + assert not isinstance(process_or_step.run, str) + result[param2_id] = example_input( + utils.type_for_source( + process_or_step.run, param2.source, parent + ) ) return result @@ -619,33 +794,22 @@ def process_workflow_inputs_and_outputs( ) -> bool: """Do any needed conversions on the given Workflow's inputs and outputs.""" modified = False - inputs = empty_inputs(workflow) for index, param in enumerate(workflow.inputs): with SourceLine(workflow.inputs, index, WorkflowException): - if param.format and get_expression(param.format, inputs, None): + if param.format is not None and has_expression(param.format): raise SourceLine( param.loadingOptions.original_doc, "format", raise_type=WorkflowException, ).makeError(TOPLEVEL_FORMAT_EXPR_ERROR.format(param.id.split("#")[-1])) - if param.secondaryFiles: - if get_expression(param.secondaryFiles, inputs, EMPTY_FILE): - raise SourceLine( - param.loadingOptions.original_doc, - "secondaryFiles", - raise_type=WorkflowException, - ).makeError(TOPLEVEL_SF_EXPR_ERROR.format(param.id.split("#")[-1])) - elif isinstance(param.secondaryFiles, MutableSequence): - for index2, entry in enumerate(param.secondaryFiles): - if get_expression(entry, inputs, EMPTY_FILE): - raise SourceLine( - param.loadingOptions.original_doc, - index2, - raise_type=WorkflowException, - ).makeError( - f"Entry {index}," - + TOPLEVEL_SF_EXPR_ERROR.format(param.id.split("#")[-1]) - ) + if param.secondaryFiles is not None and has_expression( + param.secondaryFiles + ): + raise SourceLine( + param.loadingOptions.original_doc, + "secondaryFiles", + raise_type=WorkflowException, + ).makeError(TOPLEVEL_SF_EXPR_ERROR.format(param.id.split("#")[-1])) return modified @@ -690,7 +854,7 @@ def process_workflow_reqs_and_hints( if expression: modified = True target = cwl.InputParameter( - id=None, + id="", type_="string", ) etool_id = ( @@ -711,7 +875,9 @@ def process_workflow_reqs_and_hints( prop_reqs += (cwl.EnvVarRequirement,) newEnvDef = copy.deepcopy(envDef) newEnvDef.envValue = f"$(inputs._envDef{index})" - envVarReq.envDef[index] = newEnvDef + new_envDef = list(envVarReq.envDef) + new_envDef[index] = newEnvDef + envVarReq.envDef = new_envDef generated_envVar_reqs.append((etool_id, index)) case cwl.ResourceRequirement(): for attr in cwl.ResourceRequirement.attrs: @@ -720,7 +886,7 @@ def process_workflow_reqs_and_hints( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.InputParameter(id=None, type_="long") + target = cwl.InputParameter(id="", type_="long") etool_id = "_expression_workflow_ResourceRequirement_{}".format( attr ) @@ -745,7 +911,7 @@ def process_workflow_reqs_and_hints( if expression: modified = True target = cwl.InputParameter( - id=None, + id="", type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), @@ -766,18 +932,18 @@ def process_workflow_reqs_and_hints( prop_reqs += (cwl.InitialWorkDirRequirement,) else: iwdr = copy.deepcopy(req) - for index, entry in enumerate(req.listing): - expression = get_expression(entry, inputs, None) + for index1, entry1 in enumerate(req.listing): + expression = get_expression(entry1, inputs, None) if expression: modified = True target = cwl.InputParameter( - id=None, + id="", type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index + index1 ) replace_expr_with_etool( expression, @@ -787,17 +953,19 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = f"$(inputs._iwdr_listing_{index}" - generated_iwdr_reqs.append((etool_id, index)) - elif isinstance(entry, cwl.Dirent): - if entry.entry: + new_listing = list(iwdr.listing) + new_listing[index1] = f"$(inputs._iwdr_listing_{index1}" + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) + elif isinstance(entry1, cwl.Dirent): + if entry1.entry: expression = get_expression( - entry.entry, inputs, None + entry1.entry, inputs, None ) if expression: expr: str = expression expr_result = do_eval( - ex=entry.entry, + ex=entry1.entry, jobinput=inputs, requirements=[], outdir="", @@ -807,7 +975,7 @@ def process_workflow_reqs_and_hints( modified = True if is_file_or_directory(expr_result): target = cwl.InputParameter( - id=None, + id="", type_=expr_result["class"], ) replace_expr_with_etool( @@ -818,38 +986,38 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - "$(inputs._iwdr_listing_{}".format( - index - ) + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) + iwdr.listing = new_listing generated_iwdr_reqs.append( - (etool_id, index) + (etool_id, index1) ) elif isinstance(expr_result, str): target = cwl.InputParameter( - id=None, + id="", type_=["File"], ) - if entry.entryname is None: + if entry1.entryname is None: raise SourceLine( - entry.loadingOptions.original_doc, - index, + entry1.loadingOptions.original_doc, + index1, raise_type=WorkflowException, ).makeError( - f"Entry {index}," + f"Entry {index1}," + "Invalid CWL, if 'entry' " "is a string, then entryName must be specified." ) expr = ( '${return {"class": "File", "basename": "' - + entry.entryname + + entry1.entryname + '", "contents": (function(){' + expr[2:-1] + "})() }; }" ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index + index1 ) replace_expr_with_etool( expr, @@ -859,24 +1027,24 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - f"$(inputs._iwdr_listing_{index}" + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) - generated_iwdr_reqs.append((etool_id, index)) + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) - elif entry.entryname: + elif entry1.entryname: expression = get_expression( - entry.entryname, inputs, None + entry1.entryname, inputs, None ) if expression: modified = True target = cwl.InputParameter( - id=None, + id="", type_="string", ) - etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index - ) + etool_id = f"_expression_workflow_InitialWorkDirRequirement_{index1}" replace_expr_with_etool( expression, etool_id, @@ -885,10 +1053,12 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - f"$(inputs._iwdr_listing_{index}" + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) - generated_iwdr_reqs.append((etool_id, index)) + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) if generated_iwdr_reqs: prop_reqs += (cwl.InitialWorkDirRequirement,) else: @@ -903,14 +1073,18 @@ def process_workflow_reqs_and_hints( continue else: step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(envVarReq) - for entry in generated_envVar_reqs: - step.in_.append( + new_requirements = list(step.requirements) + new_requirements.append(envVarReq) + step.requirements = new_requirements + new_ins = list(step.in_) + for entry2 in generated_envVar_reqs: + new_ins.append( cwl.WorkflowStepInput( - id=f"_envDef{entry[1]}", - source=f"{entry[0]}/result", + id=f"_envDef{entry2[1]}", + source=f"{entry2[0]}/result", ) ) + step.in_ = new_ins if resourceReq and workflow.steps: for step in workflow.steps: @@ -921,15 +1095,19 @@ def process_workflow_reqs_and_hints( if isinstance(req, cwl.ResourceRequirement): continue else: - step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(resourceReq) - for entry in generated_res_reqs: - step.in_.append( + step.requirements = [] + new_requirements = list(step.requirements) + new_requirements.append(resourceReq) + step.requirements = new_requirements + new_ins = list(step.in_) + for entry3 in generated_res_reqs: + new_ins.append( cwl.WorkflowStepInput( - id=f"_{entry[1]}", - source=f"{entry[0]}/result", + id=f"_{entry3[1]}", + source=f"{entry3[0]}/result", ) ) + step.in_ = new_ins if iwdr and workflow.steps: for step in workflow.steps: @@ -941,32 +1119,37 @@ def process_workflow_reqs_and_hints( continue else: step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(iwdr) + new_requirements = list(step.requirements) + new_requirements.append(resourceReq) + new_requirements.append(iwdr) + step.requirements = new_requirements + new_ins = list(step.in_) if generated_iwdr_reqs: - for entry in generated_iwdr_reqs: - step.in_.append( + for entry4 in generated_iwdr_reqs: + new_ins.append( cwl.WorkflowStepInput( id=f"_iwdr_listing_{index}", - source=f"{entry[0]}/result", + source=f"{entry4[0]}/result", ) ) else: - step.in_.append( + new_ins.append( cwl.WorkflowStepInput( id="_iwdr_listing", source="_expression_workflow_InitialWorkDirRequirement/result", ) ) + step.in_ = new_ins if workflow.requirements: - workflow.requirements[:] = [ + workflow.requirements = [ x for x in workflow.requirements if not isinstance(x, prop_reqs) ] return modified def process_level_reqs( - process: cwl.CommandLineTool, + process: cwl.Process, step: cwl.WorkflowStep, parent: cwl.Workflow, replace_etool: bool, @@ -986,6 +1169,7 @@ def process_level_reqs( if not process.requirements: return False modified = False + assert not isinstance(step.run, str) target_process = step.run inputs = empty_inputs(process) generated_res_reqs: list[tuple[str, str]] = [] @@ -995,6 +1179,7 @@ def process_level_reqs( return False step_name = step.id.split("#", 1)[-1] for req_index, req in enumerate(process.requirements): + assert target_process.requirements is not None match req: case cwl.EnvVarRequirement() if req.envDef: for env_index, envDef in enumerate(req.envDef): @@ -1002,7 +1187,7 @@ def process_level_reqs( expression = get_expression(envDef.envValue, inputs, None) if expression: modified = True - target = cwl.InputParameter(id=None, type_="string") + target = cwl.InputParameter(id="", type_="string") etool_id = "_expression_{}_EnvVarRequirement_{}".format( step_name, env_index ) @@ -1015,7 +1200,10 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index][ + cast( + cwl.EnvVarRequirement, + target_process.requirements[req_index], + ).envDef[ env_index ].envValue = f"$(inputs._envDef{env_index})" generated_envVar_reqs.append((etool_id, env_index)) @@ -1026,11 +1214,11 @@ def process_level_reqs( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.InputParameter(id=None, type_="long") + target = cwl.InputParameter(id="", type_="long") etool_id = "_expression_{}_ResourceRequirement_{}".format( step_name, attr ) - replace_clt_hintreq_expr_with_etool( + replace_step_process_hintreq_expr_with_etool( expression, etool_id, parent, @@ -1055,7 +1243,7 @@ def process_level_reqs( target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) - target = cwl.InputParameter(id=None, type_=target_type) + target = cwl.InputParameter(id="", type_=target_type) etool_id = "_expression_{}_InitialWorkDirRequirement".format( step_name ) @@ -1068,15 +1256,18 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing = ( - "$(inputs._iwdr_listing)", - ) - step.in_.append( + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing = ("$(inputs._iwdr_listing)",) + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput( id="_iwdr_listing", source=f"{etool_id}/result", ) ) + step.in_ = new_step_ins add_input_to_process( target_process, "_iwdr_listing", @@ -1084,15 +1275,15 @@ def process_level_reqs( process.loadingOptions, ) else: - for listing_index, entry in enumerate(req.listing): - expression = get_expression(entry, inputs, None) + for listing_index, entry5 in enumerate(req.listing): + expression = get_expression(entry5, inputs, None) if expression: modified = True target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) target = cwl.InputParameter( - id=None, + id="", type_=target_type, ) etool_id = ( @@ -1109,31 +1300,41 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing[ - listing_index - ] = f"$(inputs._iwdr_listing_{listing_index}" + new_iwdr_listing = list( + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing + ) + new_iwdr_listing[listing_index] = ( + f"$(inputs._iwdr_listing_{listing_index}" + ) + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing = new_iwdr_listing generated_iwdr_reqs.append( (etool_id, listing_index, target_type) ) - elif isinstance(entry, cwl.Dirent): - if entry.entry: - expression = get_expression(entry.entry, inputs, None) + elif isinstance(entry5, cwl.Dirent): + if entry5.entry: + expression = get_expression(entry5.entry, inputs, None) if expression: modified = True - if entry.entryname is not None: + if entry5.entryname is not None: entryname_expr = get_expression( - entry.entryname, inputs, None + entry5.entryname, inputs, None ) entryname = ( - entry.entryname + entry5.entryname if entryname_expr - else f'"{entry.entryname}"' # noqa: B907 + else f'"{entry5.entryname}"' # noqa: B907 ) new_expression = ( "${var result; var entryname = " + entryname + "; var entry = " - + entry.entry[2:-1] + + entry5.entry[2:-1] + """; if (typeof entry === 'string' || entry instanceof String) { result = {"class": "File", "basename": entryname, "contents": entry} ; @@ -1149,14 +1350,14 @@ def process_level_reqs( new_expression = expression d_target_type = ["File", "Directory"] target = cwl.InputParameter( - id=None, + id="", type_=d_target_type, ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index ) - replace_clt_hintreq_expr_with_etool( + replace_step_process_hintreq_expr_with_etool( new_expression, etool_id, parent, @@ -1164,22 +1365,26 @@ def process_level_reqs( step, replace_etool, ) - target_process.requirements[req_index].listing[ - listing_index - ].entry = "$(inputs._iwdr_listing_{})".format( + cast( + cwl.Dirent, + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing[listing_index], + ).entry = "$(inputs._iwdr_listing_{})".format( listing_index ) generated_iwdr_reqs.append( (etool_id, listing_index, d_target_type) ) - elif entry.entryname: + elif entry5.entryname: expression = get_expression( - entry.entryname, inputs, None + entry5.entryname, inputs, None ) if expression: modified = True target = cwl.InputParameter( - id=None, + id="", type_="string", ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( @@ -1194,41 +1399,57 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing[ - listing_index - ].entryname = "$(inputs._iwdr_listing_{})".format( + cast( + cwl.Dirent, + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing[listing_index], + ).entryname = "$(inputs._iwdr_listing_{})".format( listing_index ) generated_iwdr_reqs.append( (etool_id, listing_index, "string") ) - for entry in generated_envVar_reqs: - name = f"_envDef{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) + new_step_ins = list(step.in_) + for env_entry in generated_envVar_reqs: + name = f"_envDef{env_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{env_entry[0]}/result") + ) add_input_to_process(target_process, name, "string", process.loadingOptions) - for entry in generated_res_reqs: - name = f"_{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) + for res_entry in generated_res_reqs: + name = f"_{res_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{res_entry[0]}/result") + ) add_input_to_process(target_process, name, "long", process.loadingOptions) - for entry in generated_iwdr_reqs: - name = f"_iwdr_listing_{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) - add_input_to_process(target_process, name, entry[2], process.loadingOptions) + for iwdr_entry in generated_iwdr_reqs: + name = f"_iwdr_listing_{iwdr_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{iwdr_entry[0]}/result") + ) + add_input_to_process( + target_process, name, iwdr_entry[2], process.loadingOptions + ) + step.in_ = new_step_ins return modified def add_input_to_process( - process: cwl.Process, name: str, inptype: Any, loadingOptions: cwl.LoadingOptions + process: cwl.Process, name: str, inptype: Any, loadingOptions: LoadingOptions ) -> None: """Add a new InputParameter to the given CommandLineTool.""" if isinstance(process, cwl.CommandLineTool): - process.inputs.append( + new_process_inputs = list(process.inputs) + new_process_inputs.append( cwl.CommandInputParameter( id=name, type_=inptype, loadingOptions=loadingOptions, ) ) + process.inputs = new_process_inputs def traverse_CommandLineTool( @@ -1242,7 +1463,7 @@ def traverse_CommandLineTool( """Extract any CWL Expressions within the given CommandLineTool into sibling steps.""" modified = False # don't modify clt, modify step.run - target_clt = step.run + target_clt = cast(cwl.CommandLineTool, step.run) inputs = empty_inputs(clt) if not step.id: return False @@ -1256,24 +1477,28 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.InputParameter(id=None, type_=target_type) + target = cwl.InputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) - target_clt.arguments[index] = cwl.CommandLineBinding( + new_target_clt_arguments = list(target_clt.arguments or []) + new_target_clt_arguments[index] = cwl.CommandLineBinding( valueFrom=f"$(inputs.{inp_id})" ) - target_clt.inputs.append( + target_clt.arguments = new_target_clt_arguments + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=target_type, ) ) - step.in_.append( - cwl.WorkflowStepInput( - f"{etool_id}/result", None, inp_id, None, None - ) + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( + cwl.WorkflowStepInput(id=f"{etool_id}/result", source=inp_id) ) + step.in_ = new_step_ins remove_JSReq(target_clt, skip_command_line1) elif isinstance(arg, cwl.CommandLineBinding) and arg.valueFrom: expression = get_expression(arg.valueFrom, inputs, None) @@ -1282,22 +1507,28 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.InputParameter(id=None, type_=target_type) + target = cwl.InputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) - target_clt.arguments[index].valueFrom = "$(inputs.{})".format( - inp_id + new_target_clt_arguments = list(target_clt.arguments or []) + new_target_clt_arguments[index] = cwl.CommandLineBinding( + valueFrom=f"$(inputs.{inp_id})" ) - target_clt.inputs.append( + target_clt.arguments = new_target_clt_arguments + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=target_type, ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins remove_JSReq(target_clt, skip_command_line1) for streamtype in "stdout", "stderr": # add 'stdin' for v1.1 version stream_value = getattr(clt, streamtype) @@ -1308,17 +1539,21 @@ def traverse_CommandLineTool( inp_id = f"_{streamtype}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "string" - target = cwl.InputParameter(id=None, type_=target_type) + target = cwl.InputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) setattr(target_clt, streamtype, f"$(inputs.{inp_id})") - target_clt.inputs.append( + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter(id=inp_id, type_=target_type) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins for inp in clt.inputs: if not skip_command_line1 and inp.inputBinding and inp.inputBinding.valueFrom: expression = get_expression( @@ -1333,12 +1568,19 @@ def traverse_CommandLineTool( expression, etool_id, parent, inp, step, replace_etool, self_id ) inp.inputBinding.valueFrom = f"$(inputs.{inp_id})" - target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type_=inp.type_) + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( + cwl.CommandInputParameter( + id=inp_id, + type_=plain_input_schema_to_clt_input_schema(inp.type_), + ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins for outp in clt.outputs: if outp.outputBinding: if outp.outputBinding.glob: @@ -1347,21 +1589,28 @@ def traverse_CommandLineTool( modified = True inp_id = "_{}_glob".format(outp.id.split("#")[-1]) etool_id = f"_expression_{step_id}{inp_id}" - glob_target_type = ["string", cwl.ArraySchema("string", "array")] - target = cwl.InputParameter(id=None, type_=glob_target_type) + glob_target_type: CommandInputTypeSchemas = [ + "string", + cwl.CommandInputArraySchema("string", "array"), + ] + target = cwl.InputParameter(id="", type_=glob_target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) outp.outputBinding.glob = f"$(inputs.{inp_id})" - target_clt.inputs.append( + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=glob_target_type, ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins if outp.outputBinding.outputEval and not skip_command_line2: self: CWLOutputType = [ { @@ -1385,34 +1634,45 @@ def traverse_CommandLineTool( step, etool_id, outp_id ) self_type = cwl.InputParameter( - id=None, + id="", type_=cwl.InputArraySchema("File", "array", None, None), ) + if isinstance(outp, cwl.CommandOutputParameter): + target = parameter_to_plain_input_paramater(outp) + else: + target = outp etool = generate_etool_from_expr( - expression, outp, False, self_type, [clt, step, parent] + expression, target, False, self_type, [clt, step, parent] ) if outp.outputBinding.loadContents: - etool.inputs[0].type_.inputBinding = cwl.CommandLineBinding( + etool.inputs[0].inputBinding = cwl.CommandLineBinding( loadContents=True ) - etool.inputs.extend(cltool_inputs_to_etool_inputs(clt)) - sub_wf_inputs = cltool_inputs_to_etool_inputs(clt) + etool.inputs = list(etool.inputs) + process_inputs_to_etool_inputs( + clt + ) + sub_wf_inputs = process_inputs_to_etool_inputs(clt) orig_step_inputs = copy.deepcopy(step.in_) for orig_step_input in orig_step_inputs: - orig_step_input.id = orig_step_input.id.split("/")[-1] - if isinstance(orig_step_input.source, MutableSequence): + if is_sequence(orig_step_input.source): + new_orig_step_input_source = list(orig_step_input.source) for index, source in enumerate(orig_step_input.source): - orig_step_input.source[index] = source.split("#")[-1] + new_orig_step_input_source[index] = source.split("#")[ + -1 + ] + orig_step_input.source = new_orig_step_input_source + elif orig_step_input.source is None: + continue else: orig_step_input.source = orig_step_input.source.split("#")[ -1 ] - orig_step_inputs[:] = [ + orig_step_inputs = [ x for x in orig_step_inputs if not x.id.startswith("_") ] - for inp in orig_step_inputs: - inp.source = inp.id - inp.linkMerge = None + for wsi in orig_step_inputs: + wsi.source = wsi.id + wsi.linkMerge = None if replace_etool: processes = [parent] final_etool: cwl.CommandLineTool | cwl.ExpressionTool = ( @@ -1431,8 +1691,8 @@ def traverse_CommandLineTool( step ) # a deepcopy would be convenient, but params2.cwl gives it problems new_clt_step.id = new_clt_step.id.split("#")[-1] - new_clt_step.run = copy.copy(step.run) - new_clt_step.run.id = None + new_clt_step.run = copy.copy(target_clt) + new_clt_step.run.id = "" remove_JSReq(new_clt_step.run, skip_command_line1) for new_outp in new_clt_step.run.outputs: if new_outp.id.split("#")[-1] == outp_id: @@ -1460,12 +1720,17 @@ def traverse_CommandLineTool( type(new_outp), ) new_clt_step.in_ = copy.deepcopy(step.in_) - for inp in new_clt_step.in_: - inp.id = inp.id.split("/")[-1] - inp.source = inp.id - inp.linkMerge = None - for index, out in enumerate(new_clt_step.out): - new_clt_step.out[index] = out.split("/")[-1] + for wsi2 in new_clt_step.in_: + wsi2.id = wsi2.id.split("/")[-1] + wsi2.source = wsi2.id + wsi2.linkMerge = None + new_clt_step_out = list(new_clt_step.out) + for index, out in enumerate(new_clt_step_out): + if isinstance(out, str): + new_clt_step_out[index] = out.split("/")[-1] + else: + out.id = out.id.split("/")[-1] + new_clt_step.out = new_clt_step_out for tool_inp in new_clt_step.run.inputs: tool_inp.id = tool_inp.id.split("#")[-1] for tool_out in new_clt_step.run.outputs: @@ -1496,24 +1761,33 @@ def traverse_CommandLineTool( if isinstance(req, cwl.SubworkflowFeatureRequirement): has_sub_wf_req = True if not has_sub_wf_req: - parent.requirements.append( - cwl.SubworkflowFeatureRequirement() - ) + new_parent_reqs = list(parent.requirements) + new_parent_reqs.append(cwl.SubworkflowFeatureRequirement()) + parent.requirements = new_parent_reqs return modified def rename_step_source(workflow: cwl.Workflow, old: str, new: str) -> None: """Update step source names to the new name.""" - def simplify_wf_id(uri: str) -> str: - return uri.split("#")[-1].split("/", 1)[1] + def simplify_wf_ids(uris: Sequence[str] | str | None) -> set[str]: + if isinstance(uris, str): + uri_seq: Sequence[str] = [uris] + elif uris is None: + return set() + else: + uri_seq = uris + return {uri.split("#")[-1].split("/", 1)[1] for uri in uri_seq} def simplify_step_id(uri: str) -> str: return uri.split("#")[-1] for wf_outp in workflow.outputs: - if wf_outp.outputSource and simplify_wf_id(wf_outp.outputSource) == old: - wf_outp.outputSource = new + simplified_wf_ids = simplify_wf_ids(wf_outp.outputSource) + if wf_outp.outputSource and old in simplified_wf_ids: + simplified_wf_ids.remove(old) + simplified_wf_ids.add(new) + wf_outp.outputSource = list(simplified_wf_ids) for step in workflow.steps: if step.in_: for inp in step.in_: @@ -1529,7 +1803,9 @@ def simplify_step_id(uri: str) -> str: else: for index, source in enumerate(inp.source): if simplify_step_id(source) == old: - inp.source[index] = new + new_inp_source = list(inp.source) + new_inp_source[index] = new + inp.source = new_inp_source def remove_JSReq( @@ -1540,7 +1816,7 @@ def remove_JSReq( if skip_command_line1 and isinstance(process, cwl.CommandLineTool): return if process.hints: - process.hints[:] = [ + process.hints = [ hint for hint in process.hints if not isinstance(hint, cwl.InlineJavascriptRequirement) @@ -1548,7 +1824,7 @@ def remove_JSReq( if not process.hints: process.hints = None if process.requirements: - process.requirements[:] = [ + process.requirements = [ req for req in process.requirements if not isinstance(req, cwl.InlineJavascriptRequirement) @@ -1567,7 +1843,8 @@ def replace_step_clt_expr_with_etool( self_name: str | None = None, ) -> None: """Convert a step level CWL Expression to a sibling expression step.""" - etool_inputs = cltool_inputs_to_etool_inputs(step.run) + assert not isinstance(step.run, str) + etool_inputs = process_inputs_to_etool_inputs(step.run) temp_etool = generate_etool_from_expr2( expr, target, etool_inputs, self_name, step.run, [workflow] ) @@ -1581,8 +1858,9 @@ def replace_step_clt_expr_with_etool( wf_step_inputs = copy.deepcopy(step.in_) for wf_step_input in wf_step_inputs: wf_step_input.id = wf_step_input.id.split("/")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if not x.id.startswith("_")] - workflow.steps.append( + wf_step_inputs = [x for x in wf_step_inputs if not x.id.startswith("_")] + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -1590,9 +1868,10 @@ def replace_step_clt_expr_with_etool( run=etool, ) ) + workflow.steps = new_steps -def replace_clt_hintreq_expr_with_etool( +def replace_step_process_hintreq_expr_with_etool( expr: str, name: str, workflow: cwl.Workflow, @@ -1603,7 +1882,8 @@ def replace_clt_hintreq_expr_with_etool( ) -> cwl.CommandLineTool | cwl.ExpressionTool: """Factor out an expression inside a CommandLineTool req or hint into a sibling step.""" # Same as replace_step_clt_expr_with_etool or different? - etool_inputs = cltool_inputs_to_etool_inputs(step.run) + assert not isinstance(step.run, str) + etool_inputs = process_inputs_to_etool_inputs(step.run) temp_etool = generate_etool_from_expr2( expr, target, etool_inputs, self_name, step.run, [workflow] ) @@ -1617,8 +1897,9 @@ def replace_clt_hintreq_expr_with_etool( wf_step_inputs = copy.deepcopy(step.in_) for wf_step_input in wf_step_inputs: wf_step_input.id = wf_step_input.id.split("/")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if not x.id.startswith("_")] - workflow.steps.append( + wf_step_inputs = [x for x in wf_step_inputs if not x.id.startswith("_")] + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -1626,30 +1907,31 @@ def replace_clt_hintreq_expr_with_etool( run=etool, ) ) + workflow.steps = new_steps return etool -def cltool_inputs_to_etool_inputs( - tool: cwl.CommandLineTool, +def process_inputs_to_etool_inputs( + tool: cwl.Process, ) -> list[cwl.InputParameter]: - """Copy CommandLineTool input objects into the equivalent ExpressionTool input objects.""" - inputs = yaml.comments.CommentedSeq() + """Copy Process input parameters to matching ExpressionTool versions.""" + inputs = [] if tool.inputs: - for clt_inp in tool.inputs: - clt_inp_id = clt_inp.id.split("#")[-1].split("/")[-1] - if not clt_inp_id.startswith("_"): + for process_inp in tool.inputs: + process_inp_id = process_inp.id.split("#")[-1].split("/")[-1] + if not process_inp_id.startswith("_"): inputs.append( cwl.InputParameter( - id=clt_inp_id, - label=clt_inp.label, - secondaryFiles=clt_inp.secondaryFiles, - streamable=clt_inp.streamable, - doc=clt_inp.doc, - format=clt_inp.format, - default=clt_inp.default, - type_=clt_inp.type_, - extension_fields=clt_inp.extension_fields, - loadingOptions=clt_inp.loadingOptions, + id=process_inp_id, + label=process_inp.label, + secondaryFiles=process_inp.secondaryFiles, + streamable=process_inp.streamable, + doc=process_inp.doc, + format=process_inp.format, + default=process_inp.default, + type_=process_inp.type_, + extension_fields=process_inp.extension_fields, + loadingOptions=process_inp.loadingOptions, ) ) return inputs @@ -1657,17 +1939,18 @@ def cltool_inputs_to_etool_inputs( def cltool_step_outputs_to_workflow_outputs( cltool_step: cwl.WorkflowStep, etool_step_id: str, etool_out_id: str -) -> list[cwl.OutputParameter]: +) -> list[cwl.WorkflowOutputParameter]: """ Copy CommandLineTool outputs into the equivalent Workflow output parameters. Connects the outputSources for each of the new output parameters to the step they came from. """ - outputs = yaml.comments.CommentedSeq() + outputs: list[cwl.WorkflowOutputParameter] = [] if not cltool_step.id: raise WorkflowException(f"Missing step id from {cltool_step}.") default_step_id = cltool_step.id.split("#")[-1] + assert not isinstance(cltool_step.run, str) if cltool_step.run.outputs: for clt_out in cltool_step.run.outputs: clt_out_id = clt_out.id.split("#")[-1].split("/")[-1] @@ -1700,7 +1983,7 @@ def generate_etool_from_expr2( cwl.InputParameter | cwl.CommandInputParameter | cwl.CommandOutputParameter ], self_name: str | None = None, - process: cwl.CommandLineTool | cwl.ExpressionTool | None = None, + process: cwl.Process | None = None, extra_processes: None | ( Sequence[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] ) = None, @@ -1714,8 +1997,8 @@ def generate_etool_from_expr2( secondaryFiles=target.secondaryFiles, streamable=target.streamable, doc=target.doc, - format=target.format, - type_=target.type_, + format=target.format[0] if target.format else None, + type_=plain_input_schema_to_plain_output_schema(target.type_), ) ) expression = "${" @@ -1728,30 +2011,19 @@ def generate_etool_from_expr2( + """}()}; }""" ) - hints = None - procs: list[ - cwl.CommandLineTool | cwl.ExpressionTool | cwl.Workflow | cwl.WorkflowStep - ] = [] + procs: list[cwl.Process | cwl.WorkflowStep] = [] if process: procs.append(process) if extra_processes: procs.extend(extra_processes) inlineJSReq = cwl.InlineJavascriptRequirement(find_expressionLib(procs)) - reqs = [inlineJSReq] - if process: - if process.hints: - hints = copy.deepcopy(process.hints) - hints[:] = [ - x for x in hints if not isinstance(x, cwl.InitialWorkDirRequirement) - ] - if process.requirements: - reqs.extend(copy.deepcopy(process.requirements)) - reqs[:] = [ - x for x in reqs if not isinstance(x, cwl.InitialWorkDirRequirement) - ] + reqs: MutableSequence[cwl.ProcessRequirement] = [inlineJSReq] + if process and process.requirements: + reqs.extend(copy.deepcopy(process.requirements)) + reqs[:] = [x for x in reqs if not isinstance(x, cwl.InitialWorkDirRequirement)] return cwl.ExpressionTool( id="_:" + str(uuid.uuid4()), - inputs=inputs, + inputs=parameters_to_plain_input_paramaters(inputs), outputs=outputs, expression=expression, requirements=reqs, @@ -1773,43 +2045,29 @@ def traverse_step( return False step_id = step.id.split("#")[-1] original_process = copy.deepcopy(step.run) + assert not isinstance(original_process, str) + assert not isinstance(step.run, str) original_step_ins = copy.deepcopy(step.in_) for inp in step.in_: if inp.valueFrom: if not inp.source: self = None else: - if isinstance(inp.source, MutableSequence): - self = [] - for source in inp.source: - if not step.scatter: - self.append( - example_input( - utils.type_for_source(parent, source.split("#")[-1]) - ) - ) - else: - scattered_source_type = utils.type_for_source( - parent, source - ) - if isinstance(scattered_source_type, list): - for stype in scattered_source_type: - self.append(example_input(stype.type_)) - else: - self.append(example_input(scattered_source_type.type_)) - else: + self = [] + for source in inp.source: if not step.scatter: - self = example_input( - utils.type_for_source(parent, inp.source.split("#")[-1]) + self.append( + example_input( + utils.type_for_source(parent, source.split("#")[-1]) + ) ) else: - scattered_source_type2 = utils.type_for_source( - parent, inp.source - ) - if isinstance(scattered_source_type2, list): - self = example_input(scattered_source_type2[0].type_) + scattered_source_type = utils.type_for_source(parent, source) + if is_sequence(scattered_source_type): + for stype in scattered_source_type: + self.append(example_input(stype.type_)) else: - self = example_input(scattered_source_type2.type_) + self.append(example_input(scattered_source_type.type_)) expression = get_expression(inp.valueFrom, inputs, self) if expression: modified = True @@ -1825,31 +2083,23 @@ def traverse_step( | cwl.CommandOutputParameter ) = None if inp.source: - if isinstance(inp.source, MutableSequence): - input_source_id = [] - source_types: list[cwl.InputParameter] = [] - for source in inp.source: - source_id = source.split("#")[-1] - input_source_id.append(source_id) - temp_type = utils.type_for_source( - step.run, source_id, parent - ) - if isinstance(temp_type, list): - for ttype in temp_type: - if ttype not in source_types: - source_types.append(ttype) - else: - if temp_type not in source_types: - source_types.append(temp_type) - source_type = cwl.InputParameter( - id=None, - type_=cwl.ArraySchema(source_types, "array"), - ) - else: - input_source_id = inp.source.split("#")[-1] - source_type = utils.param_for_source_id( - step.run, input_source_id, parent - ) + input_source_id = [] + source_types: list[BasicInputTypeSchemas] = [] + for source in inp.source: + source_id = source.split("#")[-1] + input_source_id.append(source_id) + temp_type = utils.type_for_source(step.run, source_id, parent) + if is_sequence(temp_type): + for ttype in temp_type: + if ttype not in source_types: + source_types.append(ttype) + else: + if temp_type not in source_types: + source_types.append(temp_type) + source_type = cwl.InputParameter( + id="", + type_=cwl.InputArraySchema(source_types, "array"), + ) # target.id = target.id.split('#')[-1] if isinstance(original_process, cwl.ExpressionTool): found_JSReq = False @@ -1865,9 +2115,11 @@ def traverse_step( if not step.run.requirements: step.run.requirements = [] expr_lib = find_expressionLib([parent]) - step.run.requirements.append( + new_step_run_requirements = list(step.run.requirements) + new_step_run_requirements.append( cwl.InlineJavascriptRequirement(expr_lib) ) + step.run.requirements = new_step_run_requirements replace_step_valueFrom_expr_with_etool( expression, etool_id, @@ -1884,6 +2136,7 @@ def traverse_step( inp.valueFrom = None inp.source = f"{etool_id}/result" # TODO: skip or special process for sub workflows? + assert not isinstance(original_process, str) process_modified = process_level_reqs( original_process, step, @@ -1909,35 +2162,35 @@ def traverse_step( def workflow_step_to_InputParameters( - step_ins: list[cwl.WorkflowStepInput], parent: cwl.Workflow, except_in_id: str -) -> list[cwl.InputParameter | cwl.CommandOutputParameter]: - """Create InputParameters to match the given WorkflowStep inputs.""" + step_ins: Sequence[cwl.WorkflowStepInput], parent: cwl.Workflow, except_in_id: str +) -> list[cwl.InputParameter]: + """Create ExpressionTool InputParameters to match the given WorkflowStep inputs.""" params = [] for inp in step_ins: - if not inp.id: - continue inp_id = inp.id.split("#")[-1].split("/")[-1] if inp.source and inp_id != except_in_id: param = copy.deepcopy( - utils.param_for_source_id(parent, sourcenames=inp.source) + param_for_source_id(parent, sourcenames=inp.source) ) - if isinstance(param, MutableSequence): + if is_sequence(param): for p in param: if not p.type_: raise WorkflowException( f"Don't know how to get type id for {p!r}." ) - p.id = inp_id - p.type_ = clean_type_ids(p.type_) - params.append(p) + new_param = parameter_to_plain_input_paramater(p) + new_param.id = inp_id + new_param.type_ = clean_type_ids(new_param.type_) + params.append(new_param) else: if not param.type_: raise WorkflowException( f"Don't know how to get type id for {param!r}." ) - param.id = inp_id - param.type_ = clean_type_ids(param.type_) - params.append(param) + new_param = parameter_to_plain_input_paramater(param) + new_param.id = inp_id + new_param.type_ = clean_type_ids(new_param.type_) + params.append(new_param) return params @@ -1948,14 +2201,14 @@ def replace_step_valueFrom_expr_with_etool( target: cwl.CommandInputParameter | cwl.InputParameter, step: cwl.WorkflowStep, step_inp: cwl.WorkflowStepInput, - original_process: cwl.CommandLineTool | cwl.ExpressionTool, - original_step_ins: list[cwl.WorkflowStepInput], + original_process: cwl.Process, + original_step_ins: Sequence[cwl.WorkflowStepInput], source: str | list[str] | None, replace_etool: bool, source_type: ( cwl.InputParameter | cwl.CommandOutputParameter - | MutableSequence[cwl.InputParameter | cwl.CommandOutputParameter] + | Sequence[cwl.InputParameter | cwl.CommandOutputParameter] | None ) = None, ) -> None: @@ -1989,7 +2242,7 @@ def replace_step_valueFrom_expr_with_etool( etool: cwl.ExpressionTool | cwl.CommandLineTool = cltool else: etool = temp_etool - wf_step_inputs = copy.deepcopy(original_step_ins) + wf_step_inputs = list(original_step_ins) if source: wf_step_inputs.append(cwl.WorkflowStepInput(id="self", source=step_inp.source)) for wf_step_input in wf_step_inputs: @@ -1997,12 +2250,11 @@ def replace_step_valueFrom_expr_with_etool( if wf_step_input.valueFrom: wf_step_input.valueFrom = None if wf_step_input.source: - if isinstance(wf_step_input.source, MutableSequence): - for index, inp_source in enumerate(wf_step_input.source): - wf_step_input.source[index] = inp_source.split("#")[-1] - else: - wf_step_input.source = wf_step_input.source.split("#")[-1] - wf_step_inputs[:] = [ + new_source = list(wf_step_input.source) + for index, inp_source in enumerate(wf_step_input.source): + new_source[index] = inp_source.split("#")[-1] + wf_step_input.source = new_source + wf_step_inputs = [ x for x in wf_step_inputs if x.id and not (x.id.startswith("_") or x.id.endswith(step_inp_id)) @@ -2018,7 +2270,8 @@ def replace_step_valueFrom_expr_with_etool( # do we still need to scatter? else: scatter = None - workflow.steps.append( + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -2028,6 +2281,7 @@ def replace_step_valueFrom_expr_with_etool( scatterMethod=step.scatterMethod, ) ) + workflow.steps = new_steps def traverse_workflow( @@ -2060,7 +2314,7 @@ def traverse_workflow( if process_workflow_reqs_and_hints(workflow, replace_etool): modified = True if workflow.requirements: - workflow.requirements[:] = [ + workflow.requirements = [ x for x in workflow.requirements if not isinstance( diff --git a/src/cwl_utils/cwl_v1_1_expression_refactor.py b/src/cwl_utils/cwl_v1_1_expression_refactor.py index 1bedf4c2..24106dc6 100755 --- a/src/cwl_utils/cwl_v1_1_expression_refactor.py +++ b/src/cwl_utils/cwl_v1_1_expression_refactor.py @@ -11,6 +11,8 @@ from typing import Any, cast from ruamel import yaml +from schema_salad.metaschema import ArraySchema, RecordSchema +from schema_salad.runtime import LoadingOptions, save from schema_salad.sourceline import SourceLine from schema_salad.utils import json_dumps @@ -18,6 +20,18 @@ import cwl_utils.parser.cwl_v1_1_utils as utils from cwl_utils.errors import JavascriptException, WorkflowException from cwl_utils.expression import do_eval, interpolate +from cwl_utils.parser.cwl_v1_1_utils import ( + AnyTypeSchema, + BasicCommandInputTypeSchemas, + BasicCommandOutputTypeSchemas, + BasicInputTypeSchemas, + BasicOutputTypeSchemas, + CommandInputTypeSchemas, + CommandOutputTypeSchemas, + InputTypeSchemas, + OutputTypeSchemas, +) +from cwl_utils.parser.utils import param_for_source_id from cwl_utils.types import ( CWLDirectoryType, CWLFileType, @@ -26,6 +40,7 @@ CWLParameterContext, CWLRuntimeParameterContext, is_file_or_directory, + is_sequence, ) @@ -41,11 +56,11 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool stdout_path = process.stdout if not stdout_path: stdout_path = hashlib.sha1( # nosec - json_dumps(cwl.save(process)).encode("utf-8") + json_dumps(save(process)).encode("utf-8") ).hexdigest() result.stdout = stdout_path result.outputs[index].type_ = "File" - output.outputBinding = cwl.CommandOutputBinding(stdout_path, None, None) + output.outputBinding = cwl.CommandOutputBinding(glob=stdout_path) if result: return result return process @@ -56,33 +71,64 @@ def escape_expression_field(contents: str) -> str: return contents.replace("${", "$/{").replace("$(", "$/(") -def clean_type_ids( - cwltype: cwl.ArraySchema | cwl.InputRecordSchema, -) -> cwl.ArraySchema | cwl.InputRecordSchema: - """Simplify type identifiers.""" - result = copy.deepcopy(cwltype) - if isinstance(result, cwl.ArraySchema): - if isinstance(result.items, MutableSequence): - for item in result.items: +def _clean_type_ids( + cwltype: InputTypeSchemas | CommandOutputTypeSchemas, +) -> None: + if isinstance(cwltype, ArraySchema): + if is_sequence(cwltype.items): + for item in cwltype.items: if hasattr(item, "id"): item.id = item.id.split("#")[-1] - elif isinstance(result.items, cwl.InputRecordSchema): - if result.items.name: - result.items.name = result.items.name.split("/")[-1] - if result.items.fields: - for field in result.items.fields: + elif isinstance(cwltype.items, RecordSchema): + if ( + isinstance( + cwltype.items, + (cwl.InputRecordSchema, cwl.CommandOutputRecordSchema), + ) + and cwltype.items.name + ): + cwltype.items.name = cwltype.items.name.split("/")[-1] + if cwltype.items.fields: + for field in cwltype.items.fields: field.name = field.name.split("/")[-1] - elif isinstance(result, cwl.InputRecordSchema): - if result.name: - result.name = result.name.split("/")[-1] - if result.fields: - for field in result.fields: + elif isinstance(cwltype, RecordSchema): + if cwltype.fields: + for field in cwltype.fields: field.name = field.name.split("/")[-1] + + +def clean_type_ids( + cwltype: AnyTypeSchema, +) -> AnyTypeSchema: + """Simplify type identifiers.""" + result = copy.deepcopy(cwltype) + if is_sequence(result): + for item in result: + _clean_type_ids(item) + else: + _clean_type_ids(result) return result +def _has_expression(string: str) -> bool: + if "${" in string: + return True + if "$(" in string: + return True + return False + + +def has_expression(field: str | Sequence[str]) -> bool: + if is_sequence(field): + for entry in field: + if _has_expression(entry): + return True + return False + return _has_expression(field) + + def get_expression( - string: str, inputs: CWLObjectType, self: CWLOutputType | None + string: Any, inputs: CWLObjectType, self: CWLOutputType | None ) -> str | None: """ Find and return a normalized CWL expression, if any. @@ -137,6 +183,140 @@ def get_expression( return None +def _plain_input_schema_to_clt_input_schema( + input_type: BasicInputTypeSchemas, +) -> BasicCommandInputTypeSchemas: + match input_type: + case cwl.InputArraySchema(): + return cwl.CommandInputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputEnumSchema(): + return cwl.CommandInputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputRecordSchema(): + return cwl.CommandInputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_input_schema_to_clt_input_schema( + input_type: InputTypeSchemas, +) -> CommandInputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_input_schema_to_clt_input_schema(input_type_item) + for input_type_item in input_type + ] + return _plain_input_schema_to_clt_input_schema(input_type) + + +def _plain_input_schema_to_plain_output_schema( + input_type: BasicInputTypeSchemas, +) -> BasicOutputTypeSchemas: + match input_type: + case cwl.InputArraySchema(): + return cwl.OutputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputEnumSchema(): + return cwl.OutputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputRecordSchema(): + return cwl.OutputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_input_schema_to_plain_output_schema( + input_type: InputTypeSchemas, +) -> OutputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_input_schema_to_plain_output_schema(input_type_item) + for input_type_item in input_type + ] + return _plain_input_schema_to_plain_output_schema(input_type) + + +def _plain_output_type_to_clt_output_type( + output_type: BasicOutputTypeSchemas, +) -> BasicCommandOutputTypeSchemas: + match output_type: + case cwl.OutputArraySchema(): + return cwl.CommandOutputArraySchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case cwl.OutputEnumSchema(): + return cwl.CommandOutputEnumSchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case cwl.OutputRecordSchema(): + return cwl.CommandOutputRecordSchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case str(): + return output_type + raise WorkflowException(f"Unexpected ExpressionTool output type: {output_type}.") + + +def plain_output_type_to_clt_output_type( + output_type: OutputTypeSchemas, +) -> CommandOutputTypeSchemas: + if is_sequence(output_type): + return [ + _plain_output_type_to_clt_output_type(output_type_item) + for output_type_item in output_type + ] + return _plain_output_type_to_clt_output_type(output_type) + + +def parameter_to_workflow_input_paramater( + parameter: cwl.InputParameter | cwl.OutputParameter, +) -> cwl.WorkflowInputParameter: + return cwl.WorkflowInputParameter.fromDoc( + parameter.save(), parameter.loadingOptions.baseuri, parameter.loadingOptions + ) + + +def parameters_to_workflow_input_paramaters( + parameters: Sequence[ + cwl.WorkflowInputParameter + | cwl.CommandInputParameter + | cwl.CommandOutputParameter + ], +) -> Sequence[cwl.WorkflowInputParameter]: + return [ + parameter_to_workflow_input_paramater(parameter) for parameter in parameters + ] + + def etool_to_cltool( etool: cwl.ExpressionTool, expressionLib: list[str] | None = None ) -> cwl.CommandLineTool: @@ -152,7 +332,7 @@ def etool_to_cltool( doc=inp.doc, format=inp.format, default=inp.default, - type_=inp.type_, + type_=plain_input_schema_to_clt_input_schema(inp.type_), extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -167,7 +347,7 @@ def etool_to_cltool( streamable=outp.streamable, doc=outp.doc, format=outp.format, - type_=outp.type_, + type_=plain_output_type_to_clt_output_type(outp.type_), extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -329,51 +509,50 @@ def generate_etool_from_expr( | cwl.CommandInputParameter | list[cwl.WorkflowInputParameter | cwl.CommandInputParameter] ) = None, # if the "self" input should be a different type than the "result" output - extra_processes: None | ( - Sequence[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] - ) = None, + extra_processes: Sequence[cwl.Process | cwl.WorkflowStep] | None = None, ) -> cwl.ExpressionTool: """Convert a CWL Expression into an ExpressionTool.""" - inputs = yaml.comments.CommentedSeq() + inputs: list[cwl.WorkflowInputParameter] = [] if not no_inputs: - if not self_type: + if self_type is None: self_type = target - if isinstance(self_type, list): - new_type: ( - list[cwl.ArraySchema | cwl.InputRecordSchema] - | cwl.ArraySchema - | cwl.InputRecordSchema - ) = [clean_type_ids(t.type_) for t in self_type] + assert self_type is not None + new_type: InputTypeSchemas + if is_sequence(self_type): + new_type_list: MutableSequence[BasicInputTypeSchemas] = [] + for entry in self_type: + clean_type = clean_type_ids(entry.type_) + if is_sequence(clean_type): + new_type_list.extend(clean_type) + elif clean_type is None: + pass + else: + new_type_list.append(clean_type) + new_type = new_type_list else: new_type = clean_type_ids(self_type.type_) inputs.append( cwl.WorkflowInputParameter( id="self", - label=self_type.label if not isinstance(self_type, list) else None, + label=self_type.label if not is_sequence(self_type) else None, secondaryFiles=( - self_type.secondaryFiles - if not isinstance(self_type, list) - else None + self_type.secondaryFiles if not is_sequence(self_type) else None ), streamable=( - self_type.streamable if not isinstance(self_type, list) else None + self_type.streamable if not is_sequence(self_type) else None ), - doc=self_type.doc if not isinstance(self_type, list) else None, - format=self_type.format if not isinstance(self_type, list) else None, + doc=self_type.doc if not is_sequence(self_type) else None, + format=(self_type.format if not is_sequence(self_type) else None), type_=new_type, extension_fields=( - self_type.extension_fields - if not isinstance(self_type, list) - else None + self_type.extension_fields if not is_sequence(self_type) else None ), loadingOptions=( - self_type.loadingOptions - if not isinstance(self_type, list) - else None + self_type.loadingOptions if not is_sequence(self_type) else None ), ) ) - outputs = yaml.comments.CommentedSeq() + outputs: list[cwl.ExpressionToolOutputParameter] = [] outputs.append( cwl.ExpressionToolOutputParameter( id="result", @@ -381,8 +560,8 @@ def generate_etool_from_expr( secondaryFiles=target.secondaryFiles, streamable=target.streamable, doc=target.doc, - format=target.format, - type_=target.type_, + format=target.format[0] if target.format else None, + type_=plain_input_schema_to_plain_output_schema(target.type_), extension_fields=target.extension_fields, loadingOptions=target.loadingOptions, ) @@ -406,23 +585,27 @@ def generate_etool_from_expr( outputs=outputs, expression=expression, requirements=[inlineJSReq], - cwlVersion="v1.0", + cwlVersion="v1.1", ) def get_input_for_id( - name: str, tool: cwl.CommandLineTool | cwl.Workflow + name: str, + tool: cwl.Process, ) -> cwl.CommandInputParameter | None: """Determine the CommandInputParameter for the given input name.""" name = name.split("/")[-1] for inp in cast(list[cwl.CommandInputParameter], tool.inputs): if inp.id and inp.id.split("#")[-1].split("/")[-1] == name: - return inp + return cwl.CommandInputParameter.fromDoc( + inp.save(), inp.loadingOptions.baseuri, inp.loadingOptions + ) if isinstance(tool, cwl.Workflow) and "/" in name: stepname, stem = name.split("/", 1) for step in tool.steps: if step.id == stepname: + assert not isinstance(step.run, str) result = get_input_for_id(stem, step.run) if result: return result @@ -430,9 +613,7 @@ def get_input_for_id( def find_expressionLib( - processes: Sequence[ - cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool | cwl.WorkflowStep - ], + processes: Sequence[cwl.Process | cwl.WorkflowStep], ) -> list[str] | None: """ Return the expressionLib from the highest priority InlineJavascriptRequirement. @@ -455,24 +636,18 @@ def replace_expr_with_etool( target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, source: str | list[Any] | None, replace_etool: bool = False, - extra_process: None | ( - cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool - ) = None, + extra_process: cwl.Process | cwl.WorkflowStep | None = None, source_type: cwl.CommandInputParameter | None = None, ) -> None: """Modify the given workflow, replacing the expr with an standalone ExpressionTool.""" - extra_processes: list[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] = [ - workflow - ] + extra_processes: list[cwl.Process | cwl.WorkflowStep] = [workflow] if extra_process: extra_processes.append(extra_process) etool: cwl.ExpressionTool = generate_etool_from_expr( expr, target, source is None, source_type, extra_processes ) if replace_etool: - processes: list[cwl.WorkflowStep | cwl.Workflow | cwl.CommandLineTool] = [ - workflow - ] + processes: list[cwl.Process | cwl.WorkflowStep] = [workflow] if extra_process: processes.append(extra_process) final_tool: cwl.ExpressionTool | cwl.CommandLineTool = etool_to_cltool( @@ -483,14 +658,16 @@ def replace_expr_with_etool( inps = [] if source: inps.append(cwl.WorkflowStepInput(id="self", source=source)) - workflow.steps.append( + new_steps: list[cwl.WorkflowStep] = [ cwl.WorkflowStep( id=name, in_=inps, out=[cwl.WorkflowStepOutput("result")], run=final_tool, ) - ) + ] + new_steps.extend(workflow.steps) + workflow.steps = new_steps def replace_wf_input_ref_with_step_output( @@ -520,27 +697,28 @@ def replace_wf_input_ref_with_step_output( def empty_inputs( - process_or_step: ( - cwl.CommandLineTool | cwl.WorkflowStep | cwl.ExpressionTool | cwl.Workflow - ), + process_or_step: cwl.Process | cwl.WorkflowStep, parent: cwl.Workflow | None = None, ) -> dict[str, Any]: """Produce a mock input object for the given inputs.""" result = {} if isinstance(process_or_step, cwl.Process): - for param in process_or_step.inputs: - result[param.id.split("#")[-1]] = example_input(param.type_) + for param1 in process_or_step.inputs: + result[param1.id.split("#")[-1]] = example_input(param1.type_) else: - for param in process_or_step.in_: - param_id = param.id.split("/")[-1] - if param.source is None and param.valueFrom: - result[param_id] = example_input("string") - elif param.source is None and param.default: - result[param_id] = param.default - else: + for param2 in process_or_step.in_: + param2_id = param2.id.split("/")[-1] + if param2.source is None and param2.valueFrom: + result[param2_id] = example_input("string") + elif param2.source is None and param2.default: + result[param2_id] = param2.default + elif param2.source is not None: with suppress(WorkflowException): - result[param_id] = example_input( - utils.type_for_source(process_or_step.run, param.source, parent) + assert not isinstance(process_or_step.run, str) + result[param2_id] = example_input( + utils.type_for_source( + process_or_step.run, param2.source, parent + ) ) return result @@ -617,18 +795,17 @@ def process_workflow_inputs_and_outputs( ) -> bool: """Do any needed conversions on the given Workflow's inputs and outputs.""" modified = False - inputs = empty_inputs(workflow) for index, param in enumerate(workflow.inputs): with SourceLine(workflow.inputs, index, WorkflowException): - if param.format and get_expression(param.format, inputs, None): + if param.format is not None and has_expression(param.format): raise SourceLine( param.loadingOptions.original_doc, "format", raise_type=WorkflowException, ).makeError(TOPLEVEL_FORMAT_EXPR_ERROR.format(param.id.split("#")[-1])) if param.secondaryFiles: - if hasattr(param.secondaryFiles, "pattern") and get_expression( - param.secondaryFiles.pattern, inputs, EMPTY_FILE + if hasattr(param.secondaryFiles, "pattern") and has_expression( + param.secondaryFiles.pattern ): raise SourceLine( param.loadingOptions.original_doc, @@ -637,7 +814,7 @@ def process_workflow_inputs_and_outputs( ).makeError(TOPLEVEL_SF_EXPR_ERROR.format(param.id.split("#")[-1])) elif isinstance(param.secondaryFiles, MutableSequence): for index2, entry in enumerate(param.secondaryFiles): - if get_expression(entry.pattern, inputs, EMPTY_FILE): + if has_expression(entry.pattern): raise SourceLine( param.loadingOptions.original_doc, index2, @@ -646,6 +823,7 @@ def process_workflow_inputs_and_outputs( f"Entry {index}," + TOPLEVEL_SF_EXPR_ERROR.format(param.id.split("#")[-1]) ) + return modified @@ -690,7 +868,7 @@ def process_workflow_reqs_and_hints( if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_="string", ) etool_id = ( @@ -711,7 +889,9 @@ def process_workflow_reqs_and_hints( prop_reqs += (cwl.EnvVarRequirement,) newEnvDef = copy.deepcopy(envDef) newEnvDef.envValue = f"$(inputs._envDef{index})" - envVarReq.envDef[index] = newEnvDef + new_envDef = list(envVarReq.envDef) + new_envDef[index] = newEnvDef + envVarReq.envDef = new_envDef generated_envVar_reqs.append((etool_id, index)) case cwl.ResourceRequirement(): for attr in cwl.ResourceRequirement.attrs: @@ -720,9 +900,7 @@ def process_workflow_reqs_and_hints( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter( - id=None, type_="long" - ) + target = cwl.WorkflowInputParameter(id="", type_="long") etool_id = "_expression_workflow_ResourceRequirement_{}".format( attr ) @@ -747,7 +925,7 @@ def process_workflow_reqs_and_hints( if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), @@ -768,18 +946,18 @@ def process_workflow_reqs_and_hints( prop_reqs += (cwl.InitialWorkDirRequirement,) else: iwdr = copy.deepcopy(req) - for index, entry in enumerate(req.listing): - expression = get_expression(entry, inputs, None) + for index1, entry1 in enumerate(req.listing): + expression = get_expression(entry1, inputs, None) if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index + index1 ) replace_expr_with_etool( expression, @@ -789,17 +967,19 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = f"$(inputs._iwdr_listing_{index}" - generated_iwdr_reqs.append((etool_id, index)) - elif isinstance(entry, cwl.Dirent): - if entry.entry: + new_listing = list(iwdr.listing) + new_listing[index1] = f"$(inputs._iwdr_listing_{index1}" + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) + elif isinstance(entry1, cwl.Dirent): + if entry1.entry: expression = get_expression( - entry.entry, inputs, None + entry1.entry, inputs, None ) if expression: expr: str = expression expr_result = do_eval( - ex=entry.entry, + ex=entry1.entry, jobinput=inputs, requirements=[], outdir="", @@ -809,7 +989,7 @@ def process_workflow_reqs_and_hints( modified = True if is_file_or_directory(expr_result): target = cwl.WorkflowInputParameter( - id=None, + id="", type_=expr_result["class"], ) replace_expr_with_etool( @@ -820,38 +1000,38 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - "$(inputs._iwdr_listing_{}".format( - index - ) + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) + iwdr.listing = new_listing generated_iwdr_reqs.append( - (etool_id, index) + (etool_id, index1) ) elif isinstance(expr_result, str): target = cwl.WorkflowInputParameter( - id=None, + id="", type_=["File"], ) - if entry.entryname is None: + if entry1.entryname is None: raise SourceLine( - entry.loadingOptions.original_doc, - index, + entry1.loadingOptions.original_doc, + index1, raise_type=WorkflowException, ).makeError( - f"Entry {index}," + f"Entry {index1}," + "Invalid CWL, if 'entry' " "is a string, then entryName must be specified." ) expr = ( '${return {"class": "File", "basename": "' - + entry.entryname + + entry1.entryname + '", "contents": (function(){' + expr[2:-1] + "})() }; }" ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index + index1 ) replace_expr_with_etool( expr, @@ -861,24 +1041,24 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - f"$(inputs._iwdr_listing_{index}" + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) - generated_iwdr_reqs.append((etool_id, index)) + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) - elif entry.entryname: + elif entry1.entryname: expression = get_expression( - entry.entryname, inputs, None + entry1.entryname, inputs, None ) if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_="string", ) - etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index - ) + etool_id = f"_expression_workflow_InitialWorkDirRequirement_{index1}" replace_expr_with_etool( expression, etool_id, @@ -887,10 +1067,12 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - f"$(inputs._iwdr_listing_{index}" + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) - generated_iwdr_reqs.append((etool_id, index)) + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) if generated_iwdr_reqs: prop_reqs += (cwl.InitialWorkDirRequirement,) else: @@ -905,14 +1087,18 @@ def process_workflow_reqs_and_hints( continue else: step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(envVarReq) - for entry in generated_envVar_reqs: - step.in_.append( + new_requirements = list(step.requirements) + new_requirements.append(envVarReq) + step.requirements = new_requirements + new_ins = list(step.in_) + for entry2 in generated_envVar_reqs: + new_ins.append( cwl.WorkflowStepInput( - id=f"_envDef{entry[1]}", - source=f"{entry[0]}/result", + id=f"_envDef{entry2[1]}", + source=f"{entry2[0]}/result", ) ) + step.in_ = new_ins if resourceReq and workflow.steps: for step in workflow.steps: @@ -923,15 +1109,19 @@ def process_workflow_reqs_and_hints( if isinstance(req, cwl.ResourceRequirement): continue else: - step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(resourceReq) - for entry in generated_res_reqs: - step.in_.append( + step.requirements = [] + new_requirements = list(step.requirements) + new_requirements.append(resourceReq) + step.requirements = new_requirements + new_ins = list(step.in_) + for entry3 in generated_res_reqs: + new_ins.append( cwl.WorkflowStepInput( - id=f"_{entry[1]}", - source=f"{entry[0]}/result", + id=f"_{entry3[1]}", + source=f"{entry3[0]}/result", ) ) + step.in_ = new_ins if iwdr and workflow.steps: for step in workflow.steps: @@ -943,32 +1133,37 @@ def process_workflow_reqs_and_hints( continue else: step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(iwdr) + new_requirements = list(step.requirements) + new_requirements.append(resourceReq) + new_requirements.append(iwdr) + step.requirements = new_requirements + new_ins = list(step.in_) if generated_iwdr_reqs: - for entry in generated_iwdr_reqs: - step.in_.append( + for entry4 in generated_iwdr_reqs: + new_ins.append( cwl.WorkflowStepInput( id=f"_iwdr_listing_{index}", - source=f"{entry[0]}/result", + source=f"{entry4[0]}/result", ) ) else: - step.in_.append( + new_ins.append( cwl.WorkflowStepInput( id="_iwdr_listing", source="_expression_workflow_InitialWorkDirRequirement/result", ) ) + step.in_ = new_ins if workflow.requirements: - workflow.requirements[:] = [ + workflow.requirements = [ x for x in workflow.requirements if not isinstance(x, prop_reqs) ] return modified def process_level_reqs( - process: cwl.CommandLineTool, + process: cwl.Process, step: cwl.WorkflowStep, parent: cwl.Workflow, replace_etool: bool, @@ -988,6 +1183,7 @@ def process_level_reqs( if not process.requirements: return False modified = False + assert not isinstance(step.run, str) target_process = step.run inputs = empty_inputs(process) generated_res_reqs: list[tuple[str, str]] = [] @@ -997,6 +1193,7 @@ def process_level_reqs( return False step_name = step.id.split("#", 1)[-1] for req_index, req in enumerate(process.requirements): + assert target_process.requirements is not None match req: case cwl.EnvVarRequirement() if req.envDef: for env_index, envDef in enumerate(req.envDef): @@ -1004,7 +1201,7 @@ def process_level_reqs( expression = get_expression(envDef.envValue, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type_="string") + target = cwl.WorkflowInputParameter(id="", type_="string") etool_id = "_expression_{}_EnvVarRequirement_{}".format( step_name, env_index ) @@ -1017,7 +1214,10 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index][ + cast( + cwl.EnvVarRequirement, + target_process.requirements[req_index], + ).envDef[ env_index ].envValue = f"$(inputs._envDef{env_index})" generated_envVar_reqs.append((etool_id, env_index)) @@ -1028,11 +1228,11 @@ def process_level_reqs( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type_="long") + target = cwl.WorkflowInputParameter(id="", type_="long") etool_id = "_expression_{}_ResourceRequirement_{}".format( step_name, attr ) - replace_clt_hintreq_expr_with_etool( + replace_step_process_hintreq_expr_with_etool( expression, etool_id, parent, @@ -1057,7 +1257,7 @@ def process_level_reqs( target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) etool_id = "_expression_{}_InitialWorkDirRequirement".format( step_name ) @@ -1070,15 +1270,18 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing = ( - "$(inputs._iwdr_listing)", - ) - step.in_.append( + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing = ("$(inputs._iwdr_listing)",) + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput( id="_iwdr_listing", source=f"{etool_id}/result", ) ) + step.in_ = new_step_ins add_input_to_process( target_process, "_iwdr_listing", @@ -1086,15 +1289,15 @@ def process_level_reqs( process.loadingOptions, ) else: - for listing_index, entry in enumerate(req.listing): - expression = get_expression(entry, inputs, None) + for listing_index, entry5 in enumerate(req.listing): + expression = get_expression(entry5, inputs, None) if expression: modified = True target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) target = cwl.WorkflowInputParameter( - id=None, + id="", type_=target_type, ) etool_id = ( @@ -1111,31 +1314,41 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing[ - listing_index - ] = f"$(inputs._iwdr_listing_{listing_index}" + new_iwdr_listing = list( + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing + ) + new_iwdr_listing[listing_index] = ( + f"$(inputs._iwdr_listing_{listing_index}" + ) + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing = new_iwdr_listing generated_iwdr_reqs.append( (etool_id, listing_index, target_type) ) - elif isinstance(entry, cwl.Dirent): - if entry.entry: - expression = get_expression(entry.entry, inputs, None) + elif isinstance(entry5, cwl.Dirent): + if entry5.entry: + expression = get_expression(entry5.entry, inputs, None) if expression: modified = True - if entry.entryname is not None: + if entry5.entryname is not None: entryname_expr = get_expression( - entry.entryname, inputs, None + entry5.entryname, inputs, None ) entryname = ( - entry.entryname + entry5.entryname if entryname_expr - else f'"{entry.entryname}"' # noqa: B907 + else f'"{entry5.entryname}"' # noqa: B907 ) new_expression = ( "${var result; var entryname = " + entryname + "; var entry = " - + entry.entry[2:-1] + + entry5.entry[2:-1] + """; if (typeof entry === 'string' || entry instanceof String) { result = {"class": "File", "basename": entryname, "contents": entry} ; @@ -1151,14 +1364,14 @@ def process_level_reqs( new_expression = expression d_target_type = ["File", "Directory"] target = cwl.WorkflowInputParameter( - id=None, + id="", type_=d_target_type, ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index ) - replace_clt_hintreq_expr_with_etool( + replace_step_process_hintreq_expr_with_etool( new_expression, etool_id, parent, @@ -1166,22 +1379,26 @@ def process_level_reqs( step, replace_etool, ) - target_process.requirements[req_index].listing[ - listing_index - ].entry = "$(inputs._iwdr_listing_{})".format( + cast( + cwl.Dirent, + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing[listing_index], + ).entry = "$(inputs._iwdr_listing_{})".format( listing_index ) generated_iwdr_reqs.append( (etool_id, listing_index, d_target_type) ) - elif entry.entryname: + elif entry5.entryname: expression = get_expression( - entry.entryname, inputs, None + entry5.entryname, inputs, None ) if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_="string", ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( @@ -1196,41 +1413,57 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing[ - listing_index - ].entryname = "$(inputs._iwdr_listing_{})".format( + cast( + cwl.Dirent, + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing[listing_index], + ).entryname = "$(inputs._iwdr_listing_{})".format( listing_index ) generated_iwdr_reqs.append( (etool_id, listing_index, "string") ) - for entry in generated_envVar_reqs: - name = f"_envDef{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) + new_step_ins = list(step.in_) + for env_entry in generated_envVar_reqs: + name = f"_envDef{env_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{env_entry[0]}/result") + ) add_input_to_process(target_process, name, "string", process.loadingOptions) - for entry in generated_res_reqs: - name = f"_{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) + for res_entry in generated_res_reqs: + name = f"_{res_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{res_entry[0]}/result") + ) add_input_to_process(target_process, name, "long", process.loadingOptions) - for entry in generated_iwdr_reqs: - name = f"_iwdr_listing_{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) - add_input_to_process(target_process, name, entry[2], process.loadingOptions) + for iwdr_entry in generated_iwdr_reqs: + name = f"_iwdr_listing_{iwdr_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{iwdr_entry[0]}/result") + ) + add_input_to_process( + target_process, name, iwdr_entry[2], process.loadingOptions + ) + step.in_ = new_step_ins return modified def add_input_to_process( - process: cwl.Process, name: str, inptype: Any, loadingOptions: cwl.LoadingOptions + process: cwl.Process, name: str, inptype: Any, loadingOptions: LoadingOptions ) -> None: """Add a new InputParameter to the given CommandLineTool.""" if isinstance(process, cwl.CommandLineTool): - process.inputs.append( + new_process_inputs = list(process.inputs) + new_process_inputs.append( cwl.CommandInputParameter( id=name, type_=inptype, loadingOptions=loadingOptions, ) ) + process.inputs = new_process_inputs def traverse_CommandLineTool( @@ -1244,7 +1477,7 @@ def traverse_CommandLineTool( """Extract any CWL Expressions within the given CommandLineTool into sibling steps.""" modified = False # don't modify clt, modify step.run - target_clt = step.run + target_clt = cast(cwl.CommandLineTool, step.run) inputs = empty_inputs(clt) if not step.id: return False @@ -1258,24 +1491,28 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) - target_clt.arguments[index] = cwl.CommandLineBinding( + new_target_clt_arguments = list(target_clt.arguments or []) + new_target_clt_arguments[index] = cwl.CommandLineBinding( valueFrom=f"$(inputs.{inp_id})" ) - target_clt.inputs.append( + target_clt.arguments = new_target_clt_arguments + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=target_type, ) ) - step.in_.append( - cwl.WorkflowStepInput( - f"{etool_id}/result", None, inp_id, None, None - ) + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( + cwl.WorkflowStepInput(id=f"{etool_id}/result", source=inp_id) ) + step.in_ = new_step_ins remove_JSReq(target_clt, skip_command_line1) elif isinstance(arg, cwl.CommandLineBinding) and arg.valueFrom: expression = get_expression(arg.valueFrom, inputs, None) @@ -1284,22 +1521,28 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) - target_clt.arguments[index].valueFrom = "$(inputs.{})".format( - inp_id + new_target_clt_arguments = list(target_clt.arguments or []) + new_target_clt_arguments[index] = cwl.CommandLineBinding( + valueFrom=f"$(inputs.{inp_id})" ) - target_clt.inputs.append( + target_clt.arguments = new_target_clt_arguments + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=target_type, ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins remove_JSReq(target_clt, skip_command_line1) for streamtype in "stdout", "stderr": # add 'stdin' for v1.1 version stream_value = getattr(clt, streamtype) @@ -1310,17 +1553,21 @@ def traverse_CommandLineTool( inp_id = f"_{streamtype}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "string" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) setattr(target_clt, streamtype, f"$(inputs.{inp_id})") - target_clt.inputs.append( + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter(id=inp_id, type_=target_type) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins for inp in clt.inputs: if not skip_command_line1 and inp.inputBinding and inp.inputBinding.valueFrom: expression = get_expression( @@ -1335,12 +1582,19 @@ def traverse_CommandLineTool( expression, etool_id, parent, inp, step, replace_etool, self_id ) inp.inputBinding.valueFrom = f"$(inputs.{inp_id})" - target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type_=inp.type_) + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( + cwl.CommandInputParameter( + id=inp_id, + type_=plain_input_schema_to_clt_input_schema(inp.type_), + ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins for outp in clt.outputs: if outp.outputBinding: if outp.outputBinding.glob: @@ -1349,21 +1603,28 @@ def traverse_CommandLineTool( modified = True inp_id = "_{}_glob".format(outp.id.split("#")[-1]) etool_id = f"_expression_{step_id}{inp_id}" - glob_target_type = ["string", cwl.ArraySchema("string", "array")] - target = cwl.WorkflowInputParameter(id=None, type_=glob_target_type) + glob_target_type: CommandInputTypeSchemas = [ + "string", + cwl.CommandInputArraySchema("string", "array"), + ] + target = cwl.WorkflowInputParameter(id="", type_=glob_target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) outp.outputBinding.glob = f"$(inputs.{inp_id})" - target_clt.inputs.append( + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=glob_target_type, ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins if outp.outputBinding.outputEval and not skip_command_line2: self: CWLOutputType = [ { @@ -1387,34 +1648,45 @@ def traverse_CommandLineTool( step, etool_id, outp_id ) self_type = cwl.WorkflowInputParameter( - id=None, + id="", type_=cwl.InputArraySchema("File", "array", None, None), ) + if isinstance(outp, cwl.CommandOutputParameter): + target = parameter_to_workflow_input_paramater(outp) + else: + target = outp etool = generate_etool_from_expr( - expression, outp, False, self_type, [clt, step, parent] + expression, target, False, self_type, [clt, step, parent] ) if outp.outputBinding.loadContents: - etool.inputs[0].type_.inputBinding = cwl.CommandLineBinding( + etool.inputs[0].inputBinding = cwl.CommandLineBinding( loadContents=True ) - etool.inputs.extend(cltool_inputs_to_etool_inputs(clt)) - sub_wf_inputs = cltool_inputs_to_etool_inputs(clt) + etool.inputs = list(etool.inputs) + process_inputs_to_etool_inputs( + clt + ) + sub_wf_inputs = process_inputs_to_etool_inputs(clt) orig_step_inputs = copy.deepcopy(step.in_) for orig_step_input in orig_step_inputs: - orig_step_input.id = orig_step_input.id.split("/")[-1] - if isinstance(orig_step_input.source, MutableSequence): + if is_sequence(orig_step_input.source): + new_orig_step_input_source = list(orig_step_input.source) for index, source in enumerate(orig_step_input.source): - orig_step_input.source[index] = source.split("#")[-1] + new_orig_step_input_source[index] = source.split("#")[ + -1 + ] + orig_step_input.source = new_orig_step_input_source + elif orig_step_input.source is None: + continue else: orig_step_input.source = orig_step_input.source.split("#")[ -1 ] - orig_step_inputs[:] = [ + orig_step_inputs = [ x for x in orig_step_inputs if not x.id.startswith("_") ] - for inp in orig_step_inputs: - inp.source = inp.id - inp.linkMerge = None + for wsi in orig_step_inputs: + wsi.source = wsi.id + wsi.linkMerge = None if replace_etool: processes = [parent] final_etool: cwl.CommandLineTool | cwl.ExpressionTool = ( @@ -1433,8 +1705,8 @@ def traverse_CommandLineTool( step ) # a deepcopy would be convenient, but params2.cwl gives it problems new_clt_step.id = new_clt_step.id.split("#")[-1] - new_clt_step.run = copy.copy(step.run) - new_clt_step.run.id = None + new_clt_step.run = copy.copy(target_clt) + new_clt_step.run.id = "" remove_JSReq(new_clt_step.run, skip_command_line1) for new_outp in new_clt_step.run.outputs: if new_outp.id.split("#")[-1] == outp_id: @@ -1462,12 +1734,17 @@ def traverse_CommandLineTool( type(new_outp), ) new_clt_step.in_ = copy.deepcopy(step.in_) - for inp in new_clt_step.in_: - inp.id = inp.id.split("/")[-1] - inp.source = inp.id - inp.linkMerge = None - for index, out in enumerate(new_clt_step.out): - new_clt_step.out[index] = out.split("/")[-1] + for wsi2 in new_clt_step.in_: + wsi2.id = wsi2.id.split("/")[-1] + wsi2.source = wsi2.id + wsi2.linkMerge = None + new_clt_step_out = list(new_clt_step.out) + for index, out in enumerate(new_clt_step_out): + if isinstance(out, str): + new_clt_step_out[index] = out.split("/")[-1] + else: + out.id = out.id.split("/")[-1] + new_clt_step.out = new_clt_step_out for tool_inp in new_clt_step.run.inputs: tool_inp.id = tool_inp.id.split("#")[-1] for tool_out in new_clt_step.run.outputs: @@ -1498,24 +1775,33 @@ def traverse_CommandLineTool( if isinstance(req, cwl.SubworkflowFeatureRequirement): has_sub_wf_req = True if not has_sub_wf_req: - parent.requirements.append( - cwl.SubworkflowFeatureRequirement() - ) + new_parent_reqs = list(parent.requirements) + new_parent_reqs.append(cwl.SubworkflowFeatureRequirement()) + parent.requirements = new_parent_reqs return modified def rename_step_source(workflow: cwl.Workflow, old: str, new: str) -> None: """Update step source names to the new name.""" - def simplify_wf_id(uri: str) -> str: - return uri.split("#")[-1].split("/", 1)[1] + def simplify_wf_ids(uris: Sequence[str] | str | None) -> set[str]: + if isinstance(uris, str): + uri_seq: Sequence[str] = [uris] + elif uris is None: + return set() + else: + uri_seq = uris + return {uri.split("#")[-1].split("/", 1)[1] for uri in uri_seq} def simplify_step_id(uri: str) -> str: return uri.split("#")[-1] for wf_outp in workflow.outputs: - if wf_outp.outputSource and simplify_wf_id(wf_outp.outputSource) == old: - wf_outp.outputSource = new + simplified_wf_ids = simplify_wf_ids(wf_outp.outputSource) + if wf_outp.outputSource and old in simplified_wf_ids: + simplified_wf_ids.remove(old) + simplified_wf_ids.add(new) + wf_outp.outputSource = list(simplified_wf_ids) for step in workflow.steps: if step.in_: for inp in step.in_: @@ -1531,7 +1817,9 @@ def simplify_step_id(uri: str) -> str: else: for index, source in enumerate(inp.source): if simplify_step_id(source) == old: - inp.source[index] = new + new_inp_source = list(inp.source) + new_inp_source[index] = new + inp.source = new_inp_source def remove_JSReq( @@ -1542,7 +1830,7 @@ def remove_JSReq( if skip_command_line1 and isinstance(process, cwl.CommandLineTool): return if process.hints: - process.hints[:] = [ + process.hints = [ hint for hint in process.hints if not isinstance(hint, cwl.InlineJavascriptRequirement) @@ -1550,7 +1838,7 @@ def remove_JSReq( if not process.hints: process.hints = None if process.requirements: - process.requirements[:] = [ + process.requirements = [ req for req in process.requirements if not isinstance(req, cwl.InlineJavascriptRequirement) @@ -1563,13 +1851,14 @@ def replace_step_clt_expr_with_etool( expr: str, name: str, workflow: cwl.Workflow, - target: cwl.WorkflowInputParameter, + target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, step: cwl.WorkflowStep, replace_etool: bool, self_name: str | None = None, ) -> None: """Convert a step level CWL Expression to a sibling expression step.""" - etool_inputs = cltool_inputs_to_etool_inputs(step.run) + assert not isinstance(step.run, str) + etool_inputs = process_inputs_to_etool_inputs(step.run) temp_etool = generate_etool_from_expr2( expr, target, etool_inputs, self_name, step.run, [workflow] ) @@ -1583,8 +1872,9 @@ def replace_step_clt_expr_with_etool( wf_step_inputs = copy.deepcopy(step.in_) for wf_step_input in wf_step_inputs: wf_step_input.id = wf_step_input.id.split("/")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if not x.id.startswith("_")] - workflow.steps.append( + wf_step_inputs = [x for x in wf_step_inputs if not x.id.startswith("_")] + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -1592,9 +1882,10 @@ def replace_step_clt_expr_with_etool( run=etool, ) ) + workflow.steps = new_steps -def replace_clt_hintreq_expr_with_etool( +def replace_step_process_hintreq_expr_with_etool( expr: str, name: str, workflow: cwl.Workflow, @@ -1605,7 +1896,8 @@ def replace_clt_hintreq_expr_with_etool( ) -> cwl.CommandLineTool | cwl.ExpressionTool: """Factor out an expression inside a CommandLineTool req or hint into a sibling step.""" # Same as replace_step_clt_expr_with_etool or different? - etool_inputs = cltool_inputs_to_etool_inputs(step.run) + assert not isinstance(step.run, str) + etool_inputs = process_inputs_to_etool_inputs(step.run) temp_etool = generate_etool_from_expr2( expr, target, etool_inputs, self_name, step.run, [workflow] ) @@ -1619,8 +1911,9 @@ def replace_clt_hintreq_expr_with_etool( wf_step_inputs = copy.deepcopy(step.in_) for wf_step_input in wf_step_inputs: wf_step_input.id = wf_step_input.id.split("/")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if not x.id.startswith("_")] - workflow.steps.append( + wf_step_inputs = [x for x in wf_step_inputs if not x.id.startswith("_")] + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -1628,30 +1921,31 @@ def replace_clt_hintreq_expr_with_etool( run=etool, ) ) + workflow.steps = new_steps return etool -def cltool_inputs_to_etool_inputs( - tool: cwl.CommandLineTool, +def process_inputs_to_etool_inputs( + tool: cwl.Process, ) -> list[cwl.WorkflowInputParameter]: - """Copy CommandLineTool input objects into the equivalent ExpressionTool input objects.""" - inputs = yaml.comments.CommentedSeq() + """Copy Process input parameters to matching ExpressionTool versions.""" + inputs = [] if tool.inputs: - for clt_inp in tool.inputs: - clt_inp_id = clt_inp.id.split("#")[-1].split("/")[-1] - if not clt_inp_id.startswith("_"): + for process_inp in tool.inputs: + process_inp_id = process_inp.id.split("#")[-1].split("/")[-1] + if not process_inp_id.startswith("_"): inputs.append( cwl.WorkflowInputParameter( - id=clt_inp_id, - label=clt_inp.label, - secondaryFiles=clt_inp.secondaryFiles, - streamable=clt_inp.streamable, - doc=clt_inp.doc, - format=clt_inp.format, - default=clt_inp.default, - type_=clt_inp.type_, - extension_fields=clt_inp.extension_fields, - loadingOptions=clt_inp.loadingOptions, + id=process_inp_id, + label=process_inp.label, + secondaryFiles=process_inp.secondaryFiles, + streamable=process_inp.streamable, + doc=process_inp.doc, + format=process_inp.format, + default=process_inp.default, + type_=process_inp.type_, + extension_fields=process_inp.extension_fields, + loadingOptions=process_inp.loadingOptions, ) ) return inputs @@ -1659,17 +1953,18 @@ def cltool_inputs_to_etool_inputs( def cltool_step_outputs_to_workflow_outputs( cltool_step: cwl.WorkflowStep, etool_step_id: str, etool_out_id: str -) -> list[cwl.OutputParameter]: +) -> list[cwl.WorkflowOutputParameter]: """ Copy CommandLineTool outputs into the equivalent Workflow output parameters. Connects the outputSources for each of the new output parameters to the step they came from. """ - outputs = yaml.comments.CommentedSeq() + outputs: list[cwl.WorkflowOutputParameter] = [] if not cltool_step.id: raise WorkflowException(f"Missing step id from {cltool_step}.") default_step_id = cltool_step.id.split("#")[-1] + assert not isinstance(cltool_step.run, str) if cltool_step.run.outputs: for clt_out in cltool_step.run.outputs: clt_out_id = clt_out.id.split("#")[-1].split("/")[-1] @@ -1697,14 +1992,14 @@ def cltool_step_outputs_to_workflow_outputs( def generate_etool_from_expr2( expr: str, - target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, + target: cwl.WorkflowInputParameter | cwl.CommandInputParameter, inputs: Sequence[ cwl.WorkflowInputParameter | cwl.CommandInputParameter | cwl.CommandOutputParameter ], self_name: str | None = None, - process: cwl.CommandLineTool | cwl.ExpressionTool | None = None, + process: cwl.Process | None = None, extra_processes: None | ( Sequence[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] ) = None, @@ -1718,8 +2013,8 @@ def generate_etool_from_expr2( secondaryFiles=target.secondaryFiles, streamable=target.streamable, doc=target.doc, - format=target.format, - type_=target.type_, + format=target.format[0] if target.format else None, + type_=plain_input_schema_to_plain_output_schema(target.type_), ) ) expression = "${" @@ -1732,34 +2027,23 @@ def generate_etool_from_expr2( + """}()}; }""" ) - hints = None - procs: list[ - cwl.CommandLineTool | cwl.ExpressionTool | cwl.Workflow | cwl.WorkflowStep - ] = [] + procs: list[cwl.Process | cwl.WorkflowStep] = [] if process: procs.append(process) if extra_processes: procs.extend(extra_processes) inlineJSReq = cwl.InlineJavascriptRequirement(find_expressionLib(procs)) - reqs = [inlineJSReq] - if process: - if process.hints: - hints = copy.deepcopy(process.hints) - hints[:] = [ - x for x in hints if not isinstance(x, cwl.InitialWorkDirRequirement) - ] - if process.requirements: - reqs.extend(copy.deepcopy(process.requirements)) - reqs[:] = [ - x for x in reqs if not isinstance(x, cwl.InitialWorkDirRequirement) - ] + reqs: MutableSequence[cwl.ProcessRequirement] = [inlineJSReq] + if process and process.requirements: + reqs.extend(copy.deepcopy(process.requirements)) + reqs[:] = [x for x in reqs if not isinstance(x, cwl.InitialWorkDirRequirement)] return cwl.ExpressionTool( id="_:" + str(uuid.uuid4()), - inputs=inputs, + inputs=parameters_to_workflow_input_paramaters(inputs), outputs=outputs, expression=expression, requirements=reqs, - cwlVersion="v1.0", + cwlVersion="v1.1", ) @@ -1777,43 +2061,29 @@ def traverse_step( return False step_id = step.id.split("#")[-1] original_process = copy.deepcopy(step.run) + assert not isinstance(original_process, str) + assert not isinstance(step.run, str) original_step_ins = copy.deepcopy(step.in_) for inp in step.in_: if inp.valueFrom: if not inp.source: self = None else: - if isinstance(inp.source, MutableSequence): - self = [] - for source in inp.source: - if not step.scatter: - self.append( - example_input( - utils.type_for_source(parent, source.split("#")[-1]) - ) - ) - else: - scattered_source_type = utils.type_for_source( - parent, source - ) - if isinstance(scattered_source_type, list): - for stype in scattered_source_type: - self.append(example_input(stype.type_)) - else: - self.append(example_input(scattered_source_type.type_)) - else: + self = [] + for source in inp.source: if not step.scatter: - self = example_input( - utils.type_for_source(parent, inp.source.split("#")[-1]) + self.append( + example_input( + utils.type_for_source(parent, source.split("#")[-1]) + ) ) else: - scattered_source_type2 = utils.type_for_source( - parent, inp.source - ) - if isinstance(scattered_source_type2, list): - self = example_input(scattered_source_type2[0].type_) + scattered_source_type = utils.type_for_source(parent, source) + if is_sequence(scattered_source_type): + for stype in scattered_source_type: + self.append(example_input(stype.type_)) else: - self = example_input(scattered_source_type2.type_) + self.append(example_input(scattered_source_type.type_)) expression = get_expression(inp.valueFrom, inputs, self) if expression: modified = True @@ -1822,42 +2092,32 @@ def traverse_step( if not target: raise WorkflowException("target not found") input_source_id = None - source_type: None | ( - MutableSequence[ - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter + source_type: ( + None + | MutableSequence[ + cwl.WorkflowInputParameter | cwl.CommandOutputParameter ] - | cwl.CommandInputParameter - | cwl.CommandOutputParameter | cwl.WorkflowInputParameter + | cwl.CommandOutputParameter ) = None if inp.source: - if isinstance(inp.source, MutableSequence): - input_source_id = [] - source_types: list[cwl.WorkflowInputParameter] = [] - for source in inp.source: - source_id = source.split("#")[-1] - input_source_id.append(source_id) - temp_type = utils.type_for_source( - step.run, source_id, parent - ) - if isinstance(temp_type, list): - for ttype in temp_type: - if ttype not in source_types: - source_types.append(ttype) - else: - if temp_type not in source_types: - source_types.append(temp_type) - source_type = cwl.WorkflowInputParameter( - id=None, - type_=cwl.ArraySchema(source_types, "array"), - ) - else: - input_source_id = inp.source.split("#")[-1] - source_type = utils.param_for_source_id( - step.run, input_source_id, parent - ) + input_source_id = [] + source_types: list[BasicInputTypeSchemas] = [] + for source in inp.source: + source_id = source.split("#")[-1] + input_source_id.append(source_id) + temp_type = utils.type_for_source(step.run, source_id, parent) + if is_sequence(temp_type): + for ttype in temp_type: + if ttype not in source_types: + source_types.append(ttype) + else: + if temp_type not in source_types: + source_types.append(temp_type) + source_type = cwl.WorkflowInputParameter( + id="", + type_=cwl.InputArraySchema(source_types, "array"), + ) # target.id = target.id.split('#')[-1] if isinstance(original_process, cwl.ExpressionTool): found_JSReq = False @@ -1873,9 +2133,11 @@ def traverse_step( if not step.run.requirements: step.run.requirements = [] expr_lib = find_expressionLib([parent]) - step.run.requirements.append( + new_step_run_requirements = list(step.run.requirements) + new_step_run_requirements.append( cwl.InlineJavascriptRequirement(expr_lib) ) + step.run.requirements = new_step_run_requirements replace_step_valueFrom_expr_with_etool( expression, etool_id, @@ -1892,6 +2154,7 @@ def traverse_step( inp.valueFrom = None inp.source = f"{etool_id}/result" # TODO: skip or special process for sub workflows? + assert not isinstance(original_process, str) process_modified = process_level_reqs( original_process, step, @@ -1917,29 +2180,35 @@ def traverse_step( def workflow_step_to_WorkflowInputParameters( - step_ins: list[cwl.WorkflowStepInput], parent: cwl.Workflow, except_in_id: str -) -> MutableSequence[ - cwl.CommandInputParameter | cwl.CommandOutputParameter | cwl.WorkflowInputParameter -]: + step_ins: Sequence[cwl.WorkflowStepInput], parent: cwl.Workflow, except_in_id: str +) -> list[cwl.WorkflowInputParameter]: """Create WorkflowInputParameters to match the given WorkflowStep inputs.""" - params = [] + params: list[cwl.WorkflowInputParameter] = [] for inp in step_ins: - if not inp.id: - continue inp_id = inp.id.split("#")[-1].split("/")[-1] if inp.source and inp_id != except_in_id: param = copy.deepcopy( - utils.param_for_source_id(parent, sourcenames=inp.source) + param_for_source_id(parent, sourcenames=inp.source) ) - if isinstance(param, MutableSequence): + if is_sequence(param): for p in param: - p.id = inp_id - p.type_ = clean_type_ids(p.type_) - params.append(p) + if not p.type_: + raise WorkflowException( + f"Don't know how to get type id for {p!r}." + ) + new_param = parameter_to_workflow_input_paramater(p) + new_param.id = inp_id + new_param.type_ = clean_type_ids(new_param.type_) + params.append(new_param) else: - param.id = inp_id - param.type_ = clean_type_ids(param.type_) - params.append(param) + if not param.type_: + raise WorkflowException( + f"Don't know how to get type id for {param!r}." + ) + new_param = parameter_to_workflow_input_paramater(param) + new_param.id = inp_id + new_param.type_ = clean_type_ids(new_param.type_) + params.append(new_param) return params @@ -1950,15 +2219,15 @@ def replace_step_valueFrom_expr_with_etool( target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, step: cwl.WorkflowStep, step_inp: cwl.WorkflowStepInput, - original_process: cwl.CommandLineTool | cwl.ExpressionTool, - original_step_ins: list[cwl.WorkflowStepInput], + original_process: cwl.Process, + original_step_ins: Sequence[cwl.WorkflowStepInput], source: str | list[str] | None, replace_etool: bool, source_type: None | ( cwl.CommandInputParameter | cwl.CommandOutputParameter | cwl.WorkflowInputParameter - | MutableSequence[ + | Sequence[ cwl.CommandInputParameter | cwl.CommandOutputParameter | cwl.WorkflowInputParameter @@ -1995,22 +2264,19 @@ def replace_step_valueFrom_expr_with_etool( etool: cwl.ExpressionTool | cwl.CommandLineTool = cltool else: etool = temp_etool - wf_step_inputs = copy.deepcopy(original_step_ins) + wf_step_inputs = list(original_step_ins) if source: wf_step_inputs.append(cwl.WorkflowStepInput(id="self", source=step_inp.source)) for wf_step_input in wf_step_inputs: - if not wf_step_input.id: - continue wf_step_input.id = wf_step_input.id.split("/")[-1] if wf_step_input.valueFrom: wf_step_input.valueFrom = None if wf_step_input.source: - if isinstance(wf_step_input.source, MutableSequence): - for index, inp_source in enumerate(wf_step_input.source): - wf_step_input.source[index] = inp_source.split("#")[-1] - else: - wf_step_input.source = wf_step_input.source.split("#")[-1] - wf_step_inputs[:] = [ + new_source = list(wf_step_input.source) + for index, inp_source in enumerate(wf_step_input.source): + new_source[index] = inp_source.split("#")[-1] + wf_step_input.source = new_source + wf_step_inputs = [ x for x in wf_step_inputs if x.id and not (x.id.startswith("_") or x.id.endswith(step_inp_id)) @@ -2026,7 +2292,8 @@ def replace_step_valueFrom_expr_with_etool( # do we still need to scatter? else: scatter = None - workflow.steps.append( + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -2036,6 +2303,7 @@ def replace_step_valueFrom_expr_with_etool( scatterMethod=step.scatterMethod, ) ) + workflow.steps = new_steps def traverse_workflow( @@ -2068,7 +2336,7 @@ def traverse_workflow( if process_workflow_reqs_and_hints(workflow, replace_etool): modified = True if workflow.requirements: - workflow.requirements[:] = [ + workflow.requirements = [ x for x in workflow.requirements if not isinstance( diff --git a/src/cwl_utils/cwl_v1_2_expression_refactor.py b/src/cwl_utils/cwl_v1_2_expression_refactor.py index 1fd73d74..044ed71b 100755 --- a/src/cwl_utils/cwl_v1_2_expression_refactor.py +++ b/src/cwl_utils/cwl_v1_2_expression_refactor.py @@ -6,11 +6,13 @@ import copy import hashlib import uuid -from collections.abc import Mapping, MutableSequence, Sequence +from collections.abc import MutableSequence, Sequence from contextlib import suppress from typing import Any, cast from ruamel import yaml +from schema_salad.metaschema import ArraySchema, RecordSchema +from schema_salad.runtime import LoadingOptions, save from schema_salad.sourceline import SourceLine from schema_salad.utils import json_dumps @@ -18,6 +20,18 @@ import cwl_utils.parser.cwl_v1_2_utils as utils from cwl_utils.errors import JavascriptException, WorkflowException from cwl_utils.expression import do_eval, interpolate +from cwl_utils.parser.cwl_v1_2_utils import ( + AnyTypeSchema, + BasicCommandInputTypeSchemas, + BasicCommandOutputTypeSchemas, + BasicInputTypeSchemas, + BasicOutputTypeSchemas, + CommandInputTypeSchemas, + CommandOutputTypeSchemas, + InputTypeSchemas, + OutputTypeSchemas, +) +from cwl_utils.parser.utils import param_for_source_id from cwl_utils.types import ( CWLDirectoryType, CWLFileType, @@ -25,6 +39,8 @@ CWLOutputType, CWLParameterContext, CWLRuntimeParameterContext, + is_file_or_directory, + is_sequence, ) @@ -40,11 +56,11 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool stdout_path = process.stdout if not stdout_path: stdout_path = hashlib.sha1( # nosec - json_dumps(cwl.save(process)).encode("utf-8") + json_dumps(save(process)).encode("utf-8") ).hexdigest() result.stdout = stdout_path result.outputs[index].type_ = "File" - output.outputBinding = cwl.CommandOutputBinding(stdout_path, None, None) + output.outputBinding = cwl.CommandOutputBinding(glob=stdout_path) if result: return result return process @@ -55,33 +71,66 @@ def escape_expression_field(contents: str) -> str: return contents.replace("${", "$/{").replace("$(", "$/(") -def clean_type_ids( - cwltype: cwl.ArraySchema | cwl.InputRecordSchema, -) -> cwl.ArraySchema | cwl.InputRecordSchema: - """Simplify type identifiers.""" - result = copy.deepcopy(cwltype) - if isinstance(result, cwl.ArraySchema): - if isinstance(result.items, MutableSequence): - for item in result.items: +def _clean_type_ids( + cwltype: InputTypeSchemas | CommandOutputTypeSchemas, +) -> None: + if isinstance(cwltype, ArraySchema): + if is_sequence(cwltype.items): + for item in cwltype.items: if hasattr(item, "id"): item.id = item.id.split("#")[-1] - elif isinstance(result.items, cwl.InputRecordSchema): - if result.items.name: - result.items.name = result.items.name.split("/")[-1] - if result.items.fields: - for field in result.items.fields: + elif isinstance(cwltype.items, RecordSchema): + if ( + isinstance( + cwltype.items, + (cwl.InputRecordSchema, cwl.CommandOutputRecordSchema), + ) + and cwltype.items.name + ): + cwltype.items.name = cwltype.items.name.split("/")[-1] + if cwltype.items.fields: + for field in cwltype.items.fields: field.name = field.name.split("/")[-1] - elif isinstance(result, cwl.InputRecordSchema): - if result.name: - result.name = result.name.split("/")[-1] - if result.fields: - for field in result.fields: + elif isinstance(cwltype, RecordSchema): + if cwltype.name: + cwltype.name = cwltype.name.split("/")[-1] + if cwltype.fields: + for field in cwltype.fields: field.name = field.name.split("/")[-1] + + +def clean_type_ids( + cwltype: AnyTypeSchema, +) -> AnyTypeSchema: + """Simplify type identifiers.""" + result = copy.deepcopy(cwltype) + if is_sequence(result): + for item in result: + _clean_type_ids(item) + else: + _clean_type_ids(result) return result +def _has_expression(string: str) -> bool: + if "${" in string: + return True + if "$(" in string: + return True + return False + + +def has_expression(field: str | Sequence[str]) -> bool: + if is_sequence(field): + for entry in field: + if _has_expression(entry): + return True + return False + return _has_expression(field) + + def get_expression( - string: str, inputs: CWLObjectType, self: CWLOutputType | None + string: Any, inputs: CWLObjectType, self: CWLOutputType | None ) -> str | None: """ Find and return a normalized CWL expression, if any. @@ -136,6 +185,178 @@ def get_expression( return None +def _plain_input_schema_to_clt_input_schema( + input_type: BasicInputTypeSchemas, +) -> BasicCommandInputTypeSchemas: + match input_type: + case cwl.InputArraySchema(): + return cwl.CommandInputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputEnumSchema(): + return cwl.CommandInputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputRecordSchema(): + return cwl.CommandInputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_input_schema_to_clt_input_schema( + input_type: InputTypeSchemas, +) -> CommandInputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_input_schema_to_clt_input_schema(input_type_item) + for input_type_item in input_type + ] + return _plain_input_schema_to_clt_input_schema(input_type) + + +def _plain_input_schema_to_plain_output_schema( + input_type: BasicInputTypeSchemas, +) -> BasicOutputTypeSchemas: + match input_type: + case cwl.InputArraySchema(): + return cwl.OutputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputEnumSchema(): + return cwl.OutputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.InputRecordSchema(): + return cwl.OutputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_input_schema_to_plain_output_schema( + input_type: InputTypeSchemas, +) -> OutputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_input_schema_to_plain_output_schema(input_type_item) + for input_type_item in input_type + ] + return _plain_input_schema_to_plain_output_schema(input_type) + + +def _plain_output_schema_to_plain_input_schema( + input_type: BasicOutputTypeSchemas, +) -> BasicInputTypeSchemas: + match input_type: + case cwl.OutputArraySchema(): + return cwl.InputArraySchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.OutputEnumSchema(): + return cwl.InputEnumSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case cwl.OutputRecordSchema(): + return cwl.InputRecordSchema.fromDoc( + input_type.save(), + input_type.loadingOptions.baseuri, + input_type.loadingOptions, + ) + case str(): + return input_type + raise WorkflowException(f"Unexpected ExpressionTool input type: {input_type}.") + + +def plain_output_schema_to_plain_input_schema( + input_type: OutputTypeSchemas, +) -> InputTypeSchemas: + if is_sequence(input_type): + return [ + _plain_output_schema_to_plain_input_schema(input_type_item) + for input_type_item in input_type + ] + return _plain_output_schema_to_plain_input_schema(input_type) + + +def _plain_output_type_to_clt_output_type( + output_type: BasicOutputTypeSchemas, +) -> BasicCommandOutputTypeSchemas: + match output_type: + case cwl.OutputArraySchema(): + return cwl.CommandOutputArraySchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case cwl.OutputEnumSchema(): + return cwl.CommandOutputEnumSchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case cwl.OutputRecordSchema(): + return cwl.CommandOutputRecordSchema.fromDoc( + output_type.save(), + output_type.loadingOptions.baseuri, + output_type.loadingOptions, + ) + case str(): + return output_type + raise WorkflowException(f"Unexpected ExpressionTool output type: {output_type}.") + + +def plain_output_type_to_clt_output_type( + output_type: OutputTypeSchemas, +) -> CommandOutputTypeSchemas: + if is_sequence(output_type): + return [ + _plain_output_type_to_clt_output_type(output_type_item) + for output_type_item in output_type + ] + return _plain_output_type_to_clt_output_type(output_type) + + +def parameter_to_workflow_input_paramater( + parameter: cwl.InputParameter | cwl.OutputParameter, +) -> cwl.WorkflowInputParameter: + return cwl.WorkflowInputParameter.fromDoc( + parameter.save(), parameter.loadingOptions.baseuri, parameter.loadingOptions + ) + + +def parameters_to_workflow_input_paramaters( + parameters: Sequence[ + cwl.WorkflowInputParameter + | cwl.CommandInputParameter + | cwl.CommandOutputParameter + ], +) -> Sequence[cwl.WorkflowInputParameter]: + return [ + parameter_to_workflow_input_paramater(parameter) for parameter in parameters + ] + + def etool_to_cltool( etool: cwl.ExpressionTool, expressionLib: list[str] | None = None ) -> cwl.CommandLineTool: @@ -151,7 +372,7 @@ def etool_to_cltool( doc=inp.doc, format=inp.format, default=inp.default, - type_=inp.type_, + type_=plain_input_schema_to_clt_input_schema(inp.type_), extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -166,7 +387,7 @@ def etool_to_cltool( streamable=outp.streamable, doc=outp.doc, format=outp.format, - type_=outp.type_, + type_=plain_output_type_to_clt_output_type(outp.type_), extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -326,53 +547,52 @@ def generate_etool_from_expr( self_type: None | ( cwl.WorkflowInputParameter | cwl.CommandInputParameter - | list[cwl.WorkflowInputParameter | cwl.CommandInputParameter] + | Sequence[cwl.WorkflowInputParameter | cwl.CommandInputParameter] ) = None, # if the "self" input should be a different type than the "result" output - extra_processes: None | ( - Sequence[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] - ) = None, + extra_processes: Sequence[cwl.Process | cwl.WorkflowStep] | None = None, ) -> cwl.ExpressionTool: """Convert a CWL Expression into an ExpressionTool.""" - inputs = yaml.comments.CommentedSeq() + inputs: list[cwl.WorkflowInputParameter] = [] if not no_inputs: - if not self_type: + if self_type is None: self_type = target - if isinstance(self_type, list): - new_type: ( - list[cwl.ArraySchema | cwl.InputRecordSchema] - | cwl.ArraySchema - | cwl.InputRecordSchema - ) = [clean_type_ids(t.type_) for t in self_type] + assert self_type is not None + new_type: InputTypeSchemas + if is_sequence(self_type): + new_type_list: MutableSequence[BasicInputTypeSchemas] = [] + for entry in self_type: + clean_type = clean_type_ids(entry.type_) + if is_sequence(clean_type): + new_type_list.extend(clean_type) + elif clean_type is None: + pass + else: + new_type_list.append(clean_type) + new_type = new_type_list else: new_type = clean_type_ids(self_type.type_) inputs.append( cwl.WorkflowInputParameter( id="self", - label=self_type.label if not isinstance(self_type, list) else None, + label=self_type.label if not is_sequence(self_type) else None, secondaryFiles=( - self_type.secondaryFiles - if not isinstance(self_type, list) - else None + self_type.secondaryFiles if not is_sequence(self_type) else None ), streamable=( - self_type.streamable if not isinstance(self_type, list) else None + self_type.streamable if not is_sequence(self_type) else None ), - doc=self_type.doc if not isinstance(self_type, list) else None, - format=self_type.format if not isinstance(self_type, list) else None, + doc=self_type.doc if not is_sequence(self_type) else None, + format=(self_type.format if not is_sequence(self_type) else None), type_=new_type, extension_fields=( - self_type.extension_fields - if not isinstance(self_type, list) - else None + self_type.extension_fields if not is_sequence(self_type) else None ), loadingOptions=( - self_type.loadingOptions - if not isinstance(self_type, list) - else None + self_type.loadingOptions if not is_sequence(self_type) else None ), ) ) - outputs = yaml.comments.CommentedSeq() + outputs: list[cwl.ExpressionToolOutputParameter] = [] outputs.append( cwl.ExpressionToolOutputParameter( id="result", @@ -380,8 +600,8 @@ def generate_etool_from_expr( secondaryFiles=target.secondaryFiles, streamable=target.streamable, doc=target.doc, - format=target.format, - type_=target.type_, + format=target.format[0] if target.format else None, + type_=plain_input_schema_to_plain_output_schema(target.type_), extension_fields=target.extension_fields, loadingOptions=target.loadingOptions, ) @@ -405,23 +625,27 @@ def generate_etool_from_expr( outputs=outputs, expression=expression, requirements=[inlineJSReq], - cwlVersion="v1.0", + cwlVersion="v1.2", ) def get_input_for_id( - name: str, tool: cwl.CommandLineTool | cwl.Workflow + name: str, + tool: cwl.Process, ) -> cwl.CommandInputParameter | None: """Determine the CommandInputParameter for the given input name.""" name = name.split("/")[-1] for inp in cast(list[cwl.CommandInputParameter], tool.inputs): if inp.id and inp.id.split("#")[-1].split("/")[-1] == name: - return inp + return cwl.CommandInputParameter.fromDoc( + inp.save(), inp.loadingOptions.baseuri, inp.loadingOptions + ) if isinstance(tool, cwl.Workflow) and "/" in name: stepname, stem = name.split("/", 1) for step in tool.steps: if step.id == stepname: + assert not isinstance(step.run, str) result = get_input_for_id(stem, step.run) if result: return result @@ -429,9 +653,7 @@ def get_input_for_id( def find_expressionLib( - processes: Sequence[ - cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool | cwl.WorkflowStep - ], + processes: Sequence[cwl.Process | cwl.WorkflowStep], ) -> list[str] | None: """ Return the expressionLib from the highest priority InlineJavascriptRequirement. @@ -452,26 +674,20 @@ def replace_expr_with_etool( name: str, workflow: cwl.Workflow, target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, - source: str | list[Any] | None, + source: str | Sequence[Any] | None, replace_etool: bool = False, - extra_process: None | ( - cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool - ) = None, + extra_process: cwl.Process | cwl.WorkflowStep | None = None, source_type: cwl.CommandInputParameter | None = None, ) -> None: """Modify the given workflow, replacing the expr with an standalone ExpressionTool.""" - extra_processes: list[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] = [ - workflow - ] + extra_processes: list[cwl.Process | cwl.WorkflowStep] = [workflow] if extra_process: extra_processes.append(extra_process) etool: cwl.ExpressionTool = generate_etool_from_expr( expr, target, source is None, source_type, extra_processes ) if replace_etool: - processes: list[cwl.WorkflowStep | cwl.Workflow | cwl.CommandLineTool] = [ - workflow - ] + processes: list[cwl.Process | cwl.WorkflowStep] = [workflow] if extra_process: processes.append(extra_process) final_tool: cwl.ExpressionTool | cwl.CommandLineTool = etool_to_cltool( @@ -482,14 +698,16 @@ def replace_expr_with_etool( inps = [] if source: inps.append(cwl.WorkflowStepInput(id="self", source=source)) - workflow.steps.append( + new_steps: list[cwl.WorkflowStep] = [ cwl.WorkflowStep( id=name, in_=inps, out=[cwl.WorkflowStepOutput("result")], run=final_tool, ) - ) + ] + new_steps.extend(workflow.steps) + workflow.steps = new_steps def replace_wf_input_ref_with_step_output( @@ -519,27 +737,28 @@ def replace_wf_input_ref_with_step_output( def empty_inputs( - process_or_step: ( - cwl.CommandLineTool | cwl.WorkflowStep | cwl.ExpressionTool | cwl.Workflow - ), + process_or_step: cwl.Process | cwl.WorkflowStep, parent: cwl.Workflow | None = None, ) -> dict[str, Any]: """Produce a mock input object for the given inputs.""" result = {} if isinstance(process_or_step, cwl.Process): - for param in process_or_step.inputs: - result[param.id.split("#")[-1]] = example_input(param.type_) + for param1 in process_or_step.inputs: + result[param1.id.split("#")[-1]] = example_input(param1.type_) else: - for param in process_or_step.in_: - param_id = param.id.split("/")[-1] - if param.source is None and param.valueFrom: - result[param_id] = example_input("string") - elif param.source is None and param.default: - result[param_id] = param.default - else: + for param2 in process_or_step.in_: + param2_id = param2.id.split("/")[-1] + if param2.source is None and param2.valueFrom: + result[param2_id] = example_input("string") + elif param2.source is None and param2.default: + result[param2_id] = param2.default + elif param2.source is not None: with suppress(WorkflowException): - result[param_id] = example_input( - utils.type_for_source(process_or_step.run, param.source, parent) + assert not isinstance(process_or_step.run, str) + result[param2_id] = example_input( + utils.type_for_source( + process_or_step.run, param2.source, parent + ) ) return result @@ -660,18 +879,17 @@ def process_workflow_inputs_and_outputs( ) -> bool: """Do any needed conversions on the given Workflow's inputs and outputs.""" modified = False - inputs = empty_inputs(workflow) for index, param in enumerate(workflow.inputs): with SourceLine(workflow.inputs, index, WorkflowException): - if param.format and get_expression(param.format, inputs, None): + if param.format is not None and has_expression(param.format): raise SourceLine( param.loadingOptions.original_doc, "format", raise_type=WorkflowException, ).makeError(TOPLEVEL_FORMAT_EXPR_ERROR.format(param.id.split("#")[-1])) if param.secondaryFiles: - if hasattr(param.secondaryFiles, "pattern") and get_expression( - param.secondaryFiles.pattern, inputs, EMPTY_FILE + if hasattr(param.secondaryFiles, "pattern") and has_expression( + param.secondaryFiles.pattern ): raise SourceLine( param.loadingOptions.original_doc, @@ -680,7 +898,7 @@ def process_workflow_inputs_and_outputs( ).makeError(TOPLEVEL_SF_EXPR_ERROR.format(param.id.split("#")[-1])) elif isinstance(param.secondaryFiles, MutableSequence): for index2, entry in enumerate(param.secondaryFiles): - if get_expression(entry.pattern, inputs, EMPTY_FILE): + if has_expression(entry.pattern): raise SourceLine( param.loadingOptions.original_doc, index2, @@ -709,26 +927,36 @@ def process_workflow_inputs_and_outputs( target_type = copy.deepcopy(param2.type_) if isinstance(target_type, cwl.OutputArraySchema): target_type.name = "" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) - if not isinstance(param2.outputSource, list): + target = cwl.WorkflowInputParameter( + id="", type_=plain_output_schema_to_plain_input_schema(target_type) + ) + assert param2.outputSource is not None + if not is_sequence(param2.outputSource): sources = param2.outputSource.split("#")[-1] else: sources = [s.split("#")[-1] for s in param2.outputSource] source_type_items = utils.type_for_source(workflow, sources) - if isinstance(source_type_items, cwl.ArraySchema): - if isinstance(source_type_items.items, list): + if isinstance(source_type_items, ArraySchema): + if is_sequence(source_type_items.items): if "null" not in source_type_items.items: - source_type_items.items.append("null") + new_source_type_items_items = list(source_type_items.items) + new_source_type_items_items.append("null") + source_type_items.items = new_source_type_items_items elif source_type_items.items != "null": source_type_items.items = ["null", source_type_items.items] - elif isinstance(source_type_items, list): + source_type_items = cwl.CommandInputArraySchema.fromDoc( + source_type_items.save(), + source_type_items.loadingOptions.baseuri, + source_type_items.loadingOptions, + ) + elif is_sequence(source_type_items): if "null" not in source_type_items: - source_type_items.append("null") + new_source_type_items = list(source_type_items) + new_source_type_items.append("null") + source_type_items = new_source_type_items elif source_type_items != "null": source_type_items = ["null", source_type_items] - source_type = cwl.CommandInputParameter( - id=None, type_=source_type_items - ) + source_type = cwl.CommandInputParameter(id="", type_=source_type_items) replace_expr_with_etool( expression, etool_id, @@ -786,7 +1014,7 @@ def process_workflow_reqs_and_hints( if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_="string", ) etool_id = ( @@ -807,7 +1035,9 @@ def process_workflow_reqs_and_hints( prop_reqs += (cwl.EnvVarRequirement,) newEnvDef = copy.deepcopy(envDef) newEnvDef.envValue = f"$(inputs._envDef{index})" - envVarReq.envDef[index] = newEnvDef + new_envDef = list(envVarReq.envDef) + new_envDef[index] = newEnvDef + envVarReq.envDef = new_envDef generated_envVar_reqs.append((etool_id, index)) case cwl.ResourceRequirement(): for attr in cwl.ResourceRequirement.attrs: @@ -816,9 +1046,7 @@ def process_workflow_reqs_and_hints( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter( - id=None, type_="long" - ) + target = cwl.WorkflowInputParameter(id="", type_="long") etool_id = "_expression_workflow_ResourceRequirement_{}".format( attr ) @@ -843,7 +1071,7 @@ def process_workflow_reqs_and_hints( if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), @@ -864,18 +1092,18 @@ def process_workflow_reqs_and_hints( prop_reqs += (cwl.InitialWorkDirRequirement,) else: iwdr = copy.deepcopy(req) - for index, entry in enumerate(req.listing): - expression = get_expression(entry, inputs, None) + for index1, entry1 in enumerate(req.listing): + expression = get_expression(entry1, inputs, None) if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index + index1 ) replace_expr_with_etool( expression, @@ -885,17 +1113,19 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = f"$(inputs._iwdr_listing_{index}" - generated_iwdr_reqs.append((etool_id, index)) - elif isinstance(entry, cwl.Dirent): - if entry.entry: + new_listing = list(iwdr.listing) + new_listing[index1] = f"$(inputs._iwdr_listing_{index1}" + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) + elif isinstance(entry1, cwl.Dirent): + if entry1.entry: expression = get_expression( - entry.entry, inputs, None + entry1.entry, inputs, None ) if expression: expr: str = expression expr_result = do_eval( - ex=entry.entry, + ex=entry1.entry, jobinput=inputs, requirements=[], outdir="", @@ -903,16 +1133,9 @@ def process_workflow_reqs_and_hints( resources={}, ) modified = True - if ( - isinstance(expr_result, Mapping) - and "class" in expr_result - and ( - expr_result["class"] - in ("File", "Directory") - ) - ): + if is_file_or_directory(expr_result): target = cwl.WorkflowInputParameter( - id=None, + id="", type_=expr_result["class"], ) replace_expr_with_etool( @@ -923,38 +1146,38 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - "$(inputs._iwdr_listing_{}".format( - index - ) + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) + iwdr.listing = new_listing generated_iwdr_reqs.append( - (etool_id, index) + (etool_id, index1) ) elif isinstance(expr_result, str): target = cwl.WorkflowInputParameter( - id=None, + id="", type_=["File"], ) - if entry.entryname is None: + if entry1.entryname is None: raise SourceLine( - entry.loadingOptions.original_doc, - index, + entry1.loadingOptions.original_doc, + index1, raise_type=WorkflowException, ).makeError( - f"Entry {index}," + f"Entry {index1}," + "Invalid CWL, if 'entry' " "is a string, then entryName must be specified." ) expr = ( '${return {"class": "File", "basename": "' - + entry.entryname + + entry1.entryname + '", "contents": (function(){' + expr[2:-1] + "})() }; }" ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index + index1 ) replace_expr_with_etool( expr, @@ -964,24 +1187,24 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - f"$(inputs._iwdr_listing_{index}" + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) - generated_iwdr_reqs.append((etool_id, index)) + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) - elif entry.entryname: + elif entry1.entryname: expression = get_expression( - entry.entryname, inputs, None + entry1.entryname, inputs, None ) if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_="string", ) - etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( - index - ) + etool_id = f"_expression_workflow_InitialWorkDirRequirement_{index1}" replace_expr_with_etool( expression, etool_id, @@ -990,10 +1213,12 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - iwdr.listing[index] = ( - f"$(inputs._iwdr_listing_{index}" + new_listing = list(iwdr.listing) + new_listing[index1] = ( + f"$(inputs._iwdr_listing_{index1}" ) - generated_iwdr_reqs.append((etool_id, index)) + iwdr.listing = new_listing + generated_iwdr_reqs.append((etool_id, index1)) if generated_iwdr_reqs: prop_reqs += (cwl.InitialWorkDirRequirement,) else: @@ -1008,14 +1233,18 @@ def process_workflow_reqs_and_hints( continue else: step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(envVarReq) - for entry in generated_envVar_reqs: - step.in_.append( + new_requirements = list(step.requirements) + new_requirements.append(envVarReq) + step.requirements = new_requirements + new_ins = list(step.in_) + for entry2 in generated_envVar_reqs: + new_ins.append( cwl.WorkflowStepInput( - id=f"_envDef{entry[1]}", - source=f"{entry[0]}/result", + id=f"_envDef{entry2[1]}", + source=f"{entry2[0]}/result", ) ) + step.in_ = new_ins if resourceReq and workflow.steps: for step in workflow.steps: @@ -1026,15 +1255,19 @@ def process_workflow_reqs_and_hints( if isinstance(req, cwl.ResourceRequirement): continue else: - step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(resourceReq) - for entry in generated_res_reqs: - step.in_.append( + step.requirements = [] + new_requirements = list(step.requirements) + new_requirements.append(resourceReq) + step.requirements = new_requirements + new_ins = list(step.in_) + for entry3 in generated_res_reqs: + new_ins.append( cwl.WorkflowStepInput( - id=f"_{entry[1]}", - source=f"{entry[0]}/result", + id=f"_{entry3[1]}", + source=f"{entry3[0]}/result", ) ) + step.in_ = new_ins if iwdr and workflow.steps: for step in workflow.steps: @@ -1046,32 +1279,37 @@ def process_workflow_reqs_and_hints( continue else: step.requirements = yaml.comments.CommentedSeq() - step.requirements.append(iwdr) + new_requirements = list(step.requirements) + new_requirements.append(resourceReq) + new_requirements.append(iwdr) + step.requirements = new_requirements + new_ins = list(step.in_) if generated_iwdr_reqs: - for entry in generated_iwdr_reqs: - step.in_.append( + for entry4 in generated_iwdr_reqs: + new_ins.append( cwl.WorkflowStepInput( id=f"_iwdr_listing_{index}", - source=f"{entry[0]}/result", + source=f"{entry4[0]}/result", ) ) else: - step.in_.append( + new_ins.append( cwl.WorkflowStepInput( id="_iwdr_listing", source="_expression_workflow_InitialWorkDirRequirement/result", ) ) + step.in_ = new_ins if workflow.requirements: - workflow.requirements[:] = [ + workflow.requirements = [ x for x in workflow.requirements if not isinstance(x, prop_reqs) ] return modified def process_level_reqs( - process: cwl.CommandLineTool, + process: cwl.Process, step: cwl.WorkflowStep, parent: cwl.Workflow, replace_etool: bool, @@ -1091,6 +1329,7 @@ def process_level_reqs( if not process.requirements: return False modified = False + assert not isinstance(step.run, str) target_process = step.run inputs = empty_inputs(process) generated_res_reqs: list[tuple[str, str]] = [] @@ -1100,6 +1339,7 @@ def process_level_reqs( return False step_name = step.id.split("#", 1)[-1] for req_index, req in enumerate(process.requirements): + assert target_process.requirements is not None match req: case cwl.EnvVarRequirement() if req.envDef: for env_index, envDef in enumerate(req.envDef): @@ -1107,7 +1347,7 @@ def process_level_reqs( expression = get_expression(envDef.envValue, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type_="string") + target = cwl.WorkflowInputParameter(id="", type_="string") etool_id = "_expression_{}_EnvVarRequirement_{}".format( step_name, env_index ) @@ -1120,7 +1360,10 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index][ + cast( + cwl.EnvVarRequirement, + target_process.requirements[req_index], + ).envDef[ env_index ].envValue = f"$(inputs._envDef{env_index})" generated_envVar_reqs.append((etool_id, env_index)) @@ -1131,11 +1374,11 @@ def process_level_reqs( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type_="long") + target = cwl.WorkflowInputParameter(id="", type_="long") etool_id = "_expression_{}_ResourceRequirement_{}".format( step_name, attr ) - replace_clt_hintreq_expr_with_etool( + replace_step_process_hintreq_expr_with_etool( expression, etool_id, parent, @@ -1160,7 +1403,7 @@ def process_level_reqs( target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) etool_id = "_expression_{}_InitialWorkDirRequirement".format( step_name ) @@ -1173,15 +1416,18 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing = ( - "$(inputs._iwdr_listing)", - ) - step.in_.append( + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing = ("$(inputs._iwdr_listing)",) + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput( id="_iwdr_listing", source=f"{etool_id}/result", ) ) + step.in_ = new_step_ins add_input_to_process( target_process, "_iwdr_listing", @@ -1189,15 +1435,15 @@ def process_level_reqs( process.loadingOptions, ) else: - for listing_index, entry in enumerate(req.listing): - expression = get_expression(entry, inputs, None) + for listing_index, entry5 in enumerate(req.listing): + expression = get_expression(entry5, inputs, None) if expression: modified = True target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) target = cwl.WorkflowInputParameter( - id=None, + id="", type_=target_type, ) etool_id = ( @@ -1214,31 +1460,41 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing[ - listing_index - ] = f"$(inputs._iwdr_listing_{listing_index}" + new_iwdr_listing = list( + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing + ) + new_iwdr_listing[listing_index] = ( + f"$(inputs._iwdr_listing_{listing_index}" + ) + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing = new_iwdr_listing generated_iwdr_reqs.append( (etool_id, listing_index, target_type) ) - elif isinstance(entry, cwl.Dirent): - if entry.entry: - expression = get_expression(entry.entry, inputs, None) + elif isinstance(entry5, cwl.Dirent): + if entry5.entry: + expression = get_expression(entry5.entry, inputs, None) if expression: modified = True - if entry.entryname is not None: + if entry5.entryname is not None: entryname_expr = get_expression( - entry.entryname, inputs, None + entry5.entryname, inputs, None ) entryname = ( - entry.entryname + entry5.entryname if entryname_expr - else f'"{entry.entryname}"' # noqa: B907 + else f'"{entry5.entryname}"' # noqa: B907 ) new_expression = ( "${var result; var entryname = " + entryname + "; var entry = " - + entry.entry[2:-1] + + entry5.entry[2:-1] + """; if (typeof entry === 'string' || entry instanceof String) { result = {"class": "File", "basename": entryname, "contents": entry} ; @@ -1254,14 +1510,14 @@ def process_level_reqs( new_expression = expression d_target_type = ["File", "Directory"] target = cwl.WorkflowInputParameter( - id=None, + id="", type_=d_target_type, ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index ) - replace_clt_hintreq_expr_with_etool( + replace_step_process_hintreq_expr_with_etool( new_expression, etool_id, parent, @@ -1269,22 +1525,26 @@ def process_level_reqs( step, replace_etool, ) - target_process.requirements[req_index].listing[ - listing_index - ].entry = "$(inputs._iwdr_listing_{})".format( + cast( + cwl.Dirent, + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing[listing_index], + ).entry = "$(inputs._iwdr_listing_{})".format( listing_index ) generated_iwdr_reqs.append( (etool_id, listing_index, d_target_type) ) - elif entry.entryname: + elif entry5.entryname: expression = get_expression( - entry.entryname, inputs, None + entry5.entryname, inputs, None ) if expression: modified = True target = cwl.WorkflowInputParameter( - id=None, + id="", type_="string", ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( @@ -1299,41 +1559,57 @@ def process_level_reqs( replace_etool, process, ) - target_process.requirements[req_index].listing[ - listing_index - ].entryname = "$(inputs._iwdr_listing_{})".format( + cast( + cwl.Dirent, + cast( + cwl.InitialWorkDirRequirement, + target_process.requirements[req_index], + ).listing[listing_index], + ).entryname = "$(inputs._iwdr_listing_{})".format( listing_index ) generated_iwdr_reqs.append( (etool_id, listing_index, "string") ) - for entry in generated_envVar_reqs: - name = f"_envDef{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) + new_step_ins = list(step.in_) + for env_entry in generated_envVar_reqs: + name = f"_envDef{env_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{env_entry[0]}/result") + ) add_input_to_process(target_process, name, "string", process.loadingOptions) - for entry in generated_res_reqs: - name = f"_{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) + for res_entry in generated_res_reqs: + name = f"_{res_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{res_entry[0]}/result") + ) add_input_to_process(target_process, name, "long", process.loadingOptions) - for entry in generated_iwdr_reqs: - name = f"_iwdr_listing_{entry[1]}" - step.in_.append(cwl.WorkflowStepInput(id=name, source=f"{entry[0]}/result")) - add_input_to_process(target_process, name, entry[2], process.loadingOptions) + for iwdr_entry in generated_iwdr_reqs: + name = f"_iwdr_listing_{iwdr_entry[1]}" + new_step_ins.append( + cwl.WorkflowStepInput(id=name, source=f"{iwdr_entry[0]}/result") + ) + add_input_to_process( + target_process, name, iwdr_entry[2], process.loadingOptions + ) + step.in_ = new_step_ins return modified def add_input_to_process( - process: cwl.Process, name: str, inptype: Any, loadingOptions: cwl.LoadingOptions + process: cwl.Process, name: str, inptype: Any, loadingOptions: LoadingOptions ) -> None: """Add a new InputParameter to the given CommandLineTool.""" if isinstance(process, cwl.CommandLineTool): - process.inputs.append( + new_process_inputs = list(process.inputs) + new_process_inputs.append( cwl.CommandInputParameter( id=name, type_=inptype, loadingOptions=loadingOptions, ) ) + process.inputs = new_process_inputs def traverse_CommandLineTool( @@ -1347,7 +1623,7 @@ def traverse_CommandLineTool( """Extract any CWL Expressions within the given CommandLineTool into sibling steps.""" modified = False # don't modify clt, modify step.run - target_clt = step.run + target_clt = cast(cwl.CommandLineTool, step.run) inputs = empty_inputs(clt) if not step.id: return False @@ -1361,24 +1637,28 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) - target_clt.arguments[index] = cwl.CommandLineBinding( + new_target_clt_arguments = list(target_clt.arguments or []) + new_target_clt_arguments[index] = cwl.CommandLineBinding( valueFrom=f"$(inputs.{inp_id})" ) - target_clt.inputs.append( + target_clt.arguments = new_target_clt_arguments + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=target_type, ) ) - step.in_.append( - cwl.WorkflowStepInput( - f"{etool_id}/result", None, inp_id, None, None - ) + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( + cwl.WorkflowStepInput(id=f"{etool_id}/result", source=inp_id) ) + step.in_ = new_step_ins remove_JSReq(target_clt, skip_command_line1) elif isinstance(arg, cwl.CommandLineBinding) and arg.valueFrom: expression = get_expression(arg.valueFrom, inputs, None) @@ -1387,22 +1667,28 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) - target_clt.arguments[index].valueFrom = "$(inputs.{})".format( - inp_id + new_target_clt_arguments = list(target_clt.arguments or []) + new_target_clt_arguments[index] = cwl.CommandLineBinding( + valueFrom=f"$(inputs.{inp_id})" ) - target_clt.inputs.append( + target_clt.arguments = new_target_clt_arguments + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=target_type, ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins remove_JSReq(target_clt, skip_command_line1) for streamtype in "stdout", "stderr": # add 'stdin' for v1.1 version stream_value = getattr(clt, streamtype) @@ -1413,17 +1699,21 @@ def traverse_CommandLineTool( inp_id = f"_{streamtype}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "string" - target = cwl.WorkflowInputParameter(id=None, type_=target_type) + target = cwl.WorkflowInputParameter(id="", type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) setattr(target_clt, streamtype, f"$(inputs.{inp_id})") - target_clt.inputs.append( + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter(id=inp_id, type_=target_type) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins for inp in clt.inputs: if not skip_command_line1 and inp.inputBinding and inp.inputBinding.valueFrom: expression = get_expression( @@ -1438,12 +1728,19 @@ def traverse_CommandLineTool( expression, etool_id, parent, inp, step, replace_etool, self_id ) inp.inputBinding.valueFrom = f"$(inputs.{inp_id})" - target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type_=inp.type_) + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( + cwl.CommandInputParameter( + id=inp_id, + type_=plain_input_schema_to_clt_input_schema(inp.type_), + ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins for outp in clt.outputs: if outp.outputBinding: if outp.outputBinding.glob: @@ -1452,21 +1749,28 @@ def traverse_CommandLineTool( modified = True inp_id = "_{}_glob".format(outp.id.split("#")[-1]) etool_id = f"_expression_{step_id}{inp_id}" - glob_target_type = ["string", cwl.ArraySchema("string", "array")] - target = cwl.WorkflowInputParameter(id=None, type_=glob_target_type) + glob_target_type: CommandInputTypeSchemas = [ + "string", + cwl.CommandInputArraySchema("string", "array"), + ] + target = cwl.WorkflowInputParameter(id="", type_=glob_target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) outp.outputBinding.glob = f"$(inputs.{inp_id})" - target_clt.inputs.append( + new_target_clt_inputs = list(target_clt.inputs) + new_target_clt_inputs.append( cwl.CommandInputParameter( id=inp_id, type_=glob_target_type, ) ) - step.in_.append( + target_clt.inputs = new_target_clt_inputs + new_step_ins = list(step.in_) + new_step_ins.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") ) + step.in_ = new_step_ins if outp.outputBinding.outputEval and not skip_command_line2: self: CWLOutputType = [ { @@ -1490,34 +1794,45 @@ def traverse_CommandLineTool( step, etool_id, outp_id ) self_type = cwl.WorkflowInputParameter( - id=None, + id="", type_=cwl.InputArraySchema("File", "array", None, None), ) + if isinstance(outp, cwl.CommandOutputParameter): + target = parameter_to_workflow_input_paramater(outp) + else: + target = outp etool = generate_etool_from_expr( - expression, outp, False, self_type, [clt, step, parent] + expression, target, False, self_type, [clt, step, parent] ) if outp.outputBinding.loadContents: - etool.inputs[0].type_.inputBinding = cwl.CommandLineBinding( + etool.inputs[0].inputBinding = cwl.CommandLineBinding( loadContents=True ) - etool.inputs.extend(cltool_inputs_to_etool_inputs(clt)) - sub_wf_inputs = cltool_inputs_to_etool_inputs(clt) + etool.inputs = list(etool.inputs) + process_inputs_to_etool_inputs( + clt + ) + sub_wf_inputs = process_inputs_to_etool_inputs(clt) orig_step_inputs = copy.deepcopy(step.in_) for orig_step_input in orig_step_inputs: - orig_step_input.id = orig_step_input.id.split("/")[-1] - if isinstance(orig_step_input.source, MutableSequence): + if is_sequence(orig_step_input.source): + new_orig_step_input_source = list(orig_step_input.source) for index, source in enumerate(orig_step_input.source): - orig_step_input.source[index] = source.split("#")[-1] + new_orig_step_input_source[index] = source.split("#")[ + -1 + ] + orig_step_input.source = new_orig_step_input_source + elif orig_step_input.source is None: + continue else: orig_step_input.source = orig_step_input.source.split("#")[ -1 ] - orig_step_inputs[:] = [ + orig_step_inputs = [ x for x in orig_step_inputs if not x.id.startswith("_") ] - for inp in orig_step_inputs: - inp.source = inp.id - inp.linkMerge = None + for wsi in orig_step_inputs: + wsi.source = wsi.id + wsi.linkMerge = None if replace_etool: processes = [parent] final_etool: cwl.CommandLineTool | cwl.ExpressionTool = ( @@ -1536,8 +1851,8 @@ def traverse_CommandLineTool( step ) # a deepcopy would be convenient, but params2.cwl gives it problems new_clt_step.id = new_clt_step.id.split("#")[-1] - new_clt_step.run = copy.copy(step.run) - new_clt_step.run.id = None + new_clt_step.run = copy.copy(target_clt) + new_clt_step.run.id = "" remove_JSReq(new_clt_step.run, skip_command_line1) for new_outp in new_clt_step.run.outputs: if new_outp.id.split("#")[-1] == outp_id: @@ -1565,12 +1880,17 @@ def traverse_CommandLineTool( type(new_outp), ) new_clt_step.in_ = copy.deepcopy(step.in_) - for inp in new_clt_step.in_: - inp.id = inp.id.split("/")[-1] - inp.source = inp.id - inp.linkMerge = None - for index, out in enumerate(new_clt_step.out): - new_clt_step.out[index] = out.split("/")[-1] + for wsi2 in new_clt_step.in_: + wsi2.id = wsi2.id.split("/")[-1] + wsi2.source = wsi2.id + wsi2.linkMerge = None + new_clt_step_out = list(new_clt_step.out) + for index, out in enumerate(new_clt_step_out): + if isinstance(out, str): + new_clt_step_out[index] = out.split("/")[-1] + else: + out.id = out.id.split("/")[-1] + new_clt_step.out = new_clt_step_out for tool_inp in new_clt_step.run.inputs: tool_inp.id = tool_inp.id.split("#")[-1] for tool_out in new_clt_step.run.outputs: @@ -1601,24 +1921,33 @@ def traverse_CommandLineTool( if isinstance(req, cwl.SubworkflowFeatureRequirement): has_sub_wf_req = True if not has_sub_wf_req: - parent.requirements.append( - cwl.SubworkflowFeatureRequirement() - ) + new_parent_reqs = list(parent.requirements) + new_parent_reqs.append(cwl.SubworkflowFeatureRequirement()) + parent.requirements = new_parent_reqs return modified def rename_step_source(workflow: cwl.Workflow, old: str, new: str) -> None: """Update step source names to the new name.""" - def simplify_wf_id(uri: str) -> str: - return uri.split("#")[-1].split("/", 1)[1] + def simplify_wf_ids(uris: Sequence[str] | str | None) -> set[str]: + if isinstance(uris, str): + uri_seq: Sequence[str] = [uris] + elif uris is None: + return set() + else: + uri_seq = uris + return {uri.split("#")[-1].split("/", 1)[1] for uri in uri_seq} def simplify_step_id(uri: str) -> str: return uri.split("#")[-1] for wf_outp in workflow.outputs: - if wf_outp.outputSource and simplify_wf_id(wf_outp.outputSource) == old: - wf_outp.outputSource = new + simplified_wf_ids = simplify_wf_ids(wf_outp.outputSource) + if wf_outp.outputSource and old in simplified_wf_ids: + simplified_wf_ids.remove(old) + simplified_wf_ids.add(new) + wf_outp.outputSource = list(simplified_wf_ids) for step in workflow.steps: if step.in_: for inp in step.in_: @@ -1634,7 +1963,9 @@ def simplify_step_id(uri: str) -> str: else: for index, source in enumerate(inp.source): if simplify_step_id(source) == old: - inp.source[index] = new + new_inp_source = list(inp.source) + new_inp_source[index] = new + inp.source = new_inp_source def remove_JSReq( @@ -1645,7 +1976,7 @@ def remove_JSReq( if skip_command_line1 and isinstance(process, cwl.CommandLineTool): return if process.hints: - process.hints[:] = [ + process.hints = [ hint for hint in process.hints if not isinstance(hint, cwl.InlineJavascriptRequirement) @@ -1653,7 +1984,7 @@ def remove_JSReq( if not process.hints: process.hints = None if process.requirements: - process.requirements[:] = [ + process.requirements = [ req for req in process.requirements if not isinstance(req, cwl.InlineJavascriptRequirement) @@ -1666,13 +1997,14 @@ def replace_step_clt_expr_with_etool( expr: str, name: str, workflow: cwl.Workflow, - target: cwl.WorkflowInputParameter, + target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, step: cwl.WorkflowStep, replace_etool: bool, self_name: str | None = None, ) -> None: """Convert a step level CWL Expression to a sibling expression step.""" - etool_inputs = cltool_inputs_to_etool_inputs(step.run) + assert not isinstance(step.run, str) + etool_inputs = process_inputs_to_etool_inputs(step.run) temp_etool = generate_etool_from_expr2( expr, target, etool_inputs, self_name, step.run, [workflow] ) @@ -1686,8 +2018,9 @@ def replace_step_clt_expr_with_etool( wf_step_inputs = copy.deepcopy(step.in_) for wf_step_input in wf_step_inputs: wf_step_input.id = wf_step_input.id.split("/")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if not x.id.startswith("_")] - workflow.steps.append( + wf_step_inputs = [x for x in wf_step_inputs if not x.id.startswith("_")] + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -1695,9 +2028,10 @@ def replace_step_clt_expr_with_etool( run=etool, ) ) + workflow.steps = new_steps -def replace_clt_hintreq_expr_with_etool( +def replace_step_process_hintreq_expr_with_etool( expr: str, name: str, workflow: cwl.Workflow, @@ -1708,7 +2042,8 @@ def replace_clt_hintreq_expr_with_etool( ) -> cwl.CommandLineTool | cwl.ExpressionTool: """Factor out an expression inside a CommandLineTool req or hint into a sibling step.""" # Same as replace_step_clt_expr_with_etool or different? - etool_inputs = cltool_inputs_to_etool_inputs(step.run) + assert not isinstance(step.run, str) + etool_inputs = process_inputs_to_etool_inputs(step.run) temp_etool = generate_etool_from_expr2( expr, target, etool_inputs, self_name, step.run, [workflow] ) @@ -1722,8 +2057,9 @@ def replace_clt_hintreq_expr_with_etool( wf_step_inputs = copy.deepcopy(step.in_) for wf_step_input in wf_step_inputs: wf_step_input.id = wf_step_input.id.split("/")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if not x.id.startswith("_")] - workflow.steps.append( + wf_step_inputs = [x for x in wf_step_inputs if not x.id.startswith("_")] + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -1731,30 +2067,31 @@ def replace_clt_hintreq_expr_with_etool( run=etool, ) ) + workflow.steps = new_steps return etool -def cltool_inputs_to_etool_inputs( - tool: cwl.CommandLineTool, +def process_inputs_to_etool_inputs( + tool: cwl.Process, ) -> list[cwl.WorkflowInputParameter]: - """Copy CommandLineTool input objects into the equivalent ExpressionTool input objects.""" - inputs = yaml.comments.CommentedSeq() + """Copy Process input parameters to matching ExpressionTool versions.""" + inputs = [] if tool.inputs: - for clt_inp in tool.inputs: - clt_inp_id = clt_inp.id.split("#")[-1].split("/")[-1] - if not clt_inp_id.startswith("_"): + for process_inp in tool.inputs: + process_inp_id = process_inp.id.split("#")[-1].split("/")[-1] + if not process_inp_id.startswith("_"): inputs.append( cwl.WorkflowInputParameter( - id=clt_inp_id, - label=clt_inp.label, - secondaryFiles=clt_inp.secondaryFiles, - streamable=clt_inp.streamable, - doc=clt_inp.doc, - format=clt_inp.format, - default=clt_inp.default, - type_=clt_inp.type_, - extension_fields=clt_inp.extension_fields, - loadingOptions=clt_inp.loadingOptions, + id=process_inp_id, + label=process_inp.label, + secondaryFiles=process_inp.secondaryFiles, + streamable=process_inp.streamable, + doc=process_inp.doc, + format=process_inp.format, + default=process_inp.default, + type_=process_inp.type_, + extension_fields=process_inp.extension_fields, + loadingOptions=process_inp.loadingOptions, ) ) return inputs @@ -1762,17 +2099,18 @@ def cltool_inputs_to_etool_inputs( def cltool_step_outputs_to_workflow_outputs( cltool_step: cwl.WorkflowStep, etool_step_id: str, etool_out_id: str -) -> list[cwl.OutputParameter]: +) -> list[cwl.WorkflowOutputParameter]: """ Copy CommandLineTool outputs into the equivalent Workflow output parameters. Connects the outputSources for each of the new output parameters to the step they came from. """ - outputs = yaml.comments.CommentedSeq() + outputs: list[cwl.WorkflowOutputParameter] = [] if not cltool_step.id: raise WorkflowException(f"Missing step id from {cltool_step}.") default_step_id = cltool_step.id.split("#")[-1] + assert not isinstance(cltool_step.run, str) if cltool_step.run.outputs: for clt_out in cltool_step.run.outputs: clt_out_id = clt_out.id.split("#")[-1].split("/")[-1] @@ -1800,14 +2138,14 @@ def cltool_step_outputs_to_workflow_outputs( def generate_etool_from_expr2( expr: str, - target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, + target: cwl.WorkflowInputParameter | cwl.CommandInputParameter, inputs: Sequence[ cwl.WorkflowInputParameter | cwl.CommandInputParameter | cwl.CommandOutputParameter ], self_name: str | None = None, - process: cwl.CommandLineTool | cwl.ExpressionTool | None = None, + process: cwl.Process | None = None, extra_processes: None | ( Sequence[cwl.Workflow | cwl.WorkflowStep | cwl.CommandLineTool] ) = None, @@ -1821,8 +2159,8 @@ def generate_etool_from_expr2( secondaryFiles=target.secondaryFiles, streamable=target.streamable, doc=target.doc, - format=target.format, - type_=target.type_, + format=target.format[0] if target.format else None, + type_=plain_input_schema_to_plain_output_schema(target.type_), ) ) expression = "${" @@ -1835,34 +2173,23 @@ def generate_etool_from_expr2( + """}()}; }""" ) - hints = None - procs: list[ - cwl.CommandLineTool | cwl.ExpressionTool | cwl.Workflow | cwl.WorkflowStep - ] = [] + procs: list[cwl.Process | cwl.WorkflowStep] = [] if process: procs.append(process) if extra_processes: procs.extend(extra_processes) inlineJSReq = cwl.InlineJavascriptRequirement(find_expressionLib(procs)) - reqs = [inlineJSReq] - if process: - if process.hints: - hints = copy.deepcopy(process.hints) - hints[:] = [ - x for x in hints if not isinstance(x, cwl.InitialWorkDirRequirement) - ] - if process.requirements: - reqs.extend(copy.deepcopy(process.requirements)) - reqs[:] = [ - x for x in reqs if not isinstance(x, cwl.InitialWorkDirRequirement) - ] + reqs: MutableSequence[cwl.ProcessRequirement] = [inlineJSReq] + if process and process.requirements: + reqs.extend(copy.deepcopy(process.requirements)) + reqs[:] = [x for x in reqs if not isinstance(x, cwl.InitialWorkDirRequirement)] return cwl.ExpressionTool( id="_:" + str(uuid.uuid4()), - inputs=inputs, + inputs=parameters_to_workflow_input_paramaters(inputs), outputs=outputs, expression=expression, requirements=reqs, - cwlVersion="v1.0", + cwlVersion="v1.2", ) @@ -1880,43 +2207,29 @@ def traverse_step( return False step_id = step.id.split("#")[-1] original_process = copy.deepcopy(step.run) + assert not isinstance(original_process, str) + assert not isinstance(step.run, str) original_step_ins = copy.deepcopy(step.in_) for inp in step.in_: if inp.valueFrom: if not inp.source: self = None else: - if isinstance(inp.source, MutableSequence): - self = [] - for source in inp.source: - if not step.scatter: - self.append( - example_input( - utils.type_for_source(parent, source.split("#")[-1]) - ) - ) - else: - scattered_source_type = utils.type_for_source( - parent, source - ) - if isinstance(scattered_source_type, list): - for stype in scattered_source_type: - self.append(example_input(stype.type_)) - else: - self.append(example_input(scattered_source_type.type_)) - else: + self = [] + for source in inp.source: if not step.scatter: - self = example_input( - utils.type_for_source(parent, inp.source.split("#")[-1]) + self.append( + example_input( + utils.type_for_source(parent, source.split("#")[-1]) + ) ) else: - scattered_source_type2 = utils.type_for_source( - parent, inp.source - ) - if isinstance(scattered_source_type2, list): - self = example_input(scattered_source_type2[0].type_) + scattered_source_type = utils.type_for_source(parent, source) + if is_sequence(scattered_source_type): + for stype in scattered_source_type: + self.append(example_input(stype.type_)) else: - self = example_input(scattered_source_type2.type_) + self.append(example_input(scattered_source_type.type_)) expression = get_expression(inp.valueFrom, inputs, self) if expression: modified = True @@ -1925,42 +2238,32 @@ def traverse_step( if not target: raise WorkflowException("target not found") input_source_id = None - source_type: None | ( - MutableSequence[ - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter + source_type: ( + None + | MutableSequence[ + cwl.WorkflowInputParameter | cwl.CommandOutputParameter ] - | cwl.CommandInputParameter - | cwl.CommandOutputParameter | cwl.WorkflowInputParameter + | cwl.CommandOutputParameter ) = None if inp.source: - if isinstance(inp.source, MutableSequence): - input_source_id = [] - source_types: list[cwl.WorkflowInputParameter] = [] - for source in inp.source: - source_id = source.split("#")[-1] - input_source_id.append(source_id) - temp_type = utils.type_for_source( - step.run, source_id, parent - ) - if isinstance(temp_type, list): - for ttype in temp_type: - if ttype not in source_types: - source_types.append(ttype) - else: - if temp_type not in source_types: - source_types.append(temp_type) - source_type = cwl.WorkflowInputParameter( - id=None, - type_=cwl.ArraySchema(source_types, "array"), - ) - else: - input_source_id = inp.source.split("#")[-1] - source_type = utils.param_for_source_id( - step.run, input_source_id, parent - ) + input_source_id = [] + source_types: list[BasicInputTypeSchemas] = [] + for source in inp.source: + source_id = source.split("#")[-1] + input_source_id.append(source_id) + temp_type = utils.type_for_source(step.run, source_id, parent) + if is_sequence(temp_type): + for ttype in temp_type: + if ttype not in source_types: + source_types.append(ttype) + else: + if temp_type not in source_types: + source_types.append(temp_type) + source_type = cwl.WorkflowInputParameter( + id="", + type_=cwl.InputArraySchema(source_types, "array"), + ) # target.id = target.id.split('#')[-1] if isinstance(original_process, cwl.ExpressionTool): found_JSReq = False @@ -1976,9 +2279,11 @@ def traverse_step( if not step.run.requirements: step.run.requirements = [] expr_lib = find_expressionLib([parent]) - step.run.requirements.append( + new_step_run_requirements = list(step.run.requirements) + new_step_run_requirements.append( cwl.InlineJavascriptRequirement(expr_lib) ) + step.run.requirements = new_step_run_requirements replace_step_valueFrom_expr_with_etool( expression, etool_id, @@ -1994,15 +2299,8 @@ def traverse_step( ) inp.valueFrom = None inp.source = f"{etool_id}/result" - if step.when: - expression = get_expression(string=step.when, inputs=inputs, self=None) - if expression: - modified = True - replace_step_when_expr_with_etool( - expression, parent, step, original_step_ins, replace_etool - ) - # TODO: skip or special process for sub workflows? + assert not isinstance(original_process, str) process_modified = process_level_reqs( original_process, step, @@ -2028,29 +2326,35 @@ def traverse_step( def workflow_step_to_WorkflowInputParameters( - step_ins: list[cwl.WorkflowStepInput], parent: cwl.Workflow, except_in_id: str -) -> MutableSequence[ - cwl.CommandInputParameter | cwl.CommandOutputParameter | cwl.WorkflowInputParameter -]: + step_ins: Sequence[cwl.WorkflowStepInput], parent: cwl.Workflow, except_in_id: str +) -> list[cwl.WorkflowInputParameter]: """Create WorkflowInputParameters to match the given WorkflowStep inputs.""" - params = [] + params: list[cwl.WorkflowInputParameter] = [] for inp in step_ins: - if not inp.id: - continue inp_id = inp.id.split("#")[-1].split("/")[-1] if inp.source and inp_id != except_in_id: param = copy.deepcopy( - utils.param_for_source_id(parent, sourcenames=inp.source) + param_for_source_id(parent, sourcenames=inp.source) ) - if isinstance(param, MutableSequence): + if is_sequence(param): for p in param: - p.id = inp_id - p.type_ = clean_type_ids(p.type_) - params.append(p) + if not p.type_: + raise WorkflowException( + f"Don't know how to get type id for {p!r}." + ) + new_param = parameter_to_workflow_input_paramater(p) + new_param.id = inp_id + new_param.type_ = clean_type_ids(new_param.type_) + params.append(new_param) else: - param.id = inp_id - param.type_ = clean_type_ids(param.type_) - params.append(param) + if not param.type_: + raise WorkflowException( + f"Don't know how to get type id for {param!r}." + ) + new_param = parameter_to_workflow_input_paramater(param) + new_param.id = inp_id + new_param.type_ = clean_type_ids(new_param.type_) + params.append(new_param) return params @@ -2061,15 +2365,15 @@ def replace_step_valueFrom_expr_with_etool( target: cwl.CommandInputParameter | cwl.WorkflowInputParameter, step: cwl.WorkflowStep, step_inp: cwl.WorkflowStepInput, - original_process: cwl.CommandLineTool | cwl.ExpressionTool, - original_step_ins: list[cwl.WorkflowStepInput], + original_process: cwl.Process, + original_step_ins: Sequence[cwl.WorkflowStepInput], source: str | list[str] | None, replace_etool: bool, source_type: None | ( cwl.CommandInputParameter | cwl.CommandOutputParameter | cwl.WorkflowInputParameter - | MutableSequence[ + | Sequence[ cwl.CommandInputParameter | cwl.CommandOutputParameter | cwl.WorkflowInputParameter @@ -2106,22 +2410,19 @@ def replace_step_valueFrom_expr_with_etool( etool: cwl.ExpressionTool | cwl.CommandLineTool = cltool else: etool = temp_etool - wf_step_inputs = copy.deepcopy(original_step_ins) + wf_step_inputs = list(original_step_ins) if source: wf_step_inputs.append(cwl.WorkflowStepInput(id="self", source=step_inp.source)) for wf_step_input in wf_step_inputs: - if not wf_step_input.id: - continue wf_step_input.id = wf_step_input.id.split("/")[-1] if wf_step_input.valueFrom: wf_step_input.valueFrom = None if wf_step_input.source: - if isinstance(wf_step_input.source, MutableSequence): - for index, inp_source in enumerate(wf_step_input.source): - wf_step_input.source[index] = inp_source.split("#")[-1] - else: - wf_step_input.source = wf_step_input.source.split("#")[-1] - wf_step_inputs[:] = [ + new_source = list(wf_step_input.source) + for index, inp_source in enumerate(wf_step_input.source): + new_source[index] = inp_source.split("#")[-1] + wf_step_input.source = new_source + wf_step_inputs = [ x for x in wf_step_inputs if x.id and not (x.id.startswith("_") or x.id.endswith(step_inp_id)) @@ -2137,7 +2438,8 @@ def replace_step_valueFrom_expr_with_etool( # do we still need to scatter? else: scatter = None - workflow.steps.append( + new_steps = list(workflow.steps) + new_steps.append( cwl.WorkflowStep( id=name, in_=wf_step_inputs, @@ -2147,72 +2449,7 @@ def replace_step_valueFrom_expr_with_etool( scatterMethod=step.scatterMethod, ) ) - - -def replace_step_when_expr_with_etool( - expr: str, - workflow: cwl.Workflow, - step: cwl.WorkflowStep, - original_step_ins: list[cwl.WorkflowStepInput], - replace_etool: bool, -) -> None: - """Replace a WorkflowStep level 'when' expression with a sibling ExpressionTool step.""" - if not step.id: - raise WorkflowException(f"Missing id from {step}.") - etool_id = "_when_expression_{}".format(step.id.split("#")[-1]) - etool_inputs = workflow_step_to_WorkflowInputParameters( - original_step_ins, workflow, "" - ) - temp_etool = generate_etool_from_expr2( - expr, - cwl.WorkflowInputParameter(id=None, type_="boolean"), - etool_inputs, - None, - None, - [workflow, step], - ) - if replace_etool: - processes: list[ - (cwl.Workflow | cwl.CommandLineTool | cwl.ExpressionTool | cwl.WorkflowStep) - ] = [ - workflow, - step, - ] - cltool = etool_to_cltool(temp_etool, find_expressionLib(processes)) - etool: cwl.ExpressionTool | cwl.CommandLineTool = cltool - else: - etool = temp_etool - wf_step_inputs = copy.deepcopy(original_step_ins) - for wf_step_input in wf_step_inputs: - if not wf_step_input.id: - continue - wf_step_input.id = wf_step_input.id.split("/")[-1] - if wf_step_input.source: - if isinstance(wf_step_input.source, MutableSequence): - for index, inp_source in enumerate(wf_step_input.source): - wf_step_input.source[index] = inp_source.split("#")[-1] - else: - wf_step_input.source = wf_step_input.source.split("#")[-1] - wf_step_inputs[:] = [x for x in wf_step_inputs if x.id and not x.id.startswith("_")] - scatter = copy.deepcopy(step.scatter) - if isinstance(scatter, str): - scatter = [scatter] - if isinstance(scatter, MutableSequence): - for index, entry in enumerate(scatter): - scatter[index] = entry.split("/")[-1] - scatter = step.scatter - workflow.steps.append( - cwl.WorkflowStep( - id=etool_id, - in_=wf_step_inputs, - out=[cwl.WorkflowStepOutput("result")], - run=etool, - scatter=scatter, - scatterMethod=step.scatterMethod, - ) - ) - step.when = "$(inputs._when)" - step.in_.append(cwl.WorkflowStepInput(id="_when", source=f"{etool_id}/result")) + workflow.steps = new_steps def traverse_workflow( @@ -2245,7 +2482,7 @@ def traverse_workflow( if process_workflow_reqs_and_hints(workflow, replace_etool): modified = True if workflow.requirements: - workflow.requirements[:] = [ + workflow.requirements = [ x for x in workflow.requirements if not isinstance( diff --git a/src/cwl_utils/docker_extract.py b/src/cwl_utils/docker_extract.py index f67163d0..1c5626d9 100755 --- a/src/cwl_utils/docker_extract.py +++ b/src/cwl_utils/docker_extract.py @@ -102,7 +102,9 @@ def extract_docker_requirements( yield req -def extract_docker_reqs(process: cwl.Process) -> Iterator[cwl.DockerRequirement]: +def extract_docker_reqs( + process: cwl.Process | cwl.WorkflowStep, +) -> Iterator[cwl.DockerRequirement]: """For the given process, extract the DockerRequirement(s).""" if process.requirements: for req in process.requirements: @@ -125,7 +127,7 @@ def get_process_from_step(step: cwl.WorkflowStep) -> cwl.Process: """Return the process for this step, loading it if necessary.""" if isinstance(step.run, str): return cast(cwl.Process, cwl.load_document_by_uri(step.run)) - return cast(cwl.Process, step.run) + return step.run def traverse_workflow(workflow: cwl.Workflow) -> Iterator[cwl.DockerRequirement]: diff --git a/src/cwl_utils/expression_refactor.py b/src/cwl_utils/expression_refactor.py index 094f5810..fd40d404 100755 --- a/src/cwl_utils/expression_refactor.py +++ b/src/cwl_utils/expression_refactor.py @@ -7,12 +7,13 @@ import logging import shutil import sys -from collections.abc import Callable, MutableMapping, MutableSequence +from collections.abc import Callable, MutableSequence from pathlib import Path -from typing import Any, Protocol +from typing import Any from ruamel.yaml.main import YAML from ruamel.yaml.scalarstring import walk_tree +from schema_salad.runtime import save from cwl_utils import ( cwl_v1_0_expression_refactor, @@ -29,24 +30,6 @@ _logger.setLevel(logging.INFO) _cwlutilslogger.setLevel(100) -save_type = ( - MutableMapping[str, Any] | MutableSequence[Any] | int | float | bool | str | None -) - - -class saveCWL(Protocol): - """Shortcut type for CWL v1.x parse.save().""" - - def __call__( - self, - val: Any, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, - ) -> save_type: - """Must use this instead of a Callable due to the keyword args.""" - ... - def arg_parser() -> argparse.ArgumentParser: """Build the argument parser.""" @@ -111,15 +94,12 @@ def refactor(args: argparse.Namespace) -> int: traverse: Callable[[Any, bool, bool, bool, bool], tuple[Any, bool]] = ( cwl_v1_0_expression_refactor.traverse ) - save: saveCWL = cwl_v1_0.save case "v1.1": top = cwl_v1_1.load_document_by_yaml(result, uri) traverse = cwl_v1_1_expression_refactor.traverse - save = cwl_v1_1.save case "v1.2": top = cwl_v1_2.load_document_by_yaml(result, uri) traverse = cwl_v1_2_expression_refactor.traverse - save = cwl_v1_2.save case _: _logger.error( "Sorry, %s is not a supported CWL version by this tool.", diff --git a/src/cwl_utils/graph_split.py b/src/cwl_utils/graph_split.py index 8a1ef14a..525d055b 100755 --- a/src/cwl_utils/graph_split.py +++ b/src/cwl_utils/graph_split.py @@ -20,9 +20,9 @@ from typing import ( IO, Any, - Callable, cast, ) +from collections.abc import Callable try: stringify_dict: Callable[[dict[str, Any]], str] | None diff --git a/src/cwl_utils/inputs_schema_gen.py b/src/cwl_utils/inputs_schema_gen.py index a3592a5e..562c11ee 100644 --- a/src/cwl_utils/inputs_schema_gen.py +++ b/src/cwl_utils/inputs_schema_gen.py @@ -6,17 +6,20 @@ """Generate JSON Schema from CWL inputs object.""" import argparse +import hashlib import json import logging import sys +from collections.abc import Sequence from contextlib import suppress from copy import deepcopy from importlib.resources import files from pathlib import Path -from typing import Any, TypeGuard +from typing import Any, TypeGuard, cast from urllib.parse import urlparse import requests +from schema_salad.utils import json_dumps from cwl_utils.loghandler import _logger as _cwlutilslogger from cwl_utils.parser import ( @@ -27,6 +30,7 @@ InputEnumSchema, InputRecordSchema, InputRecordSchemaTypes, + SchemaDefRequirement, Workflow, WorkflowInputParameter, cwl_v1_0, @@ -34,6 +38,7 @@ cwl_v1_2, load_document_by_uri, ) +from cwl_utils.types import is_sequence from cwl_utils.utils import ( get_value_from_uri, is_local_uri, @@ -252,7 +257,11 @@ def generate_json_schema_property_from_input_parameter( """ # Get the input name and documentation for description input_name = get_value_from_uri(str(input_parameter.id)) - doc = input_parameter.doc + doc = ( + "\n".join(input_parameter.doc) + if is_sequence(input_parameter.doc) + else input_parameter.doc + ) required = get_is_required_from_input_parameter(input_parameter) return JSONSchemaProperty( @@ -263,27 +272,27 @@ def generate_json_schema_property_from_input_parameter( ) -def generate_definition_from_schema(schema: InputRecordSchema) -> dict[str, Any]: - """ - Given a schema, generate a JSON schema definition. +def generate_definition_from_schema( + schema: InputRecordSchema | InputArraySchema | InputEnumSchema, +) -> dict[str, Any]: + """Given a schema, generate a JSON schema definition.""" + # TODO: handle InputArraySchema & InputEnumSchema (from SchemaDefRequirement.types) - :param schema: - :return: - """ # Sanitise each field of the schema sanitised_fields = {} - if schema.fields is None: - return {} + if isinstance(schema, InputRecordSchema): + if schema.fields is None: + return {} - for field in schema.fields: - sanitised_fields.update( - { - get_value_from_uri(field.name): sanitise_schema_field( - {"type": field.type_} - ) - } - ) + for field in schema.fields: + sanitised_fields.update( + { + get_value_from_uri(field.name): sanitise_schema_field( + {"type": field.type_} + ) + } + ) # Generate JSON properties property_list = [] @@ -316,8 +325,17 @@ def generate_definition_from_schema(schema: InputRecordSchema) -> dict[str, Any] ) property_list.append(prop) + if not isinstance(schema, cwl_v1_0.InputArraySchema) or hasattr(schema, "name"): + schema_name = to_pascal_case(get_value_from_uri(str(schema.name))) + else: + schema_name = ( + "AnonymousInputArraySchema" + + hashlib.sha1( # nosec + json_dumps(schema.save()).encode("utf-8") + ).hexdigest() + ) return { - to_pascal_case(get_value_from_uri(str(schema.name))): { + schema_name: { "type": "object", "properties": {prop.name: prop.type_dict for prop in property_list}, "required": [prop.name for prop in property_list if prop.required], @@ -325,7 +343,7 @@ def generate_definition_from_schema(schema: InputRecordSchema) -> dict[str, Any] } -def cwl_to_jsonschema(cwl_obj: Workflow | CommandLineTool) -> Any: +def cwl_to_jsonschema(cwl_obj: Workflow | CommandLineTool) -> dict[str, object]: """ cwl_obj: A CWL Object. @@ -386,11 +404,9 @@ def get_complex_schema_values(idx_iter: str) -> InputRecordSchema: return input_record_schema - complex_schema_values: list[InputRecordSchema] = list( - map( - get_complex_schema_values, - complex_schema_keys, - ) + complex_schema_values: map[InputRecordSchema] = map( + get_complex_schema_values, + complex_schema_keys, ) # Load in all $imports to be referred by complex input types @@ -403,20 +419,21 @@ def get_complex_schema_values(idx_iter: str) -> InputRecordSchema: if cwl_obj.requirements is not None: with suppress(StopIteration): - schema_def_requirement = next( - filter( - lambda requirement_iter: requirement_iter.class_ - == "SchemaDefRequirement", - cwl_obj.requirements, - ) + schema_def_requirement = cast( + SchemaDefRequirement, + next( + filter( + lambda requirement_iter: requirement_iter.class_ + == "SchemaDefRequirement", + cwl_obj.requirements, + ) + ), ) workflow_schema_definitions_list.extend( - list( - map( - generate_definition_from_schema, - schema_def_requirement.types, - ) + map( + generate_definition_from_schema, + schema_def_requirement.types, ) ) @@ -429,7 +446,7 @@ def get_complex_schema_values(idx_iter: str) -> InputRecordSchema: properties = list( map( generate_json_schema_property_from_input_parameter, - cwl_obj.inputs, + cast(Sequence[WorkflowInputParameter], cwl_obj.inputs), ) ) diff --git a/src/cwl_utils/normalizer.py b/src/cwl_utils/normalizer.py index 29231758..100095d5 100644 --- a/src/cwl_utils/normalizer.py +++ b/src/cwl_utils/normalizer.py @@ -13,12 +13,13 @@ from cwlupgrader import main as cwlupgrader from ruamel.yaml import YAML +from schema_salad.runtime import save from schema_salad.sourceline import add_lc_filename from cwl_utils import cwl_v1_2_expression_refactor from cwl_utils.loghandler import _logger as _cwlutilslogger from cwl_utils.pack import pack -from cwl_utils.parser.cwl_v1_2 import load_document_by_yaml, save +from cwl_utils.parser.cwl_v1_2 import load_document_by_yaml _logger = logging.getLogger("cwl-normalizer") # pylint: disable=invalid-name defaultStreamHandler = logging.StreamHandler() # pylint: disable=invalid-name diff --git a/src/cwl_utils/parser/__init__.py b/src/cwl_utils/parser/__init__.py index 6e105072..cde0764d 100644 --- a/src/cwl_utils/parser/__init__.py +++ b/src/cwl_utils/parser/__init__.py @@ -4,26 +4,21 @@ from abc import ABC from collections.abc import MutableMapping, MutableSequence from pathlib import Path -from typing import Any, Optional, TypeAlias, cast +from typing import Any, TypeAlias, cast, TypeVar from urllib.parse import unquote_plus, urlparse from schema_salad.exceptions import ValidationException +from schema_salad.runtime import LoadingOptions, Saveable, file_uri from schema_salad.utils import yaml_no_ts -from ..errors import GraphTargetMissingException from . import cwl_v1_0, cwl_v1_1, cwl_v1_2 +from ..errors import GraphTargetMissingException class NoType(ABC): pass -LoadingOptions: TypeAlias = ( - cwl_v1_0.LoadingOptions | cwl_v1_1.LoadingOptions | cwl_v1_2.LoadingOptions -) -"""Type union for a CWL v1.x LoadingOptions object.""" -Saveable: TypeAlias = cwl_v1_0.Saveable | cwl_v1_1.Saveable | cwl_v1_2.Saveable -"""Type union for a CWL v1.x Saveable object.""" InputParameter: TypeAlias = ( cwl_v1_0.InputParameter | cwl_v1_1.InputParameter | cwl_v1_2.InputParameter ) @@ -31,23 +26,37 @@ class NoType(ABC): InputRecordField: TypeAlias = ( cwl_v1_0.InputRecordField | cwl_v1_1.InputRecordField | cwl_v1_2.InputRecordField ) -"""Type union for a CWL v1.x InputRecordSchema object.""" +"""Type union for a CWL v1.x InputRecordField object.""" InputSchema: TypeAlias = ( cwl_v1_0.InputSchema | cwl_v1_1.InputSchema | cwl_v1_2.InputSchema ) """Type union for a CWL v1.x InputSchema object.""" OutputParameter: TypeAlias = ( - cwl_v1_0.OutputParameter | cwl_v1_1.OutputParameter | cwl_v1_2.OutputParameter + cwl_v1_0.CommandOutputParameter + | cwl_v1_0.ExpressionToolOutputParameter + | cwl_v1_0.WorkflowOutputParameter + | cwl_v1_1.OutputParameter + | cwl_v1_2.OutputParameter ) """Type union for a CWL v1.x OutputParameter object.""" OutputArraySchema: TypeAlias = ( cwl_v1_0.OutputArraySchema | cwl_v1_1.OutputArraySchema | cwl_v1_2.OutputArraySchema ) """Type union for a CWL v1.x OutputArraySchema object.""" +OutputArraySchemaTypes = ( + cwl_v1_0.OutputArraySchema, + cwl_v1_1.OutputArraySchema, + cwl_v1_2.OutputArraySchema, +) OutputEnumSchema: TypeAlias = ( cwl_v1_0.OutputEnumSchema | cwl_v1_1.OutputEnumSchema | cwl_v1_2.OutputEnumSchema ) """Type union for a CWL v1.x OutputEnumSchema object.""" +OutputEnumSchemaTypes = ( + cwl_v1_0.OutputEnumSchema, + cwl_v1_1.OutputEnumSchema, + cwl_v1_2.OutputEnumSchema, +) OutputRecordField: TypeAlias = ( cwl_v1_0.OutputRecordField | cwl_v1_1.OutputRecordField | cwl_v1_2.OutputRecordField ) @@ -58,6 +67,11 @@ class NoType(ABC): | cwl_v1_2.OutputRecordSchema ) """Type union for a CWL v1.x OutputRecordSchema object.""" +OutputRecordSchemaTypes = ( + cwl_v1_0.OutputRecordSchema, + cwl_v1_1.OutputRecordSchema, + cwl_v1_2.OutputRecordSchema, +) OutputSchema: TypeAlias = ( cwl_v1_0.OutputSchema | cwl_v1_1.OutputSchema | cwl_v1_2.OutputSchema ) @@ -97,6 +111,12 @@ class NoType(ABC): | cwl_v1_2.WorkflowStepOutput ) """Type union for a CWL v1.x WorkflowStepOutput object.""" +Operation: TypeAlias = cwl_v1_2.Operation +"""Type union for a CWL v1.x Operation object.""" +OperationInputParameter: TypeAlias = cwl_v1_2.OperationInputParameter +"""Type union for a CWL v1.x OperationInputParameter object.""" +OperationOutputParameter: TypeAlias = cwl_v1_2.OperationOutputParameter +"""Type union for a CWL v1.x OperationOutputParameter object.""" CommandLineTool: TypeAlias = ( cwl_v1_0.CommandLineTool | cwl_v1_1.CommandLineTool | cwl_v1_2.CommandLineTool ) @@ -138,6 +158,17 @@ class NoType(ABC): | cwl_v1_2.CommandOutputRecordField ) """Type union for a CWL v1.x CommandOutputRecordField object.""" +CommandOutputRecordSchema: TypeAlias = ( + cwl_v1_0.CommandOutputRecordSchema + | cwl_v1_1.CommandOutputRecordSchema + | cwl_v1_2.CommandOutputRecordSchema +) +CommandOutputRecordSchemaTypes = ( + cwl_v1_0.CommandOutputRecordSchema, + cwl_v1_1.CommandOutputRecordSchema, + cwl_v1_2.CommandOutputRecordSchema, +) +"""Type Union for a CWL v1.x CommandOutputRecordSchema object.""" ExpressionTool: TypeAlias = ( cwl_v1_0.ExpressionTool | cwl_v1_1.ExpressionTool | cwl_v1_2.ExpressionTool ) @@ -181,9 +212,6 @@ class NoType(ABC): cwl_v1_2.SoftwareRequirement, ) """Type union for a CWL v1.x SoftwareRequirement object.""" -ArraySchema: TypeAlias = ( - cwl_v1_0.ArraySchema | cwl_v1_1.ArraySchema | cwl_v1_2.ArraySchema -) InputArraySchema: TypeAlias = ( cwl_v1_0.InputArraySchema | cwl_v1_1.InputArraySchema | cwl_v1_2.InputArraySchema ) @@ -192,8 +220,6 @@ class NoType(ABC): cwl_v1_1.InputArraySchema, cwl_v1_2.InputArraySchema, ) -"""Type Union for a CWL v1.x ArraySchema object.""" -EnumSchema: TypeAlias = cwl_v1_0.EnumSchema | cwl_v1_1.EnumSchema | cwl_v1_2.EnumSchema InputEnumSchema: TypeAlias = ( cwl_v1_0.InputEnumSchema | cwl_v1_1.InputEnumSchema | cwl_v1_2.InputEnumSchema ) @@ -202,10 +228,6 @@ class NoType(ABC): cwl_v1_1.InputEnumSchema, cwl_v1_2.InputEnumSchema, ) -"""Type Union for a CWL v1.x EnumSchema object.""" -RecordSchema: TypeAlias = ( - cwl_v1_0.RecordSchema | cwl_v1_1.RecordSchema | cwl_v1_2.RecordSchema -) InputRecordSchema: TypeAlias = ( cwl_v1_0.InputRecordSchema | cwl_v1_1.InputRecordSchema | cwl_v1_2.InputRecordSchema ) @@ -214,7 +236,8 @@ class NoType(ABC): cwl_v1_1.InputRecordSchema, cwl_v1_2.InputRecordSchema, ) -"""Type Union for a CWL v1.x RecordSchema object.""" +"""Type Union for a CWL v1.x InputRecordSchema object.""" + File: TypeAlias = cwl_v1_0.File | cwl_v1_1.File | cwl_v1_2.File """Type Union for a CWL v1.x File object.""" SecondaryFileSchema: TypeAlias = ( @@ -225,20 +248,18 @@ class NoType(ABC): """Type Union for a CWL v1.x Directory object.""" Dirent: TypeAlias = cwl_v1_0.Dirent | cwl_v1_1.Dirent | cwl_v1_2.Dirent """Type Union for a CWL v1.x Dirent object.""" -LoadContents: TypeAlias = ( - cwl_v1_1.CommandInputParameter - | cwl_v1_2.CommandInputParameter - | cwl_v1_1.CommandOutputBinding - | cwl_v1_2.CommandOutputBinding - | cwl_v1_1.InputRecordField - | cwl_v1_2.InputRecordField - | cwl_v1_1.WorkflowInputParameter - | cwl_v1_2.WorkflowInputParameter - | cwl_v1_1.WorkflowStepInput - | cwl_v1_2.WorkflowStepInput -) +LoadContents: TypeAlias = cwl_v1_1.LoadContents | cwl_v1_2.LoadContents """Type Union for a CWL v1.x LoadContents object.""" -_Loader: TypeAlias = cwl_v1_0._Loader | cwl_v1_1._Loader | cwl_v1_2._Loader +SchemaDefRequirement: TypeAlias = ( + cwl_v1_0.SchemaDefRequirement + | cwl_v1_1.SchemaDefRequirement + | cwl_v1_2.SchemaDefRequirement +) +"""Type Union for a CWL v1.x SchemaDefRequirement object.""" +__T = TypeVar("__T", covariant=True) +_Loader: TypeAlias = ( + cwl_v1_0._Loader[__T] | cwl_v1_1._Loader[__T] | cwl_v1_2._Loader[__T] +) """Type union for a CWL v1.x _Loader.""" @@ -289,53 +310,16 @@ def load_document_by_uri( base_uri = path.resolve().parent.as_uri() id_ = path.resolve().name.split("#")[1] if "#" in path.resolve().name else None - match loadingOptions: - case cwl_v1_0.LoadingOptions(): - loadingOptions = cwl_v1_0.LoadingOptions( - fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions - ) - return load_document_by_string( - loadingOptions.fetcher.fetch_text(real_uri), - real_uri, - loadingOptions, - id_, - load_all, - ) - case cwl_v1_1.LoadingOptions(): - loadingOptions = cwl_v1_1.LoadingOptions( - fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions - ) - return load_document_by_string( - loadingOptions.fetcher.fetch_text(real_uri), - real_uri, - loadingOptions, - id_, - load_all, - ) - case cwl_v1_2.LoadingOptions(): - loadingOptions = cwl_v1_2.LoadingOptions( - fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions - ) - return load_document_by_string( - loadingOptions.fetcher.fetch_text(real_uri), - real_uri, - loadingOptions, - id_, - load_all, - ) - case None: - loadingOptions = cwl_v1_2.LoadingOptions(fileuri=real_uri, baseuri=base_uri) - return load_document_by_string( - loadingOptions.fetcher.fetch_text(real_uri), - real_uri, - None, - id_, - load_all, - ) - case _: - raise ValidationException( - f"Unsupported loadingOptions type: {type(loadingOptions)}" - ) + loadingOptions = LoadingOptions( + fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions + ) + return load_document_by_string( + loadingOptions.fetcher.fetch_text(real_uri), + real_uri, + loadingOptions, + id_, + load_all, + ) def load_document( @@ -347,7 +331,7 @@ def load_document( ) -> Any: """Load a CWL object from a serialized YAML string or a YAML object.""" if baseuri is None: - baseuri = cwl_v1_0.file_uri(str(Path.cwd())) + "/" + baseuri = file_uri(str(Path.cwd())) + "/" if isinstance(doc, str): return load_document_by_string(doc, baseuri, loadingOptions, id_) return load_document_by_yaml(doc, baseuri, loadingOptions, id_, load_all) @@ -379,17 +363,11 @@ def load_document_by_yaml( yaml["cwlVersion"] = version match version: case "v1.0": - result = cwl_v1_0.load_document_by_yaml( - yaml, uri, cast(Optional[cwl_v1_0.LoadingOptions], loadingOptions) - ) + result = cwl_v1_0.load_document_by_yaml(yaml, uri, loadingOptions) case "v1.1": - result = cwl_v1_1.load_document_by_yaml( - yaml, uri, cast(Optional[cwl_v1_1.LoadingOptions], loadingOptions) - ) + result = cwl_v1_1.load_document_by_yaml(yaml, uri, loadingOptions) case "v1.2": - result = cwl_v1_2.load_document_by_yaml( - yaml, uri, cast(Optional[cwl_v1_2.LoadingOptions], loadingOptions) - ) + result = cwl_v1_2.load_document_by_yaml(yaml, uri, loadingOptions) case None: raise ValidationException("could not get the cwlVersion") case _: @@ -415,7 +393,7 @@ def save( ) -> Any: """Convert a CWL Python object into a JSON/YAML serializable object.""" match val: - case cwl_v1_0.Saveable() | cwl_v1_1.Saveable() | cwl_v1_2.Saveable(): + case Saveable(): return val.save(top=top, base_url=base_url, relative_uris=relative_uris) case MutableSequence(): lst = [ diff --git a/src/cwl_utils/parser/cwl_v1_0.py b/src/cwl_utils/parser/cwl_v1_0.py index 7f3110dd..60af0275 100644 --- a/src/cwl_utils/parser/cwl_v1_0.py +++ b/src/cwl_utils/parser/cwl_v1_0.py @@ -2,460 +2,92 @@ # This file was autogenerated using schema-salad-tool --codegen=python # The code itself is released under the Apache 2.0 license and the help text is # subject to the license of the original schema. +from __future__ import annotations -import copy -import logging import os -import pathlib -import tempfile -import uuid as _uuid__ # pylint: disable=unused-import # noqa: F401 -import xml.sax # nosec -from abc import ABC, abstractmethod -from collections.abc import MutableMapping, MutableSequence, Sequence +import sys +import uuid as _uuid__ +from collections.abc import Collection +from typing import ClassVar + +from schema_salad.runtime import ( + Saveable, + file_uri, + parse_errors, + prefix_url, + save, + save_relative_uri, +) + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +import schema_salad.metaschema + +import copy +from abc import ABCMeta, abstractmethod +from collections.abc import MutableSequence, Sequence, MutableMapping from io import StringIO from itertools import chain -from typing import Any, Final, Optional, Union, cast -from urllib.parse import quote, urldefrag, urlparse, urlsplit, urlunsplit -from urllib.request import pathname2url - -from rdflib import Graph -from rdflib.plugins.parsers.notation3 import BadSyntax +from typing import Literal, TypeVar # pylint: disable=unused-import # noqa: F401 +from collections.abc import Mapping +from typing import TypeAlias # pylint: disable=unused-import # noqa: F401 +from typing import Any, Final, cast, Generic +from urllib.parse import urldefrag, urlsplit, urlunsplit + +from mypy_extensions import i32, i64 # pylint: disable=unused-import # noqa: F401 +from mypy_extensions import mypyc_attr from ruamel.yaml.comments import CommentedMap -from schema_salad.exceptions import SchemaSaladException, ValidationException -from schema_salad.fetcher import DefaultFetcher, Fetcher, MemoryCachingFetcher +from schema_salad.exceptions import ValidationException, SchemaSaladException +from schema_salad.runtime import ( + LoadingOptions, + convert_typing, + extract_type, + SaveableType, + FieldType, + EnumFieldType, +) from schema_salad.sourceline import SourceLine, add_lc_filename -from schema_salad.utils import CacheType, yaml_no_ts # requires schema-salad v8.2+ - -_vocab: dict[str, str] = {} -_rvocab: dict[str, str] = {} - -_logger: Final = logging.getLogger("salad") - - -IdxType = MutableMapping[str, tuple[Any, "LoadingOptions"]] - - -class LoadingOptions: - idx: Final[IdxType] - fileuri: Final[Optional[str]] - baseuri: Final[str] - namespaces: Final[MutableMapping[str, str]] - schemas: Final[MutableSequence[str]] - original_doc: Final[Optional[Any]] - addl_metadata: Final[MutableMapping[str, Any]] - fetcher: Final[Fetcher] - vocab: Final[dict[str, str]] - rvocab: Final[dict[str, str]] - cache: Final[CacheType] - imports: Final[list[str]] - includes: Final[list[str]] - no_link_check: Final[Optional[bool]] - container: Final[Optional[str]] - - def __init__( - self, - fetcher: Optional[Fetcher] = None, - namespaces: Optional[dict[str, str]] = None, - schemas: Optional[list[str]] = None, - fileuri: Optional[str] = None, - copyfrom: Optional["LoadingOptions"] = None, - original_doc: Optional[Any] = None, - addl_metadata: Optional[dict[str, str]] = None, - baseuri: Optional[str] = None, - idx: Optional[IdxType] = None, - imports: Optional[list[str]] = None, - includes: Optional[list[str]] = None, - no_link_check: Optional[bool] = None, - container: Optional[str] = None, - ) -> None: - """Create a LoadingOptions object.""" - self.original_doc = original_doc - - if idx is not None: - temp_idx = idx - else: - temp_idx = copyfrom.idx if copyfrom is not None else {} - self.idx = temp_idx - - if fileuri is not None: - temp_fileuri: Optional[str] = fileuri - else: - temp_fileuri = copyfrom.fileuri if copyfrom is not None else None - self.fileuri = temp_fileuri - - if baseuri is not None: - temp_baseuri = baseuri - else: - temp_baseuri = copyfrom.baseuri if copyfrom is not None else "" - self.baseuri = temp_baseuri - - if namespaces is not None: - temp_namespaces: MutableMapping[str, str] = namespaces - else: - temp_namespaces = copyfrom.namespaces if copyfrom is not None else {} - self.namespaces = temp_namespaces - - if schemas is not None: - temp_schemas: MutableSequence[str] = schemas - else: - temp_schemas = copyfrom.schemas if copyfrom is not None else [] - self.schemas = temp_schemas - - if addl_metadata is not None: - temp_addl_metadata: MutableMapping[str, Any] = addl_metadata - else: - temp_addl_metadata = copyfrom.addl_metadata if copyfrom is not None else {} - self.addl_metadata = temp_addl_metadata - - if imports is not None: - temp_imports = imports - else: - temp_imports = copyfrom.imports if copyfrom is not None else [] - self.imports = temp_imports - - if includes is not None: - temp_includes = includes - else: - temp_includes = copyfrom.includes if copyfrom is not None else [] - self.includes = temp_includes - - if no_link_check is not None: - temp_no_link_check: Optional[bool] = no_link_check - else: - temp_no_link_check = copyfrom.no_link_check if copyfrom is not None else False - self.no_link_check = temp_no_link_check - - if container is not None: - temp_container: Optional[str] = container - else: - temp_container = copyfrom.container if copyfrom is not None else None - self.container = temp_container - - if fetcher is not None: - temp_fetcher = fetcher - elif copyfrom is not None: - temp_fetcher = copyfrom.fetcher - else: - import requests - from cachecontrol.caches import SeparateBodyFileCache - from cachecontrol.wrapper import CacheControl - - root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir())) - session = CacheControl( - requests.Session(), - cache=SeparateBodyFileCache(root / ".cache" / "salad"), - ) - temp_fetcher = DefaultFetcher({}, session) - self.fetcher = temp_fetcher - - self.cache = self.fetcher.cache if isinstance(self.fetcher, MemoryCachingFetcher) else {} - - if self.namespaces != {}: - temp_vocab = _vocab.copy() - temp_rvocab = _rvocab.copy() - for k, v in self.namespaces.items(): - temp_vocab[k] = v - temp_rvocab[v] = k - else: - temp_vocab = _vocab - temp_rvocab = _rvocab - self.vocab = temp_vocab - self.rvocab = temp_rvocab - - @property - def graph(self) -> Graph: - """Generate a merged rdflib.Graph from all entries in self.schemas.""" - graph = Graph() - if not self.schemas: - return graph - key: Final = str(hash(tuple(self.schemas))) - if key in self.cache: - return cast(Graph, self.cache[key]) - for schema in self.schemas: - fetchurl = ( - self.fetcher.urljoin(self.fileuri, schema) - if self.fileuri is not None - else pathlib.Path(schema).resolve().as_uri() - ) - if fetchurl not in self.cache or self.cache[fetchurl] is True: - _logger.debug("Getting external schema %s", fetchurl) - try: - content = self.fetcher.fetch_text(fetchurl) - except Exception as e: - _logger.warning("Could not load extension schema %s: %s", fetchurl, str(e)) - continue - newGraph = Graph() - err_msg = "unknown error" - for fmt in ["xml", "turtle"]: - try: - newGraph.parse(data=content, format=fmt, publicID=str(fetchurl)) - self.cache[fetchurl] = newGraph - graph += newGraph - break - except (xml.sax.SAXParseException, TypeError, BadSyntax) as e: - err_msg = str(e) - else: - _logger.warning("Could not load extension schema %s: %s", fetchurl, err_msg) - self.cache[key] = graph - return graph +from schema_salad.utils import yaml_no_ts # requires schema-salad v8.2+ +_vocab: Final[dict[str, str]] = {} +_rvocab: Final[dict[str, str]] = {} -class Saveable(ABC): - """Mark classes than have a save() and fromDoc() function.""" - - @classmethod - @abstractmethod - def fromDoc( - cls, - _doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - ) -> "Saveable": - """Construct this object from the result of yaml.load().""" +@mypyc_attr(native_class=True) +class _Loader(Generic[FieldType], metaclass=ABCMeta): @abstractmethod - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - """Convert this object to a JSON/YAML friendly dictionary.""" - - -def load_field( - val: Union[str, dict[str, str]], - fieldtype: "_Loader", - baseuri: str, - loadingOptions: LoadingOptions, - lc: Optional[list[Any]] = None, -) -> Any: - """Load field.""" - if isinstance(val, MutableMapping): - if "$import" in val: - if loadingOptions.fileuri is None: - raise SchemaSaladException("Cannot load $import without fileuri") - url1: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$import"]) - result, metadata = _document_load_by_url( - fieldtype, - url1, - loadingOptions, - ) - loadingOptions.imports.append(url1) - return result - if "$include" in val: - if loadingOptions.fileuri is None: - raise SchemaSaladException("Cannot load $import without fileuri") - url2: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) - val = loadingOptions.fetcher.fetch_text(url2) - loadingOptions.includes.append(url2) - return fieldtype.load(val, baseuri, loadingOptions, lc=lc) - - -save_type = Optional[Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]] - - -def extract_type(val_type: type[Any]) -> str: - """Take a type of value, and extracts the value as a string.""" - val_str: Final = str(val_type) - return val_str.split("'")[1] - - -def convert_typing(val_type: str) -> str: - """Normalize type names to schema-salad types.""" - if "None" in val_type: - return "null" - if "CommentedSeq" in val_type or "list" in val_type: - return "array" - if "CommentedMap" in val_type or "dict" in val_type: - return "object" - if "False" in val_type or "True" in val_type: - return "boolean" - return val_type - - -def parse_errors(error_message: str) -> tuple[str, str, str]: - """Parse error messages from several loaders into one error message.""" - if not error_message.startswith("Expected"): - return error_message, "", "" - vals: Final = error_message.split("\n") - if len(vals) == 1: - return error_message, "", "" - types1: Final = set() - for val in vals: - individual_vals = val.split(" ") - if val == "": - continue - if individual_vals[1] == "one": - individual_vals = val.split("(")[1].split(",") - for t in individual_vals: - types1.add(t.strip(" ").strip(")\n")) - elif individual_vals[2] == "").replace("'", "")) - elif individual_vals[0] == "Value": - types1.add(individual_vals[-1].strip(".")) - else: - types1.add(individual_vals[1].replace(",", "")) - types2: Final = {val for val in types1 if val != "NoneType"} - if "str" in types2: - types3 = {convert_typing(val) for val in types2 if "'" not in val} - else: - types3 = types2 - to_print = "" - for val in types3: - if "'" in val: - to_print = "value" if len(types3) == 1 else "values" - - if to_print == "": - to_print = "type" if len(types3) == 1 else "types" - - verb_tensage: Final = "is" if len(types3) == 1 else "are" - - return str(types3).replace("{", "(").replace("}", ")").replace("'", ""), to_print, verb_tensage - - -def save( - val: Any, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, -) -> save_type: - if isinstance(val, Saveable): - return val.save(top=top, base_url=base_url, relative_uris=relative_uris) - if isinstance(val, MutableSequence): - return [save(v, top=False, base_url=base_url, relative_uris=relative_uris) for v in val] - if isinstance(val, MutableMapping): - newdict: Final = {} - for key in val: - newdict[key] = save(val[key], top=False, base_url=base_url, relative_uris=relative_uris) - return newdict - if val is None or isinstance(val, (int, float, bool, str)): - return val - raise Exception("Not Saveable: %s" % type(val)) - - -def save_with_metadata( - val: Any, - valLoadingOpts: LoadingOptions, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, -) -> save_type: - """Save and set $namespaces, $schemas, $base and any other metadata fields at the top level.""" - saved_val: Final = save(val, top, base_url, relative_uris) - newdict: MutableMapping[str, Any] = {} - if isinstance(saved_val, MutableSequence): - newdict = {"$graph": saved_val} - elif isinstance(saved_val, MutableMapping): - newdict = saved_val - - if valLoadingOpts.namespaces: - newdict["$namespaces"] = valLoadingOpts.namespaces - if valLoadingOpts.schemas: - newdict["$schemas"] = valLoadingOpts.schemas - if valLoadingOpts.baseuri: - newdict["$base"] = valLoadingOpts.baseuri - for k, v in valLoadingOpts.addl_metadata.items(): - if k not in newdict: - newdict[k] = v - - return newdict - - -def expand_url( - url: str, - base_url: str, - loadingOptions: LoadingOptions, - scoped_id: bool = False, - vocab_term: bool = False, - scoped_ref: Optional[int] = None, -) -> str: - if url in ("@id", "@type"): - return url - - if vocab_term and url in loadingOptions.vocab: - return url - - if bool(loadingOptions.vocab) and ":" in url: - prefix: Final = url.split(":")[0] - if prefix in loadingOptions.vocab: - url = loadingOptions.vocab[prefix] + url[len(prefix) + 1 :] - - split1: Final = urlsplit(url) - - if ( - (bool(split1.scheme) and split1.scheme in loadingOptions.fetcher.supported_schemes()) - or url.startswith("$(") - or url.startswith("${") - ): - pass - elif scoped_id and not bool(split1.fragment): - splitbase1: Final = urlsplit(base_url) - frg: str - if bool(splitbase1.fragment): - frg = splitbase1.fragment + "/" + split1.path - else: - frg = split1.path - pt: Final = splitbase1.path if splitbase1.path != "" else "/" - url = urlunsplit((splitbase1.scheme, splitbase1.netloc, pt, splitbase1.query, frg)) - elif scoped_ref is not None and not bool(split1.fragment): - splitbase2: Final = urlsplit(base_url) - sp = splitbase2.fragment.split("/") - n = scoped_ref - while n > 0 and len(sp) > 0: - sp.pop() - n -= 1 - sp.append(url) - url = urlunsplit( - ( - splitbase2.scheme, - splitbase2.netloc, - splitbase2.path, - splitbase2.query, - "/".join(sp), - ) - ) - else: - url = loadingOptions.fetcher.urljoin(base_url, url) - - if vocab_term: - split2: Final = urlsplit(url) - if bool(split2.scheme): - if url in loadingOptions.rvocab: - return loadingOptions.rvocab[url] - else: - raise ValidationException(f"Term {url!r} not in vocabulary") - - return url - - -class _Loader: def load( self, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: - pass + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: ... -class _AnyLoader(_Loader): +@mypyc_attr(native_class=True) +class _AnyLoader(_Loader[Any]): def load( self, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, + docRoot: str | None = None, + lc: Any | None = None, ) -> Any: if doc is not None: return doc raise ValidationException("Expected non-null") -class _PrimitiveLoader(_Loader): - def __init__(self, tp: Union[type, tuple[type[str], type[str]]]) -> None: +@mypyc_attr(native_class=True) +class _PrimitiveLoader(_Loader[FieldType]): + def __init__(self, tp: type[FieldType]) -> None: self.tp: Final = tp def load( @@ -463,9 +95,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if not isinstance(doc, self.tp): raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}") return doc @@ -474,8 +106,9 @@ def __repr__(self) -> str: return str(self.tp) -class _ArrayLoader(_Loader): - def __init__(self, items: _Loader) -> None: +@mypyc_attr(native_class=True) +class _ArrayLoader(_Loader[Sequence[FieldType]]): + def __init__(self, items: _Loader[FieldType]) -> None: self.items: Final = items def load( @@ -483,9 +116,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> list[FieldType]: if not isinstance(doc, MutableSequence): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " @@ -496,7 +129,7 @@ def load( fields: Final[list[str]] = [] for i in range(0, len(doc)): try: - lf = load_field( + lf = _load_field( doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc ) flatten = loadingOptions.container != "@list" @@ -531,13 +164,14 @@ def __repr__(self) -> str: return f"array<{self.items}>" -class _MapLoader(_Loader): +@mypyc_attr(native_class=True) +class _MapLoader(_Loader[Mapping[str, FieldType]]): def __init__( self, - values: _Loader, - name: Optional[str] = None, - container: Optional[str] = None, - no_link_check: Optional[bool] = None, + values: _Loader[FieldType], + name: str | None = None, + container: str | None = None, + no_link_check: bool | None = None, ) -> None: self.values: Final = values self.name: Final = name @@ -549,9 +183,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> dict[str, FieldType]: if not isinstance(doc, MutableMapping): raise ValidationException(f"Expected a map, was {type(doc)}") if self.container is not None or self.no_link_check is not None: @@ -562,7 +196,7 @@ def load( errors: Final[list[SchemaSaladException]] = [] for k, v in doc.items(): try: - lf = load_field(v, self.values, baseuri, loadingOptions, lc) + lf = _load_field(v, self.values, baseuri, loadingOptions, lc) r[k] = lf except ValidationException as e: errors.append(e.with_sourceline(SourceLine(doc, k, str))) @@ -574,7 +208,8 @@ def __repr__(self) -> str: return self.name if self.name is not None else f"map" -class _EnumLoader(_Loader): +@mypyc_attr(native_class=True) +class _EnumLoader(_Loader[EnumFieldType]): def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols: Final = symbols self.name: Final = name @@ -584,19 +219,20 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> EnumFieldType: if doc in self.symbols: - return doc + return cast(EnumFieldType, doc) raise ValidationException(f"Expected one of {self.symbols}") def __repr__(self) -> str: return self.name -class _SecondaryDSLLoader(_Loader): - def __init__(self, inner: _Loader) -> None: +@mypyc_attr(native_class=True) +class _SecondaryDSLLoader(_Loader[FieldType]): + def __init__(self, inner: _Loader[FieldType]) -> None: self.inner: Final = inner def load( @@ -604,75 +240,77 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: r: Final[list[dict[str, Any]]] = [] - if isinstance(doc, MutableSequence): - for d in doc: - if isinstance(d, str): - if d.endswith("?"): - r.append({"pattern": d[:-1], "required": False}) - else: - r.append({"pattern": d}) - elif isinstance(d, dict): - new_dict1: dict[str, Any] = {} - dict_copy = copy.deepcopy(d) - if "pattern" in dict_copy: - new_dict1["pattern"] = dict_copy.pop("pattern") - else: - raise ValidationException( - f"Missing pattern in secondaryFiles specification entry: {d}" + match doc: + case MutableSequence() as dlist: + for d in dlist: + if isinstance(d, str): + if d.endswith("?"): + r.append({"pattern": d[:-1], "required": False}) + else: + r.append({"pattern": d}) + elif isinstance(d, dict): + new_dict1: dict[str, Any] = {} + dict_copy = copy.deepcopy(d) + if "pattern" in dict_copy: + new_dict1["pattern"] = dict_copy.pop("pattern") + else: + raise ValidationException( + f"Missing pattern in secondaryFiles specification entry: {d}" + ) + new_dict1["required"] = ( + dict_copy.pop("required") if "required" in dict_copy else None ) - new_dict1["required"] = ( - dict_copy.pop("required") if "required" in dict_copy else None - ) - if len(dict_copy): - raise ValidationException( - "Unallowed values in secondaryFiles specification entry: {}".format( - dict_copy + if len(dict_copy): + raise ValidationException( + "Unallowed values in secondaryFiles specification entry: {}".format( + dict_copy + ) ) - ) - r.append(new_dict1) + r.append(new_dict1) + else: + raise ValidationException( + "Expected a string or sequence of (strings or mappings)." + ) + case MutableMapping() as decl: + new_dict2 = {} + doc_copy = copy.deepcopy(decl) + if "pattern" in doc_copy: + new_dict2["pattern"] = doc_copy.pop("pattern") else: raise ValidationException( - "Expected a string or sequence of (strings or mappings)." + f"Missing pattern in secondaryFiles specification entry: {decl}" ) - elif isinstance(doc, MutableMapping): - new_dict2: Final = {} - doc_copy: Final = copy.deepcopy(doc) - if "pattern" in doc_copy: - new_dict2["pattern"] = doc_copy.pop("pattern") - else: - raise ValidationException( - f"Missing pattern in secondaryFiles specification entry: {doc}" - ) - new_dict2["required"] = doc_copy.pop("required") if "required" in doc_copy else None + new_dict2["required"] = doc_copy.pop("required") if "required" in doc_copy else None - if len(doc_copy): - raise ValidationException( - f"Unallowed values in secondaryFiles specification entry: {doc_copy}" - ) - r.append(new_dict2) + if len(doc_copy): + raise ValidationException( + f"Unallowed values in secondaryFiles specification entry: {doc_copy}" + ) + r.append(new_dict2) - elif isinstance(doc, str): - if doc.endswith("?"): - r.append({"pattern": doc[:-1], "required": False}) - else: - r.append({"pattern": doc}) - else: - raise ValidationException("Expected str or sequence of str") + case str(decl): + if decl.endswith("?"): + r.append({"pattern": decl[:-1], "required": False}) + else: + r.append({"pattern": decl}) + case _: + raise ValidationException("Expected str or sequence of str") return self.inner.load(r, baseuri, loadingOptions, docRoot, lc=lc) -class _RecordLoader(_Loader): +@mypyc_attr(native_class=True) +class _RecordLoader(_Loader[SaveableType]): def __init__( self, - classtype: type[Saveable], - container: Optional[str] = None, - no_link_check: Optional[bool] = None, + classtype: type[SaveableType], + container: str | None = None, + no_link_check: bool | None = None, ) -> None: self.classtype: Final = classtype self.container: Final = container @@ -683,9 +321,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> SaveableType: if not isinstance(doc, MutableMapping): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " @@ -701,7 +339,8 @@ def __repr__(self) -> str: return str(self.classtype.__name__) -class _ExpressionLoader(_Loader): +@mypyc_attr(native_class=True) +class _ExpressionLoader(_Loader[str]): def __init__(self, items: type[str]) -> None: self.items: Final = items @@ -710,23 +349,25 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> str: if not isinstance(doc, str): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " f"but valid type for this field is a str." ) - return doc + else: + return doc -class _UnionLoader(_Loader): - def __init__(self, alternates: Sequence[_Loader], name: Optional[str] = None) -> None: +@mypyc_attr(native_class=True) +class _UnionLoader(_Loader[FieldType]): + def __init__(self, alternates: Sequence[_Loader[FieldType]], name: str | None = None) -> None: self.alternates = alternates self.name: Final = name - def add_loaders(self, loaders: Sequence[_Loader]) -> None: + def add_loaders(self, loaders: Sequence[_Loader[FieldType]]) -> None: self.alternates = tuple(loader for loader in chain(self.alternates, loaders)) def load( @@ -734,9 +375,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: errors: Final = [] if lc is None: @@ -811,14 +452,15 @@ def __repr__(self) -> str: return self.name if self.name is not None else " | ".join(str(a) for a in self.alternates) -class _URILoader(_Loader): +@mypyc_attr(native_class=True) +class _URILoader(_Loader[FieldType]): def __init__( self, - inner: _Loader, + inner: _Loader[FieldType], scoped_id: bool, vocab_term: bool, - scoped_ref: Optional[int], - no_link_check: Optional[bool], + scoped_ref: int | None, + no_link_check: bool | None, ) -> None: self.inner: Final = inner self.scoped_id: Final = scoped_id @@ -831,39 +473,40 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if self.no_link_check is not None: loadingOptions = LoadingOptions( copyfrom=loadingOptions, no_link_check=self.no_link_check ) - if isinstance(doc, MutableSequence): - newdoc: Final = [] - for i in doc: - if isinstance(i, str): - newdoc.append( - expand_url( - i, - baseuri, - loadingOptions, - self.scoped_id, - self.vocab_term, - self.scoped_ref, - ) - ) - else: - newdoc.append(i) - doc = newdoc - elif isinstance(doc, str): - doc = expand_url( - doc, - baseuri, - loadingOptions, - self.scoped_id, - self.vocab_term, - self.scoped_ref, - ) + match doc: + case MutableSequence() as decl: + newdoc: Final = [] + for i in decl: + if isinstance(i, str): + newdoc.append( + _expand_url( + i, + baseuri, + loadingOptions, + self.scoped_id, + self.vocab_term, + self.scoped_ref, + ) + ) + else: + newdoc.append(i) + doc = newdoc + case str(decl): + doc = _expand_url( + decl, + baseuri, + loadingOptions, + self.scoped_id, + self.vocab_term, + self.scoped_ref, + ) if isinstance(doc, str): if not loadingOptions.no_link_check: errors: Final = [] @@ -879,8 +522,14 @@ def load( return self.inner.load(doc, baseuri, loadingOptions, lc=lc) -class _TypeDSLLoader(_Loader): - def __init__(self, inner: _Loader, refScope: Optional[int], salad_version: str) -> None: +@mypyc_attr(native_class=True) +class _TypeDSLLoader(_Loader[FieldType]): + def __init__( + self, + inner: _Loader[FieldType], + refScope: int | None, + salad_version: str, + ) -> None: self.inner: Final = inner self.refScope: Final = refScope self.salad_version: Final = salad_version @@ -890,7 +539,7 @@ def resolve( doc: str, baseuri: str, loadingOptions: LoadingOptions, - ) -> Union[list[Union[dict[str, Any], str]], dict[str, Any], str]: + ) -> list[dict[str, Any] | str] | dict[str, Any] | str: doc_ = doc optional = False if doc_.endswith("?"): @@ -899,21 +548,42 @@ def resolve( if doc_.endswith("[]"): salad_versions: Final = [int(v) for v in self.salad_version[1:].split(".")] - items: Union[list[Union[dict[str, Any], str]], dict[str, Any], str] = "" + items: list[dict[str, Any] | str] | dict[str, Any] | str = "" rest: Final = doc_[0:-2] if salad_versions < [1, 3]: if rest.endswith("[]"): # To show the error message with the original type return doc else: - items = expand_url(rest, baseuri, loadingOptions, False, True, self.refScope) + items = _expand_url( + rest, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) else: items = self.resolve(rest, baseuri, loadingOptions) if isinstance(items, str): - items = expand_url(items, baseuri, loadingOptions, False, True, self.refScope) - expanded: Union[dict[str, Any], str] = {"type": "array", "items": items} + items = _expand_url( + items, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) + expanded: dict[str, Any] | str = {"type": "array", "items": items} else: - expanded = expand_url(doc_, baseuri, loadingOptions, False, True, self.refScope) + expanded = _expand_url( + doc_, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) if optional: return ["null", expanded] @@ -925,9 +595,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if isinstance(doc, MutableSequence): r: Final[list[Any]] = [] for d in doc: @@ -949,8 +619,10 @@ def load( return self.inner.load(doc, baseuri, loadingOptions, lc=lc) -class _IdMapLoader(_Loader): - def __init__(self, inner: _Loader, mapSubject: str, mapPredicate: Optional[str]) -> None: +class _IdMapLoader(_Loader[FieldType]): + def __init__( + self, inner: _Loader[FieldType], mapSubject: str, mapPredicate: str | None + ) -> None: self.inner: Final = inner self.mapSubject: Final = mapSubject self.mapPredicate: Final = mapPredicate @@ -960,9 +632,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if isinstance(doc, MutableMapping): r: Final[list[Any]] = [] for k in doc.keys(): @@ -989,12 +661,12 @@ def load( def _document_load( - loader: _Loader, - doc: Union[str, MutableMapping[str, Any], MutableSequence[Any]], + loader: _Loader[FieldType], + doc: str | MutableMapping[str, Any] | MutableSequence[Any], baseuri: str, loadingOptions: LoadingOptions, - addl_metadata_fields: Optional[MutableSequence[str]] = None, -) -> tuple[Any, LoadingOptions]: + addl_metadata_fields: MutableSequence[str] | None = None, +) -> tuple[FieldType, LoadingOptions]: if isinstance(doc, str): return _document_load_by_url( loader, @@ -1059,11 +731,11 @@ def _document_load( def _document_load_by_url( - loader: _Loader, + loader: _Loader[FieldType], url: str, loadingOptions: LoadingOptions, - addl_metadata_fields: Optional[MutableSequence[str]] = None, -) -> tuple[Any, LoadingOptions]: + addl_metadata_fields: MutableSequence[str] | None = None, +) -> tuple[FieldType, LoadingOptions]: if url in loadingOptions.idx: return loadingOptions.idx[url] @@ -1089,118 +761,313 @@ def _document_load_by_url( return loadingOptions.idx[url] -def file_uri(path: str, split_frag: bool = False) -> str: - """Transform a file path into a URL with file scheme.""" - if path.startswith("file://"): - return path - if split_frag: - pathsp: Final = path.split("#", 2) - frag = "#" + quote(str(pathsp[1])) if len(pathsp) == 2 else "" - urlpath = pathname2url(str(pathsp[0])) - else: - urlpath = pathname2url(path) - frag = "" - if urlpath.startswith("//"): - return f"file:{urlpath}{frag}" - return f"file://{urlpath}{frag}" - - -def prefix_url(url: str, namespaces: dict[str, str]) -> str: - """Expand short forms into full URLs using the given namespace dictionary.""" - for k, v in namespaces.items(): - if url.startswith(v): - return k + ":" + url[len(v) :] - return url - - -def save_relative_uri( - uri: Any, +def _expand_url( + url: str, base_url: str, - scoped_id: bool, - ref_scope: Optional[int], - relative_uris: bool, -) -> Any: - """Convert any URI to a relative one, obeying the scoping rules.""" - if isinstance(uri, MutableSequence): - return [save_relative_uri(u, base_url, scoped_id, ref_scope, relative_uris) for u in uri] - elif isinstance(uri, str): - if not relative_uris or uri == base_url: - return uri - urisplit: Final = urlsplit(uri) - basesplit: Final = urlsplit(base_url) - if urisplit.scheme == basesplit.scheme and urisplit.netloc == basesplit.netloc: - if urisplit.path != basesplit.path: - p = os.path.relpath(urisplit.path, os.path.dirname(basesplit.path)) - if urisplit.fragment: - p = p + "#" + urisplit.fragment - return p - - basefrag = basesplit.fragment + "/" - if ref_scope: - sp = basefrag.split("/") - i = 0 - while i < ref_scope: - sp.pop() - i += 1 - basefrag = "/".join(sp) - - if urisplit.fragment.startswith(basefrag): - return urisplit.fragment[len(basefrag) :] - return urisplit.fragment - return uri - else: - return save(uri, top=False, base_url=base_url, relative_uris=relative_uris) - - -def shortname(inputid: str) -> str: - """ - Compute the shortname of a fully qualified identifier. - - See https://w3id.org/cwl/v1.2/SchemaSalad.html#Short_names. - """ - parsed_id: Final = urlparse(inputid) - if parsed_id.fragment: - return parsed_id.fragment.split("/")[-1] - return parsed_id.path.split("/")[-1] - - -def parser_info() -> str: - return "org.w3id.cwl.v1_0" - - -class Documented(Saveable): - pass + loadingOptions: LoadingOptions, + scoped_id: bool = False, + vocab_term: bool = False, + scoped_ref: int | None = None, +) -> str: + if url in ("@id", "@type"): + return url + vocab = _vocab | loadingOptions.vocab + if vocab_term and url in vocab: + return url -class RecordField(Documented): - """ - A field of a record. - """ + if bool(vocab) and ":" in url: + prefix: Final = url.split(":")[0] + if prefix in vocab: + url = vocab[prefix] + url[len(prefix) + 1 :] - name: str + split1: Final = urlsplit(url) - def __init__( - self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions + if ( + (bool(split1.scheme) and split1.scheme in loadingOptions.fetcher.supported_schemes()) + or url.startswith("$(") + or url.startswith("${") + ): + pass + elif scoped_id and not bool(split1.fragment): + splitbase1: Final = urlsplit(base_url) + frg: str + if bool(splitbase1.fragment): + frg = splitbase1.fragment + "/" + split1.path else: - self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + frg = split1.path + pt: Final = splitbase1.path if splitbase1.path != "" else "/" + url = urlunsplit((splitbase1.scheme, splitbase1.netloc, pt, splitbase1.query, frg)) + elif scoped_ref is not None and not bool(split1.fragment): + splitbase2: Final = urlsplit(base_url) + sp = splitbase2.fragment.split("/") + n = scoped_ref + while n > 0 and len(sp) > 0: + sp.pop() + n -= 1 + sp.append(url) + url = urlunsplit( + ( + splitbase2.scheme, + splitbase2.netloc, + splitbase2.path, + splitbase2.query, + "/".join(sp), + ) + ) + else: + url = loadingOptions.fetcher.urljoin(base_url, url) + + if vocab_term: + split2: Final = urlsplit(url) + if bool(split2.scheme): + if url in (rvocab := _rvocab | loadingOptions.rvocab): + return rvocab[url] + else: + raise ValidationException(f"Term {url!r} not in vocabulary") + + return url + + +def _load_field( + val: Any | None, + fieldtype: _Loader[FieldType], + baseuri: str, + loadingOptions: LoadingOptions, + lc: Any | None = None, +) -> FieldType: + """Load field.""" + if isinstance(val, MutableMapping): + if "$import" in val: + if loadingOptions.fileuri is None: + raise SchemaSaladException("Cannot load $import without fileuri") + url1: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$import"]) + result, metadata = _document_load_by_url( + fieldtype, + url1, + loadingOptions, + ) + loadingOptions.imports.append(url1) + return result + if "$include" in val: + if loadingOptions.fileuri is None: + raise SchemaSaladException("Cannot load $import without fileuri") + url2: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) + val = loadingOptions.fetcher.fetch_text(url2) + loadingOptions.includes.append(url2) + return fieldtype.load(val, baseuri, loadingOptions, lc=lc) + + +def parser_info() -> str: + return "org.w3id.cwl.v1_0" + + +@mypyc_attr(native_class=True) +class CWLArraySchema(schema_salad.metaschema.ArraySchema): + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLArraySchema | CWLRecordSchema | PrimitiveType | Sequence[CWLArraySchema | CWLRecordSchema | PrimitiveType | schema_salad.metaschema.EnumSchema | str] | schema_salad.metaschema.EnumSchema | str, + type_: Array_name, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["items", "type"]) + + +@mypyc_attr(native_class=True) +class CWLRecordField(schema_salad.metaschema.RecordField): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, RecordField): + if isinstance(other, CWLRecordField): return bool( self.doc == other.doc and self.name == other.name @@ -1217,8 +1084,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "RecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -1228,7 +1095,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_strtype_True_False_None_None, baseuri, @@ -1273,18 +1140,18 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: + name = "" _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -1332,9 +1199,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2, + typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -1376,7 +1243,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -1384,7 +1251,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -1401,13 +1268,13 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + doc=doc, type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -1422,7 +1289,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.doc is not None: r["doc"] = save( @@ -1441,16 +1308,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type"]) - - -class RecordSchema(Saveable): def __init__( self, - type_: Any, - fields: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLArraySchema | CWLRecordSchema | PrimitiveType | Sequence[CWLArraySchema | CWLRecordSchema | PrimitiveType | schema_salad.metaschema.EnumSchema | str] | schema_salad.metaschema.EnumSchema | str, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -1460,11 +1324,17 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.doc = doc + self.name = name self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["doc", "name", "type"]) + + +@mypyc_attr(native_class=True) +class CWLRecordSchema(schema_salad.metaschema.RecordSchema): def __eq__(self, other: Any) -> bool: - if isinstance(other, RecordSchema): + if isinstance(other, CWLRecordSchema): return bool(self.fields == other.fields and self.type_ == other.type_) return False @@ -1477,8 +1347,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "RecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -1488,9 +1358,9 @@ def fromDoc( fields = None if "fields" in _doc: try: - fields = load_field( + fields = _load_field( _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader, + idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, baseuri, loadingOptions, lc=_doc.get("fields") @@ -1536,7 +1406,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, @@ -1580,7 +1450,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -1588,7 +1458,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -1640,24 +1510,12 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type"]) - - -class EnumSchema(Saveable): - """ - Define an enumerated type. - - """ - - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CWLRecordField] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -1667,21 +1525,76 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.fields = fields self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type"]) + + +@mypyc_attr(native_class=True) +class File(Saveable): + """ + Represents a file (or group of files when ``secondaryFiles`` is provided) that will be accessible by tools using standard POSIX file system call API such as open(2) and read(2). + + Files are represented as objects with ``class`` of ``File``. File objects have a number of properties that provide metadata about the file. + + The ``location`` property of a File is a URI that uniquely identifies the file. Implementations must support the file:// URI scheme and may support other schemes such as http://. The value of ``location`` may also be a relative reference, in which case it must be resolved relative to the URI of the document it appears in. Alternately to ``location``, implementations must also accept the ``path`` property on File, which must be a filesystem path available on the same host as the CWL runner (for inputs) or the runtime environment of a command line tool execution (for command line tool outputs). + + If no ``location`` or ``path`` is specified, a file object must specify ``contents`` with the UTF-8 text content of the file. This is a "file literal". File literals do not correspond to external resources, but are created on disk with ``contents`` with when needed for a executing a tool. Where appropriate, expressions can return file literals to define new files on a runtime. The maximum size of ``contents`` is 64 kilobytes. + + The ``basename`` property defines the filename on disk where the file is staged. This may differ from the resource name. If not provided, ``basename`` must be computed from the last path part of ``location`` and made available to expressions. + + The ``secondaryFiles`` property is a list of File or Directory objects that must be staged in the same directory as the primary file. It is an error for file names to be duplicated in ``secondaryFiles``. + + The ``size`` property is the size in bytes of the File. It must be computed from the resource and made available to expressions. The ``checksum`` field contains a cryptographic hash of the file content for use it verifying file contents. Implementations may, at user option, enable or disable computation of the ``checksum`` field for performance or other reasons. However, the ability to compute output checksums is required to pass the CWL conformance test suite. + + When executing a CommandLineTool, the files and secondary files may be staged to an arbitrary directory, but must use the value of ``basename`` for the filename. The ``path`` property must be file path in the context of the tool execution runtime (local to the compute node, or within the executing container). All computed properties should be available to expressions. File literals also must be staged and ``path`` must be set. + + When collecting CommandLineTool outputs, ``glob`` matching returns file paths (with the ``path`` property) and the derived properties. This can all be modified by ``outputEval``. Alternately, if the file ``cwl.output.json`` is present in the output, ``outputBinding`` is ignored. + + File objects in the output must provide either a ``location`` URI or a ``path`` property in the context of the tool execution runtime (local to the compute node, or within the executing container). + + When evaluating an ExpressionTool, file objects must be referenced via ``location`` (the expression tool does not have access to files on disk so ``path`` is meaningless) or as file literals. It is legal to return a file object with an existing ``location`` but a different ``basename``. The ``loadContents`` field of ExpressionTool inputs behaves the same as on CommandLineTool inputs, however it is not meaningful on the outputs. + + An ExpressionTool may forward file references from input to output by using the same value for ``location``. + + """ + def __eq__(self, other: Any) -> bool: - if isinstance(other, EnumSchema): + if isinstance(other, File): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ + self.class_ == other.class_ + and self.location == other.location + and self.path == other.path + and self.basename == other.basename + and self.dirname == other.dirname + and self.nameroot == other.nameroot + and self.nameext == other.nameext + and self.checksum == other.checksum + and self.size == other.size + and self.secondaryFiles == other.secondaryFiles + and self.format == other.format + and self.contents == other.contents ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_)) + return hash( + ( + self.class_, + self.location, + self.path, + self.basename, + self.dirname, + self.nameroot, + self.nameext, + self.checksum, + self.size, + self.secondaryFiles, + self.format, + self.contents, + ) + ) @classmethod def fromDoc( @@ -1689,29 +1602,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_File_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + location = None + if "location" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + location = _load_field( + _doc.get("location"), + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("location") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `location`": _errors__.append( ValidationException( str(e), @@ -1719,13 +1649,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("location") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -1737,548 +1667,519 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `location` field with value `{val}` " "is not valid because:", ) ) + path = None + if "path" in _doc: + try: + path = _load_field( + _doc.get("path"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("path") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `path`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + val = _doc.get("path") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + detailed_message=f"the `path` field with value `{val}` " + "is not valid because:", + ) + ) + basename = None + if "basename" in _doc: + try: + basename = _load_field( + _doc.get("basename"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("basename") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("basename") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + detailed_message=f"the `basename` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type"]) - - -class ArraySchema(Saveable): - def __init__( - self, - items: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ArraySchema): - return bool(self.items == other.items and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.items, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ArraySchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) + dirname = None + if "dirname" in _doc: + try: + dirname = _load_field( + _doc.get("dirname"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dirname") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `dirname`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", + val = _doc.get("dirname") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [e], + detailed_message=f"the `dirname` field with value `{val}` " + "is not valid because:", + ) + ) + nameroot = None + if "nameroot" in _doc: + try: + nameroot = _load_field( + _doc.get("nameroot"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("nameroot") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `nameroot`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("nameroot") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [e], + detailed_message=f"the `nameroot` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - items=items, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["items", "type"]) - - -class MapSchema(Saveable): - def __init__( - self, - type_: Any, - values: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.type_ = type_ - self.values = values - - def __eq__(self, other: Any) -> bool: - if isinstance(other, MapSchema): - return bool(self.type_ == other.type_ and self.values == other.values) - return False - - def __hash__(self) -> int: - return hash((self.type_, self.values)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MapSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Map_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + nameext = None + if "nameext" in _doc: + try: + nameext = _load_field( + _doc.get("nameext"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("nameext") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `nameext`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("nameext") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("values") is None: - raise ValidationException("missing required field `values`", None, []) - - values = load_field( - _doc.get("values"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("values") - ) + else: + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [e], + detailed_message=f"the `nameext` field with value `{val}` " + "is not valid because:", + ) + ) + checksum = None + if "checksum" in _doc: + try: + checksum = _load_field( + _doc.get("checksum"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("checksum") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `values`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("values") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `checksum`": _errors__.append( ValidationException( - "the `values` field is not valid because:", - SourceLine(_doc, "values", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `values` field is not valid because:", - SourceLine(_doc, "values", str), - [e], - detailed_message=f"the `values` field with value `{val}` " - "is not valid because:", + val = _doc.get("checksum") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + else: + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [e], + detailed_message=f"the `checksum` field with value `{val}` " + "is not valid because:", + ) + ) + size = None + if "size" in _doc: + try: + size = _load_field( + _doc.get("size"), + union_of_None_type_or_inttype_or_longtype, + baseuri, + loadingOptions, + lc=_doc.get("size") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `type`, `values`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") + else: + val = _doc.get("size") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + detailed_message=f"the `size` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + contents = None + if "contents" in _doc: + try: + contents = _load_field( + _doc.get("contents"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("contents") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `contents`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("contents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [e], + detailed_message=f"the `contents` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `dirname`, `nameroot`, `nameext`, `checksum`, `size`, `secondaryFiles`, `format`, `contents`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") _constructed = cls( - type_=type_, - values=values, + location=location, + path=path, + basename=basename, + dirname=dirname, + nameroot=nameroot, + nameext=nameext, + checksum=checksum, + size=size, + secondaryFiles=secondaryFiles, + format=format, + contents=contents, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -2295,13 +2196,60 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.location is not None: + u = save_relative_uri(self.location, base_url, False, None, relative_uris) + r["location"] = u + if self.path is not None: + u = save_relative_uri(self.path, base_url, False, None, relative_uris) + r["path"] = u + if self.basename is not None: + r["basename"] = save( + self.basename, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.dirname is not None: + r["dirname"] = save( + self.dirname, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.nameroot is not None: + r["nameroot"] = save( + self.nameroot, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.nameext is not None: + r["nameext"] = save( + self.nameext, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.checksum is not None: + r["checksum"] = save( + self.checksum, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, base_url, True, None, relative_uris) + r["format"] = u + if self.contents is not None: + r["contents"] = save( + self.contents, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.values is not None: - u = save_relative_uri(self.values, base_url, False, 2, relative_uris) - r["values"] = u # top refers to the directory level if top: @@ -2311,16 +2259,21 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["type", "values"]) - - -class UnionSchema(Saveable): def __init__( self, - names: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + location: None | str = None, + path: None | str = None, + basename: None | str = None, + dirname: None | str = None, + nameroot: None | str = None, + nameext: None | str = None, + checksum: None | str = None, + size: None | i32 | i64 = None, + secondaryFiles: None | Sequence[Directory | File] = None, + format: None | str = None, + contents: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2330,215 +2283,77 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.names = names - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, UnionSchema): - return bool(self.names == other.names and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.names, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "UnionSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("names") is None: - raise ValidationException("missing required field `names`", None, []) + self.class_: Final[str] = "File" + self.location = location + self.path = path + self.basename = basename + self.dirname = dirname + self.nameroot = nameroot + self.nameext = nameext + self.checksum = checksum + self.size = size + self.secondaryFiles = secondaryFiles + self.format = format + self.contents = contents - names = load_field( - _doc.get("names"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("names") - ) + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "location", + "path", + "basename", + "dirname", + "nameroot", + "nameext", + "checksum", + "size", + "secondaryFiles", + "format", + "contents", + ] + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `names`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("names") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `names` field is not valid because:", - SourceLine(_doc, "names", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `names` field is not valid because:", - SourceLine(_doc, "names", str), - [e], - detailed_message=f"the `names` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) +@mypyc_attr(native_class=True) +class Directory(Saveable): + """ + Represents a directory to present to a command line tool. - type_ = load_field( - _doc.get("type"), - typedsl_Union_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + Directories are represented as objects with ``class`` of ``Directory``. Directory objects have a number of properties that provide metadata about the directory. - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + The ``location`` property of a Directory is a URI that uniquely identifies the directory. Implementations must support the file:// URI scheme and may support other schemes such as http://. Alternately to ``location``, implementations must also accept the ``path`` property on Directory, which must be a filesystem path available on the same host as the CWL runner (for inputs) or the runtime environment of a command line tool execution (for command line tool outputs). - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `names`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) + A Directory object may have a ``listing`` field. This is a list of File and Directory objects that are contained in the Directory. For each entry in ``listing``, the ``basename`` property defines the name of the File or Subdirectory when staged to disk. If ``listing`` is not provided, the implementation must have some way of fetching the Directory listing at runtime based on the ``location`` field. - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - names=names, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed + If a Directory does not have ``location``, it is a Directory literal. A Directory literal must provide ``listing``. Directory literals must be created on disk at runtime as needed. - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + The resources in a Directory literal do not need to have any implied relationship in their ``location``. For example, a Directory listing may contain two files located on different hosts. It is the responsibility of the runtime to ensure that those files are staged to disk appropriately. Secondary files associated with files in ``listing`` must also be staged to the same Directory. - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.names is not None: - u = save_relative_uri(self.names, base_url, False, 2, relative_uris) - r["names"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) + When executing a CommandLineTool, Directories must be recursively staged first and have local values of ``path`` assigned. - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r + Directory objects in CommandLineTool output must provide either a ``location`` URI or a ``path`` property in the context of the tool execution runtime (local to the compute node, or within the executing container). - attrs = frozenset(["names", "type"]) + An ExpressionTool may forward file references from input to output by using the same value for ``location``. + Name conflicts (the same ``basename`` appearing multiple times in ``listing`` or in any entry in ``secondaryFiles`` in the listing) is a fatal error. -class CWLArraySchema(ArraySchema): - def __init__( - self, - items: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLArraySchema): - return bool(self.items == other.items and self.type_ == other.type_) + if isinstance(other, Directory): + return bool( + self.class_ == other.class_ + and self.location == other.location + and self.path == other.path + and self.basename == other.basename + and self.listing == other.listing + ) return False def __hash__(self) -> int: - return hash((self.items, self.type_)) + return hash( + (self.class_, self.location, self.path, self.basename, self.listing) + ) @classmethod def fromDoc( @@ -2546,8 +2361,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -2555,102 +2370,211 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + class_ = _load_field( + _doc.get("class"), + uri_Directory_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("class") ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) + raise e + location = None + if "location" in _doc: + try: + location = _load_field( + _doc.get("location"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("location") ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + val = _doc.get("location") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + detailed_message=f"the `location` field with value `{val}` " + "is not valid because:", + ) + ) + path = None + if "path" in _doc: + try: + path = _load_field( + _doc.get("path"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("path") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("path") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + detailed_message=f"the `path` field with value `{val}` " + "is not valid because:", + ) + ) + basename = None + if "basename" in _doc: + try: + basename = _load_field( + _doc.get("basename"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("basename") ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("basename") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + detailed_message=f"the `basename` field with value `{val}` " + "is not valid because:", + ) + ) + listing = None + if "listing" in _doc: + try: + listing = _load_field( + _doc.get("listing"), + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("listing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - extension_fields: dict[str, Any] = {} + else: + val = _doc.get("listing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + detailed_message=f"the `listing` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -2658,14 +2582,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( + "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `listing`".format( k ), SourceLine(_doc, k, str), @@ -2675,8 +2599,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, + location=location, + path=path, + basename=basename, + listing=listing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -2693,12 +2619,29 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.location is not None: + u = save_relative_uri(self.location, base_url, False, None, relative_uris) + r["location"] = u + if self.path is not None: + u = save_relative_uri(self.path, base_url, False, None, relative_uris) + r["path"] = u + if self.basename is not None: + r["basename"] = save( + self.basename, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.listing is not None: + r["listing"] = save( + self.listing, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -2709,19 +2652,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type"]) - - -class CWLRecordField(RecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + location: None | str = None, + path: None | str = None, + basename: None | str = None, + listing: None | Sequence[Directory | File] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2731,21 +2669,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.type_ = type_ + self.class_: Final[str] = "Directory" + self.location = location + self.path = path + self.basename = basename + self.listing = listing + + attrs: ClassVar[Collection[str]] = frozenset( + ["class", "location", "path", "basename", "listing"] + ) + + +@mypyc_attr(native_class=True) +class InputRecordField(CWLRecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLRecordField): + if isinstance(other, InputRecordField): return bool( self.doc == other.doc and self.name == other.name and self.type_ == other.type_ + and self.inputBinding == other.inputBinding + and self.label == other.label ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_)) + return hash((self.doc, self.name, self.type_, self.inputBinding, self.label)) @classmethod def fromDoc( @@ -2753,8 +2704,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -2764,7 +2715,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_strtype_True_False_None_None, baseuri, @@ -2809,18 +2760,18 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: + name = "" _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -2868,9 +2819,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, + typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -2912,22 +2863,116 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `inputBinding`, `label`".format( k ), SourceLine(_doc, k, str), @@ -2937,13 +2982,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + doc=doc, type_=type_, + inputBinding=inputBinding, + label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -2958,7 +3005,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.doc is not None: r["doc"] = save( @@ -2968,6 +3015,17 @@ def save( r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -2977,16 +3035,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type"]) - - -class CWLRecordSchema(RecordSchema): def __init__( self, - type_: Any, - fields: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + inputBinding: CommandLineBinding | None = None, + label: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2996,16 +3053,33 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.doc = doc + self.name = name self.type_ = type_ + self.inputBinding = inputBinding + self.label = label + + attrs: ClassVar[Collection[str]] = frozenset( + ["doc", "name", "type", "inputBinding", "label"] + ) + + +@mypyc_attr(native_class=True) +class InputRecordSchema(CWLRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLRecordSchema): - return bool(self.fields == other.fields and self.type_ == other.type_) + if isinstance(other, InputRecordSchema): + return bool( + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.name == other.name + ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_)) + return hash((self.fields, self.type_, self.label, self.name)) @classmethod def fromDoc( @@ -3013,20 +3087,75 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + name = None + if "name" in _doc: + try: + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("name") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + detailed_message=f"the `name` field with value `{val}` " + "is not valid because:", + ) + ) + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name fields = None if "fields" in _doc: try: - fields = load_field( + fields = _load_field( _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, + idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, baseuri, loadingOptions, lc=_doc.get("fields") @@ -3072,7 +3201,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, @@ -3116,7 +3245,54 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -3124,14 +3300,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `name`".format( k ), SourceLine(_doc, k, str), @@ -3141,11 +3317,14 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, fields=fields, type_=type_, + label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -3159,13 +3338,20 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u if self.fields is not None: r["fields"] = save( - self.fields, top=False, base_url=base_url, relative_uris=relative_uris + self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) if self.type_ is not None: r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -3176,95 +3362,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type"]) - - -class File(Saveable): - """ - Represents a file (or group of files when `secondaryFiles` is provided) that - will be accessible by tools using standard POSIX file system call API such as - open(2) and read(2). - - Files are represented as objects with `class` of `File`. File objects have - a number of properties that provide metadata about the file. - - The `location` property of a File is a URI that uniquely identifies the - file. Implementations must support the file:// URI scheme and may support - other schemes such as http://. The value of `location` may also be a - relative reference, in which case it must be resolved relative to the URI - of the document it appears in. Alternately to `location`, implementations - must also accept the `path` property on File, which must be a filesystem - path available on the same host as the CWL runner (for inputs) or the - runtime environment of a command line tool execution (for command line tool - outputs). - - If no `location` or `path` is specified, a file object must specify - `contents` with the UTF-8 text content of the file. This is a "file - literal". File literals do not correspond to external resources, but are - created on disk with `contents` with when needed for a executing a tool. - Where appropriate, expressions can return file literals to define new files - on a runtime. The maximum size of `contents` is 64 kilobytes. - - The `basename` property defines the filename on disk where the file is - staged. This may differ from the resource name. If not provided, - `basename` must be computed from the last path part of `location` and made - available to expressions. - - The `secondaryFiles` property is a list of File or Directory objects that - must be staged in the same directory as the primary file. It is an error - for file names to be duplicated in `secondaryFiles`. - - The `size` property is the size in bytes of the File. It must be computed - from the resource and made available to expressions. The `checksum` field - contains a cryptographic hash of the file content for use it verifying file - contents. Implementations may, at user option, enable or disable - computation of the `checksum` field for performance or other reasons. - However, the ability to compute output checksums is required to pass the - CWL conformance test suite. - - When executing a CommandLineTool, the files and secondary files may be - staged to an arbitrary directory, but must use the value of `basename` for - the filename. The `path` property must be file path in the context of the - tool execution runtime (local to the compute node, or within the executing - container). All computed properties should be available to expressions. - File literals also must be staged and `path` must be set. - - When collecting CommandLineTool outputs, `glob` matching returns file paths - (with the `path` property) and the derived properties. This can all be - modified by `outputEval`. Alternately, if the file `cwl.output.json` is - present in the output, `outputBinding` is ignored. - - File objects in the output must provide either a `location` URI or a `path` - property in the context of the tool execution runtime (local to the compute - node, or within the executing container). - - When evaluating an ExpressionTool, file objects must be referenced via - `location` (the expression tool does not have access to files on disk so - `path` is meaningless) or as file literals. It is legal to return a file - object with an existing `location` but a different `basename`. The - `loadContents` field of ExpressionTool inputs behaves the same as on - CommandLineTool inputs, however it is not meaningful on the outputs. - - An ExpressionTool may forward file references from input to output by using - the same value for `location`. - - """ - def __init__( self, - location: Optional[Any] = None, - path: Optional[Any] = None, - basename: Optional[Any] = None, - dirname: Optional[Any] = None, - nameroot: Optional[Any] = None, - nameext: Optional[Any] = None, - checksum: Optional[Any] = None, - size: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - format: Optional[Any] = None, - contents: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[InputRecordField] = None, + label: None | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -3274,53 +3379,32 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "File" - self.location = location - self.path = path - self.basename = basename - self.dirname = dirname - self.nameroot = nameroot - self.nameext = nameext - self.checksum = checksum - self.size = size - self.secondaryFiles = secondaryFiles - self.format = format - self.contents = contents + self.fields = fields + self.type_ = type_ + self.label = label + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type", "label", "name"]) + + +@mypyc_attr(native_class=True) +class InputEnumSchema(schema_salad.metaschema.EnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, File): + if isinstance(other, InputEnumSchema): return bool( - self.class_ == other.class_ - and self.location == other.location - and self.path == other.path - and self.basename == other.basename - and self.dirname == other.dirname - and self.nameroot == other.nameroot - and self.nameext == other.nameext - and self.checksum == other.checksum - and self.size == other.size - and self.secondaryFiles == other.secondaryFiles - and self.format == other.format - and self.contents == other.contents + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ + and self.label == other.label + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: return hash( - ( - self.class_, - self.location, - self.path, - self.basename, - self.dirname, - self.nameroot, - self.nameext, - self.checksum, - self.size, - self.secondaryFiles, - self.format, - self.contents, - ) + (self.name, self.symbols, self.type_, self.label, self.inputBinding) ) @classmethod @@ -3329,45 +3413,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "File": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_File_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - location = None - if "location" in _doc: + name = None + if "name" in _doc: try: - location = load_field( - _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None_None, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("location") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `location`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3375,13 +3443,13 @@ def fromDoc( ) ) else: - val = _doc.get("location") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3393,75 +3461,132 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `location` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - path = None - if "path" in _doc: - try: - path = load_field( - _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("path") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - if str(e) == "missing required field `path`": + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("path") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) - else: - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [e], - detailed_message=f"the `path` field with value `{val}` " - "is not valid because:", - ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Enum_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - basename = None - if "basename" in _doc: + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - basename = load_field( - _doc.get("basename"), + label = _load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("basename") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `basename`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -3469,13 +3594,13 @@ def fromDoc( ) ) else: - val = _doc.get("basename") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3487,28 +3612,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `basename` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - dirname = None - if "dirname" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - dirname = load_field( - _doc.get("dirname"), - union_of_None_type_or_strtype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("dirname") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `dirname`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -3516,13 +3641,13 @@ def fromDoc( ) ) else: - val = _doc.get("dirname") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `dirname` field is not valid because:", - SourceLine(_doc, "dirname", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3534,28 +3659,259 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `dirname` field is not valid because:", - SourceLine(_doc, "dirname", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `dirname` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - nameroot = None - if "nameroot" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `inputBinding`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + symbols=symbols, + type_=type_, + label=label, + inputBinding=inputBinding, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols + self.type_ = type_ + self.label = label + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class InputArraySchema(CWLArraySchema): + def __eq__(self, other: Any) -> bool: + if isinstance(other, InputArraySchema): + return bool( + self.items == other.items + and self.type_ == other.type_ + and self.label == other.label + and self.inputBinding == other.inputBinding + ) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_, self.label, self.inputBinding)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - nameroot = load_field( - _doc.get("nameroot"), + label = _load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("nameroot") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `nameroot`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -3563,13 +3919,13 @@ def fromDoc( ) ) else: - val = _doc.get("nameroot") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `nameroot` field is not valid because:", - SourceLine(_doc, "nameroot", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3581,28 +3937,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `nameroot` field is not valid because:", - SourceLine(_doc, "nameroot", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `nameroot` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - nameext = None - if "nameext" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - nameext = load_field( - _doc.get("nameext"), - union_of_None_type_or_strtype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("nameext") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `nameext`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -3610,13 +3966,13 @@ def fromDoc( ) ) else: - val = _doc.get("nameext") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `nameext` field is not valid because:", - SourceLine(_doc, "nameext", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3628,28 +3984,158 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `nameext` field is not valid because:", - SourceLine(_doc, "nameext", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `nameext` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - checksum = None - if "checksum" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `inputBinding`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + label=label, + inputBinding=inputBinding, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + self.label = label + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class OutputRecordField(CWLRecordField): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, OutputRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.outputBinding == other.outputBinding + ) + return False + + def __hash__(self) -> int: + return hash((self.doc, self.name, self.type_, self.outputBinding)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - checksum = load_field( - _doc.get("checksum"), - union_of_None_type_or_strtype, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("checksum") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `checksum`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3657,13 +4143,13 @@ def fromDoc( ) ) else: - val = _doc.get("checksum") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `checksum` field is not valid because:", - SourceLine(_doc, "checksum", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3675,28 +4161,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `checksum` field is not valid because:", - SourceLine(_doc, "checksum", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `checksum` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_inttype, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -3704,13 +4199,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3722,28 +4217,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + outputBinding = None + if "outputBinding" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -3751,13 +4294,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3769,108 +4312,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - contents = None - if "contents" in _doc: - try: - contents = load_field( - _doc.get("contents"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("contents") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `contents`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("contents") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `contents` field is not valid because:", - SourceLine(_doc, "contents", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `contents` field is not valid because:", - SourceLine(_doc, "contents", str), - [e], - detailed_message=f"the `contents` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -3878,14 +4327,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `dirname`, `nameroot`, `nameext`, `checksum`, `size`, `secondaryFiles`, `format`, `contents`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -3895,20 +4344,14 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - location=location, - path=path, - basename=basename, - dirname=dirname, - nameroot=nameroot, - nameext=nameext, - checksum=checksum, - size=size, - secondaryFiles=secondaryFiles, - format=format, - contents=contents, + name=name, + doc=doc, + type_=type_, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -3922,58 +4365,24 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.location is not None: - u = save_relative_uri(self.location, base_url, False, None, relative_uris) - r["location"] = u - if self.path is not None: - u = save_relative_uri(self.path, base_url, False, None, relative_uris) - r["path"] = u - if self.basename is not None: - r["basename"] = save( - self.basename, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.dirname is not None: - r["dirname"] = save( - self.dirname, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.nameroot is not None: - r["nameroot"] = save( - self.nameroot, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.nameext is not None: - r["nameext"] = save( - self.nameext, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.checksum is not None: - r["checksum"] = save( - self.checksum, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) - if self.format is not None: - u = save_relative_uri(self.format, base_url, True, None, relative_uris) - r["format"] = u - if self.contents is not None: - r["contents"] = save( - self.contents, top=False, base_url=base_url, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -3983,80 +4392,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "location", - "path", - "basename", - "dirname", - "nameroot", - "nameext", - "checksum", - "size", - "secondaryFiles", - "format", - "contents", - ] - ) - - -class Directory(Saveable): - """ - Represents a directory to present to a command line tool. - - Directories are represented as objects with `class` of `Directory`. Directory objects have - a number of properties that provide metadata about the directory. - - The `location` property of a Directory is a URI that uniquely identifies - the directory. Implementations must support the file:// URI scheme and may - support other schemes such as http://. Alternately to `location`, - implementations must also accept the `path` property on Directory, which - must be a filesystem path available on the same host as the CWL runner (for - inputs) or the runtime environment of a command line tool execution (for - command line tool outputs). - - A Directory object may have a `listing` field. This is a list of File and - Directory objects that are contained in the Directory. For each entry in - `listing`, the `basename` property defines the name of the File or - Subdirectory when staged to disk. If `listing` is not provided, the - implementation must have some way of fetching the Directory listing at - runtime based on the `location` field. - - If a Directory does not have `location`, it is a Directory literal. A - Directory literal must provide `listing`. Directory literals must be - created on disk at runtime as needed. - - The resources in a Directory literal do not need to have any implied - relationship in their `location`. For example, a Directory listing may - contain two files located on different hosts. It is the responsibility of - the runtime to ensure that those files are staged to disk appropriately. - Secondary files associated with files in `listing` must also be staged to - the same Directory. - - When executing a CommandLineTool, Directories must be recursively staged - first and have local values of `path` assigend. - - Directory objects in CommandLineTool output must provide either a - `location` URI or a `path` property in the context of the tool execution - runtime (local to the compute node, or within the executing container). - - An ExpressionTool may forward file references from input to output by using - the same value for `location`. - - Name conflicts (the same `basename` appearing multiple times in `listing` - or in any entry in `secondaryFiles` in the listing) is a fatal error. - - """ - def __init__( self, - location: Optional[Any] = None, - path: Optional[Any] = None, - basename: Optional[Any] = None, - listing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4066,27 +4409,29 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "Directory" - self.location = location - self.path = path - self.basename = basename - self.listing = listing + self.doc = doc + self.name = name + self.type_ = type_ + self.outputBinding = outputBinding + attrs: ClassVar[Collection[str]] = frozenset( + ["doc", "name", "type", "outputBinding"] + ) + + +@mypyc_attr(native_class=True) +class OutputRecordSchema(CWLRecordSchema): def __eq__(self, other: Any) -> bool: - if isinstance(other, Directory): + if isinstance(other, OutputRecordSchema): return bool( - self.class_ == other.class_ - and self.location == other.location - and self.path == other.path - and self.basename == other.basename - and self.listing == other.listing + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label ) return False def __hash__(self) -> int: - return hash( - (self.class_, self.location, self.path, self.basename, self.listing) - ) + return hash((self.fields, self.type_, self.label)) @classmethod def fromDoc( @@ -4094,45 +4439,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Directory": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_Directory_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - location = None - if "location" in _doc: + fields = None + if "fields" in _doc: try: - location = load_field( - _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None_None, + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, baseuri, loadingOptions, - lc=_doc.get("location") + lc=_doc.get("fields") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `location`": + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( str(e), @@ -4140,13 +4469,13 @@ def fromDoc( ) ) else: - val = _doc.get("location") + val = _doc.get("fields") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4158,122 +4487,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [e], - detailed_message=f"the `location` field with value `{val}` " + detailed_message=f"the `fields` field with value `{val}` " "is not valid because:", ) ) - path = None - if "path" in _doc: - try: - path = load_field( - _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("path") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - if str(e) == "missing required field `path`": + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("path") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [e], - detailed_message=f"the `path` field with value `{val}` " - "is not valid because:", - ) - ) - basename = None - if "basename" in _doc: - try: - basename = load_field( - _doc.get("basename"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("basename") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("basename") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), - [e], - detailed_message=f"the `basename` field with value `{val}` " - "is not valid because:", - ) - ) - listing = None - if "listing" in _doc: + label = None + if "label" in _doc: try: - listing = load_field( - _doc.get("listing"), - union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("listing") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `listing`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4281,13 +4564,13 @@ def fromDoc( ) ) else: - val = _doc.get("listing") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4299,14 +4582,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `listing` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -4314,14 +4597,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `listing`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`".format( k ), SourceLine(_doc, k, str), @@ -4331,10 +4614,9 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - location=location, - path=path, - basename=basename, - listing=listing, + fields=fields, + type_=type_, + label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -4351,27 +4633,17 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.location is not None: - u = save_relative_uri(self.location, base_url, False, None, relative_uris) - r["location"] = u - if self.path is not None: - u = save_relative_uri(self.path, base_url, False, None, relative_uris) - r["path"] = u - if self.basename is not None: - r["basename"] = save( - self.basename, top=False, base_url=base_url, relative_uris=relative_uris + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.listing is not None: - r["listing"] = save( - self.listing, top=False, base_url=base_url, relative_uris=relative_uris + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -4382,50 +4654,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "location", "path", "basename", "listing"]) - - -class SchemaBase(Saveable): - pass - - -class Parameter(SchemaBase): - """ - Define an input or output parameter to a process. - - """ - - pass - - -class InputBinding(Saveable): - pass - - -class OutputBinding(Saveable): - pass - - -class InputSchema(SchemaBase): - pass - - -class OutputSchema(SchemaBase): - pass - - -class InputRecordField(CWLRecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - inputBinding: Optional[Any] = None, - label: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[OutputRecordField] = None, + label: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4435,25 +4670,32 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.fields = fields self.type_ = type_ - self.inputBinding = inputBinding self.label = label + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type", "label"]) + + +@mypyc_attr(native_class=True) +class OutputEnumSchema(schema_salad.metaschema.EnumSchema): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, InputRecordField): + if isinstance(other, OutputEnumSchema): return bool( - self.doc == other.doc - and self.name == other.name + self.name == other.name + and self.symbols == other.symbols and self.type_ == other.type_ - and self.inputBinding == other.inputBinding and self.label == other.label + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_, self.inputBinding, self.label)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.outputBinding) + ) @classmethod def fromDoc( @@ -4461,8 +4703,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -4472,9 +4714,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -4517,68 +4759,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -4620,21 +4862,21 @@ def fromDoc( "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + label = None + if "label" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4642,13 +4884,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4660,28 +4902,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + outputBinding = None + if "outputBinding" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -4689,13 +4931,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4707,14 +4949,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -4722,14 +4964,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `inputBinding`, `label`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -4739,15 +4981,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + symbols=symbols, type_=type_, - inputBinding=inputBinding, label=label, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -4762,27 +5004,26 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) # top refers to the directory level if top: @@ -4792,20 +5033,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type", "inputBinding", "label"]) - - -class InputRecordSchema(CWLRecordSchema, InputSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4815,23 +5051,31 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "outputBinding"] + ) + +@mypyc_attr(native_class=True) +class OutputArraySchema(CWLArraySchema): def __eq__(self, other: Any) -> bool: - if isinstance(other, InputRecordSchema): + if isinstance(other, OutputArraySchema): return bool( - self.fields == other.fields + self.items == other.items and self.type_ == other.type_ and self.label == other.label - and self.name == other.name + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.name)) + return hash((self.items, self.type_, self.label, self.outputBinding)) @classmethod def fromDoc( @@ -4839,29 +5083,125 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4869,13 +5209,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4887,132 +5227,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: - try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, - baseuri, - loadingOptions, - lc=_doc.get("fields") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `fields`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("fields") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [e], - detailed_message=f"the `fields` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: + outputBinding = None + if "outputBinding" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -5020,13 +5256,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5038,14 +5274,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5053,14 +5289,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `name`".format( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -5070,14 +5306,13 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, + items=items, type_=type_, label=label, - name=name, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -5091,20 +5326,23 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u if self.type_ is not None: r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + self.label, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -5115,21 +5353,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "name"]) - - -class InputEnumSchema(EnumSchema, InputSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5139,26 +5370,48 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.items = items self.type_ = type_ self.label = label - self.inputBinding = inputBinding + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "outputBinding"] + ) + + +@mypyc_attr(native_class=True) +class InputParameter(Saveable): + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputEnumSchema): + if isinstance(other, InputParameter): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id + and self.format == other.format and self.inputBinding == other.inputBinding + and self.default == other.default + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( - (self.name, self.symbols, self.type_, self.label, self.inputBinding) + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.inputBinding, + self.default, + self.type_, + ) ) @classmethod @@ -5167,29 +5420,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -5197,13 +5450,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5215,133 +5468,225 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `label`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("streamable") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("streamable") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - label = None - if "label" in _doc: + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -5349,13 +5694,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5367,17 +5712,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) inputBinding = None if "inputBinding" in _doc: try: - inputBinding = load_field( + inputBinding = _load_field( _doc.get("inputBinding"), union_of_None_type_or_CommandLineBindingLoader, baseuri, @@ -5421,261 +5766,35 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `inputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - label=label, - inputBinding=inputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type", "label", "inputBinding"]) - - -class InputArraySchema(CWLArraySchema, InputSchema): - def __init__( - self, - items: Any, - type_: Any, - label: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.inputBinding = inputBinding - - def __eq__(self, other: Any) -> bool: - if isinstance(other, InputArraySchema): - return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label - and self.inputBinding == other.inputBinding - ) - return False - - def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.inputBinding)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputArraySchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None + str(e), + None ) ) else: - val = _doc.get("label") + val = _doc.get("default") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5687,28 +5806,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `default` field with value `{val}` " "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + type_ = None + if "type" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -5716,13 +5835,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5734,14 +5853,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5749,14 +5868,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `inputBinding`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `inputBinding`, `default`, `type`".format( k ), SourceLine(_doc, k, str), @@ -5766,13 +5885,19 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, + id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + format=format, inputBinding=inputBinding, + default=default, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -5786,24 +5911,49 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.label is not None: r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u if self.inputBinding is not None: r["inputBinding"] = save( self.inputBinding, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -5813,20 +5963,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "inputBinding"]) - - -class OutputRecordField(CWLRecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + label: None | str = None, + secondaryFiles: None | Sequence[str] | str = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + inputBinding: CommandLineBinding | None = None, + default: CWLObjectType | None = None, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | None | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5836,23 +5985,60 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.id = id + self.format = format + self.inputBinding = inputBinding + self.default = default self.type_ = type_ - self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "inputBinding", + "default", + "type", + ] + ) + + +@mypyc_attr(native_class=True) +class OutputParameter(Saveable): + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputRecordField): + if isinstance(other, OutputParameter): return bool( - self.doc == other.doc - and self.name == other.name - and self.type_ == other.type_ + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id and self.outputBinding == other.outputBinding + and self.format == other.format ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_, self.outputBinding)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.outputBinding, + self.format, + ) + ) @classmethod def fromDoc( @@ -5860,29 +6046,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), + id = _load_field( + _doc.get("id"), uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -5890,13 +6076,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5908,37 +6094,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -5946,13 +6132,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5964,76 +6150,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - outputBinding = None - if "outputBinding" in _doc: + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -6041,13 +6226,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6059,151 +6244,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - doc=doc, - name=name, - type_=type_, - outputBinding=outputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["doc", "name", "type", "outputBinding"]) - - -class OutputRecordSchema(CWLRecordSchema, OutputSchema): - def __init__( - self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.fields = fields - self.type_ = type_ - self.label = label - - def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputRecordSchema): - return bool( - self.fields == other.fields - and self.type_ == other.type_ - and self.label == other.label - ) - return False - - def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputRecordSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - fields = None - if "fields" in _doc: + doc = None + if "doc" in _doc: try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -6211,13 +6273,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6229,76 +6291,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + outputBinding = None + if "outputBinding" in _doc: + try: + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputBinding") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("outputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - label = None - if "label" in _doc: + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + detailed_message=f"the `outputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -6306,13 +6367,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6324,14 +6385,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -6339,14 +6400,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`".format( k ), SourceLine(_doc, k, str), @@ -6356,12 +6417,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, - type_=type_, + id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + outputBinding=outputBinding, + format=format, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -6375,42 +6441,61 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.label is not None: r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + self.label, top=False, base_url=self.id, relative_uris=relative_uris ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["fields", "type", "label"]) - - -class OutputEnumSchema(EnumSchema, OutputSchema): - name: str + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + label: None | str = None, + secondaryFiles: None | Sequence[str] | str = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + outputBinding: CommandOutputBinding | None = None, + format: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -6420,27 +6505,44 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols - self.type_ = type_ self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id self.outputBinding = outputBinding + self.format = format + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "outputBinding", + "format", + ] + ) + + +@mypyc_attr(native_class=True) +class InlineJavascriptRequirement(Saveable): + """ + Indicates that the workflow platform must support inline Javascript expressions. If this requirement is not present, the workflow platform must not perform expression interpolatation. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputEnumSchema): + if isinstance(other, InlineJavascriptRequirement): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label - and self.outputBinding == other.outputBinding + self.class_ == other.class_ + and self.expressionLib == other.expressionLib ) return False def __hash__(self) -> int: - return hash( - (self.name, self.symbols, self.type_, self.label, self.outputBinding) - ) + return hash((self.class_, self.expressionLib)) @classmethod def fromDoc( @@ -6448,29 +6550,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_InlineJavascriptRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + expressionLib = None + if "expressionLib" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + expressionLib = _load_field( + _doc.get("expressionLib"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("expressionLib") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `expressionLib`": _errors__.append( ValidationException( str(e), @@ -6478,13 +6597,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("expressionLib") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6496,38 +6615,163 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `expressionLib` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `expressionLib`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + expressionLib=expressionLib, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.expressionLib is not None: + r["expressionLib"] = save( + self.expressionLib, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + expressionLib: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "InlineJavascriptRequirement" + self.expressionLib = expressionLib + + attrs: ClassVar[Collection[str]] = frozenset(["class", "expressionLib"]) + + +@mypyc_attr(native_class=True) +class SchemaDefRequirement(Saveable): + """ + This field consists of an array of type definitions which must be used when interpreting the ``inputs`` and ``outputs`` fields. When a ``type`` field contain a IRI, the implementation must check if the type is defined in ``schemaDefs`` and use that definition. If the type is not found in ``schemaDefs``, it is an error. The entries in ``schemaDefs`` must be processed in the order listed such that later schema definitions may refer to earlier schema definitions. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, SchemaDefRequirement): + return bool(self.class_ == other.class_ and self.types == other.types) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.types)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, + class_ = _load_field( + _doc.get("class"), + uri_SchemaDefRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("symbols") + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("types") is None: + raise ValidationException("missing required field `types`", None, []) + + types = _load_field( + _doc.get("types"), + array_of_union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("types") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": + if str(e) == "missing required field `types`": _errors__.append( ValidationException( str(e), @@ -6535,13 +6779,13 @@ def fromDoc( ) ) else: - val = _doc.get("symbols") + val = _doc.get("types") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6553,156 +6797,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), [e], - detailed_message=f"the `symbols` field with value `{val}` " + detailed_message=f"the `types` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -6710,14 +6812,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `outputBinding`".format( + "invalid field `{}`, expected one of: `class`, `types`".format( k ), SourceLine(_doc, k, str), @@ -6727,15 +6829,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - label=label, - outputBinding=outputBinding, + types=types, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -6749,26 +6846,19 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.types is not None: + r["types"] = save( + self.types, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -6779,18 +6869,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "outputBinding"]) - - -class OutputArraySchema(CWLArraySchema, OutputSchema): def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + types: Sequence[InputArraySchema | InputEnumSchema | InputRecordSchema], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -6800,23 +6883,28 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.outputBinding = outputBinding + self.class_: Final[str] = "SchemaDefRequirement" + self.types = types + + attrs: ClassVar[Collection[str]] = frozenset(["class", "types"]) + + +@mypyc_attr(native_class=True) +class EnvironmentDef(Saveable): + """ + Define an environment variable that will be set in the runtime environment by the workflow platform when executing the command line tool. May be the result of executing an expression, such as getting a parameter from input. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputArraySchema): + if isinstance(other, EnvironmentDef): return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label - and self.outputBinding == other.outputBinding + self.envName == other.envName and self.envValue == other.envValue ) return False def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.outputBinding)) + return hash((self.envName, self.envValue)) @classmethod def fromDoc( @@ -6824,8 +6912,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -6833,21 +6921,21 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("envName") is None: + raise ValidationException("missing required field `envName`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, + envName = _load_field( + _doc.get("envName"), + strtype, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("envName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": + if str(e) == "missing required field `envName`": _errors__.append( ValidationException( str(e), @@ -6855,13 +6943,13 @@ def fromDoc( ) ) else: - val = _doc.get("items") + val = _doc.get("envName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6873,29 +6961,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), [e], - detailed_message=f"the `items` field with value `{val}` " + detailed_message=f"the `envName` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("envValue") is None: + raise ValidationException("missing required field `envValue`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, + envValue = _load_field( + _doc.get("envValue"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("envValue") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `envValue`": _errors__.append( ValidationException( str(e), @@ -6903,13 +6991,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("envValue") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6921,123 +7009,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `envValue` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `outputBinding`".format( + "invalid field `{}`, expected one of: `envName`, `envValue`".format( k ), SourceLine(_doc, k, str), @@ -7047,10 +7041,8 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, - label=label, - outputBinding=outputBinding, + envName=envName, + envValue=envValue, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -7067,23 +7059,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + if self.envName is not None: + r["envName"] = save( + self.envName, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.envValue is not None: + r["envValue"] = save( + self.envValue, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7094,25 +7076,12 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "outputBinding"]) - - -class InputParameter(Parameter): - id: str - def __init__( self, - id: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - inputBinding: Optional[Any] = None, - default: Optional[Any] = None, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + envName: str, + envValue: str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -7122,43 +7091,60 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.inputBinding = inputBinding - self.default = default - self.type_ = type_ + self.envName = envName + self.envValue = envValue + + attrs: ClassVar[Collection[str]] = frozenset(["envName", "envValue"]) + + +@mypyc_attr(native_class=True) +class CommandLineBinding(Saveable): + """ + When listed under ``inputBinding`` in the input schema, the term "value" refers to the the corresponding value in the input object. For binding objects listed in ``CommandLineTool.arguments``, the term "value" refers to the effective value after evaluating ``valueFrom``. + + The binding behavior when building the command line depends on the data type of the value. If there is a mismatch between the type described by the input schema and the effective value, such as resulting from an expression evaluation, an implementation must use the data type of the effective value. + + - **string**: Add ``prefix`` and the string to the command line. + + - **number**: Add ``prefix`` and decimal representation to command line. + + - **boolean**: If true, add ``prefix`` to the command line. If false, add nothing. + + - **File**: Add ``prefix`` and the value of ```File.path`` <#File>`__ to the command line. + + - **Directory**: Add ``prefix`` and the value of ```Directory.path`` <#Directory>`__ to the command line. + + - **array**: If ``itemSeparator`` is specified, add ``prefix`` and the join the array into a single string with ``itemSeparator`` separating the items. Otherwise first add ``prefix``, then recursively process individual elements. If the array is empty, it does not add anything to command line. + + - **object**: Add ``prefix`` only, and recursively add object fields for which ``inputBinding`` is specified. + + - **null**: Add nothing. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, InputParameter): + if isinstance(other, CommandLineBinding): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.inputBinding == other.inputBinding - and self.default == other.default - and self.type_ == other.type_ + self.loadContents == other.loadContents + and self.position == other.position + and self.prefix == other.prefix + and self.separate == other.separate + and self.itemSeparator == other.itemSeparator + and self.valueFrom == other.valueFrom + and self.shellQuote == other.shellQuote ) return False def __hash__(self) -> int: return hash( ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.inputBinding, - self.default, - self.type_, + self.loadContents, + self.position, + self.prefix, + self.separate, + self.itemSeparator, + self.valueFrom, + self.shellQuote, ) ) @@ -7168,29 +7154,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: + loadContents = None + if "loadContents" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -7198,13 +7184,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7216,37 +7202,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + position = None + if "position" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + position = _load_field( + _doc.get("position"), + union_of_None_type_or_inttype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -7254,13 +7231,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7272,28 +7249,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + prefix = None + if "prefix" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + prefix = _load_field( + _doc.get("prefix"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("prefix") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `prefix`": _errors__.append( ValidationException( str(e), @@ -7301,13 +7278,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("prefix") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7319,122 +7296,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `prefix` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + separate = None + if "separate" in _doc: try: - streamable = load_field( - _doc.get("streamable"), + separate = _load_field( + _doc.get("separate"), union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") + lc=_doc.get("separate") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `separate`": _errors__.append( ValidationException( str(e), @@ -7442,13 +7325,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("separate") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7460,28 +7343,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `separate` field with value `{val}` " "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + itemSeparator = None + if "itemSeparator" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + itemSeparator = _load_field( + _doc.get("itemSeparator"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("itemSeparator") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `itemSeparator`": _errors__.append( ValidationException( str(e), @@ -7489,13 +7372,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("itemSeparator") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7507,28 +7390,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `itemSeparator` field with value `{val}` " "is not valid because:", ) ) - default = None - if "default" in _doc: + valueFrom = None + if "valueFrom" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, + valueFrom = _load_field( + _doc.get("valueFrom"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("valueFrom") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `valueFrom`": _errors__.append( ValidationException( str(e), @@ -7536,13 +7419,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("valueFrom") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7554,28 +7437,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `valueFrom` field with value `{val}` " "is not valid because:", ) ) - type_ = None - if "type" in _doc: + shellQuote = None + if "shellQuote" in _doc: try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + shellQuote = _load_field( + _doc.get("shellQuote"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("shellQuote") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `shellQuote`": _errors__.append( ValidationException( str(e), @@ -7583,13 +7466,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("shellQuote") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7601,14 +7484,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `shellQuote` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -7616,14 +7499,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `inputBinding`, `default`, `type`".format( + "invalid field `{}`, expected one of: `loadContents`, `position`, `prefix`, `separate`, `itemSeparator`, `valueFrom`, `shellQuote`".format( k ), SourceLine(_doc, k, str), @@ -7633,19 +7516,16 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - inputBinding=inputBinding, - default=default, - type_=type_, + loadContents=loadContents, + position=position, + prefix=prefix, + separate=separate, + itemSeparator=itemSeparator, + valueFrom=valueFrom, + shellQuote=shellQuote, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -7659,49 +7539,46 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.prefix is not None: + r["prefix"] = save( + self.prefix, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.separate is not None: + r["separate"] = save( + self.separate, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.itemSeparator is not None: + r["itemSeparator"] = save( + self.itemSeparator, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris + if self.valueFrom is not None: + r["valueFrom"] = save( + self.valueFrom, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, + if self.shellQuote is not None: + r["shellQuote"] = save( + self.shellQuote, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -7711,35 +7588,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "inputBinding", - "default", - "type", - ] - ) - - -class OutputParameter(Parameter): - id: str - def __init__( self, - id: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - outputBinding: Optional[Any] = None, - format: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + position: None | i32 = None, + prefix: None | str = None, + separate: None | bool = None, + itemSeparator: None | str = None, + valueFrom: None | str = None, + shellQuote: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -7749,39 +7608,52 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.outputBinding = outputBinding - self.format = format + self.loadContents = loadContents + self.position = position + self.prefix = prefix + self.separate = separate + self.itemSeparator = itemSeparator + self.valueFrom = valueFrom + self.shellQuote = shellQuote + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "loadContents", + "position", + "prefix", + "separate", + "itemSeparator", + "valueFrom", + "shellQuote", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputBinding(Saveable): + """ + Describes how to generate an output parameter based on the files produced by a CommandLineTool. + + The output parameter value is generated by applying these operations in the following order: + + - glob + - loadContents + - outputEval + - secondaryFiles + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputParameter): + if isinstance(other, CommandOutputBinding): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.outputBinding == other.outputBinding - and self.format == other.format + self.glob == other.glob + and self.loadContents == other.loadContents + and self.outputEval == other.outputEval ) return False def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.outputBinding, - self.format, - ) - ) + return hash((self.glob, self.loadContents, self.outputEval)) @classmethod def fromDoc( @@ -7789,29 +7661,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: + glob = None + if "glob" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + glob = _load_field( + _doc.get("glob"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("glob") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `glob`": _errors__.append( ValidationException( str(e), @@ -7819,13 +7691,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("glob") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7837,37 +7709,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `glob` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + loadContents = None + if "loadContents" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -7875,13 +7738,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7893,28 +7756,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + outputEval = None + if "outputEval" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + outputEval = _load_field( + _doc.get("outputEval"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("outputEval") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `outputEval`": _errors__.append( ValidationException( str(e), @@ -7922,13 +7785,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("outputEval") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7940,237 +7803,44 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `outputEval` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `glob`, `loadContents`, `outputEval`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - outputBinding=outputBinding, - format=format, + glob=glob, + loadContents=loadContents, + outputEval=outputEval, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -8184,41 +7854,24 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, + if self.glob is not None: + r["glob"] = save( + self.glob, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, + if self.outputEval is not None: + r["outputEval"] = save( + self.outputEval, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u # top refers to the directory level if top: @@ -8228,58 +7881,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "outputBinding", - "format", - ] - ) - - -class ProcessRequirement(Saveable): - """ - A process requirement declares a prerequisite that may or must be fulfilled - before executing a process. See [`Process.hints`](#process) and - [`Process.requirements`](#process). - - Process requirements are the primary mechanism for specifying extensions to - the CWL core specification. - - """ - - pass - - -class Process(Saveable): - """ - - The base executable type in CWL is the `Process` object defined by the - document. Note that the `Process` object is abstract and cannot be - directly executed. - - """ - - pass - - -class InlineJavascriptRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support inline Javascript expressions. - If this requirement is not present, the workflow platform must not perform expression - interpolatation. - - """ - def __init__( self, - expressionLib: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + glob: None | Sequence[str] | str = None, + loadContents: None | bool = None, + outputEval: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8289,19 +7897,30 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "InlineJavascriptRequirement" - self.expressionLib = expressionLib + self.glob = glob + self.loadContents = loadContents + self.outputEval = outputEval + + attrs: ClassVar[Collection[str]] = frozenset(["glob", "loadContents", "outputEval"]) + + +@mypyc_attr(native_class=True) +class CommandInputRecordField(InputRecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InlineJavascriptRequirement): + if isinstance(other, CommandInputRecordField): return bool( - self.class_ == other.class_ - and self.expressionLib == other.expressionLib + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.inputBinding == other.inputBinding + and self.label == other.label ) return False def __hash__(self) -> int: - return hash((self.class_, self.expressionLib)) + return hash((self.doc, self.name, self.type_, self.inputBinding, self.label)) @classmethod def fromDoc( @@ -8309,45 +7928,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InlineJavascriptRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_InlineJavascriptRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - expressionLib = None - if "expressionLib" in _doc: + name = None + if "name" in _doc: try: - expressionLib = load_field( - _doc.get("expressionLib"), - union_of_None_type_or_array_of_strtype, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("expressionLib") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `expressionLib`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -8355,13 +7958,13 @@ def fromDoc( ) ) else: - val = _doc.get("expressionLib") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `expressionLib` field is not valid because:", - SourceLine(_doc, "expressionLib", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8373,29 +7976,227 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `expressionLib` field is not valid because:", - SourceLine(_doc, "expressionLib", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `expressionLib` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `expressionLib`".format( + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `inputBinding`, `label`".format( k ), SourceLine(_doc, k, str), @@ -8405,10 +8206,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - expressionLib=expressionLib, + name=name, + doc=doc, + type_=type_, + inputBinding=inputBinding, + label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -8422,21 +8228,28 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.expressionLib is not None: - r["expressionLib"] = save( - self.expressionLib, + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -8446,26 +8259,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "expressionLib"]) - - -class SchemaDefRequirement(ProcessRequirement): - """ - This field consists of an array of type definitions which must be used when - interpreting the `inputs` and `outputs` fields. When a `type` field - contain a IRI, the implementation must check if the type is defined in - `schemaDefs` and use that definition. If the type is not found in - `schemaDefs`, it is an error. The entries in `schemaDefs` must be - processed in the order listed such that later schema definitions may refer - to earlier schema definitions. - - """ - def __init__( self, - types: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + inputBinding: CommandLineBinding | None = None, + label: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8475,16 +8277,33 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "SchemaDefRequirement" - self.types = types + self.doc = doc + self.name = name + self.type_ = type_ + self.inputBinding = inputBinding + self.label = label - def __eq__(self, other: Any) -> bool: - if isinstance(other, SchemaDefRequirement): - return bool(self.class_ == other.class_ and self.types == other.types) - return False + attrs: ClassVar[Collection[str]] = frozenset( + ["doc", "name", "type", "inputBinding", "label"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputRecordSchema(InputRecordSchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CommandInputRecordSchema): + return bool( + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.name == other.name + ) + return False def __hash__(self) -> int: - return hash((self.class_, self.types)) + return hash((self.fields, self.type_, self.label, self.name)) @classmethod def fromDoc( @@ -8492,46 +8311,132 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SchemaDefRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + name = None + if "name" in _doc: + try: + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) - class_ = load_field( - _doc.get("class"), - uri_SchemaDefRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("name") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + detailed_message=f"the `name` field with value `{val}` " + "is not valid because:", + ) + ) + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + fields = None + if "fields" in _doc: + try: + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, + baseuri, + loadingOptions, + lc=_doc.get("fields") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("fields") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + detailed_message=f"the `fields` field with value `{val}` " + "is not valid because:", + ) + ) try: - if _doc.get("types") is None: - raise ValidationException("missing required field `types`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - types = load_field( - _doc.get("types"), - array_of_union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, baseuri, loadingOptions, - lc=_doc.get("types") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `types`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -8539,13 +8444,13 @@ def fromDoc( ) ) else: - val = _doc.get("types") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `types` field is not valid because:", - SourceLine(_doc, "types", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8557,14 +8462,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `types` field is not valid because:", - SourceLine(_doc, "types", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `types` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -8572,14 +8524,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `types`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `name`".format( k ), SourceLine(_doc, k, str), @@ -8589,10 +8541,14 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - types=types, + name=name, + fields=fields, + type_=type_, + label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -8606,17 +8562,20 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.types is not None: - r["types"] = save( - self.types, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -8627,23 +8586,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "types"]) - - -class EnvironmentDef(Saveable): - """ - Define an environment variable that will be set in the runtime environment - by the workflow platform when executing the command line tool. May be the - result of executing an expression, such as getting a parameter from input. - - """ - def __init__( self, - envName: Any, - envValue: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CommandInputRecordField] = None, + label: None | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8653,18 +8603,33 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.envName = envName - self.envValue = envValue + self.fields = fields + self.type_ = type_ + self.label = label + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type", "label", "name"]) + + +@mypyc_attr(native_class=True) +class CommandInputEnumSchema(InputEnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, EnvironmentDef): + if isinstance(other, CommandInputEnumSchema): return bool( - self.envName == other.envName and self.envValue == other.envValue + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ + and self.label == other.label + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.envName, self.envValue)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.inputBinding) + ) @classmethod def fromDoc( @@ -8672,30 +8637,85 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnvironmentDef": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("envName") is None: - raise ValidationException("missing required field `envName`", None, []) - - envName = load_field( - _doc.get("envName"), - strtype, + name = None + if "name" in _doc: + try: + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("name") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + detailed_message=f"the `name` field with value `{val}` " + "is not valid because:", + ) + ) + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("envName") + lc=_doc.get("symbols") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `envName`": + if str(e) == "missing required field `symbols`": _errors__.append( ValidationException( str(e), @@ -8703,13 +8723,13 @@ def fromDoc( ) ) else: - val = _doc.get("envName") + val = _doc.get("symbols") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `envName` field is not valid because:", - SourceLine(_doc, "envName", str), + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8721,29 +8741,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `envName` field is not valid because:", - SourceLine(_doc, "envName", str), + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), [e], - detailed_message=f"the `envName` field with value `{val}` " + detailed_message=f"the `symbols` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("envValue") is None: - raise ValidationException("missing required field `envValue`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - envValue = load_field( - _doc.get("envValue"), - union_of_strtype_or_ExpressionLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, - lc=_doc.get("envValue") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `envValue`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -8751,13 +8771,13 @@ def fromDoc( ) ) else: - val = _doc.get("envValue") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `envValue` field is not valid because:", - SourceLine(_doc, "envValue", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8769,14 +8789,108 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `envValue` field is not valid because:", - SourceLine(_doc, "envValue", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `envValue` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -8784,14 +8898,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `envName`, `envValue`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -8801,11 +8915,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - envName=envName, - envValue=envValue, + name=name, + symbols=symbols, + type_=type_, + label=label, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -8819,13 +8937,26 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.envName is not None: - r["envName"] = save( - self.envName, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.envValue is not None: - r["envValue"] = save( - self.envValue, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) # top refers to the directory level @@ -8836,60 +8967,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["envName", "envValue"]) - - -class CommandLineBinding(InputBinding): - """ - - When listed under `inputBinding` in the input schema, the term - "value" refers to the the corresponding value in the input object. For - binding objects listed in `CommandLineTool.arguments`, the term "value" - refers to the effective value after evaluating `valueFrom`. - - The binding behavior when building the command line depends on the data - type of the value. If there is a mismatch between the type described by - the input schema and the effective value, such as resulting from an - expression evaluation, an implementation must use the data type of the - effective value. - - - **string**: Add `prefix` and the string to the command line. - - - **number**: Add `prefix` and decimal representation to command line. - - - **boolean**: If true, add `prefix` to the command line. If false, add - nothing. - - - **File**: Add `prefix` and the value of - [`File.path`](#File) to the command line. - - - **Directory**: Add `prefix` and the value of - [`Directory.path`](#Directory) to the command line. - - - **array**: If `itemSeparator` is specified, add `prefix` and the join - the array into a single string with `itemSeparator` separating the - items. Otherwise first add `prefix`, then recursively process - individual elements. - If the array is empty, it does not add anything to command line. - - - **object**: Add `prefix` only, and recursively add object fields for - which `inputBinding` is specified. - - - **null**: Add nothing. - - """ - def __init__( self, - loadContents: Optional[Any] = None, - position: Optional[Any] = None, - prefix: Optional[Any] = None, - separate: Optional[Any] = None, - itemSeparator: Optional[Any] = None, - valueFrom: Optional[Any] = None, - shellQuote: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8899,39 +8985,31 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.loadContents = loadContents - self.position = position - self.prefix = prefix - self.separate = separate - self.itemSeparator = itemSeparator - self.valueFrom = valueFrom - self.shellQuote = shellQuote + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols + self.type_ = type_ + self.label = label + self.inputBinding = inputBinding - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandLineBinding): + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputArraySchema(InputArraySchema): + def __eq__(self, other: Any) -> bool: + if isinstance(other, CommandInputArraySchema): return bool( - self.loadContents == other.loadContents - and self.position == other.position - and self.prefix == other.prefix - and self.separate == other.separate - and self.itemSeparator == other.itemSeparator - and self.valueFrom == other.valueFrom - and self.shellQuote == other.shellQuote + self.items == other.items + and self.type_ == other.type_ + and self.label == other.label + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash( - ( - self.loadContents, - self.position, - self.prefix, - self.separate, - self.itemSeparator, - self.valueFrom, - self.shellQuote, - ) - ) + return hash((self.items, self.type_, self.label, self.inputBinding)) @classmethod def fromDoc( @@ -8939,123 +9017,125 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandLineBinding": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - loadContents = None - if "loadContents" in _doc: - try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("loadContents") - ) + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) - if str(e) == "missing required field `loadContents`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("loadContents") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], - detailed_message=f"the `loadContents` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", ) - position = None - if "position" in _doc: - try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_inttype, - baseuri, - loadingOptions, - lc=_doc.get("position") - ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `position`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("position") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), - [e], - detailed_message=f"the `position` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) - prefix = None - if "prefix" in _doc: + ) + label = None + if "label" in _doc: try: - prefix = load_field( - _doc.get("prefix"), + label = _load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("prefix") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `prefix`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -9063,13 +9143,13 @@ def fromDoc( ) ) else: - val = _doc.get("prefix") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `prefix` field is not valid because:", - SourceLine(_doc, "prefix", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9081,28 +9161,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `prefix` field is not valid because:", - SourceLine(_doc, "prefix", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `prefix` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - separate = None - if "separate" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - separate = load_field( - _doc.get("separate"), - union_of_None_type_or_booltype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("separate") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `separate`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -9110,13 +9190,13 @@ def fromDoc( ) ) else: - val = _doc.get("separate") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `separate` field is not valid because:", - SourceLine(_doc, "separate", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9128,42 +9208,172 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `separate` field is not valid because:", - SourceLine(_doc, "separate", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `separate` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - itemSeparator = None - if "itemSeparator" in _doc: - try: - itemSeparator = load_field( - _doc.get("itemSeparator"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("itemSeparator") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `itemSeparator`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("itemSeparator") + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `inputBinding`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + label=label, + inputBinding=inputBinding, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + self.label = label + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputRecordField(OutputRecordField): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CommandOutputRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.outputBinding == other.outputBinding + ) + return False + + def __hash__(self) -> int: + return hash((self.doc, self.name, self.type_, self.outputBinding)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: + try: + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `itemSeparator` field is not valid because:", - SourceLine(_doc, "itemSeparator", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9175,28 +9385,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `itemSeparator` field is not valid because:", - SourceLine(_doc, "itemSeparator", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `itemSeparator` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -9204,13 +9423,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9222,28 +9441,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - shellQuote = None - if "shellQuote" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + outputBinding = None + if "outputBinding" in _doc: try: - shellQuote = load_field( - _doc.get("shellQuote"), - union_of_None_type_or_booltype, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("shellQuote") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `shellQuote`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -9251,13 +9518,13 @@ def fromDoc( ) ) else: - val = _doc.get("shellQuote") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `shellQuote` field is not valid because:", - SourceLine(_doc, "shellQuote", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9269,14 +9536,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `shellQuote` field is not valid because:", - SourceLine(_doc, "shellQuote", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `shellQuote` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -9284,14 +9551,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `loadContents`, `position`, `prefix`, `separate`, `itemSeparator`, `valueFrom`, `shellQuote`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -9301,16 +9568,14 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - loadContents=loadContents, - position=position, - prefix=prefix, - separate=separate, - itemSeparator=itemSeparator, - valueFrom=valueFrom, - shellQuote=shellQuote, + name=name, + doc=doc, + type_=type_, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -9324,44 +9589,22 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.prefix is not None: - r["prefix"] = save( - self.prefix, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.separate is not None: - r["separate"] = save( - self.separate, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.itemSeparator is not None: - r["itemSeparator"] = save( - self.itemSeparator, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.shellQuote is not None: - r["shellQuote"] = save( - self.shellQuote, + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) @@ -9373,41 +9616,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "loadContents", - "position", - "prefix", - "separate", - "itemSeparator", - "valueFrom", - "shellQuote", - ] - ) - - -class CommandOutputBinding(OutputBinding): - """ - Describes how to generate an output parameter based on the files produced - by a CommandLineTool. - - The output parameter value is generated by applying these operations in the - following order: - - - glob - - loadContents - - outputEval - - secondaryFiles - - """ - def __init__( self, - glob: Optional[Any] = None, - loadContents: Optional[Any] = None, - outputEval: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -9417,21 +9633,32 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.glob = glob - self.loadContents = loadContents - self.outputEval = outputEval + self.doc = doc + self.name = name + self.type_ = type_ + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["doc", "name", "type", "outputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputRecordSchema(OutputRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputBinding): + if isinstance(other, CommandOutputRecordSchema): return bool( - self.glob == other.glob - and self.loadContents == other.loadContents - and self.outputEval == other.outputEval + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.glob, self.loadContents, self.outputEval)) + return hash((self.fields, self.type_, self.label, self.name)) @classmethod def fromDoc( @@ -9439,29 +9666,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputBinding": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - glob = None - if "glob" in _doc: + name = None + if "name" in _doc: try: - glob = load_field( - _doc.get("glob"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("glob") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `glob`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -9469,13 +9696,13 @@ def fromDoc( ) ) else: - val = _doc.get("glob") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `glob` field is not valid because:", - SourceLine(_doc, "glob", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9487,28 +9714,36 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `glob` field is not valid because:", - SourceLine(_doc, "glob", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `glob` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + fields = None + if "fields" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("fields") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( str(e), @@ -9516,13 +9751,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("fields") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9534,28 +9769,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `fields` field with value `{val}` " "is not valid because:", ) ) - outputEval = None - if "outputEval" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - outputEval = load_field( - _doc.get("outputEval"), - union_of_None_type_or_strtype_or_ExpressionLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("outputEval") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputEval`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -9563,13 +9846,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputEval") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputEval` field is not valid because:", - SourceLine(_doc, "outputEval", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9581,14 +9864,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputEval` field is not valid because:", - SourceLine(_doc, "outputEval", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `outputEval` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -9596,14 +9879,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `glob`, `loadContents`, `outputEval`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `name`".format( k ), SourceLine(_doc, k, str), @@ -9613,12 +9896,14 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - glob=glob, - loadContents=loadContents, - outputEval=outputEval, + name=name, + fields=fields, + type_=type_, + label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -9632,23 +9917,20 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.glob is not None: - r["glob"] = save( - self.glob, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.outputEval is not None: - r["outputEval"] = save( - self.outputEval, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -9659,21 +9941,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["glob", "loadContents", "outputEval"]) - - -class CommandInputRecordField(InputRecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - inputBinding: Optional[Any] = None, - label: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CommandOutputRecordField] = None, + label: None | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -9683,25 +9958,33 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.fields = fields self.type_ = type_ - self.inputBinding = inputBinding self.label = label + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type", "label", "name"]) + + +@mypyc_attr(native_class=True) +class CommandOutputEnumSchema(OutputEnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputRecordField): + if isinstance(other, CommandOutputEnumSchema): return bool( - self.doc == other.doc - and self.name == other.name + self.name == other.name + and self.symbols == other.symbols and self.type_ == other.type_ - and self.inputBinding == other.inputBinding and self.label == other.label + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_, self.inputBinding, self.label)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.outputBinding) + ) @classmethod def fromDoc( @@ -9709,8 +9992,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -9720,9 +10003,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -9765,68 +10048,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -9868,21 +10151,21 @@ def fromDoc( "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + label = None + if "label" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -9890,13 +10173,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9908,28 +10191,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + outputBinding = None + if "outputBinding" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -9937,13 +10220,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9955,14 +10238,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -9970,14 +10253,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `inputBinding`, `label`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -9987,15 +10270,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + symbols=symbols, type_=type_, - inputBinding=inputBinding, label=label, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -10010,27 +10293,26 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) # top refers to the directory level if top: @@ -10040,20 +10322,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type", "inputBinding", "label"]) - - -class CommandInputRecordSchema(InputRecordSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -10063,23 +10340,31 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "outputBinding"] + ) + +@mypyc_attr(native_class=True) +class CommandOutputArraySchema(OutputArraySchema): def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputRecordSchema): + if isinstance(other, CommandOutputArraySchema): return bool( - self.fields == other.fields + self.items == other.items and self.type_ == other.type_ and self.label == other.label - and self.name == other.name + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.name)) + return hash((self.items, self.type_, self.label, self.outputBinding)) @classmethod def fromDoc( @@ -10087,124 +10372,69 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) - if str(e) == "missing required field `name`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: - try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, - baseuri, - loadingOptions, - lc=_doc.get("fields") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `fields`": _errors__.append( ValidationException( - str(e), - None + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("fields") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [e], - detailed_message=f"the `fields` field with value `{val}` " - "is not valid because:", - ) - ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Record_nameLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -10249,7 +10479,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -10293,7 +10523,54 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + outputBinding = None + if "outputBinding" in _doc: + try: + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + detailed_message=f"the `outputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -10301,14 +10578,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `name`".format( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -10318,14 +10595,13 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, + items=items, type_=type_, label=label, - name=name, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -10339,20 +10615,23 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u if self.type_ is not None: r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + self.label, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -10363,21 +10642,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "name"]) - - -class CommandInputEnumSchema(InputEnumSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -10387,26 +10659,53 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.items = items self.type_ = type_ self.label = label - self.inputBinding = inputBinding + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "outputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputParameter(InputParameter): + """ + An input parameter for a CommandLineTool. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputEnumSchema): + if isinstance(other, CommandInputParameter): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id + and self.format == other.format and self.inputBinding == other.inputBinding + and self.default == other.default + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( - (self.name, self.symbols, self.type_, self.label, self.inputBinding) + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.inputBinding, + self.default, + self.type_, + ) ) @classmethod @@ -10415,29 +10714,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -10445,13 +10744,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10463,133 +10762,225 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `label`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("streamable") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("streamable") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - label = None - if "label" in _doc: + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -10597,13 +10988,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10615,17 +11006,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) inputBinding = None if "inputBinding" in _doc: try: - inputBinding = load_field( + inputBinding = _load_field( _doc.get("inputBinding"), union_of_None_type_or_CommandLineBindingLoader, baseuri, @@ -10669,261 +11060,35 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `inputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - label=label, - inputBinding=inputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type", "label", "inputBinding"]) - - -class CommandInputArraySchema(InputArraySchema): - def __init__( - self, - items: Any, - type_: Any, - label: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.inputBinding = inputBinding - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputArraySchema): - return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label - and self.inputBinding == other.inputBinding - ) - return False - - def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.inputBinding)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputArraySchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None + str(e), + None ) ) else: - val = _doc.get("label") + val = _doc.get("default") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10935,28 +11100,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `default` field with value `{val}` " "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + type_ = None + if "type" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -10964,13 +11129,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10982,14 +11147,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -10997,14 +11162,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `inputBinding`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `inputBinding`, `default`, `type`".format( k ), SourceLine(_doc, k, str), @@ -11014,13 +11179,19 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, + id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + format=format, inputBinding=inputBinding, + default=default, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -11034,24 +11205,49 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.label is not None: r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u if self.inputBinding is not None: r["inputBinding"] = save( self.inputBinding, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -11061,20 +11257,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "inputBinding"]) - - -class CommandOutputRecordField(OutputRecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + label: None | str = None, + secondaryFiles: None | Sequence[str] | str = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + inputBinding: CommandLineBinding | None = None, + default: CWLObjectType | None = None, + type_: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | None | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11084,23 +11279,67 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.id = id + self.format = format + self.inputBinding = inputBinding + self.default = default self.type_ = type_ - self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "inputBinding", + "default", + "type", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputParameter(OutputParameter): + """ + An output parameter for a CommandLineTool. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputRecordField): + if isinstance(other, CommandOutputParameter): return bool( - self.doc == other.doc - and self.name == other.name - and self.type_ == other.type_ + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id and self.outputBinding == other.outputBinding + and self.format == other.format + and self.type_ == other.type_ ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_, self.outputBinding)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.outputBinding, + self.format, + self.type_, + ) + ) @classmethod def fromDoc( @@ -11108,29 +11347,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), + id = _load_field( + _doc.get("id"), uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -11138,13 +11377,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11156,37 +11395,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -11194,13 +11433,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11212,76 +11451,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - outputBinding = None - if "outputBinding" in _doc: + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -11289,13 +11527,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11307,156 +11545,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - doc=doc, - name=name, - type_=type_, - outputBinding=outputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["doc", "name", "type", "outputBinding"]) - - -class CommandOutputRecordSchema(OutputRecordSchema): - name: str - - def __init__( - self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.fields = fields - self.type_ = type_ - self.label = label - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputRecordSchema): - return bool( - self.fields == other.fields - and self.type_ == other.type_ - and self.label == other.label - and self.name == other.name - ) - return False - - def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.name)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputRecordSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - name = None - if "name" in _doc: + doc = None + if "doc" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -11464,13 +11574,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11482,37 +11592,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: + outputBinding = None + if "outputBinding" in _doc: try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -11520,13 +11621,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11538,76 +11639,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: + format = None + if "format" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -11615,13 +11668,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11633,29 +11686,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + type_ = None + if "type" in _doc: + try: + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": _errors__.append( - ValidationException("mapping with implicit null key") - ) + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `name`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`, `type`".format( k ), SourceLine(_doc, k, str), @@ -11665,14 +11765,18 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, - type_=type_, + id=id, label=label, - name=name, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + outputBinding=outputBinding, + format=format, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -11686,20 +11790,44 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u if self.type_ is not None: r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -11710,21 +11838,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "name"]) - - -class CommandOutputEnumSchema(OutputEnumSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + label: None | str = None, + secondaryFiles: None | Sequence[str] | str = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + outputBinding: CommandOutputBinding | None = None, + format: None | str = None, + type_: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | None | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | stderr | stdout | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11734,26 +11859,82 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols - self.type_ = type_ self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id self.outputBinding = outputBinding + self.format = format + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "outputBinding", + "format", + "type", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandLineTool(Saveable): + """ + This defines the schema of the CWL Command Line Tool Description document. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputEnumSchema): + if isinstance(other, CommandLineTool): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ + self.id == other.id + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.requirements == other.requirements + and self.hints == other.hints and self.label == other.label - and self.outputBinding == other.outputBinding + and self.doc == other.doc + and self.cwlVersion == other.cwlVersion + and self.class_ == other.class_ + and self.baseCommand == other.baseCommand + and self.arguments == other.arguments + and self.stdin == other.stdin + and self.stderr == other.stderr + and self.stdout == other.stdout + and self.successCodes == other.successCodes + and self.temporaryFailCodes == other.temporaryFailCodes + and self.permanentFailCodes == other.permanentFailCodes ) return False def __hash__(self) -> int: return hash( - (self.name, self.symbols, self.type_, self.label, self.outputBinding) + ( + self.id, + self.inputs, + self.outputs, + self.requirements, + self.hints, + self.label, + self.doc, + self.cwlVersion, + self.class_, + self.baseCommand, + self.arguments, + self.stdin, + self.stderr, + self.stdout, + self.successCodes, + self.temporaryFailCodes, + self.permanentFailCodes, + ) ) @classmethod @@ -11762,29 +11943,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), + id = _load_field( + _doc.get("id"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -11792,13 +11973,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11810,38 +11991,54 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + id = "_:" + str(_uuid__.uuid4()) + else: + baseuri = id try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, + class_ = _load_field( + _doc.get("class"), + uri_CommandLineTool_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("symbols") + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_CommandInputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": + if str(e) == "missing required field `inputs`": _errors__.append( ValidationException( str(e), @@ -11849,13 +12046,13 @@ def fromDoc( ) ) else: - val = _doc.get("symbols") + val = _doc.get("inputs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11867,29 +12064,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), [e], - detailed_message=f"the `symbols` field with value `{val}` " + detailed_message=f"the `inputs` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_CommandOutputParameterLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("outputs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `outputs`": _errors__.append( ValidationException( str(e), @@ -11897,13 +12094,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("outputs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11915,17 +12112,111 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `outputs` field with value `{val}` " "is not valid because:", ) ) + requirements = None + if "requirements" in _doc: + try: + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, + baseuri, + loadingOptions, + lc=_doc.get("requirements") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("requirements") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + detailed_message=f"the `requirements` field with value `{val}` " + "is not valid because:", + ) + ) + hints = None + if "hints" in _doc: + try: + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("hints") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("hints") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + detailed_message=f"the `hints` field with value `{val}` " + "is not valid because:", + ) + ) label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -11969,21 +12260,21 @@ def fromDoc( "is not valid because:", ) ) - outputBinding = None - if "outputBinding" in _doc: + doc = None + if "doc" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -11991,13 +12282,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12009,254 +12300,216 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + cwlVersion = None + if "cwlVersion" in _doc: + try: + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("cwlVersion") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("cwlVersion") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + detailed_message=f"the `cwlVersion` field with value `{val}` " + "is not valid because:", + ) + ) + baseCommand = None + if "baseCommand" in _doc: + try: + baseCommand = _load_field( + _doc.get("baseCommand"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("baseCommand") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `baseCommand`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("baseCommand") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [e], + detailed_message=f"the `baseCommand` field with value `{val}` " + "is not valid because:", + ) + ) + arguments = None + if "arguments" in _doc: + try: + arguments = _load_field( + _doc.get("arguments"), + union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("arguments") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - label=label, - outputBinding=outputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type", "label", "outputBinding"]) - - -class CommandOutputArraySchema(OutputArraySchema): - def __init__( - self, - items: Any, - type_: Any, - label: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.outputBinding = outputBinding - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputArraySchema): - return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label - and self.outputBinding == other.outputBinding - ) - return False - - def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.outputBinding)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputArraySchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `arguments`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", + val = _doc.get("arguments") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [e], + detailed_message=f"the `arguments` field with value `{val}` " + "is not valid because:", + ) + ) + stdin = None + if "stdin" in _doc: + try: + stdin = _load_field( + _doc.get("stdin"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("stdin") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `stdin`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("stdin") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - label = None - if "label" in _doc: + else: + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [e], + detailed_message=f"the `stdin` field with value `{val}` " + "is not valid because:", + ) + ) + stderr = None + if "stderr" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + stderr = _load_field( + _doc.get("stderr"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("stderr") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `stderr`": _errors__.append( ValidationException( str(e), @@ -12264,13 +12517,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("stderr") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12282,28 +12535,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `stderr` field with value `{val}` " "is not valid because:", ) ) - outputBinding = None - if "outputBinding" in _doc: + stdout = None + if "stdout" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + stdout = _load_field( + _doc.get("stdout"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("stdout") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `stdout`": _errors__.append( ValidationException( str(e), @@ -12311,13 +12564,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("stdout") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12329,186 +12582,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `stdout` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - items=items, - type_=type_, - label=label, - outputBinding=outputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["items", "type", "label", "outputBinding"]) - - -class CommandInputParameter(InputParameter): - """ - An input parameter for a CommandLineTool. - """ - - id: str - - def __init__( - self, - id: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - inputBinding: Optional[Any] = None, - default: Optional[Any] = None, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.inputBinding = inputBinding - self.default = default - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputParameter): - return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.inputBinding == other.inputBinding - and self.default == other.default - and self.type_ == other.type_ - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.inputBinding, - self.default, - self.type_, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputParameter": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + successCodes = None + if "successCodes" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + successCodes = _load_field( + _doc.get("successCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("successCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `successCodes`": _errors__.append( ValidationException( str(e), @@ -12516,13 +12611,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("successCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12534,37 +12629,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `successCodes` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + temporaryFailCodes = None + if "temporaryFailCodes" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + temporaryFailCodes = _load_field( + _doc.get("temporaryFailCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("temporaryFailCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `temporaryFailCodes`": _errors__.append( ValidationException( str(e), @@ -12572,13 +12658,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("temporaryFailCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12590,28 +12676,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `temporaryFailCodes` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + permanentFailCodes = None + if "permanentFailCodes" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + permanentFailCodes = _load_field( + _doc.get("permanentFailCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("permanentFailCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `permanentFailCodes`": _errors__.append( ValidationException( str(e), @@ -12619,13 +12705,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("permanentFailCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12637,4282 +12723,58 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `permanentFailCodes` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - default = None - if "default" in _doc: - try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, - baseuri, - loadingOptions, - lc=_doc.get("default") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `default`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("default") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [e], - detailed_message=f"the `default` field with value `{val}` " - "is not valid because:", - ) - ) - type_ = None - if "type" in _doc: - try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `inputBinding`, `default`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - inputBinding=inputBinding, - default=default, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "inputBinding", - "default", - "type", - ] - ) - - -class CommandOutputParameter(OutputParameter): - """ - An output parameter for a CommandLineTool. - """ - - id: str - - def __init__( - self, - id: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - outputBinding: Optional[Any] = None, - format: Optional[Any] = None, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.outputBinding = outputBinding - self.format = format - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputParameter): - return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.outputBinding == other.outputBinding - and self.format == other.format - and self.type_ == other.type_ - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.outputBinding, - self.format, - self.type_, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputParameter": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `secondaryFiles`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - type_ = None - if "type" in _doc: - try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - outputBinding=outputBinding, - format=format, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "outputBinding", - "format", - "type", - ] - ) - - -class CommandLineTool(Process): - """ - This defines the schema of the CWL Command Line Tool Description document. - - """ - - id: str - - def __init__( - self, - inputs: Any, - outputs: Any, - id: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - baseCommand: Optional[Any] = None, - arguments: Optional[Any] = None, - stdin: Optional[Any] = None, - stderr: Optional[Any] = None, - stdout: Optional[Any] = None, - successCodes: Optional[Any] = None, - temporaryFailCodes: Optional[Any] = None, - permanentFailCodes: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.label = label - self.doc = doc - self.cwlVersion = cwlVersion - self.class_ = "CommandLineTool" - self.baseCommand = baseCommand - self.arguments = arguments - self.stdin = stdin - self.stderr = stderr - self.stdout = stdout - self.successCodes = successCodes - self.temporaryFailCodes = temporaryFailCodes - self.permanentFailCodes = permanentFailCodes - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandLineTool): - return bool( - self.id == other.id - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.label == other.label - and self.doc == other.doc - and self.cwlVersion == other.cwlVersion - and self.class_ == other.class_ - and self.baseCommand == other.baseCommand - and self.arguments == other.arguments - and self.stdin == other.stdin - and self.stderr == other.stderr - and self.stdout == other.stdout - and self.successCodes == other.successCodes - and self.temporaryFailCodes == other.temporaryFailCodes - and self.permanentFailCodes == other.permanentFailCodes - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.id, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.label, - self.doc, - self.cwlVersion, - self.class_, - self.baseCommand, - self.arguments, - self.stdin, - self.stderr, - self.stdout, - self.successCodes, - self.temporaryFailCodes, - self.permanentFailCodes, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandLineTool": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_CommandLineTool_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_CommandInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_CommandOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: - try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, - baseuri, - loadingOptions, - lc=_doc.get("requirements") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `requirements`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("requirements") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], - detailed_message=f"the `requirements` field with value `{val}` " - "is not valid because:", - ) - ) - hints = None - if "hints" in _doc: - try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("hints") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `hints`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("hints") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [e], - detailed_message=f"the `hints` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - cwlVersion = None - if "cwlVersion" in _doc: - try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("cwlVersion") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cwlVersion`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cwlVersion") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " - "is not valid because:", - ) - ) - baseCommand = None - if "baseCommand" in _doc: - try: - baseCommand = load_field( - _doc.get("baseCommand"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("baseCommand") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `baseCommand`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("baseCommand") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `baseCommand` field is not valid because:", - SourceLine(_doc, "baseCommand", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `baseCommand` field is not valid because:", - SourceLine(_doc, "baseCommand", str), - [e], - detailed_message=f"the `baseCommand` field with value `{val}` " - "is not valid because:", - ) - ) - arguments = None - if "arguments" in _doc: - try: - arguments = load_field( - _doc.get("arguments"), - union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("arguments") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `arguments`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("arguments") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `arguments` field is not valid because:", - SourceLine(_doc, "arguments", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `arguments` field is not valid because:", - SourceLine(_doc, "arguments", str), - [e], - detailed_message=f"the `arguments` field with value `{val}` " - "is not valid because:", - ) - ) - stdin = None - if "stdin" in _doc: - try: - stdin = load_field( - _doc.get("stdin"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stdin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stdin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stdin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stdin` field is not valid because:", - SourceLine(_doc, "stdin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stdin` field is not valid because:", - SourceLine(_doc, "stdin", str), - [e], - detailed_message=f"the `stdin` field with value `{val}` " - "is not valid because:", - ) - ) - stderr = None - if "stderr" in _doc: - try: - stderr = load_field( - _doc.get("stderr"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stderr") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stderr`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stderr") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stderr` field is not valid because:", - SourceLine(_doc, "stderr", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stderr` field is not valid because:", - SourceLine(_doc, "stderr", str), - [e], - detailed_message=f"the `stderr` field with value `{val}` " - "is not valid because:", - ) - ) - stdout = None - if "stdout" in _doc: - try: - stdout = load_field( - _doc.get("stdout"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stdout") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stdout`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stdout") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stdout` field is not valid because:", - SourceLine(_doc, "stdout", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stdout` field is not valid because:", - SourceLine(_doc, "stdout", str), - [e], - detailed_message=f"the `stdout` field with value `{val}` " - "is not valid because:", - ) - ) - successCodes = None - if "successCodes" in _doc: - try: - successCodes = load_field( - _doc.get("successCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("successCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `successCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("successCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `successCodes` field is not valid because:", - SourceLine(_doc, "successCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `successCodes` field is not valid because:", - SourceLine(_doc, "successCodes", str), - [e], - detailed_message=f"the `successCodes` field with value `{val}` " - "is not valid because:", - ) - ) - temporaryFailCodes = None - if "temporaryFailCodes" in _doc: - try: - temporaryFailCodes = load_field( - _doc.get("temporaryFailCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("temporaryFailCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `temporaryFailCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("temporaryFailCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `temporaryFailCodes` field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `temporaryFailCodes` field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [e], - detailed_message=f"the `temporaryFailCodes` field with value `{val}` " - "is not valid because:", - ) - ) - permanentFailCodes = None - if "permanentFailCodes" in _doc: - try: - permanentFailCodes = load_field( - _doc.get("permanentFailCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("permanentFailCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `permanentFailCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("permanentFailCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `permanentFailCodes` field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `permanentFailCodes` field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [e], - detailed_message=f"the `permanentFailCodes` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `baseCommand`, `arguments`, `stdin`, `stderr`, `stdout`, `successCodes`, `temporaryFailCodes`, `permanentFailCodes`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - label=label, - doc=doc, - cwlVersion=cwlVersion, - baseCommand=baseCommand, - arguments=arguments, - stdin=stdin, - stderr=stderr, - stdout=stdout, - successCodes=successCodes, - temporaryFailCodes=temporaryFailCodes, - permanentFailCodes=permanentFailCodes, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.baseCommand is not None: - r["baseCommand"] = save( - self.baseCommand, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.arguments is not None: - r["arguments"] = save( - self.arguments, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stdin is not None: - r["stdin"] = save( - self.stdin, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stderr is not None: - r["stderr"] = save( - self.stderr, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stdout is not None: - r["stdout"] = save( - self.stdout, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.successCodes is not None: - r["successCodes"] = save( - self.successCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.temporaryFailCodes is not None: - r["temporaryFailCodes"] = save( - self.temporaryFailCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.permanentFailCodes is not None: - r["permanentFailCodes"] = save( - self.permanentFailCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "inputs", - "outputs", - "requirements", - "hints", - "label", - "doc", - "cwlVersion", - "class", - "baseCommand", - "arguments", - "stdin", - "stderr", - "stdout", - "successCodes", - "temporaryFailCodes", - "permanentFailCodes", - ] - ) - - -class DockerRequirement(ProcessRequirement): - """ - Indicates that a workflow component should be run in a - [Docker](http://docker.com) container, and specifies how to fetch or build - the image. - - If a CommandLineTool lists `DockerRequirement` under - `hints` (or `requirements`), it may (or must) be run in the specified Docker - container. - - The platform must first acquire or install the correct Docker image as - specified by `dockerPull`, `dockerImport`, `dockerLoad` or `dockerFile`. - - The platform must execute the tool in the container using `docker run` with - the appropriate Docker image and tool command line. - - The workflow platform may provide input files and the designated output - directory through the use of volume bind mounts. The platform should rewrite - file paths in the input object to correspond to the Docker bind mounted - locations. That is, the platform should rewrite values in the parameter context - such as `runtime.outdir`, `runtime.tmpdir` and others to be valid paths - within the container. - - When running a tool contained in Docker, the workflow platform must not - assume anything about the contents of the Docker container, such as the - presence or absence of specific software, except to assume that the - generated command line represents a valid command within the runtime - environment of the container. - - ## Interaction with other requirements - - If [EnvVarRequirement](#EnvVarRequirement) is specified alongside a - DockerRequirement, the environment variables must be provided to Docker - using `--env` or `--env-file` and interact with the container's preexisting - environment as defined by Docker. - - """ - - def __init__( - self, - dockerPull: Optional[Any] = None, - dockerLoad: Optional[Any] = None, - dockerFile: Optional[Any] = None, - dockerImport: Optional[Any] = None, - dockerImageId: Optional[Any] = None, - dockerOutputDirectory: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "DockerRequirement" - self.dockerPull = dockerPull - self.dockerLoad = dockerLoad - self.dockerFile = dockerFile - self.dockerImport = dockerImport - self.dockerImageId = dockerImageId - self.dockerOutputDirectory = dockerOutputDirectory - - def __eq__(self, other: Any) -> bool: - if isinstance(other, DockerRequirement): - return bool( - self.class_ == other.class_ - and self.dockerPull == other.dockerPull - and self.dockerLoad == other.dockerLoad - and self.dockerFile == other.dockerFile - and self.dockerImport == other.dockerImport - and self.dockerImageId == other.dockerImageId - and self.dockerOutputDirectory == other.dockerOutputDirectory - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.dockerPull, - self.dockerLoad, - self.dockerFile, - self.dockerImport, - self.dockerImageId, - self.dockerOutputDirectory, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "DockerRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_DockerRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - dockerPull = None - if "dockerPull" in _doc: - try: - dockerPull = load_field( - _doc.get("dockerPull"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerPull") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerPull`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerPull") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerPull` field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerPull` field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [e], - detailed_message=f"the `dockerPull` field with value `{val}` " - "is not valid because:", - ) - ) - dockerLoad = None - if "dockerLoad" in _doc: - try: - dockerLoad = load_field( - _doc.get("dockerLoad"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerLoad") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerLoad`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerLoad") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerLoad` field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerLoad` field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [e], - detailed_message=f"the `dockerLoad` field with value `{val}` " - "is not valid because:", - ) - ) - dockerFile = None - if "dockerFile" in _doc: - try: - dockerFile = load_field( - _doc.get("dockerFile"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerFile") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerFile`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerFile") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerFile` field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerFile` field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [e], - detailed_message=f"the `dockerFile` field with value `{val}` " - "is not valid because:", - ) - ) - dockerImport = None - if "dockerImport" in _doc: - try: - dockerImport = load_field( - _doc.get("dockerImport"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerImport") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerImport`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerImport") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerImport` field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerImport` field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [e], - detailed_message=f"the `dockerImport` field with value `{val}` " - "is not valid because:", - ) - ) - dockerImageId = None - if "dockerImageId" in _doc: - try: - dockerImageId = load_field( - _doc.get("dockerImageId"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerImageId") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerImageId`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerImageId") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerImageId` field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerImageId` field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [e], - detailed_message=f"the `dockerImageId` field with value `{val}` " - "is not valid because:", - ) - ) - dockerOutputDirectory = None - if "dockerOutputDirectory" in _doc: - try: - dockerOutputDirectory = load_field( - _doc.get("dockerOutputDirectory"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerOutputDirectory") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerOutputDirectory`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerOutputDirectory") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerOutputDirectory` field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerOutputDirectory` field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [e], - detailed_message=f"the `dockerOutputDirectory` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `dockerPull`, `dockerLoad`, `dockerFile`, `dockerImport`, `dockerImageId`, `dockerOutputDirectory`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - dockerPull=dockerPull, - dockerLoad=dockerLoad, - dockerFile=dockerFile, - dockerImport=dockerImport, - dockerImageId=dockerImageId, - dockerOutputDirectory=dockerOutputDirectory, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.dockerPull is not None: - r["dockerPull"] = save( - self.dockerPull, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerLoad is not None: - r["dockerLoad"] = save( - self.dockerLoad, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerFile is not None: - r["dockerFile"] = save( - self.dockerFile, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerImport is not None: - r["dockerImport"] = save( - self.dockerImport, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerImageId is not None: - r["dockerImageId"] = save( - self.dockerImageId, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerOutputDirectory is not None: - r["dockerOutputDirectory"] = save( - self.dockerOutputDirectory, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "class", - "dockerPull", - "dockerLoad", - "dockerFile", - "dockerImport", - "dockerImageId", - "dockerOutputDirectory", - ] - ) - - -class SoftwareRequirement(ProcessRequirement): - """ - A list of software packages that should be configured in the environment of - the defined process. - - """ - - def __init__( - self, - packages: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SoftwareRequirement" - self.packages = packages - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SoftwareRequirement): - return bool(self.class_ == other.class_ and self.packages == other.packages) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.packages)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SoftwareRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_SoftwareRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("packages") is None: - raise ValidationException("missing required field `packages`", None, []) - - packages = load_field( - _doc.get("packages"), - idmap_packages_array_of_SoftwarePackageLoader, - baseuri, - loadingOptions, - lc=_doc.get("packages") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `packages`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("packages") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `packages` field is not valid because:", - SourceLine(_doc, "packages", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `packages` field is not valid because:", - SourceLine(_doc, "packages", str), - [e], - detailed_message=f"the `packages` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `packages`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - packages=packages, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.packages is not None: - r["packages"] = save( - self.packages, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "packages"]) - - -class SoftwarePackage(Saveable): - def __init__( - self, - package: Any, - version: Optional[Any] = None, - specs: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.package = package - self.version = version - self.specs = specs - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SoftwarePackage): - return bool( - self.package == other.package - and self.version == other.version - and self.specs == other.specs - ) - return False - - def __hash__(self) -> int: - return hash((self.package, self.version, self.specs)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SoftwarePackage": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("package") is None: - raise ValidationException("missing required field `package`", None, []) - - package = load_field( - _doc.get("package"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("package") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `package`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("package") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `package` field is not valid because:", - SourceLine(_doc, "package", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `package` field is not valid because:", - SourceLine(_doc, "package", str), - [e], - detailed_message=f"the `package` field with value `{val}` " - "is not valid because:", - ) - ) - version = None - if "version" in _doc: - try: - version = load_field( - _doc.get("version"), - union_of_None_type_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("version") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `version`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("version") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `version` field is not valid because:", - SourceLine(_doc, "version", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `version` field is not valid because:", - SourceLine(_doc, "version", str), - [e], - detailed_message=f"the `version` field with value `{val}` " - "is not valid because:", - ) - ) - specs = None - if "specs" in _doc: - try: - specs = load_field( - _doc.get("specs"), - uri_union_of_None_type_or_array_of_strtype_False_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("specs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `specs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("specs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `specs` field is not valid because:", - SourceLine(_doc, "specs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `specs` field is not valid because:", - SourceLine(_doc, "specs", str), - [e], - detailed_message=f"the `specs` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `package`, `version`, `specs`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - package=package, - version=version, - specs=specs, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.package is not None: - r["package"] = save( - self.package, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.version is not None: - r["version"] = save( - self.version, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.specs is not None: - u = save_relative_uri(self.specs, base_url, False, None, relative_uris) - r["specs"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["package", "version", "specs"]) - - -class Dirent(Saveable): - """ - Define a file or subdirectory that must be placed in the designated output - directory prior to executing the command line tool. May be the result of - executing an expression, such as building a configuration file from a - template. - - """ - - def __init__( - self, - entry: Any, - entryname: Optional[Any] = None, - writable: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.entryname = entryname - self.entry = entry - self.writable = writable - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Dirent): - return bool( - self.entryname == other.entryname - and self.entry == other.entry - and self.writable == other.writable - ) - return False - - def __hash__(self) -> int: - return hash((self.entryname, self.entry, self.writable)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Dirent": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - entryname = None - if "entryname" in _doc: - try: - entryname = load_field( - _doc.get("entryname"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("entryname") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `entryname`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("entryname") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `entryname` field is not valid because:", - SourceLine(_doc, "entryname", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `entryname` field is not valid because:", - SourceLine(_doc, "entryname", str), - [e], - detailed_message=f"the `entryname` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("entry") is None: - raise ValidationException("missing required field `entry`", None, []) - - entry = load_field( - _doc.get("entry"), - union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("entry") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `entry`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("entry") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `entry` field is not valid because:", - SourceLine(_doc, "entry", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `entry` field is not valid because:", - SourceLine(_doc, "entry", str), - [e], - detailed_message=f"the `entry` field with value `{val}` " - "is not valid because:", - ) - ) - writable = None - if "writable" in _doc: - try: - writable = load_field( - _doc.get("writable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("writable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `writable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("writable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `writable` field is not valid because:", - SourceLine(_doc, "writable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `writable` field is not valid because:", - SourceLine(_doc, "writable", str), - [e], - detailed_message=f"the `writable` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `entryname`, `entry`, `writable`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - entryname=entryname, - entry=entry, - writable=writable, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.entryname is not None: - r["entryname"] = save( - self.entryname, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.entry is not None: - r["entry"] = save( - self.entry, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.writable is not None: - r["writable"] = save( - self.writable, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["entryname", "entry", "writable"]) - - -class InitialWorkDirRequirement(ProcessRequirement): - """ - Define a list of files and subdirectories that must be created by the workflow platform in the designated output directory prior to executing the command line tool. - """ - - def __init__( - self, - listing: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "InitialWorkDirRequirement" - self.listing = listing - - def __eq__(self, other: Any) -> bool: - if isinstance(other, InitialWorkDirRequirement): - return bool(self.class_ == other.class_ and self.listing == other.listing) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.listing)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InitialWorkDirRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_InitialWorkDirRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("listing") is None: - raise ValidationException("missing required field `listing`", None, []) - - listing = load_field( - _doc.get("listing"), - union_of_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("listing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `listing`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("listing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), - [e], - detailed_message=f"the `listing` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `listing`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - listing=listing, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.listing is not None: - r["listing"] = save( - self.listing, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "listing"]) - - -class EnvVarRequirement(ProcessRequirement): - """ - Define a list of environment variables which will be set in the - execution environment of the tool. See `EnvironmentDef` for details. - - """ - - def __init__( - self, - envDef: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "EnvVarRequirement" - self.envDef = envDef - - def __eq__(self, other: Any) -> bool: - if isinstance(other, EnvVarRequirement): - return bool(self.class_ == other.class_ and self.envDef == other.envDef) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.envDef)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnvVarRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_EnvVarRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("envDef") is None: - raise ValidationException("missing required field `envDef`", None, []) - - envDef = load_field( - _doc.get("envDef"), - idmap_envDef_array_of_EnvironmentDefLoader, - baseuri, - loadingOptions, - lc=_doc.get("envDef") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `envDef`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("envDef") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `envDef` field is not valid because:", - SourceLine(_doc, "envDef", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `envDef` field is not valid because:", - SourceLine(_doc, "envDef", str), - [e], - detailed_message=f"the `envDef` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `envDef`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - envDef=envDef, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.envDef is not None: - r["envDef"] = save( - self.envDef, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "envDef"]) - - -class ShellCommandRequirement(ProcessRequirement): - """ - Modify the behavior of CommandLineTool to generate a single string - containing a shell command line. Each item in the argument list must be - joined into a string separated by single spaces and quoted to prevent - intepretation by the shell, unless `CommandLineBinding` for that argument - contains `shellQuote: false`. If `shellQuote: false` is specified, the - argument is joined into the command string without quoting, which allows - the use of shell metacharacters such as `|` for pipes. - - """ - - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "ShellCommandRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ShellCommandRequirement): - return bool(self.class_ == other.class_) - return False - - def __hash__(self) -> int: - return hash((self.class_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ShellCommandRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ShellCommandRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class ResourceRequirement(ProcessRequirement): - """ - Specify basic hardware resource requirements. - - "min" is the minimum amount of a resource that must be reserved to schedule - a job. If "min" cannot be satisfied, the job should not be run. - - "max" is the maximum amount of a resource that the job shall be permitted - to use. If a node has sufficient resources, multiple jobs may be scheduled - on a single node provided each job's "max" resource requirements are - met. If a job attempts to exceed its "max" resource allocation, an - implementation may deny additional resources, which may result in job - failure. - - If "min" is specified but "max" is not, then "max" == "min" - If "max" is specified by "min" is not, then "min" == "max". - - It is an error if max < min. - - It is an error if the value of any of these fields is negative. - - If neither "min" nor "max" is specified for a resource, an implementation may provide a default. - - """ - - def __init__( - self, - coresMin: Optional[Any] = None, - coresMax: Optional[Any] = None, - ramMin: Optional[Any] = None, - ramMax: Optional[Any] = None, - tmpdirMin: Optional[Any] = None, - tmpdirMax: Optional[Any] = None, - outdirMin: Optional[Any] = None, - outdirMax: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "ResourceRequirement" - self.coresMin = coresMin - self.coresMax = coresMax - self.ramMin = ramMin - self.ramMax = ramMax - self.tmpdirMin = tmpdirMin - self.tmpdirMax = tmpdirMax - self.outdirMin = outdirMin - self.outdirMax = outdirMax - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ResourceRequirement): - return bool( - self.class_ == other.class_ - and self.coresMin == other.coresMin - and self.coresMax == other.coresMax - and self.ramMin == other.ramMin - and self.ramMax == other.ramMax - and self.tmpdirMin == other.tmpdirMin - and self.tmpdirMax == other.tmpdirMax - and self.outdirMin == other.outdirMin - and self.outdirMax == other.outdirMax - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.coresMin, - self.coresMax, - self.ramMin, - self.ramMax, - self.tmpdirMin, - self.tmpdirMax, - self.outdirMin, - self.outdirMax, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ResourceRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ResourceRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - coresMin = None - if "coresMin" in _doc: - try: - coresMin = load_field( - _doc.get("coresMin"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("coresMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `coresMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("coresMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `coresMin` field is not valid because:", - SourceLine(_doc, "coresMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `coresMin` field is not valid because:", - SourceLine(_doc, "coresMin", str), - [e], - detailed_message=f"the `coresMin` field with value `{val}` " - "is not valid because:", - ) - ) - coresMax = None - if "coresMax" in _doc: - try: - coresMax = load_field( - _doc.get("coresMax"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("coresMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `coresMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("coresMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `coresMax` field is not valid because:", - SourceLine(_doc, "coresMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `coresMax` field is not valid because:", - SourceLine(_doc, "coresMax", str), - [e], - detailed_message=f"the `coresMax` field with value `{val}` " - "is not valid because:", - ) - ) - ramMin = None - if "ramMin" in _doc: - try: - ramMin = load_field( - _doc.get("ramMin"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("ramMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `ramMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("ramMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `ramMin` field is not valid because:", - SourceLine(_doc, "ramMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `ramMin` field is not valid because:", - SourceLine(_doc, "ramMin", str), - [e], - detailed_message=f"the `ramMin` field with value `{val}` " - "is not valid because:", - ) - ) - ramMax = None - if "ramMax" in _doc: - try: - ramMax = load_field( - _doc.get("ramMax"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("ramMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `ramMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("ramMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `ramMax` field is not valid because:", - SourceLine(_doc, "ramMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `ramMax` field is not valid because:", - SourceLine(_doc, "ramMax", str), - [e], - detailed_message=f"the `ramMax` field with value `{val}` " - "is not valid because:", - ) - ) - tmpdirMin = None - if "tmpdirMin" in _doc: - try: - tmpdirMin = load_field( - _doc.get("tmpdirMin"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("tmpdirMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `tmpdirMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("tmpdirMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `tmpdirMin` field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `tmpdirMin` field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [e], - detailed_message=f"the `tmpdirMin` field with value `{val}` " - "is not valid because:", - ) - ) - tmpdirMax = None - if "tmpdirMax" in _doc: - try: - tmpdirMax = load_field( - _doc.get("tmpdirMax"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("tmpdirMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `tmpdirMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("tmpdirMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `tmpdirMax` field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `tmpdirMax` field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [e], - detailed_message=f"the `tmpdirMax` field with value `{val}` " - "is not valid because:", - ) - ) - outdirMin = None - if "outdirMin" in _doc: - try: - outdirMin = load_field( - _doc.get("outdirMin"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("outdirMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outdirMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outdirMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outdirMin` field is not valid because:", - SourceLine(_doc, "outdirMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outdirMin` field is not valid because:", - SourceLine(_doc, "outdirMin", str), - [e], - detailed_message=f"the `outdirMin` field with value `{val}` " - "is not valid because:", - ) - ) - outdirMax = None - if "outdirMax" in _doc: - try: - outdirMax = load_field( - _doc.get("outdirMax"), - union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("outdirMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outdirMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outdirMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outdirMax` field is not valid because:", - SourceLine(_doc, "outdirMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outdirMax` field is not valid because:", - SourceLine(_doc, "outdirMax", str), - [e], - detailed_message=f"the `outdirMax` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `coresMin`, `coresMax`, `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, `outdirMax`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `baseCommand`, `arguments`, `stdin`, `stderr`, `stdout`, `successCodes`, `temporaryFailCodes`, `permanentFailCodes`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - coresMin=coresMin, - coresMax=coresMax, - ramMin=ramMin, - ramMax=ramMax, - tmpdirMin=tmpdirMin, - tmpdirMax=tmpdirMax, - outdirMin=outdirMin, - outdirMax=outdirMax, + id=id, + inputs=inputs, + outputs=outputs, + requirements=requirements, + hints=hints, + label=label, + doc=doc, + cwlVersion=cwlVersion, + baseCommand=baseCommand, + arguments=arguments, + stdin=stdin, + stderr=stderr, + stdout=stdout, + successCodes=successCodes, + temporaryFailCodes=temporaryFailCodes, + permanentFailCodes=permanentFailCodes, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -16926,56 +12788,91 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) + u = save_relative_uri(uri, self.id, False, None, relative_uris) r["class"] = u - if self.coresMin is not None: - r["coresMin"] = save( - self.coresMin, top=False, base_url=base_url, relative_uris=relative_uris + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.coresMax is not None: - r["coresMax"] = save( - self.coresMax, top=False, base_url=base_url, relative_uris=relative_uris + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.ramMin is not None: - r["ramMin"] = save( - self.ramMin, top=False, base_url=base_url, relative_uris=relative_uris + if self.requirements is not None: + r["requirements"] = save( + self.requirements, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.ramMax is not None: - r["ramMax"] = save( - self.ramMax, top=False, base_url=base_url, relative_uris=relative_uris + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.tmpdirMin is not None: - r["tmpdirMin"] = save( - self.tmpdirMin, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.baseCommand is not None: + r["baseCommand"] = save( + self.baseCommand, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) - if self.tmpdirMax is not None: - r["tmpdirMax"] = save( - self.tmpdirMax, + if self.arguments is not None: + r["arguments"] = save( + self.arguments, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stdin is not None: + r["stdin"] = save( + self.stdin, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stderr is not None: + r["stderr"] = save( + self.stderr, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stdout is not None: + r["stdout"] = save( + self.stdout, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.successCodes is not None: + r["successCodes"] = save( + self.successCodes, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) - if self.outdirMin is not None: - r["outdirMin"] = save( - self.outdirMin, + if self.temporaryFailCodes is not None: + r["temporaryFailCodes"] = save( + self.temporaryFailCodes, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) - if self.outdirMax is not None: - r["outdirMax"] = save( - self.outdirMax, + if self.permanentFailCodes is not None: + r["permanentFailCodes"] = save( + self.permanentFailCodes, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) @@ -16987,36 +12884,26 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "coresMin", - "coresMax", - "ramMin", - "ramMax", - "tmpdirMin", - "tmpdirMax", - "outdirMin", - "outdirMax", - ] - ) - - -class ExpressionToolOutputParameter(OutputParameter): - id: str - def __init__( self, - id: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - outputBinding: Optional[Any] = None, - format: Optional[Any] = None, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + inputs: Sequence[CommandInputParameter], + outputs: Sequence[CommandOutputParameter], + id: None | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + label: None | str = None, + doc: None | str = None, + cwlVersion: CWLVersion | None = None, + baseCommand: None | Sequence[str] | str = None, + arguments: None | Sequence[CommandLineBinding | str] = None, + stdin: None | str = None, + stderr: None | str = None, + stdout: None | str = None, + successCodes: None | Sequence[i32] = None, + temporaryFailCodes: None | Sequence[i32] = None, + permanentFailCodes: None | Sequence[i32] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -17026,40 +12913,92 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.outputBinding = outputBinding - self.format = format - self.type_ = type_ + self.cwlVersion = cwlVersion + self.class_: Final[str] = "CommandLineTool" + self.baseCommand = baseCommand + self.arguments = arguments + self.stdin = stdin + self.stderr = stderr + self.stdout = stdout + self.successCodes = successCodes + self.temporaryFailCodes = temporaryFailCodes + self.permanentFailCodes = permanentFailCodes + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "inputs", + "outputs", + "requirements", + "hints", + "label", + "doc", + "cwlVersion", + "class", + "baseCommand", + "arguments", + "stdin", + "stderr", + "stdout", + "successCodes", + "temporaryFailCodes", + "permanentFailCodes", + ] + ) + + +@mypyc_attr(native_class=True) +class DockerRequirement(Saveable): + """ + Indicates that a workflow component should be run in a `Docker `__ container, and specifies how to fetch or build the image. + + If a CommandLineTool lists ``DockerRequirement`` under ``hints`` (or ``requirements``), it may (or must) be run in the specified Docker container. + + The platform must first acquire or install the correct Docker image as specified by ``dockerPull``, ``dockerImport``, ``dockerLoad`` or ``dockerFile``. + + The platform must execute the tool in the container using ``docker run`` with the appropriate Docker image and tool command line. + + The workflow platform may provide input files and the designated output directory through the use of volume bind mounts. The platform should rewrite file paths in the input object to correspond to the Docker bind mounted locations. That is, the platform should rewrite values in the parameter context such as ``runtime.outdir``, ``runtime.tmpdir`` and others to be valid paths within the container. + + When running a tool contained in Docker, the workflow platform must not assume anything about the contents of the Docker container, such as the presence or absence of specific software, except to assume that the generated command line represents a valid command within the runtime environment of the container. + + Interaction with other requirements + ----------------------------------- + + If `EnvVarRequirement <#EnvVarRequirement>`__ is specified alongside a DockerRequirement, the environment variables must be provided to Docker using ``--env`` or ``--env-file`` and interact with the container's preexisting environment as defined by Docker. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ExpressionToolOutputParameter): + if isinstance(other, DockerRequirement): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.outputBinding == other.outputBinding - and self.format == other.format - and self.type_ == other.type_ + self.class_ == other.class_ + and self.dockerPull == other.dockerPull + and self.dockerLoad == other.dockerLoad + and self.dockerFile == other.dockerFile + and self.dockerImport == other.dockerImport + and self.dockerImageId == other.dockerImageId + and self.dockerOutputDirectory == other.dockerOutputDirectory ) return False def __hash__(self) -> int: return hash( ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.outputBinding, - self.format, - self.type_, + self.class_, + self.dockerPull, + self.dockerLoad, + self.dockerFile, + self.dockerImport, + self.dockerImageId, + self.dockerOutputDirectory, ) ) @@ -17069,85 +13008,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ExpressionToolOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) + class_ = _load_field( + _doc.get("class"), + uri_DockerRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + dockerPull = None + if "dockerPull" in _doc: try: - label = load_field( - _doc.get("label"), + dockerPull = _load_field( + _doc.get("dockerPull"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("dockerPull") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `dockerPull`": _errors__.append( ValidationException( str(e), @@ -17155,13 +13055,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("dockerPull") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17173,28 +13073,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `dockerPull` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + dockerLoad = None + if "dockerLoad" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + dockerLoad = _load_field( + _doc.get("dockerLoad"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("dockerLoad") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `dockerLoad`": _errors__.append( ValidationException( str(e), @@ -17202,13 +13102,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("dockerLoad") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17220,28 +13120,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `dockerLoad` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + dockerFile = None + if "dockerFile" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + dockerFile = _load_field( + _doc.get("dockerFile"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("dockerFile") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `dockerFile`": _errors__.append( ValidationException( str(e), @@ -17249,13 +13149,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("dockerFile") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17267,28 +13167,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `dockerFile` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + dockerImport = None + if "dockerImport" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + dockerImport = _load_field( + _doc.get("dockerImport"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("dockerImport") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `dockerImport`": _errors__.append( ValidationException( str(e), @@ -17296,13 +13196,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("dockerImport") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17314,28 +13214,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `dockerImport` field with value `{val}` " "is not valid because:", ) ) - outputBinding = None - if "outputBinding" in _doc: + dockerImageId = None + if "dockerImageId" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + dockerImageId = _load_field( + _doc.get("dockerImageId"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("dockerImageId") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `dockerImageId`": _errors__.append( ValidationException( str(e), @@ -17343,13 +13243,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("dockerImageId") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17361,28 +13261,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `dockerImageId` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + dockerOutputDirectory = None + if "dockerOutputDirectory" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + dockerOutputDirectory = _load_field( + _doc.get("dockerOutputDirectory"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("dockerOutputDirectory") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `dockerOutputDirectory`": _errors__.append( ValidationException( str(e), @@ -17390,13 +13290,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("dockerOutputDirectory") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17408,61 +13308,256 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `dockerOutputDirectory` field with value `{val}` " "is not valid because:", ) ) - type_ = None - if "type" in _doc: - try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `dockerPull`, `dockerLoad`, `dockerFile`, `dockerImport`, `dockerImageId`, `dockerOutputDirectory`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + dockerPull=dockerPull, + dockerLoad=dockerLoad, + dockerFile=dockerFile, + dockerImport=dockerImport, + dockerImageId=dockerImageId, + dockerOutputDirectory=dockerOutputDirectory, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.dockerPull is not None: + r["dockerPull"] = save( + self.dockerPull, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerLoad is not None: + r["dockerLoad"] = save( + self.dockerLoad, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerFile is not None: + r["dockerFile"] = save( + self.dockerFile, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerImport is not None: + r["dockerImport"] = save( + self.dockerImport, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerImageId is not None: + r["dockerImageId"] = save( + self.dockerImageId, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerOutputDirectory is not None: + r["dockerOutputDirectory"] = save( + self.dockerOutputDirectory, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + dockerPull: None | str = None, + dockerLoad: None | str = None, + dockerFile: None | str = None, + dockerImport: None | str = None, + dockerImageId: None | str = None, + dockerOutputDirectory: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "DockerRequirement" + self.dockerPull = dockerPull + self.dockerLoad = dockerLoad + self.dockerFile = dockerFile + self.dockerImport = dockerImport + self.dockerImageId = dockerImageId + self.dockerOutputDirectory = dockerOutputDirectory + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "dockerPull", + "dockerLoad", + "dockerFile", + "dockerImport", + "dockerImageId", + "dockerOutputDirectory", + ] + ) + + +@mypyc_attr(native_class=True) +class SoftwareRequirement(Saveable): + """ + A list of software packages that should be configured in the environment of the defined process. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, SoftwareRequirement): + return bool(self.class_ == other.class_ and self.packages == other.packages) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.packages)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_SoftwareRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("packages") is None: + raise ValidationException("missing required field `packages`", None, []) + + packages = _load_field( + _doc.get("packages"), + idmap_packages_array_of_SoftwarePackageLoader, + baseuri, + loadingOptions, + lc=_doc.get("packages") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `packages`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("packages") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [e], + detailed_message=f"the `packages` field with value `{val}` " + "is not valid because:", ) - extension_fields: dict[str, Any] = {} + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -17470,14 +13565,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`, `type`".format( + "invalid field `{}`, expected one of: `class`, `packages`".format( k ), SourceLine(_doc, k, str), @@ -17487,18 +13582,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - outputBinding=outputBinding, - format=format, - type_=type_, + packages=packages, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -17512,44 +13599,19 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.packages is not None: + r["packages"] = save( + self.packages, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -17560,243 +13622,70 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "outputBinding", - "format", - "type", - ] - ) - - -class ExpressionTool(Process): - """ - Execute an expression as a Workflow step. - - """ - - id: str - def __init__( self, - inputs: Any, - outputs: Any, - expression: Any, - id: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.label = label - self.doc = doc - self.cwlVersion = cwlVersion - self.class_ = "ExpressionTool" - self.expression = expression - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ExpressionTool): - return bool( - self.id == other.id - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.label == other.label - and self.doc == other.doc - and self.cwlVersion == other.cwlVersion - and self.class_ == other.class_ - and self.expression == other.expression - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.id, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.label, - self.doc, - self.cwlVersion, - self.class_, - self.expression, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ExpressionTool": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + packages: Sequence[SoftwarePackage], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "SoftwareRequirement" + self.packages = packages - class_ = load_field( - _doc.get("class"), - uri_ExpressionTool_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + attrs: ClassVar[Collection[str]] = frozenset(["class", "packages"]) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_InputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") +@mypyc_attr(native_class=True) +class SoftwarePackage(Saveable): + def __eq__(self, other: Any) -> bool: + if isinstance(other, SoftwarePackage): + return bool( + self.package == other.package + and self.version == other.version + and self.specs == other.specs ) + return False - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + def __hash__(self) -> int: + return hash((self.package, self.version, self.specs)) - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) + if _doc.get("package") is None: + raise ValidationException("missing required field `package`", None, []) - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_ExpressionToolOutputParameterLoader, + package = _load_field( + _doc.get("package"), + strtype, baseuri, loadingOptions, - lc=_doc.get("outputs") + lc=_doc.get("package") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputs`": + if str(e) == "missing required field `package`": _errors__.append( ValidationException( str(e), @@ -17804,13 +13693,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputs") + val = _doc.get("package") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17822,28 +13711,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), [e], - detailed_message=f"the `outputs` field with value `{val}` " + detailed_message=f"the `package` field with value `{val}` " "is not valid because:", ) ) - requirements = None - if "requirements" in _doc: + version = None + if "version" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + version = _load_field( + _doc.get("version"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("version") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `version`": _errors__.append( ValidationException( str(e), @@ -17851,13 +13740,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("version") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17869,28 +13758,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `version` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + specs = None + if "specs" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + specs = _load_field( + _doc.get("specs"), + uri_union_of_None_type_or_array_of_strtype_False_False_None_True, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("specs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `specs`": _errors__.append( ValidationException( str(e), @@ -17898,13 +13787,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("specs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17916,28 +13805,148 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `specs` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `package`, `version`, `specs`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + package=package, + version=version, + specs=specs, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.package is not None: + r["package"] = save( + self.package, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.version is not None: + r["version"] = save( + self.version, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.specs is not None: + u = save_relative_uri(self.specs, base_url, False, None, relative_uris) + r["specs"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + package: str, + version: None | Sequence[str] = None, + specs: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.package = package + self.version = version + self.specs = specs + + attrs: ClassVar[Collection[str]] = frozenset(["package", "version", "specs"]) + + +@mypyc_attr(native_class=True) +class Dirent(Saveable): + """ + Define a file or subdirectory that must be placed in the designated output directory prior to executing the command line tool. May be the result of executing an expression, such as building a configuration file from a template. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, Dirent): + return bool( + self.entryname == other.entryname + and self.entry == other.entry + and self.writable == other.writable + ) + return False + + def __hash__(self) -> int: + return hash((self.entryname, self.entry, self.writable)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + entryname = None + if "entryname" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + entryname = _load_field( + _doc.get("entryname"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("entryname") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `entryname`": _errors__.append( ValidationException( str(e), @@ -17945,13 +13954,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("entryname") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -17963,75 +13972,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `entryname` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + try: + if _doc.get("entry") is None: + raise ValidationException("missing required field `entry`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + entry = _load_field( + _doc.get("entry"), + union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("entry") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entry`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("entry") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [e], + detailed_message=f"the `entry` field with value `{val}` " + "is not valid because:", ) - cwlVersion = None - if "cwlVersion" in _doc: + ) + writable = None + if "writable" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + writable = _load_field( + _doc.get("writable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("writable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `writable`": _errors__.append( ValidationException( str(e), @@ -18039,13 +14049,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("writable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18057,29 +14067,166 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `writable` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `entryname`, `entry`, `writable`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + entryname=entryname, + entry=entry, + writable=writable, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.entryname is not None: + r["entryname"] = save( + self.entryname, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.entry is not None: + r["entry"] = save( + self.entry, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.writable is not None: + r["writable"] = save( + self.writable, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + entry: str, + entryname: None | str = None, + writable: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.entryname = entryname + self.entry = entry + self.writable = writable + + attrs: ClassVar[Collection[str]] = frozenset(["entryname", "entry", "writable"]) + + +@mypyc_attr(native_class=True) +class InitialWorkDirRequirement(Saveable): + """ + Define a list of files and subdirectories that must be created by the workflow platform in the designated output directory prior to executing the command line tool. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InitialWorkDirRequirement): + return bool(self.class_ == other.class_ and self.listing == other.listing) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.listing)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("expression") is None: - raise ValidationException("missing required field `expression`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - expression = load_field( - _doc.get("expression"), - union_of_strtype_or_ExpressionLoader, + class_ = _load_field( + _doc.get("class"), + uri_InitialWorkDirRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("listing") is None: + raise ValidationException("missing required field `listing`", None, []) + + listing = _load_field( + _doc.get("listing"), + union_of_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("expression") + lc=_doc.get("listing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `expression`": + if str(e) == "missing required field `listing`": _errors__.append( ValidationException( str(e), @@ -18087,13 +14234,13 @@ def fromDoc( ) ) else: - val = _doc.get("expression") + val = _doc.get("listing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `expression` field is not valid because:", - SourceLine(_doc, "expression", str), + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18105,14 +14252,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `expression` field is not valid because:", - SourceLine(_doc, "expression", str), + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), [e], - detailed_message=f"the `expression` field with value `{val}` " + detailed_message=f"the `listing` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18120,14 +14267,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `expression`".format( + "invalid field `{}`, expected one of: `class`, `listing`".format( k ), SourceLine(_doc, k, str), @@ -18137,19 +14284,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - label=label, - doc=doc, - cwlVersion=cwlVersion, - expression=expression, + listing=listing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -18163,53 +14301,19 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) + u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.expression is not None: - r["expression"] = save( - self.expression, - top=False, - base_url=self.id, - relative_uris=relative_uris, + if self.listing is not None: + r["listing"] = save( + self.listing, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -18220,46 +14324,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "inputs", - "outputs", - "requirements", - "hints", - "label", - "doc", - "cwlVersion", - "class", - "expression", - ] - ) - - -class WorkflowOutputParameter(OutputParameter): - """ - Describe an output parameter of a workflow. The parameter must be - connected to one or more parameters defined in the workflow that will - provide the value of the output parameter. - - """ - - id: str - def __init__( self, - id: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - outputBinding: Optional[Any] = None, - format: Optional[Any] = None, - outputSource: Optional[Any] = None, - linkMerge: Optional[Any] = None, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + listing: Sequence[Directory | Dirent | File | str] | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -18269,48 +14338,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.outputBinding = outputBinding - self.format = format - self.outputSource = outputSource - self.linkMerge = linkMerge - self.type_ = type_ + self.class_: Final[str] = "InitialWorkDirRequirement" + self.listing = listing + + attrs: ClassVar[Collection[str]] = frozenset(["class", "listing"]) + + +@mypyc_attr(native_class=True) +class EnvVarRequirement(Saveable): + """ + Define a list of environment variables which will be set in the execution environment of the tool. See ``EnvironmentDef`` for details. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowOutputParameter): - return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.outputBinding == other.outputBinding - and self.format == other.format - and self.outputSource == other.outputSource - and self.linkMerge == other.linkMerge - and self.type_ == other.type_ - ) + if isinstance(other, EnvVarRequirement): + return bool(self.class_ == other.class_ and self.envDef == other.envDef) return False def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.outputBinding, - self.format, - self.outputSource, - self.linkMerge, - self.type_, - ) - ) + return hash((self.class_, self.envDef)) @classmethod def fromDoc( @@ -18318,414 +14365,381 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) + class_ = _load_field( + _doc.get("class"), + uri_EnvVarRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("envDef") is None: + raise ValidationException("missing required field `envDef`", None, []) - if str(e) == "missing required field `secondaryFiles`": + envDef = _load_field( + _doc.get("envDef"), + idmap_envDef_array_of_EnvironmentDefLoader, + baseuri, + loadingOptions, + lc=_doc.get("envDef") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envDef`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("envDef") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( - str(e), - None + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [e], + detailed_message=f"the `envDef` field with value `{val}` " + "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `class`, `envDef`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + envDef=envDef, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.envDef is not None: + r["envDef"] = save( + self.envDef, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + envDef: Sequence[EnvironmentDef], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "EnvVarRequirement" + self.envDef = envDef + + attrs: ClassVar[Collection[str]] = frozenset(["class", "envDef"]) + + +@mypyc_attr(native_class=True) +class ShellCommandRequirement(Saveable): + """ + Modify the behavior of CommandLineTool to generate a single string containing a shell command line. Each item in the argument list must be joined into a string separated by single spaces and quoted to prevent interpretation by the shell, unless ``CommandLineBinding`` for that argument contains ``shellQuote: false``. If ``shellQuote: false`` is specified, the argument is joined into the command string without quoting, which allows the use of shell metacharacters such as ``|`` for pipes. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, ShellCommandRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ShellCommandRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - if str(e) == "missing required field `outputBinding`": + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `class`".format(k), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - outputSource = None - if "outputSource" in _doc: - try: - outputSource = load_field( - _doc.get("outputSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, - baseuri, - loadingOptions, - lc=_doc.get("outputSource") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed - if str(e) == "missing required field `outputSource`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputSource") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), - [e], - detailed_message=f"the `outputSource` field with value `{val}` " - "is not valid because:", - ) - ) - linkMerge = None - if "linkMerge" in _doc: + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "ShellCommandRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class ResourceRequirement(Saveable): + """ + Specify basic hardware resource requirements. + + "min" is the minimum amount of a resource that must be reserved to schedule a job. If "min" cannot be satisfied, the job should not be run. + + "max" is the maximum amount of a resource that the job shall be permitted to use. If a node has sufficient resources, multiple jobs may be scheduled on a single node provided each job's "max" resource requirements are met. If a job attempts to exceed its "max" resource allocation, an implementation may deny additional resources, which may result in job failure. + + If "min" is specified but "max" is not, then "max" == "min" If "max" is specified by "min" is not, then "min" == "max". + + It is an error if max < min. + + It is an error if the value of any of these fields is negative. + + If neither "min" nor "max" is specified for a resource, an implementation may provide a default. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, ResourceRequirement): + return bool( + self.class_ == other.class_ + and self.coresMin == other.coresMin + and self.coresMax == other.coresMax + and self.ramMin == other.ramMin + and self.ramMax == other.ramMax + and self.tmpdirMin == other.tmpdirMin + and self.tmpdirMax == other.tmpdirMax + and self.outdirMin == other.outdirMin + and self.outdirMax == other.outdirMax + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.class_, + self.coresMin, + self.coresMax, + self.ramMin, + self.ramMax, + self.tmpdirMin, + self.tmpdirMax, + self.outdirMin, + self.outdirMax, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ResourceRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + coresMin = None + if "coresMin" in _doc: try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, + coresMin = _load_field( + _doc.get("coresMin"), + union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("linkMerge") + lc=_doc.get("coresMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `linkMerge`": + if str(e) == "missing required field `coresMin`": _errors__.append( ValidationException( str(e), @@ -18733,13 +14747,13 @@ def fromDoc( ) ) else: - val = _doc.get("linkMerge") + val = _doc.get("coresMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18751,28 +14765,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), [e], - detailed_message=f"the `linkMerge` field with value `{val}` " + detailed_message=f"the `coresMin` field with value `{val}` " "is not valid because:", ) ) - type_ = None - if "type" in _doc: + coresMax = None + if "coresMax" in _doc: try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + coresMax = _load_field( + _doc.get("coresMax"), + union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("coresMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `coresMax`": _errors__.append( ValidationException( str(e), @@ -18780,13 +14794,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("coresMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18798,255 +14812,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `coresMax` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`, `outputSource`, `linkMerge`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - outputBinding=outputBinding, - format=format, - outputSource=outputSource, - linkMerge=linkMerge, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.outputSource is not None: - u = save_relative_uri(self.outputSource, self.id, False, 1, relative_uris) - r["outputSource"] = u - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "outputBinding", - "format", - "outputSource", - "linkMerge", - "type", - ] - ) - - -class Sink(Saveable): - pass - - -class WorkflowStepInput(Sink): - """ - The input of a workflow step connects an upstream parameter (from the - workflow inputs, or the outputs of other workflows steps) with the input - parameters of the underlying step. - - ## Input object - - A WorkflowStepInput object must contain an `id` field in the form - `#fieldname` or `#prefix/fieldname`. When the `id` field contains a slash - `/` the field name consists of the characters following the final slash - (the prefix portion may contain one or more slashes to indicate scope). - This defines a field of the workflow step input object with the value of - the `source` parameter(s). - - ## Merging - - To merge multiple inbound data links, - [MultipleInputFeatureRequirement](#MultipleInputFeatureRequirement) must be specified - in the workflow or workflow step requirements. - - If the sink parameter is an array, or named in a [workflow - scatter](#WorkflowStep) operation, there may be multiple inbound data links - listed in the `source` field. The values from the input links are merged - depending on the method specified in the `linkMerge` field. If not - specified, the default method is "merge_nested". - - * **merge_nested** - - The input must be an array consisting of exactly one entry for each - input link. If "merge_nested" is specified with a single link, the value - from the link must be wrapped in a single-item list. - - * **merge_flattened** - - 1. The source and sink parameters must be compatible types, or the source - type must be compatible with single element from the "items" type of - the destination array parameter. - 2. Source parameters which are arrays are concatenated. - Source parameters which are single element types are appended as - single elements. - - """ - - id: str - - def __init__( - self, - id: Any, - source: Optional[Any] = None, - linkMerge: Optional[Any] = None, - default: Optional[Any] = None, - valueFrom: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.source = source - self.linkMerge = linkMerge - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.default = default - self.valueFrom = valueFrom - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepInput): - return bool( - self.source == other.source - and self.linkMerge == other.linkMerge - and self.id == other.id - and self.default == other.default - and self.valueFrom == other.valueFrom - ) - return False - - def __hash__(self) -> int: - return hash( - (self.source, self.linkMerge, self.id, self.default, self.valueFrom) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStepInput": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + ramMin = None + if "ramMin" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + ramMin = _load_field( + _doc.get("ramMin"), + union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("ramMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `ramMin`": _errors__.append( ValidationException( str(e), @@ -19054,13 +14841,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("ramMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19072,37 +14859,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `ramMin` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - source = None - if "source" in _doc: + ramMax = None + if "ramMax" in _doc: try: - source = load_field( - _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + ramMax = _load_field( + _doc.get("ramMax"), + union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("source") + lc=_doc.get("ramMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `source`": + if str(e) == "missing required field `ramMax`": _errors__.append( ValidationException( str(e), @@ -19110,13 +14888,13 @@ def fromDoc( ) ) else: - val = _doc.get("source") + val = _doc.get("ramMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19128,28 +14906,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), [e], - detailed_message=f"the `source` field with value `{val}` " + detailed_message=f"the `ramMax` field with value `{val}` " "is not valid because:", ) ) - linkMerge = None - if "linkMerge" in _doc: + tmpdirMin = None + if "tmpdirMin" in _doc: try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, + tmpdirMin = _load_field( + _doc.get("tmpdirMin"), + union_of_None_type_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("linkMerge") + lc=_doc.get("tmpdirMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `linkMerge`": + if str(e) == "missing required field `tmpdirMin`": _errors__.append( ValidationException( str(e), @@ -19157,13 +14935,13 @@ def fromDoc( ) ) else: - val = _doc.get("linkMerge") + val = _doc.get("tmpdirMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19175,28 +14953,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), [e], - detailed_message=f"the `linkMerge` field with value `{val}` " + detailed_message=f"the `tmpdirMin` field with value `{val}` " "is not valid because:", ) ) - default = None - if "default" in _doc: + tmpdirMax = None + if "tmpdirMax" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, + tmpdirMax = _load_field( + _doc.get("tmpdirMax"), + union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("tmpdirMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `tmpdirMax`": _errors__.append( ValidationException( str(e), @@ -19204,13 +14982,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("tmpdirMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19222,28 +15000,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `tmpdirMax` field with value `{val}` " "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + outdirMin = None + if "outdirMin" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + outdirMin = _load_field( + _doc.get("outdirMin"), + union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("outdirMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `outdirMin`": _errors__.append( ValidationException( str(e), @@ -19251,13 +15029,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("outdirMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19269,154 +15047,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `outdirMin` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `source`, `linkMerge`, `id`, `default`, `valueFrom`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - source=source, - linkMerge=linkMerge, - id=id, - default=default, - valueFrom=valueFrom, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.source is not None: - u = save_relative_uri(self.source, self.id, False, 2, relative_uris) - r["source"] = u - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["source", "linkMerge", "id", "default", "valueFrom"]) - - -class WorkflowStepOutput(Saveable): - """ - Associate an output parameter of the underlying process with a workflow - parameter. The workflow parameter (given in the `id` field) be may be used - as a `source` to connect with input parameters of other workflow steps, or - with an output parameter of the process. - - """ - - id: str - - def __init__( - self, - id: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepOutput): - return bool(self.id == other.id) - return False - - def __hash__(self) -> int: - return hash((self.id)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStepOutput": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + outdirMax = None + if "outdirMax" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + outdirMax = _load_field( + _doc.get("outdirMax"), + union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("outdirMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `outdirMax`": _errors__.append( ValidationException( str(e), @@ -19424,13 +15076,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("outdirMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19442,23 +15094,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `outdirMax` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -19466,14 +15109,16 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`".format(k), + "invalid field `{}`, expected one of: `class`, `coresMin`, `coresMax`, `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, `outdirMax`".format( + k + ), SourceLine(_doc, k, str), ) ) @@ -19481,11 +15126,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, + coresMin=coresMin, + coresMax=coresMax, + ramMin=ramMin, + ramMax=ramMax, + tmpdirMin=tmpdirMin, + tmpdirMax=tmpdirMax, + outdirMin=outdirMin, + outdirMax=outdirMax, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -19499,9 +15150,60 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.coresMin is not None: + r["coresMin"] = save( + self.coresMin, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.coresMax is not None: + r["coresMax"] = save( + self.coresMax, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.ramMin is not None: + r["ramMin"] = save( + self.ramMin, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.ramMax is not None: + r["ramMax"] = save( + self.ramMax, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.tmpdirMin is not None: + r["tmpdirMin"] = save( + self.tmpdirMin, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.tmpdirMax is not None: + r["tmpdirMax"] = save( + self.tmpdirMax, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.outdirMin is not None: + r["outdirMin"] = save( + self.outdirMin, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.outdirMax is not None: + r["outdirMax"] = save( + self.outdirMax, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) # top refers to the directory level if top: @@ -19511,85 +15213,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["id"]) - - -class WorkflowStep(Saveable): - """ - A workflow step is an executable element of a workflow. It specifies the - underlying process implementation (such as `CommandLineTool` or another - `Workflow`) in the `run` field and connects the input and output parameters - of the underlying process to workflow parameters. - - # Scatter/gather - - To use scatter/gather, - [ScatterFeatureRequirement](#ScatterFeatureRequirement) must be specified - in the workflow or workflow step requirements. - - A "scatter" operation specifies that the associated workflow step or - subworkflow should execute separately over a list of input elements. Each - job making up a scatter operation is independent and may be executed - concurrently. - - The `scatter` field specifies one or more input parameters which will be - scattered. An input parameter may be listed more than once. The declared - type of each input parameter is implicitly becomes an array of items of the - input parameter type. If a parameter is listed more than once, it becomes - a nested array. As a result, upstream parameters which are connected to - scattered parameters must be arrays. - - All output parameter types are also implicitly wrapped in arrays. Each job - in the scatter results in an entry in the output array. - - If any scattered parameter runtime value is an empty array, all outputs are - set to empty arrays and no work is done for the step, according to - applicable scattering rules. - - If `scatter` declares more than one input parameter, `scatterMethod` - describes how to decompose the input into a discrete set of jobs. - - * **dotproduct** specifies that each of the input arrays are aligned and one - element taken from each array to construct each job. It is an error - if all input arrays are not the same length. - - * **nested_crossproduct** specifies the Cartesian product of the inputs, - producing a job for every combination of the scattered inputs. The - output must be nested arrays for each level of scattering, in the - order that the input arrays are listed in the `scatter` field. - - * **flat_crossproduct** specifies the Cartesian product of the inputs, - producing a job for every combination of the scattered inputs. The - output arrays must be flattened to a single level, but otherwise listed in the - order that the input arrays are listed in the `scatter` field. - - # Subworkflows - - To specify a nested workflow as part of a workflow step, - [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) must be - specified in the workflow or workflow step requirements. - - It is a fatal error if a workflow directly or indirectly invokes itself as - a subworkflow (recursive workflows are not allowed). - - """ - - id: str - def __init__( self, - id: Any, - in_: Any, - out: Any, - run: Any, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - scatter: Optional[Any] = None, - scatterMethod: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + coresMin: None | i32 | i64 | str = None, + coresMax: None | i32 | str = None, + ramMin: None | i32 | i64 | str = None, + ramMax: None | i32 | i64 | str = None, + tmpdirMin: None | i64 | str = None, + tmpdirMax: None | i32 | i64 | str = None, + outdirMin: None | i32 | i64 | str = None, + outdirMax: None | i32 | i64 | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -19599,46 +15234,60 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.in_ = in_ - self.out = out - self.requirements = requirements - self.hints = hints - self.label = label - self.doc = doc - self.run = run - self.scatter = scatter - self.scatterMethod = scatterMethod + self.class_: Final[str] = "ResourceRequirement" + self.coresMin = coresMin + self.coresMax = coresMax + self.ramMin = ramMin + self.ramMax = ramMax + self.tmpdirMin = tmpdirMin + self.tmpdirMax = tmpdirMax + self.outdirMin = outdirMin + self.outdirMax = outdirMax + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "coresMin", + "coresMax", + "ramMin", + "ramMax", + "tmpdirMin", + "tmpdirMax", + "outdirMin", + "outdirMax", + ] + ) + + +@mypyc_attr(native_class=True) +class ExpressionToolOutputParameter(OutputParameter): + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStep): + if isinstance(other, ExpressionToolOutputParameter): return bool( - self.id == other.id - and self.in_ == other.in_ - and self.out == other.out - and self.requirements == other.requirements - and self.hints == other.hints - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.run == other.run - and self.scatter == other.scatter - and self.scatterMethod == other.scatterMethod + and self.id == other.id + and self.outputBinding == other.outputBinding + and self.format == other.format + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( ( - self.id, - self.in_, - self.out, - self.requirements, - self.hints, self.label, + self.secondaryFiles, + self.streamable, self.doc, - self.run, - self.scatter, - self.scatterMethod, + self.id, + self.outputBinding, + self.format, + self.type_, ) ) @@ -19648,8 +15297,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStep": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -19659,7 +15308,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_strtype_True_False_None_None, baseuri, @@ -19704,125 +15353,29 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: + id = "" _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("in") is None: - raise ValidationException("missing required field `in`", None, []) - - in_ = load_field( - _doc.get("in"), - idmap_in__array_of_WorkflowStepInputLoader, - baseuri, - loadingOptions, - lc=_doc.get("in") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `in`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("in") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), - [e], - detailed_message=f"the `in` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("out") is None: - raise ValidationException("missing required field `out`", None, []) - - out = load_field( - _doc.get("out"), - uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("out") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `out`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("out") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), - [e], - detailed_message=f"the `out` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + else: + baseuri = id + label = None + if "label" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -19830,13 +15383,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19848,28 +15401,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_Any_type, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -19877,13 +15430,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19895,28 +15448,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + streamable = None + if "streamable" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -19924,13 +15477,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19942,19 +15495,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), - union_of_None_type_or_strtype, + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, lc=_doc.get("doc") @@ -19996,69 +15549,68 @@ def fromDoc( "is not valid because:", ) ) - try: - if _doc.get("run") is None: - raise ValidationException("missing required field `run`", None, []) - - run = load_field( - _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("run") - ) + outputBinding = None + if "outputBinding" in _doc: + try: + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputBinding") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `run`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("run") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [e], - detailed_message=f"the `run` field with value `{val}` " - "is not valid because:", + val = _doc.get("outputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - scatter = None - if "scatter" in _doc: + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + detailed_message=f"the `outputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: try: - scatter = load_field( - _doc.get("scatter"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("scatter") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `scatter`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -20066,13 +15618,13 @@ def fromDoc( ) ) else: - val = _doc.get("scatter") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `scatter` field is not valid because:", - SourceLine(_doc, "scatter", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20084,28 +15636,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `scatter` field is not valid because:", - SourceLine(_doc, "scatter", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `scatter` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - scatterMethod = None - if "scatterMethod" in _doc: + type_ = None + if "type" in _doc: try: - scatterMethod = load_field( - _doc.get("scatterMethod"), - uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("scatterMethod") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `scatterMethod`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -20113,13 +15665,13 @@ def fromDoc( ) ) else: - val = _doc.get("scatterMethod") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `scatterMethod` field is not valid because:", - SourceLine(_doc, "scatterMethod", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20131,14 +15683,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `scatterMethod` field is not valid because:", - SourceLine(_doc, "scatterMethod", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `scatterMethod` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -20146,14 +15698,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `in`, `out`, `requirements`, `hints`, `label`, `doc`, `run`, `scatter`, `scatterMethod`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`, `type`".format( k ), SourceLine(_doc, k, str), @@ -20164,19 +15716,17 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, - in_=in_, - out=out, - requirements=requirements, - hints=hints, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, doc=doc, - run=run, - scatter=scatter, - scatterMethod=scatterMethod, + outputBinding=outputBinding, + format=format, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -20191,135 +15741,65 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u - if self.in_ is not None: - r["in"] = save( - self.in_, top=False, base_url=self.id, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.out is not None: - u = save_relative_uri(self.out, self.id, True, None, relative_uris) - r["out"] = u - if self.requirements is not None: - r["requirements"] = save( - self.requirements, + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u - if self.scatter is not None: - u = save_relative_uri(self.scatter, self.id, False, 0, relative_uris) - r["scatter"] = u - if self.scatterMethod is not None: - u = save_relative_uri( - self.scatterMethod, self.id, False, None, relative_uris - ) - r["scatterMethod"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "in", - "out", - "requirements", - "hints", - "label", - "doc", - "run", - "scatter", - "scatterMethod", - ] - ) - - -class Workflow(Process): - """ - A workflow describes a set of **steps** and the **dependencies** between - those steps. When a step produces output that will be consumed by a - second step, the first step is a dependency of the second step. - - When there is a dependency, the workflow engine must execute the preceding - step and wait for it to successfully produce output before executing the - dependent step. If two steps are defined in the workflow graph that - are not directly or indirectly dependent, these steps are **independent**, - and may execute in any order or execute concurrently. A workflow is - complete when all steps have been executed. - - Dependencies between parameters are expressed using the `source` field on - [workflow step input parameters](#WorkflowStepInput) and [workflow output - parameters](#WorkflowOutputParameter). - - The `source` field expresses the dependency of one parameter on another - such that when a value is associated with the parameter specified by - `source`, that value is propagated to the destination parameter. When all - data links inbound to a given step are fufilled, the step is ready to - execute. - - ## Workflow success and failure - - A completed step must result in one of `success`, `temporaryFailure` or - `permanentFailure` states. An implementation may choose to retry a step - execution which resulted in `temporaryFailure`. An implementation may - choose to either continue running other steps of a workflow, or terminate - immediately upon `permanentFailure`. - - * If any step of a workflow execution results in `permanentFailure`, then - the workflow status is `permanentFailure`. - - * If one or more steps result in `temporaryFailure` and all other steps - complete `success` or are not executed, then the workflow status is - `temporaryFailure`. - - * If all workflow steps are executed and complete with `success`, then the - workflow status is `success`. - - # Extensions - - [ScatterFeatureRequirement](#ScatterFeatureRequirement) and - [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) are - available as standard [extensions](#Extensions_and_Metadata) to core - workflow semantics. - - """ + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) - id: str + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r def __init__( self, - inputs: Any, - outputs: Any, - steps: Any, - id: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + label: None | str = None, + secondaryFiles: None | Sequence[str] | str = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + outputBinding: CommandOutputBinding | None = None, + format: None | str = None, + type_: CWLType | None | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -20329,19 +15809,40 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable self.doc = doc - self.cwlVersion = cwlVersion - self.class_ = "Workflow" - self.steps = steps + self.id = id + self.outputBinding = outputBinding + self.format = format + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "outputBinding", + "format", + "type", + ] + ) + + +@mypyc_attr(native_class=True) +class ExpressionTool(Saveable): + """ + Execute an expression as a Workflow step. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, Workflow): + if isinstance(other, ExpressionTool): return bool( self.id == other.id and self.inputs == other.inputs @@ -20352,7 +15853,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.cwlVersion == other.cwlVersion and self.class_ == other.class_ - and self.steps == other.steps + and self.expression == other.expression ) return False @@ -20368,7 +15869,7 @@ def __hash__(self) -> int: self.doc, self.cwlVersion, self.class_, - self.steps, + self.expression, ) ) @@ -20378,8 +15879,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Workflow": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -20389,7 +15890,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -20434,35 +15935,35 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id try: if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_Workflow_classLoader_False_True_None_None, + uri_ExpressionTool_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + raise e try: if _doc.get("inputs") is None: raise ValidationException("missing required field `inputs`", None, []) - inputs = load_field( + inputs = _load_field( _doc.get("inputs"), idmap_inputs_array_of_InputParameterLoader, baseuri, @@ -20510,9 +16011,9 @@ def fromDoc( if _doc.get("outputs") is None: raise ValidationException("missing required field `outputs`", None, []) - outputs = load_field( + outputs = _load_field( _doc.get("outputs"), - idmap_outputs_array_of_WorkflowOutputParameterLoader, + idmap_outputs_array_of_ExpressionToolOutputParameterLoader, baseuri, loadingOptions, lc=_doc.get("outputs") @@ -20557,9 +16058,9 @@ def fromDoc( requirements = None if "requirements" in _doc: try: - requirements = load_field( + requirements = _load_field( _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, lc=_doc.get("requirements") @@ -20604,9 +16105,9 @@ def fromDoc( hints = None if "hints" in _doc: try: - hints = load_field( + hints = _load_field( _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, lc=_doc.get("hints") @@ -20651,7 +16152,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -20698,7 +16199,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype, baseuri, @@ -20745,7 +16246,7 @@ def fromDoc( cwlVersion = None if "cwlVersion" in _doc: try: - cwlVersion = load_field( + cwlVersion = _load_field( _doc.get("cwlVersion"), uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, @@ -20790,21 +16291,21 @@ def fromDoc( ) ) try: - if _doc.get("steps") is None: - raise ValidationException("missing required field `steps`", None, []) + if _doc.get("expression") is None: + raise ValidationException("missing required field `expression`", None, []) - steps = load_field( - _doc.get("steps"), - idmap_steps_union_of_array_of_WorkflowStepLoader, + expression = _load_field( + _doc.get("expression"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("steps") + lc=_doc.get("expression") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `steps`": + if str(e) == "missing required field `expression`": _errors__.append( ValidationException( str(e), @@ -20812,13 +16313,13 @@ def fromDoc( ) ) else: - val = _doc.get("steps") + val = _doc.get("expression") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `steps` field is not valid because:", - SourceLine(_doc, "steps", str), + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20830,14 +16331,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `steps` field is not valid because:", - SourceLine(_doc, "steps", str), + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), [e], - detailed_message=f"the `steps` field with value `{val}` " + detailed_message=f"the `expression` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -20845,14 +16346,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `steps`".format( + "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `expression`".format( k ), SourceLine(_doc, k, str), @@ -20870,11 +16371,11 @@ def fromDoc( label=label, doc=doc, cwlVersion=cwlVersion, - steps=steps, + expression=expression, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -20889,11 +16390,13 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ @@ -20929,9 +16432,12 @@ def save( if self.cwlVersion is not None: u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) r["cwlVersion"] = u - if self.steps is not None: - r["steps"] = save( - self.steps, top=False, base_url=self.id, relative_uris=relative_uris + if self.expression is not None: + r["expression"] = save( + self.expression, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) # top refers to the directory level @@ -20942,7 +16448,40 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( + def __init__( + self, + inputs: Sequence[InputParameter], + outputs: Sequence[ExpressionToolOutputParameter], + expression: str, + id: None | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + label: None | str = None, + doc: None | str = None, + cwlVersion: CWLVersion | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.label = label + self.doc = doc + self.cwlVersion = cwlVersion + self.class_: Final[str] = "ExpressionTool" + self.expression = expression + + attrs: ClassVar[Collection[str]] = frozenset( [ "id", "inputs", @@ -20953,40 +16492,51 @@ def save( "doc", "cwlVersion", "class", - "steps", + "expression", ] ) -class SubworkflowFeatureRequirement(ProcessRequirement): +@mypyc_attr(native_class=True) +class WorkflowOutputParameter(OutputParameter): """ - Indicates that the workflow platform must support nested workflows in - the `run` field of [WorkflowStep](#WorkflowStep). + Describe an output parameter of a workflow. The parameter must be connected to one or more parameters defined in the workflow that will provide the value of the output parameter. """ - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SubworkflowFeatureRequirement" + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, SubworkflowFeatureRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, WorkflowOutputParameter): + return bool( + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id + and self.outputBinding == other.outputBinding + and self.format == other.format + and self.outputSource == other.outputSource + and self.linkMerge == other.linkMerge + and self.type_ == other.type_ + ) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.outputBinding, + self.format, + self.outputSource, + self.linkMerge, + self.type_, + ) + ) @classmethod def fromDoc( @@ -20994,269 +16544,494 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SubworkflowFeatureRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) - class_ = load_field( - _doc.get("class"), - uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + if str(e) == "missing required field `secondaryFiles`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("streamable") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("streamable") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class ScatterFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support the `scatter` and - `scatterMethod` fields of [WorkflowStep](#WorkflowStep). - - """ - - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "ScatterFeatureRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ScatterFeatureRequirement): - return bool(self.class_ == other.class_) - return False - - def __hash__(self) -> int: - return hash((self.class_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ScatterFeatureRequirement": - _doc = copy.copy(doc) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + outputBinding = None + if "outputBinding" in _doc: + try: + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputBinding") + ) - class_ = load_field( - _doc.get("class"), - uri_ScatterFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + if str(e) == "missing required field `outputBinding`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("outputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + detailed_message=f"the `outputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + outputSource = None + if "outputSource" in _doc: + try: + outputSource = _load_field( + _doc.get("outputSource"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, + baseuri, + loadingOptions, + lc=_doc.get("outputSource") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class MultipleInputFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support multiple inbound data links - listed in the `source` field of [WorkflowStepInput](#WorkflowStepInput). - - """ - - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "MultipleInputFeatureRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, MultipleInputFeatureRequirement): - return bool(self.class_ == other.class_) - return False + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - def __hash__(self) -> int: - return hash((self.class_)) + if str(e) == "missing required field `outputSource`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputSource") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [e], + detailed_message=f"the `outputSource` field with value `{val}` " + "is not valid because:", + ) + ) + linkMerge = None + if "linkMerge" in _doc: + try: + linkMerge = _load_field( + _doc.get("linkMerge"), + union_of_None_type_or_LinkMergeMethodLoader, + baseuri, + loadingOptions, + lc=_doc.get("linkMerge") + ) - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MultipleInputFeatureRequirement": - _doc = copy.copy(doc) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("linkMerge") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + detailed_message=f"the `linkMerge` field with value `{val}` " + "is not valid because:", + ) + ) + type_ = None + if "type" in _doc: + try: + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - class_ = load_field( - _doc.get("class"), - uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -21264,14 +17039,16 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `outputBinding`, `format`, `outputSource`, `linkMerge`, `type`".format( + k + ), SourceLine(_doc, k, str), ) ) @@ -21279,9 +17056,20 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + outputBinding=outputBinding, + format=format, + outputSource=outputSource, + linkMerge=linkMerge, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -21295,14 +17083,52 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.outputSource is not None: + u = save_relative_uri(self.outputSource, self.id, False, 1, relative_uris) + r["outputSource"] = u + if self.linkMerge is not None: + r["linkMerge"] = save( + self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -21312,20 +17138,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class"]) - - -class StepInputExpressionRequirement(ProcessRequirement): - """ - Indicate that the workflow platform must support the `valueFrom` field - of [WorkflowStepInput](#WorkflowStepInput). - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + label: None | str = None, + secondaryFiles: None | Sequence[str] | str = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + outputBinding: CommandOutputBinding | None = None, + format: None | str = None, + outputSource: None | Sequence[str] | str = None, + linkMerge: LinkMergeMethod | None = None, + type_: CWLType | None | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -21335,15 +17161,78 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "StepInputExpressionRequirement" + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.outputBinding = outputBinding + self.format = format + self.outputSource = outputSource + self.linkMerge = linkMerge + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "outputBinding", + "format", + "outputSource", + "linkMerge", + "type", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkflowStepInput(Saveable): + """ + The input of a workflow step connects an upstream parameter (from the workflow inputs, or the outputs of other workflows steps) with the input parameters of the underlying step. + + Input object + ------------ + + A WorkflowStepInput object must contain an ``id`` field in the form ``#fieldname`` or ``#prefix/fieldname``. When the ``id`` field contains a slash ``/`` the field name consists of the characters following the final slash (the prefix portion may contain one or more slashes to indicate scope). This defines a field of the workflow step input object with the value of the ``source`` parameter(s). + + Merging + ------- + + To merge multiple inbound data links, `MultipleInputFeatureRequirement <#MultipleInputFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + If the sink parameter is an array, or named in a `workflow scatter <#WorkflowStep>`__ operation, there may be multiple inbound data links listed in the ``source`` field. The values from the input links are merged depending on the method specified in the ``linkMerge`` field. If not specified, the default method is "merge_nested". + + * **merge_nested** + + The input must be an array consisting of exactly one entry for each input link. If "merge_nested" is specified with a single link, the value from the link must be wrapped in a single-item list. + + * **merge_flattened** + + 1. The source and sink parameters must be compatible types, or the source type must be compatible with single element from the "items" type of the destination array parameter. + 2. Source parameters which are arrays are concatenated. Source parameters which are single element types are appended as single elements. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, StepInputExpressionRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, WorkflowStepInput): + return bool( + self.source == other.source + and self.linkMerge == other.linkMerge + and self.id == other.id + and self.default == other.default + and self.valueFrom == other.valueFrom + ) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash( + (self.source, self.linkMerge, self.id, self.default, self.valueFrom) + ) @classmethod def fromDoc( @@ -21351,196 +17240,259 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "StepInputExpressionRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) - class_ = load_field( - _doc.get("class"), - uri_StepInputExpressionRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + if str(e) == "missing required field `id`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class LoadListingRequirement(ProcessRequirement): - def __init__( - self, - loadListing: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) else: - self.loadingOptions = LoadingOptions() - self.class_ = "LoadListingRequirement" - self.loadListing = loadListing - - def __eq__(self, other: Any) -> bool: - if isinstance(other, LoadListingRequirement): - return bool( - self.class_ == other.class_ and self.loadListing == other.loadListing - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.loadListing)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "LoadListingRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + baseuri = id + source = None + if "source" in _doc: + try: + source = _load_field( + _doc.get("source"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + baseuri, + loadingOptions, + lc=_doc.get("source") + ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("loadListing") is None: - raise ValidationException("missing required field `loadListing`", None, []) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - loadListing = load_field( - _doc.get("loadListing"), - union_of_LoadListingEnumLoader, - baseuri, - loadingOptions, - lc=_doc.get("loadListing") - ) + if str(e) == "missing required field `source`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("source") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [e], + detailed_message=f"the `source` field with value `{val}` " + "is not valid because:", + ) + ) + linkMerge = None + if "linkMerge" in _doc: + try: + linkMerge = _load_field( + _doc.get("linkMerge"), + union_of_None_type_or_LinkMergeMethodLoader, + baseuri, + loadingOptions, + lc=_doc.get("linkMerge") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("linkMerge") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + detailed_message=f"the `linkMerge` field with value `{val}` " + "is not valid because:", + ) + ) + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") ) - else: - val = _doc.get("loadListing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("default") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + detailed_message=f"the `default` field with value `{val}` " + "is not valid because:", + ) + ) + valueFrom = None + if "valueFrom" in _doc: + try: + valueFrom = _load_field( + _doc.get("valueFrom"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("valueFrom") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], - detailed_message=f"the `loadListing` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - extension_fields: dict[str, Any] = {} + else: + val = _doc.get("valueFrom") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + detailed_message=f"the `valueFrom` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -21548,14 +17500,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `loadListing`".format( + "invalid field `{}`, expected one of: `source`, `linkMerge`, `id`, `default`, `valueFrom`".format( k ), SourceLine(_doc, k, str), @@ -21565,10 +17517,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - loadListing=loadListing, + id=id, + source=source, + linkMerge=linkMerge, + default=default, + valueFrom=valueFrom, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -21579,23 +17536,26 @@ def save( if relative_uris: for ef in self.extension_fields: r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=base_url, - relative_uris=relative_uris, + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.source is not None: + u = save_relative_uri(self.source, self.id, False, 2, relative_uris) + r["source"] = u + if self.linkMerge is not None: + r["linkMerge"] = save( + self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.valueFrom is not None: + r["valueFrom"] = save( + self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -21606,15 +17566,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "loadListing"]) - - -class InplaceUpdateRequirement(ProcessRequirement): def __init__( self, - inplaceUpdate: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + source: None | Sequence[str] | str = None, + linkMerge: LinkMergeMethod | None = None, + default: CWLObjectType | None = None, + valueFrom: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -21624,19 +17584,33 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "InplaceUpdateRequirement" - self.inplaceUpdate = inplaceUpdate + self.source = source + self.linkMerge = linkMerge + self.id = id + self.default = default + self.valueFrom = valueFrom + + attrs: ClassVar[Collection[str]] = frozenset( + ["source", "linkMerge", "id", "default", "valueFrom"] + ) + + +@mypyc_attr(native_class=True) +class WorkflowStepOutput(Saveable): + """ + Associate an output parameter of the underlying process with a workflow parameter. The workflow parameter (given in the ``id`` field) be may be used as a ``source`` to connect with input parameters of other workflow steps, or with an output parameter of the process. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InplaceUpdateRequirement): - return bool( - self.class_ == other.class_ - and self.inplaceUpdate == other.inplaceUpdate - ) + if isinstance(other, WorkflowStepOutput): + return bool(self.id == other.id) return False def __hash__(self) -> int: - return hash((self.class_, self.inplaceUpdate)) + return hash((self.id)) @classmethod def fromDoc( @@ -21644,79 +17618,71 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InplaceUpdateRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("inplaceUpdate") is None: - raise ValidationException("missing required field `inplaceUpdate`", None, []) - - inplaceUpdate = load_field( - _doc.get("inplaceUpdate"), - booltype, - baseuri, - loadingOptions, - lc=_doc.get("inplaceUpdate") - ) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inplaceUpdate`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inplaceUpdate") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `id`": _errors__.append( ValidationException( - "the `inplaceUpdate` field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `inplaceUpdate` field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), - [e], - detailed_message=f"the `inplaceUpdate` field with value `{val}` " - "is not valid because:", + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -21724,16 +17690,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `inplaceUpdate`".format( - k - ), + "invalid field `{}`, expected one of: `id`".format(k), SourceLine(_doc, k, str), ) ) @@ -21741,10 +17705,11 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - inplaceUpdate=inplaceUpdate, + id=id, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -21758,21 +17723,9 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.inplaceUpdate is not None: - r["inplaceUpdate"] = save( - self.inplaceUpdate, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u # top refers to the directory level if top: @@ -21782,81 +17735,228 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "inplaceUpdate"]) + def __init__( + self, + id: str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id + + attrs: ClassVar[Collection[str]] = frozenset(["id"]) + + +@mypyc_attr(native_class=True) +class WorkflowStep(Saveable): + """ + A workflow step is an executable element of a workflow. It specifies the underlying process implementation (such as ``CommandLineTool`` or another ``Workflow``) in the ``run`` field and connects the input and output parameters of the underlying process to workflow parameters. + + Scatter/gather + ============== + + To use scatter/gather, `ScatterFeatureRequirement <#ScatterFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + A "scatter" operation specifies that the associated workflow step or subworkflow should execute separately over a list of input elements. Each job making up a scatter operation is independent and may be executed concurrently. + + The ``scatter`` field specifies one or more input parameters which will be scattered. An input parameter may be listed more than once. The declared type of each input parameter is implicitly becomes an array of items of the input parameter type. If a parameter is listed more than once, it becomes a nested array. As a result, upstream parameters which are connected to scattered parameters must be arrays. + + All output parameter types are also implicitly wrapped in arrays. Each job in the scatter results in an entry in the output array. + + If any scattered parameter runtime value is an empty array, all outputs are set to empty arrays and no work is done for the step, according to applicable scattering rules. + + If ``scatter`` declares more than one input parameter, ``scatterMethod`` describes how to decompose the input into a discrete set of jobs. + + * **dotproduct** specifies that each of the input arrays are aligned and one element taken from each array to construct each job. It is an error if all input arrays are not the same length. + + * **nested_crossproduct** specifies the Cartesian product of the inputs, producing a job for every combination of the scattered inputs. The output must be nested arrays for each level of scattering, in the order that the input arrays are listed in the ``scatter`` field. + + * **flat_crossproduct** specifies the Cartesian product of the inputs, producing a job for every combination of the scattered inputs. The output arrays must be flattened to a single level, but otherwise listed in the order that the input arrays are listed in the ``scatter`` field. + + Subworkflows + ============ + + To specify a nested workflow as part of a workflow step, `SubworkflowFeatureRequirement <#SubworkflowFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + It is a fatal error if a workflow directly or indirectly invokes itself as a subworkflow (recursive workflows are not allowed). + + """ + + id: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, WorkflowStep): + return bool( + self.id == other.id + and self.in_ == other.in_ + and self.out == other.out + and self.requirements == other.requirements + and self.hints == other.hints + and self.label == other.label + and self.doc == other.doc + and self.run == other.run + and self.scatter == other.scatter + and self.scatterMethod == other.scatterMethod + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.id, + self.in_, + self.out, + self.requirements, + self.hints, + self.label, + self.doc, + self.run, + self.scatter, + self.scatterMethod, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) -class Secrets(ProcessRequirement): - def __init__( - self, - secrets: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) else: - self.loadingOptions = LoadingOptions() - self.class_ = "Secrets" - self.secrets = secrets - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Secrets): - return bool(self.class_ == other.class_ and self.secrets == other.secrets) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.secrets)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Secrets": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] + baseuri = id try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if _doc.get("in") is None: + raise ValidationException("missing required field `in`", None, []) - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, + in_ = _load_field( + _doc.get("in"), + idmap_in__array_of_WorkflowStepInputLoader, baseuri, loadingOptions, - lc=_doc.get("class") + lc=_doc.get("in") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("in") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + detailed_message=f"the `in` field with value `{val}` " + "is not valid because:", + ) + ) try: - if _doc.get("secrets") is None: - raise ValidationException("missing required field `secrets`", None, []) + if _doc.get("out") is None: + raise ValidationException("missing required field `out`", None, []) - secrets = load_field( - _doc.get("secrets"), - uri_array_of_strtype_False_False_0_None, + out = _load_field( + _doc.get("out"), + uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("secrets") + lc=_doc.get("out") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secrets`": + if str(e) == "missing required field `out`": _errors__.append( ValidationException( str(e), @@ -21864,13 +17964,13 @@ def fromDoc( ) ) else: - val = _doc.get("secrets") + val = _doc.get("out") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secrets` field is not valid because:", - SourceLine(_doc, "secrets", str), + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -21882,160 +17982,217 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secrets` field is not valid because:", - SourceLine(_doc, "secrets", str), + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), [e], - detailed_message=f"the `secrets` field with value `{val}` " + detailed_message=f"the `out` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + requirements = None + if "requirements" in _doc: + try: + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, + baseuri, + loadingOptions, + lc=_doc.get("requirements") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("requirements") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + detailed_message=f"the `requirements` field with value `{val}` " + "is not valid because:", + ) + ) + hints = None + if "hints" in _doc: + try: + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("hints") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `secrets`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("hints") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + detailed_message=f"the `hints` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - secrets=secrets, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.secrets is not None: - u = save_relative_uri(self.secrets, base_url, False, 0, relative_uris) - r["secrets"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "secrets"]) - - -class TimeLimit(ProcessRequirement): - """ - Set an upper limit on the execution time of a CommandLineTool or - ExpressionTool. A tool execution which exceeds the time limit may - be preemptively terminated and considered failed. May also be - used by batch systems to make scheduling decisions. - - """ - - def __init__( - self, - timelimit: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "TimeLimit" - self.timelimit = timelimit - - def __eq__(self, other: Any) -> bool: - if isinstance(other, TimeLimit): - return bool( - self.class_ == other.class_ and self.timelimit == other.timelimit - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.timelimit)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "TimeLimit": - _doc = copy.copy(doc) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) try: - if _doc.get("timelimit") is None: - raise ValidationException("missing required field `timelimit`", None, []) + if _doc.get("run") is None: + raise ValidationException("missing required field `run`", None, []) - timelimit = load_field( - _doc.get("timelimit"), - union_of_inttype_or_strtype, + run = _load_field( + _doc.get("run"), + uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None, baseuri, loadingOptions, - lc=_doc.get("timelimit") + lc=_doc.get("run") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `timelimit`": + if str(e) == "missing required field `run`": _errors__.append( ValidationException( str(e), @@ -22043,13 +18200,13 @@ def fromDoc( ) ) else: - val = _doc.get("timelimit") + val = _doc.get("run") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `timelimit` field is not valid because:", - SourceLine(_doc, "timelimit", str), + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22061,202 +18218,108 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `timelimit` field is not valid because:", - SourceLine(_doc, "timelimit", str), + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), [e], - detailed_message=f"the `timelimit` field with value `{val}` " + detailed_message=f"the `run` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + scatter = None + if "scatter" in _doc: + try: + scatter = _load_field( + _doc.get("scatter"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, + baseuri, + loadingOptions, + lc=_doc.get("scatter") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatter`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `timelimit`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("scatter") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [e], + detailed_message=f"the `scatter` field with value `{val}` " + "is not valid because:", + ) + ) + scatterMethod = None + if "scatterMethod" in _doc: + try: + scatterMethod = _load_field( + _doc.get("scatterMethod"), + uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("scatterMethod") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - timelimit=timelimit, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.timelimit is not None: - r["timelimit"] = save( - self.timelimit, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "timelimit"]) - - -class WorkReuse(ProcessRequirement): - """ - For implementations that support reusing output from past work (on - the assumption that same code and same input produce same - results), control whether to enable or disable the reuse behavior - for a particular tool or step (to accommodate situations where that - assumption is incorrect). A reused step is not executed but - instead returns the same output as the original execution. - - If `enableReuse` is not specified, correct tools should assume it - is enabled by default. - - """ - - def __init__( - self, - enableReuse: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "WorkReuse" - self.enableReuse = enableReuse - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkReuse): - return bool( - self.class_ == other.class_ and self.enableReuse == other.enableReuse - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.enableReuse)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkReuse": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("enableReuse") is None: - raise ValidationException("missing required field `enableReuse`", None, []) - - enableReuse = load_field( - _doc.get("enableReuse"), - union_of_booltype_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("enableReuse") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `enableReuse`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("enableReuse") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `scatterMethod`": _errors__.append( ValidationException( - "the `enableReuse` field is not valid because:", - SourceLine(_doc, "enableReuse", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `enableReuse` field is not valid because:", - SourceLine(_doc, "enableReuse", str), - [e], - detailed_message=f"the `enableReuse` field with value `{val}` " - "is not valid because:", + val = _doc.get("scatterMethod") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} + else: + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [e], + detailed_message=f"the `scatterMethod` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -22264,14 +18327,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `enableReuse`".format( + "invalid field `{}`, expected one of: `id`, `in`, `out`, `requirements`, `hints`, `label`, `doc`, `run`, `scatter`, `scatterMethod`".format( k ), SourceLine(_doc, k, str), @@ -22281,10 +18344,20 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - enableReuse=enableReuse, + id=id, + in_=in_, + out=out, + requirements=requirements, + hints=hints, + label=label, + doc=doc, + run=run, + scatter=scatter, + scatterMethod=scatterMethod, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -22298,21 +18371,46 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.enableReuse is not None: - r["enableReuse"] = save( - self.enableReuse, + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.in_ is not None: + r["in"] = save( + self.in_, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.out is not None: + u = save_relative_uri(self.out, self.id, True, None, relative_uris) + r["out"] = u + if self.requirements is not None: + r["requirements"] = save( + self.requirements, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.run is not None: + u = save_relative_uri(self.run, self.id, False, None, relative_uris) + r["run"] = u + if self.scatter is not None: + u = save_relative_uri(self.scatter, self.id, False, 0, relative_uris) + r["scatter"] = u + if self.scatterMethod is not None: + u = save_relative_uri( + self.scatterMethod, self.id, False, None, relative_uris + ) + r["scatterMethod"] = u # top refers to the directory level if top: @@ -22322,34 +18420,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "enableReuse"]) - - -class NetworkAccess(ProcessRequirement): - """ - Indicate whether a process requires outgoing IPv4/IPv6 network - access. Choice of IPv4 or IPv6 is implementation and site - specific, correct tools must support both. - - If `networkAccess` is false or not specified, tools must not - assume network access, except for localhost (the loopback device). - - If `networkAccess` is true, the tool must be able to make outgoing - connections to network resources. Resources may be on a private - subnet or the public Internet. However, implementations and sites - may apply their own security policies to restrict what is - accessible by the tool. - - Enabling network access does not imply a publicly routable IP - address or the ability to accept inbound connections. - - """ - def __init__( self, - networkAccess: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + in_: Sequence[WorkflowStepInput], + out: Sequence[WorkflowStepOutput | str], + run: CommandLineTool | ExpressionTool | Workflow | str, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + hints: None | Sequence[Any] = None, + label: None | str = None, + doc: None | str = None, + scatter: None | Sequence[str] | str = None, + scatterMethod: None | ScatterMethod = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -22359,205 +18443,66 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "NetworkAccess" - self.networkAccess = networkAccess - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NetworkAccess): - return bool( - self.class_ == other.class_ - and self.networkAccess == other.networkAccess - ) - return False + self.id = id + self.in_ = in_ + self.out = out + self.requirements = requirements + self.hints = hints + self.label = label + self.doc = doc + self.run = run + self.scatter = scatter + self.scatterMethod = scatterMethod - def __hash__(self) -> int: - return hash((self.class_, self.networkAccess)) + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "in", + "out", + "requirements", + "hints", + "label", + "doc", + "run", + "scatter", + "scatterMethod", + ] + ) - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NetworkAccess": - _doc = copy.copy(doc) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) +@mypyc_attr(native_class=True) +class Workflow(Saveable): + """ + A workflow describes a set of **steps** and the **dependencies** between those steps. When a step produces output that will be consumed by a second step, the first step is a dependency of the second step. - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + When there is a dependency, the workflow engine must execute the preceding step and wait for it to successfully produce output before executing the dependent step. If two steps are defined in the workflow graph that are not directly or indirectly dependent, these steps are **independent**, and may execute in any order or execute concurrently. A workflow is complete when all steps have been executed. - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("networkAccess") is None: - raise ValidationException("missing required field `networkAccess`", None, []) + Dependencies between parameters are expressed using the ``source`` field on `workflow step input parameters <#WorkflowStepInput>`__ and `workflow output parameters <#WorkflowOutputParameter>`__. - networkAccess = load_field( - _doc.get("networkAccess"), - union_of_booltype_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("networkAccess") - ) + The ``source`` field expresses the dependency of one parameter on another such that when a value is associated with the parameter specified by ``source``, that value is propagated to the destination parameter. When all data links inbound to a given step are fulfilled, the step is ready to execute. - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + Workflow success and failure + ---------------------------- - if str(e) == "missing required field `networkAccess`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("networkAccess") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `networkAccess` field is not valid because:", - SourceLine(_doc, "networkAccess", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `networkAccess` field is not valid because:", - SourceLine(_doc, "networkAccess", str), - [e], - detailed_message=f"the `networkAccess` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `networkAccess`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) + A completed step must result in one of ``success``, ``temporaryFailure`` or ``permanentFailure`` states. An implementation may choose to retry a step execution which resulted in ``temporaryFailure``. An implementation may choose to either continue running other steps of a workflow, or terminate immediately upon ``permanentFailure``. - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - networkAccess=networkAccess, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed + * If any step of a workflow execution results in ``permanentFailure``, then the workflow status is ``permanentFailure``. - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + * If one or more steps result in ``temporaryFailure`` and all other steps complete ``success`` or are not executed, then the workflow status is ``temporaryFailure``. - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.networkAccess is not None: - r["networkAccess"] = save( - self.networkAccess, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) + * If all workflow steps are executed and complete with ``success``, then the workflow status is ``success``. - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r + Extensions + ========== - attrs = frozenset(["class", "networkAccess"]) + `ScatterFeatureRequirement <#ScatterFeatureRequirement>`__ and `SubworkflowFeatureRequirement <#SubworkflowFeatureRequirement>`__ are available as standard `extensions <#Extensions_and_Metadata>`__ to core workflow semantics. + """ -class ProcessGenerator(Process): id: str - def __init__( - self, - inputs: Any, - outputs: Any, - run: Any, - id: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.label = label - self.doc = doc - self.cwlVersion = cwlVersion - self.class_ = "ProcessGenerator" - self.run = run - def __eq__(self, other: Any) -> bool: - if isinstance(other, ProcessGenerator): + if isinstance(other, Workflow): return bool( self.id == other.id and self.inputs == other.inputs @@ -22568,7 +18513,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.cwlVersion == other.cwlVersion and self.class_ == other.class_ - and self.run == other.run + and self.steps == other.steps ) return False @@ -22584,7 +18529,7 @@ def __hash__(self) -> int: self.doc, self.cwlVersion, self.class_, - self.run, + self.steps, ) ) @@ -22594,8 +18539,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ProcessGenerator": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -22605,7 +18550,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -22650,35 +18595,35 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id try: if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_Workflow_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + raise e try: if _doc.get("inputs") is None: raise ValidationException("missing required field `inputs`", None, []) - inputs = load_field( + inputs = _load_field( _doc.get("inputs"), idmap_inputs_array_of_InputParameterLoader, baseuri, @@ -22726,9 +18671,9 @@ def fromDoc( if _doc.get("outputs") is None: raise ValidationException("missing required field `outputs`", None, []) - outputs = load_field( + outputs = _load_field( _doc.get("outputs"), - idmap_outputs_array_of_OutputParameterLoader, + idmap_outputs_array_of_WorkflowOutputParameterLoader, baseuri, loadingOptions, lc=_doc.get("outputs") @@ -22773,9 +18718,9 @@ def fromDoc( requirements = None if "requirements" in _doc: try: - requirements = load_field( + requirements = _load_field( _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, lc=_doc.get("requirements") @@ -22820,9 +18765,9 @@ def fromDoc( hints = None if "hints" in _doc: try: - hints = load_field( + hints = _load_field( _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, lc=_doc.get("hints") @@ -22867,7 +18812,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -22914,7 +18859,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype, baseuri, @@ -22961,7 +18906,7 @@ def fromDoc( cwlVersion = None if "cwlVersion" in _doc: try: - cwlVersion = load_field( + cwlVersion = _load_field( _doc.get("cwlVersion"), uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, @@ -23006,21 +18951,21 @@ def fromDoc( ) ) try: - if _doc.get("run") is None: - raise ValidationException("missing required field `run`", None, []) + if _doc.get("steps") is None: + raise ValidationException("missing required field `steps`", None, []) - run = load_field( - _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_False_False_None_None, + steps = _load_field( + _doc.get("steps"), + idmap_steps_union_of_array_of_WorkflowStepLoader, baseuri, loadingOptions, - lc=_doc.get("run") + lc=_doc.get("steps") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `run`": + if str(e) == "missing required field `steps`": _errors__.append( ValidationException( str(e), @@ -23028,13 +18973,13 @@ def fromDoc( ) ) else: - val = _doc.get("run") + val = _doc.get("steps") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23046,14 +18991,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), [e], - detailed_message=f"the `run` field with value `{val}` " + detailed_message=f"the `steps` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23061,14 +19006,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `run`".format( + "invalid field `{}`, expected one of: `id`, `inputs`, `outputs`, `requirements`, `hints`, `label`, `doc`, `cwlVersion`, `class`, `steps`".format( k ), SourceLine(_doc, k, str), @@ -23086,11 +19031,11 @@ def fromDoc( label=label, doc=doc, cwlVersion=cwlVersion, - run=run, + steps=steps, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -23105,11 +19050,13 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ @@ -23145,9 +19092,10 @@ def save( if self.cwlVersion is not None: u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) r["cwlVersion"] = u - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u + if self.steps is not None: + r["steps"] = save( + self.steps, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -23157,7 +19105,40 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( + def __init__( + self, + inputs: Sequence[InputParameter], + outputs: Sequence[WorkflowOutputParameter], + steps: Sequence[WorkflowStep], + id: None | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | MultipleInputFeatureRequirement | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement] = None, + label: None | str = None, + doc: None | str = None, + cwlVersion: CWLVersion | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.label = label + self.doc = doc + self.cwlVersion = cwlVersion + self.class_: Final[str] = "Workflow" + self.steps = steps + + attrs: ClassVar[Collection[str]] = frozenset( [ "id", "inputs", @@ -23168,22 +19149,119 @@ def save( "doc", "cwlVersion", "class", - "run", + "steps", ] ) -class MPIRequirement(ProcessRequirement): +@mypyc_attr(native_class=True) +class SubworkflowFeatureRequirement(Saveable): """ - Indicates that a process requires an MPI runtime. + Indicates that the workflow platform must support nested workflows in the ``run`` field of `WorkflowStep <#WorkflowStep>`__. """ + def __eq__(self, other: Any) -> bool: + if isinstance(other, SubworkflowFeatureRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`".format(k), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + def __init__( self, - processes: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -23193,18 +19271,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "MPIRequirement" - self.processes = processes + self.class_: Final[str] = "SubworkflowFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class ScatterFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support the ``scatter`` and ``scatterMethod`` fields of `WorkflowStep <#WorkflowStep>`__. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, MPIRequirement): - return bool( - self.class_ == other.class_ and self.processes == other.processes - ) + if isinstance(other, ScatterFeatureRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash((self.class_, self.processes)) + return hash((self.class_)) @classmethod def fromDoc( @@ -23212,8 +19297,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MPIRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -23224,67 +19309,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_ScatterFeatureRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("processes") is None: - raise ValidationException("missing required field `processes`", None, []) - - processes = load_field( - _doc.get("processes"), - union_of_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("processes") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `processes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("processes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `processes` field is not valid because:", - SourceLine(_doc, "processes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `processes` field is not valid because:", - SourceLine(_doc, "processes", str), - [e], - detailed_message=f"the `processes` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23292,16 +19330,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `processes`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -23309,7 +19345,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - processes=processes, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -23327,20 +19362,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.processes is not None: - r["processes"] = save( - self.processes, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -23350,23 +19380,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "processes"]) - - -class CUDARequirement(ProcessRequirement): - """ - Require support for NVIDA CUDA (GPU hardware acceleration). - - """ - def __init__( self, - cudaComputeCapability: Any, - cudaVersionMin: Any, - cudaDeviceCountMax: Optional[Any] = None, - cudaDeviceCountMin: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -23376,33 +19393,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "CUDARequirement" - self.cudaComputeCapability = cudaComputeCapability - self.cudaDeviceCountMax = cudaDeviceCountMax - self.cudaDeviceCountMin = cudaDeviceCountMin - self.cudaVersionMin = cudaVersionMin + self.class_: Final[str] = "ScatterFeatureRequirement" - def __eq__(self, other: Any) -> bool: - if isinstance(other, CUDARequirement): - return bool( - self.class_ == other.class_ - and self.cudaComputeCapability == other.cudaComputeCapability - and self.cudaDeviceCountMax == other.cudaDeviceCountMax - and self.cudaDeviceCountMin == other.cudaDeviceCountMin - and self.cudaVersionMin == other.cudaVersionMin - ) - return False + attrs: ClassVar[Collection[str]] = frozenset(["class"]) - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.cudaComputeCapability, - self.cudaDeviceCountMax, - self.cudaDeviceCountMin, - self.cudaVersionMin, - ) - ) + +@mypyc_attr(native_class=True) +class MultipleInputFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support multiple inbound data links listed in the ``source`` field of `WorkflowStepInput <#WorkflowStepInput>`__. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, MultipleInputFeatureRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) @classmethod def fromDoc( @@ -23410,8 +19419,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CUDARequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -23422,209 +19431,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("cudaComputeCapability") is None: - raise ValidationException("missing required field `cudaComputeCapability`", None, []) - - cudaComputeCapability = load_field( - _doc.get("cudaComputeCapability"), - union_of_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("cudaComputeCapability") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaComputeCapability`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaComputeCapability") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaComputeCapability` field is not valid because:", - SourceLine(_doc, "cudaComputeCapability", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaComputeCapability` field is not valid because:", - SourceLine(_doc, "cudaComputeCapability", str), - [e], - detailed_message=f"the `cudaComputeCapability` field with value `{val}` " - "is not valid because:", - ) - ) - cudaDeviceCountMax = None - if "cudaDeviceCountMax" in _doc: - try: - cudaDeviceCountMax = load_field( - _doc.get("cudaDeviceCountMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("cudaDeviceCountMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaDeviceCountMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaDeviceCountMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaDeviceCountMax` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaDeviceCountMax` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMax", str), - [e], - detailed_message=f"the `cudaDeviceCountMax` field with value `{val}` " - "is not valid because:", - ) - ) - cudaDeviceCountMin = None - if "cudaDeviceCountMin" in _doc: - try: - cudaDeviceCountMin = load_field( - _doc.get("cudaDeviceCountMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("cudaDeviceCountMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaDeviceCountMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaDeviceCountMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaDeviceCountMin` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaDeviceCountMin` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMin", str), - [e], - detailed_message=f"the `cudaDeviceCountMin` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("cudaVersionMin") is None: - raise ValidationException("missing required field `cudaVersionMin`", None, []) - - cudaVersionMin = load_field( - _doc.get("cudaVersionMin"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("cudaVersionMin") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaVersionMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaVersionMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaVersionMin` field is not valid because:", - SourceLine(_doc, "cudaVersionMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaVersionMin` field is not valid because:", - SourceLine(_doc, "cudaVersionMin", str), - [e], - detailed_message=f"the `cudaVersionMin` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23632,16 +19452,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `cudaComputeCapability`, `cudaDeviceCountMax`, `cudaDeviceCountMin`, `cudaVersionMin`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -23649,10 +19467,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - cudaComputeCapability=cudaComputeCapability, - cudaDeviceCountMax=cudaDeviceCountMax, - cudaDeviceCountMin=cudaDeviceCountMin, - cudaVersionMin=cudaVersionMin, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -23670,41 +19484,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.cudaComputeCapability is not None: - r["cudaComputeCapability"] = save( - self.cudaComputeCapability, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.cudaDeviceCountMax is not None: - r["cudaDeviceCountMax"] = save( - self.cudaDeviceCountMax, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.cudaDeviceCountMin is not None: - r["cudaDeviceCountMin"] = save( - self.cudaDeviceCountMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.cudaVersionMin is not None: - r["cudaVersionMin"] = save( - self.cudaVersionMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -23714,23 +19502,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "cudaComputeCapability", - "cudaDeviceCountMax", - "cudaDeviceCountMin", - "cudaVersionMin", - ] - ) - - -class ShmSize(ProcessRequirement): def __init__( self, - shmSize: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -23740,16 +19515,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ShmSize" - self.shmSize = shmSize + self.class_: Final[str] = "MultipleInputFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class StepInputExpressionRequirement(Saveable): + """ + Indicate that the workflow platform must support the ``valueFrom`` field of `WorkflowStepInput <#WorkflowStepInput>`__. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ShmSize): - return bool(self.class_ == other.class_ and self.shmSize == other.shmSize) + if isinstance(other, StepInputExpressionRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash((self.class_, self.shmSize)) + return hash((self.class_)) @classmethod def fromDoc( @@ -23757,8 +19541,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ShmSize": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -23769,67 +19553,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_StepInputExpressionRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("shmSize") is None: - raise ValidationException("missing required field `shmSize`", None, []) - - shmSize = load_field( - _doc.get("shmSize"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("shmSize") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `shmSize`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("shmSize") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `shmSize` field is not valid because:", - SourceLine(_doc, "shmSize", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `shmSize` field is not valid because:", - SourceLine(_doc, "shmSize", str), - [e], - detailed_message=f"the `shmSize` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23837,16 +19574,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `shmSize`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -23854,7 +19589,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - shmSize=shmSize, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -23872,17 +19606,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.shmSize is not None: - r["shmSize"] = save( - self.shmSize, top=False, base_url=base_url, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -23892,13 +19624,27 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "shmSize"]) + def __init__( + self, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "StepInputExpressionRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) -_vocab = { +_vocab.update({ "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", - "CUDARequirement": "http://commonwl.org/cwltool#CUDARequirement", "CWLArraySchema": "https://w3id.org/cwl/cwl#CWLArraySchema", "CWLInputFile": "https://w3id.org/cwl/cwl#CWLInputFile", "CWLObjectType": "https://w3id.org/cwl/cwl#CWLObjectType", @@ -23933,7 +19679,6 @@ def save( "File": "https://w3id.org/cwl/cwl#File", "InitialWorkDirRequirement": "https://w3id.org/cwl/cwl#InitialWorkDirRequirement", "InlineJavascriptRequirement": "https://w3id.org/cwl/cwl#InlineJavascriptRequirement", - "InplaceUpdateRequirement": "http://commonwl.org/cwltool#InplaceUpdateRequirement", "InputArraySchema": "https://w3id.org/cwl/cwl#InputArraySchema", "InputBinding": "https://w3id.org/cwl/cwl#InputBinding", "InputEnumSchema": "https://w3id.org/cwl/cwl#InputEnumSchema", @@ -23942,11 +19687,8 @@ def save( "InputRecordSchema": "https://w3id.org/cwl/cwl#InputRecordSchema", "InputSchema": "https://w3id.org/cwl/cwl#InputSchema", "LinkMergeMethod": "https://w3id.org/cwl/cwl#LinkMergeMethod", - "LoadListingRequirement": "http://commonwl.org/cwltool#LoadListingRequirement", - "MPIRequirement": "http://commonwl.org/cwltool#MPIRequirement", "MapSchema": "https://w3id.org/cwl/salad#MapSchema", "MultipleInputFeatureRequirement": "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement", - "NetworkAccess": "http://commonwl.org/cwltool#NetworkAccess", "OutputArraySchema": "https://w3id.org/cwl/cwl#OutputArraySchema", "OutputBinding": "https://w3id.org/cwl/cwl#OutputBinding", "OutputEnumSchema": "https://w3id.org/cwl/cwl#OutputEnumSchema", @@ -23957,7 +19699,6 @@ def save( "Parameter": "https://w3id.org/cwl/cwl#Parameter", "PrimitiveType": "https://w3id.org/cwl/salad#PrimitiveType", "Process": "https://w3id.org/cwl/cwl#Process", - "ProcessGenerator": "http://commonwl.org/cwltool#ProcessGenerator", "ProcessRequirement": "https://w3id.org/cwl/cwl#ProcessRequirement", "RecordField": "https://w3id.org/cwl/salad#RecordField", "RecordSchema": "https://w3id.org/cwl/salad#RecordSchema", @@ -23966,17 +19707,13 @@ def save( "ScatterMethod": "https://w3id.org/cwl/cwl#ScatterMethod", "SchemaBase": "https://w3id.org/cwl/cwl#SchemaBase", "SchemaDefRequirement": "https://w3id.org/cwl/cwl#SchemaDefRequirement", - "Secrets": "http://commonwl.org/cwltool#Secrets", "ShellCommandRequirement": "https://w3id.org/cwl/cwl#ShellCommandRequirement", - "ShmSize": "http://commonwl.org/cwltool#ShmSize", "Sink": "https://w3id.org/cwl/cwl#Sink", "SoftwarePackage": "https://w3id.org/cwl/cwl#SoftwarePackage", "SoftwareRequirement": "https://w3id.org/cwl/cwl#SoftwareRequirement", "StepInputExpressionRequirement": "https://w3id.org/cwl/cwl#StepInputExpressionRequirement", "SubworkflowFeatureRequirement": "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement", - "TimeLimit": "http://commonwl.org/cwltool#TimeLimit", "UnionSchema": "https://w3id.org/cwl/salad#UnionSchema", - "WorkReuse": "http://commonwl.org/cwltool#WorkReuse", "Workflow": "https://w3id.org/cwl/cwl#Workflow", "WorkflowOutputParameter": "https://w3id.org/cwl/cwl#WorkflowOutputParameter", "WorkflowStep": "https://w3id.org/cwl/cwl#WorkflowStep", @@ -23984,19 +19721,8 @@ def save( "WorkflowStepOutput": "https://w3id.org/cwl/cwl#WorkflowStepOutput", "array": "https://w3id.org/cwl/salad#array", "boolean": "http://www.w3.org/2001/XMLSchema#boolean", - "deep_listing": "http://commonwl.org/cwltool#LoadListingRequirement/loadListing/LoadListingEnum/deep_listing", "dotproduct": "https://w3id.org/cwl/cwl#ScatterMethod/dotproduct", "double": "http://www.w3.org/2001/XMLSchema#double", - "draft-2": "https://w3id.org/cwl/cwl#draft-2", - "draft-3": "https://w3id.org/cwl/cwl#draft-3", - "draft-3.dev1": "https://w3id.org/cwl/cwl#draft-3.dev1", - "draft-3.dev2": "https://w3id.org/cwl/cwl#draft-3.dev2", - "draft-3.dev3": "https://w3id.org/cwl/cwl#draft-3.dev3", - "draft-3.dev4": "https://w3id.org/cwl/cwl#draft-3.dev4", - "draft-3.dev5": "https://w3id.org/cwl/cwl#draft-3.dev5", - "draft-4.dev1": "https://w3id.org/cwl/cwl#draft-4.dev1", - "draft-4.dev2": "https://w3id.org/cwl/cwl#draft-4.dev2", - "draft-4.dev3": "https://w3id.org/cwl/cwl#draft-4.dev3", "enum": "https://w3id.org/cwl/salad#enum", "flat_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/flat_crossproduct", "float": "http://www.w3.org/2001/XMLSchema#float", @@ -24006,21 +19732,17 @@ def save( "merge_flattened": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened", "merge_nested": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested", "nested_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct", - "no_listing": "http://commonwl.org/cwltool#LoadListingRequirement/loadListing/LoadListingEnum/no_listing", "null": "https://w3id.org/cwl/salad#null", "record": "https://w3id.org/cwl/salad#record", - "shallow_listing": "http://commonwl.org/cwltool#LoadListingRequirement/loadListing/LoadListingEnum/shallow_listing", "stderr": "https://w3id.org/cwl/cwl#stderr", "stdout": "https://w3id.org/cwl/cwl#stdout", "string": "http://www.w3.org/2001/XMLSchema#string", "union": "https://w3id.org/cwl/salad#union", "v1.0": "https://w3id.org/cwl/cwl#v1.0", - "v1.0.dev4": "https://w3id.org/cwl/cwl#v1.0.dev4", -} -_rvocab = { +}) +_rvocab.update({ "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", - "http://commonwl.org/cwltool#CUDARequirement": "CUDARequirement", "https://w3id.org/cwl/cwl#CWLArraySchema": "CWLArraySchema", "https://w3id.org/cwl/cwl#CWLInputFile": "CWLInputFile", "https://w3id.org/cwl/cwl#CWLObjectType": "CWLObjectType", @@ -24055,7 +19777,6 @@ def save( "https://w3id.org/cwl/cwl#File": "File", "https://w3id.org/cwl/cwl#InitialWorkDirRequirement": "InitialWorkDirRequirement", "https://w3id.org/cwl/cwl#InlineJavascriptRequirement": "InlineJavascriptRequirement", - "http://commonwl.org/cwltool#InplaceUpdateRequirement": "InplaceUpdateRequirement", "https://w3id.org/cwl/cwl#InputArraySchema": "InputArraySchema", "https://w3id.org/cwl/cwl#InputBinding": "InputBinding", "https://w3id.org/cwl/cwl#InputEnumSchema": "InputEnumSchema", @@ -24064,11 +19785,8 @@ def save( "https://w3id.org/cwl/cwl#InputRecordSchema": "InputRecordSchema", "https://w3id.org/cwl/cwl#InputSchema": "InputSchema", "https://w3id.org/cwl/cwl#LinkMergeMethod": "LinkMergeMethod", - "http://commonwl.org/cwltool#LoadListingRequirement": "LoadListingRequirement", - "http://commonwl.org/cwltool#MPIRequirement": "MPIRequirement", "https://w3id.org/cwl/salad#MapSchema": "MapSchema", "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement": "MultipleInputFeatureRequirement", - "http://commonwl.org/cwltool#NetworkAccess": "NetworkAccess", "https://w3id.org/cwl/cwl#OutputArraySchema": "OutputArraySchema", "https://w3id.org/cwl/cwl#OutputBinding": "OutputBinding", "https://w3id.org/cwl/cwl#OutputEnumSchema": "OutputEnumSchema", @@ -24079,7 +19797,6 @@ def save( "https://w3id.org/cwl/cwl#Parameter": "Parameter", "https://w3id.org/cwl/salad#PrimitiveType": "PrimitiveType", "https://w3id.org/cwl/cwl#Process": "Process", - "http://commonwl.org/cwltool#ProcessGenerator": "ProcessGenerator", "https://w3id.org/cwl/cwl#ProcessRequirement": "ProcessRequirement", "https://w3id.org/cwl/salad#RecordField": "RecordField", "https://w3id.org/cwl/salad#RecordSchema": "RecordSchema", @@ -24088,17 +19805,13 @@ def save( "https://w3id.org/cwl/cwl#ScatterMethod": "ScatterMethod", "https://w3id.org/cwl/cwl#SchemaBase": "SchemaBase", "https://w3id.org/cwl/cwl#SchemaDefRequirement": "SchemaDefRequirement", - "http://commonwl.org/cwltool#Secrets": "Secrets", "https://w3id.org/cwl/cwl#ShellCommandRequirement": "ShellCommandRequirement", - "http://commonwl.org/cwltool#ShmSize": "ShmSize", "https://w3id.org/cwl/cwl#Sink": "Sink", "https://w3id.org/cwl/cwl#SoftwarePackage": "SoftwarePackage", "https://w3id.org/cwl/cwl#SoftwareRequirement": "SoftwareRequirement", "https://w3id.org/cwl/cwl#StepInputExpressionRequirement": "StepInputExpressionRequirement", "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement": "SubworkflowFeatureRequirement", - "http://commonwl.org/cwltool#TimeLimit": "TimeLimit", "https://w3id.org/cwl/salad#UnionSchema": "UnionSchema", - "http://commonwl.org/cwltool#WorkReuse": "WorkReuse", "https://w3id.org/cwl/cwl#Workflow": "Workflow", "https://w3id.org/cwl/cwl#WorkflowOutputParameter": "WorkflowOutputParameter", "https://w3id.org/cwl/cwl#WorkflowStep": "WorkflowStep", @@ -24106,19 +19819,8 @@ def save( "https://w3id.org/cwl/cwl#WorkflowStepOutput": "WorkflowStepOutput", "https://w3id.org/cwl/salad#array": "array", "http://www.w3.org/2001/XMLSchema#boolean": "boolean", - "http://commonwl.org/cwltool#LoadListingRequirement/loadListing/LoadListingEnum/deep_listing": "deep_listing", "https://w3id.org/cwl/cwl#ScatterMethod/dotproduct": "dotproduct", "http://www.w3.org/2001/XMLSchema#double": "double", - "https://w3id.org/cwl/cwl#draft-2": "draft-2", - "https://w3id.org/cwl/cwl#draft-3": "draft-3", - "https://w3id.org/cwl/cwl#draft-3.dev1": "draft-3.dev1", - "https://w3id.org/cwl/cwl#draft-3.dev2": "draft-3.dev2", - "https://w3id.org/cwl/cwl#draft-3.dev3": "draft-3.dev3", - "https://w3id.org/cwl/cwl#draft-3.dev4": "draft-3.dev4", - "https://w3id.org/cwl/cwl#draft-3.dev5": "draft-3.dev5", - "https://w3id.org/cwl/cwl#draft-4.dev1": "draft-4.dev1", - "https://w3id.org/cwl/cwl#draft-4.dev2": "draft-4.dev2", - "https://w3id.org/cwl/cwl#draft-4.dev3": "draft-4.dev3", "https://w3id.org/cwl/salad#enum": "enum", "https://w3id.org/cwl/cwl#ScatterMethod/flat_crossproduct": "flat_crossproduct", "http://www.w3.org/2001/XMLSchema#float": "float", @@ -24128,25 +19830,26 @@ def save( "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened": "merge_flattened", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested": "merge_nested", "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct": "nested_crossproduct", - "http://commonwl.org/cwltool#LoadListingRequirement/loadListing/LoadListingEnum/no_listing": "no_listing", "https://w3id.org/cwl/salad#null": "null", "https://w3id.org/cwl/salad#record": "record", - "http://commonwl.org/cwltool#LoadListingRequirement/loadListing/LoadListingEnum/shallow_listing": "shallow_listing", "https://w3id.org/cwl/cwl#stderr": "stderr", "https://w3id.org/cwl/cwl#stdout": "stdout", "http://www.w3.org/2001/XMLSchema#string": "string", "https://w3id.org/cwl/salad#union": "union", "https://w3id.org/cwl/cwl#v1.0": "v1.0", - "https://w3id.org/cwl/cwl#v1.0.dev4": "v1.0.dev4", -} - -strtype = _PrimitiveLoader(str) -inttype = _PrimitiveLoader(int) -floattype = _PrimitiveLoader(float) -booltype = _PrimitiveLoader(bool) -None_type = _PrimitiveLoader(type(None)) -Any_type = _AnyLoader() -PrimitiveTypeLoader = _EnumLoader( +}) + +strtype: Final[_Loader[str]] = _PrimitiveLoader(str) +inttype: Final[_Loader[i32]] = _PrimitiveLoader(i32) +longtype: Final[_Loader[i64]] = _PrimitiveLoader(i64) +floattype: Final[_Loader[float]] = _PrimitiveLoader(float) +booltype: Final[_Loader[bool]] = _PrimitiveLoader(bool) +None_type: Final[_Loader[None]] = _PrimitiveLoader(type(None)) +Any_type: Final[_Loader[Any]] = _AnyLoader() +PrimitiveType: TypeAlias = Literal[ + "null", "boolean", "int", "long", "float", "double", "string" +] +PrimitiveTypeLoader: Final[_Loader[PrimitiveType]] = _EnumLoader( ( "null", "boolean", @@ -24161,28 +19864,49 @@ def save( """ Names of salad data types (based on Avro schema declarations). -Refer to the [Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for -detailed information. +Refer to the `Avro schema declaration documentation `__ for detailed information. null: no value + boolean: a binary value + int: 32-bit signed integer + long: 64-bit signed integer + float: single precision (32-bit) IEEE 754 floating-point number + double: double precision (64-bit) IEEE 754 floating-point number + string: Unicode character sequence """ -AnyLoader = _EnumLoader(("Any",), "Any") +Any_: TypeAlias = Literal["Any"] +Any_Loader: Final[_Loader[Any_]] = _EnumLoader(("Any",), "Any_") """ The **Any** type validates for any non-null value. """ -RecordFieldLoader = _RecordLoader(RecordField, None, None) -RecordSchemaLoader = _RecordLoader(RecordSchema, None, None) -EnumSchemaLoader = _RecordLoader(EnumSchema, None, None) -ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) -MapSchemaLoader = _RecordLoader(MapSchema, None, None) -UnionSchemaLoader = _RecordLoader(UnionSchema, None, None) -CWLTypeLoader = _EnumLoader( +RecordFieldLoader: Final[_Loader[schema_salad.metaschema.RecordField]] = _RecordLoader( + schema_salad.metaschema.RecordField, None, None +) +RecordSchemaLoader: Final[_Loader[schema_salad.metaschema.RecordSchema]] = ( + _RecordLoader(schema_salad.metaschema.RecordSchema, None, None) +) +EnumSchemaLoader: Final[_Loader[schema_salad.metaschema.EnumSchema]] = _RecordLoader( + schema_salad.metaschema.EnumSchema, None, None +) +ArraySchemaLoader: Final[_Loader[schema_salad.metaschema.ArraySchema]] = _RecordLoader( + schema_salad.metaschema.ArraySchema, None, None +) +MapSchemaLoader: Final[_Loader[schema_salad.metaschema.MapSchema]] = _RecordLoader( + schema_salad.metaschema.MapSchema, None, None +) +UnionSchemaLoader: Final[_Loader[schema_salad.metaschema.UnionSchema]] = _RecordLoader( + schema_salad.metaschema.UnionSchema, None, None +) +CWLType: TypeAlias = Literal[ + "null", "boolean", "int", "long", "float", "double", "string", "File", "Directory" +] +CWLTypeLoader: Final[_Loader[CWLType]] = _EnumLoader( ( "null", "boolean", @@ -24197,179 +19921,260 @@ def save( "CWLType", ) """ -Extends primitive types with the concept of a file and directory as a builtin type. -File: A File object -Directory: A Directory object +Extends primitive types with the concept of a file and directory as a builtin type. + +File: A File object + +Directory: A Directory object +""" +CWLArraySchemaLoader: Final[_Loader[CWLArraySchema]] = _RecordLoader( + CWLArraySchema, None, None +) +CWLRecordFieldLoader: Final[_Loader[CWLRecordField]] = _RecordLoader( + CWLRecordField, None, None +) +CWLRecordSchemaLoader: Final[_Loader[CWLRecordSchema]] = _RecordLoader( + CWLRecordSchema, None, None +) +FileLoader: Final[_Loader[File]] = _RecordLoader(File, None, None) +DirectoryLoader: Final[_Loader[Directory]] = _RecordLoader(Directory, None, None) +CWLObjectTypeLoader: Final[_UnionLoader[Any]] = _UnionLoader((), "CWLObjectTypeLoader") +union_of_None_type_or_CWLObjectTypeLoader: Final[_Loader[CWLObjectType | None]] = ( + _UnionLoader( + ( + None_type, + CWLObjectTypeLoader, + ) + ) +) +array_of_union_of_None_type_or_CWLObjectTypeLoader: Final[ + _Loader[Sequence[CWLObjectType | None]] +] = _ArrayLoader(union_of_None_type_or_CWLObjectTypeLoader) +map_of_union_of_None_type_or_CWLObjectTypeLoader: Final[ + _Loader[Mapping[str, CWLObjectType | None]] +] = _MapLoader(union_of_None_type_or_CWLObjectTypeLoader, "CWLInputFile", "@list", True) +CWLInputFileLoader: Final[_Loader[Mapping[str, CWLObjectType | None]]] = ( + map_of_union_of_None_type_or_CWLObjectTypeLoader +) +CWLVersion: TypeAlias = Literal["v1.0"] +CWLVersionLoader: Final[_Loader[CWLVersion]] = _EnumLoader(("v1.0",), "CWLVersion") +""" +Current version symbol for CWL documents. """ -CWLArraySchemaLoader = _RecordLoader(CWLArraySchema, None, None) -CWLRecordFieldLoader = _RecordLoader(CWLRecordField, None, None) -CWLRecordSchemaLoader = _RecordLoader(CWLRecordSchema, None, None) -FileLoader = _RecordLoader(File, None, None) -DirectoryLoader = _RecordLoader(Directory, None, None) -CWLObjectTypeLoader = _UnionLoader((), "CWLObjectTypeLoader") -union_of_None_type_or_CWLObjectTypeLoader = _UnionLoader( - ( - None_type, - CWLObjectTypeLoader, - ) +Expression: TypeAlias = Literal["ExpressionPlaceholder"] +ExpressionLoader: Final[_Loader[str]] = _ExpressionLoader(str) +InputRecordFieldLoader: Final[_Loader[InputRecordField]] = _RecordLoader( + InputRecordField, None, None ) -array_of_union_of_None_type_or_CWLObjectTypeLoader = _ArrayLoader( - union_of_None_type_or_CWLObjectTypeLoader +InputRecordSchemaLoader: Final[_Loader[InputRecordSchema]] = _RecordLoader( + InputRecordSchema, None, None ) -map_of_union_of_None_type_or_CWLObjectTypeLoader = _MapLoader( - union_of_None_type_or_CWLObjectTypeLoader, "CWLInputFile", "@list", True +InputEnumSchemaLoader: Final[_Loader[InputEnumSchema]] = _RecordLoader( + InputEnumSchema, None, None ) -CWLInputFileLoader = map_of_union_of_None_type_or_CWLObjectTypeLoader -CWLVersionLoader = _EnumLoader( - ( - "draft-2", - "draft-3.dev1", - "draft-3.dev2", - "draft-3.dev3", - "draft-3.dev4", - "draft-3.dev5", - "draft-3", - "draft-4.dev1", - "draft-4.dev2", - "draft-4.dev3", - "v1.0.dev4", - "v1.0", - ), - "CWLVersion", +InputArraySchemaLoader: Final[_Loader[InputArraySchema]] = _RecordLoader( + InputArraySchema, None, None ) -""" -Version symbols for published CWL document versions. -""" -ExpressionLoader = _ExpressionLoader(str) -InputRecordFieldLoader = _RecordLoader(InputRecordField, None, None) -InputRecordSchemaLoader = _RecordLoader(InputRecordSchema, None, None) -InputEnumSchemaLoader = _RecordLoader(InputEnumSchema, None, None) -InputArraySchemaLoader = _RecordLoader(InputArraySchema, None, None) -OutputRecordFieldLoader = _RecordLoader(OutputRecordField, None, None) -OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema, None, None) -OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema, None, None) -OutputArraySchemaLoader = _RecordLoader(OutputArraySchema, None, None) -InputParameterLoader = _RecordLoader(InputParameter, None, None) -OutputParameterLoader = _RecordLoader(OutputParameter, None, None) -InlineJavascriptRequirementLoader = _RecordLoader( - InlineJavascriptRequirement, None, None +OutputRecordFieldLoader: Final[_Loader[OutputRecordField]] = _RecordLoader( + OutputRecordField, None, None +) +OutputRecordSchemaLoader: Final[_Loader[OutputRecordSchema]] = _RecordLoader( + OutputRecordSchema, None, None +) +OutputEnumSchemaLoader: Final[_Loader[OutputEnumSchema]] = _RecordLoader( + OutputEnumSchema, None, None +) +OutputArraySchemaLoader: Final[_Loader[OutputArraySchema]] = _RecordLoader( + OutputArraySchema, None, None +) +InputParameterLoader: Final[_Loader[InputParameter]] = _RecordLoader( + InputParameter, None, None +) +OutputParameterLoader: Final[_Loader[OutputParameter]] = _RecordLoader( + OutputParameter, None, None +) +InlineJavascriptRequirementLoader: Final[_Loader[InlineJavascriptRequirement]] = ( + _RecordLoader(InlineJavascriptRequirement, None, None) +) +SchemaDefRequirementLoader: Final[_Loader[SchemaDefRequirement]] = _RecordLoader( + SchemaDefRequirement, None, None +) +EnvironmentDefLoader: Final[_Loader[EnvironmentDef]] = _RecordLoader( + EnvironmentDef, None, None +) +CommandLineBindingLoader: Final[_Loader[CommandLineBinding]] = _RecordLoader( + CommandLineBinding, None, None +) +CommandOutputBindingLoader: Final[_Loader[CommandOutputBinding]] = _RecordLoader( + CommandOutputBinding, None, None +) +CommandInputRecordFieldLoader: Final[_Loader[CommandInputRecordField]] = _RecordLoader( + CommandInputRecordField, None, None +) +CommandInputRecordSchemaLoader: Final[_Loader[CommandInputRecordSchema]] = ( + _RecordLoader(CommandInputRecordSchema, None, None) +) +CommandInputEnumSchemaLoader: Final[_Loader[CommandInputEnumSchema]] = _RecordLoader( + CommandInputEnumSchema, None, None +) +CommandInputArraySchemaLoader: Final[_Loader[CommandInputArraySchema]] = _RecordLoader( + CommandInputArraySchema, None, None +) +CommandOutputRecordFieldLoader: Final[_Loader[CommandOutputRecordField]] = ( + _RecordLoader(CommandOutputRecordField, None, None) +) +CommandOutputRecordSchemaLoader: Final[_Loader[CommandOutputRecordSchema]] = ( + _RecordLoader(CommandOutputRecordSchema, None, None) +) +CommandOutputEnumSchemaLoader: Final[_Loader[CommandOutputEnumSchema]] = _RecordLoader( + CommandOutputEnumSchema, None, None +) +CommandOutputArraySchemaLoader: Final[_Loader[CommandOutputArraySchema]] = ( + _RecordLoader(CommandOutputArraySchema, None, None) +) +CommandInputParameterLoader: Final[_Loader[CommandInputParameter]] = _RecordLoader( + CommandInputParameter, None, None ) -SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement, None, None) -EnvironmentDefLoader = _RecordLoader(EnvironmentDef, None, None) -CommandLineBindingLoader = _RecordLoader(CommandLineBinding, None, None) -CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding, None, None) -CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField, None, None) -CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema, None, None) -CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema, None, None) -CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema, None, None) -CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField, None, None) -CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema, None, None) -CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema, None, None) -CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema, None, None) -CommandInputParameterLoader = _RecordLoader(CommandInputParameter, None, None) -CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter, None, None) -stdoutLoader = _EnumLoader(("stdout",), "stdout") +CommandOutputParameterLoader: Final[_Loader[CommandOutputParameter]] = _RecordLoader( + CommandOutputParameter, None, None +) +stdout: TypeAlias = Literal["stdout"] +stdoutLoader: Final[_Loader[stdout]] = _EnumLoader(("stdout",), "stdout") """ -Only valid as a `type` for a `CommandLineTool` output with no -`outputBinding` set. +Only valid as a ``type`` for a ``CommandLineTool`` output with no ``outputBinding`` set. The following -``` -outputs: - an_output_name: - type: stdout -stdout: a_stdout_file -``` +:: + + outputs: + an_output_name: + type: stdout + + stdout: a_stdout_file + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: a_stdout_file - -stdout: a_stdout_file -``` - -If there is no `stdout` name provided, a random filename will be created. -For example, the following -``` -outputs: - an_output_name: - type: stdout -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: a_stdout_file + + stdout: a_stdout_file + + +If there is no ``stdout`` name provided, a random filename will be created. For example, the following + +:: + + outputs: + an_output_name: + type: stdout + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: random_stdout_filenameABCDEFG - -stdout: random_stdout_filenameABCDEFG -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: random_stdout_filenameABCDEFG + + stdout: random_stdout_filenameABCDEFG """ -stderrLoader = _EnumLoader(("stderr",), "stderr") +stderr: TypeAlias = Literal["stderr"] +stderrLoader: Final[_Loader[stderr]] = _EnumLoader(("stderr",), "stderr") """ -Only valid as a `type` for a `CommandLineTool` output with no -`outputBinding` set. +Only valid as a ``type`` for a ``CommandLineTool`` output with no ``outputBinding`` set. The following -``` -outputs: - an_output_name: - type: stderr -stderr: a_stderr_file -``` +:: + + outputs: + an_output_name: + type: stderr + + stderr: a_stderr_file + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: a_stderr_file - -stderr: a_stderr_file -``` - -If there is no `stderr` name provided, a random filename will be created. -For example, the following -``` -outputs: - an_output_name: - type: stderr -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: a_stderr_file + + stderr: a_stderr_file + + +If there is no ``stderr`` name provided, a random filename will be created. For example, the following + +:: + + outputs: + an_output_name: + type: stderr + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: random_stderr_filenameABCDEFG - -stderr: random_stderr_filenameABCDEFG -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: random_stderr_filenameABCDEFG + + stderr: random_stderr_filenameABCDEFG """ -CommandLineToolLoader = _RecordLoader(CommandLineTool, None, None) -DockerRequirementLoader = _RecordLoader(DockerRequirement, None, None) -SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement, None, None) -SoftwarePackageLoader = _RecordLoader(SoftwarePackage, None, None) -DirentLoader = _RecordLoader(Dirent, None, None) -InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement, None, None) -EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement, None, None) -ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement, None, None) -ResourceRequirementLoader = _RecordLoader(ResourceRequirement, None, None) -ExpressionToolOutputParameterLoader = _RecordLoader( - ExpressionToolOutputParameter, None, None +CommandLineToolLoader: Final[_Loader[CommandLineTool]] = _RecordLoader( + CommandLineTool, None, None +) +DockerRequirementLoader: Final[_Loader[DockerRequirement]] = _RecordLoader( + DockerRequirement, None, None +) +SoftwareRequirementLoader: Final[_Loader[SoftwareRequirement]] = _RecordLoader( + SoftwareRequirement, None, None +) +SoftwarePackageLoader: Final[_Loader[SoftwarePackage]] = _RecordLoader( + SoftwarePackage, None, None +) +DirentLoader: Final[_Loader[Dirent]] = _RecordLoader(Dirent, None, None) +InitialWorkDirRequirementLoader: Final[_Loader[InitialWorkDirRequirement]] = ( + _RecordLoader(InitialWorkDirRequirement, None, None) +) +EnvVarRequirementLoader: Final[_Loader[EnvVarRequirement]] = _RecordLoader( + EnvVarRequirement, None, None +) +ShellCommandRequirementLoader: Final[_Loader[ShellCommandRequirement]] = _RecordLoader( + ShellCommandRequirement, None, None +) +ResourceRequirementLoader: Final[_Loader[ResourceRequirement]] = _RecordLoader( + ResourceRequirement, None, None ) -ExpressionToolLoader = _RecordLoader(ExpressionTool, None, None) -LinkMergeMethodLoader = _EnumLoader( +ExpressionToolOutputParameterLoader: Final[_Loader[ExpressionToolOutputParameter]] = ( + _RecordLoader(ExpressionToolOutputParameter, None, None) +) +ExpressionToolLoader: Final[_Loader[ExpressionTool]] = _RecordLoader( + ExpressionTool, None, None +) +LinkMergeMethod: TypeAlias = Literal["merge_nested", "merge_flattened"] +LinkMergeMethodLoader: Final[_Loader[LinkMergeMethod]] = _EnumLoader( ( "merge_nested", "merge_flattened", @@ -24377,12 +20182,21 @@ def save( "LinkMergeMethod", ) """ -The input link merge method, described in [WorkflowStepInput](#WorkflowStepInput). +The input link merge method, described in `WorkflowStepInput <#WorkflowStepInput>`__. """ -WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter, None, None) -WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput, None, None) -WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput, None, None) -ScatterMethodLoader = _EnumLoader( +WorkflowOutputParameterLoader: Final[_Loader[WorkflowOutputParameter]] = _RecordLoader( + WorkflowOutputParameter, None, None +) +WorkflowStepInputLoader: Final[_Loader[WorkflowStepInput]] = _RecordLoader( + WorkflowStepInput, None, None +) +WorkflowStepOutputLoader: Final[_Loader[WorkflowStepOutput]] = _RecordLoader( + WorkflowStepOutput, None, None +) +ScatterMethod: TypeAlias = Literal[ + "dotproduct", "nested_crossproduct", "flat_crossproduct" +] +ScatterMethodLoader: Final[_Loader[ScatterMethod]] = _EnumLoader( ( "dotproduct", "nested_crossproduct", @@ -24391,40 +20205,48 @@ def save( "ScatterMethod", ) """ -The scatter method, as described in [workflow step scatter](#WorkflowStep). +The scatter method, as described in `workflow step scatter <#WorkflowStep>`__. """ -WorkflowStepLoader = _RecordLoader(WorkflowStep, None, None) -WorkflowLoader = _RecordLoader(Workflow, None, None) -SubworkflowFeatureRequirementLoader = _RecordLoader( - SubworkflowFeatureRequirement, None, None +WorkflowStepLoader: Final[_Loader[WorkflowStep]] = _RecordLoader( + WorkflowStep, None, None +) +WorkflowLoader: Final[_Loader[Workflow]] = _RecordLoader(Workflow, None, None) +SubworkflowFeatureRequirementLoader: Final[_Loader[SubworkflowFeatureRequirement]] = ( + _RecordLoader(SubworkflowFeatureRequirement, None, None) ) -ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement, None, None) -MultipleInputFeatureRequirementLoader = _RecordLoader( - MultipleInputFeatureRequirement, None, None +ScatterFeatureRequirementLoader: Final[_Loader[ScatterFeatureRequirement]] = ( + _RecordLoader(ScatterFeatureRequirement, None, None) ) -StepInputExpressionRequirementLoader = _RecordLoader( - StepInputExpressionRequirement, None, None +MultipleInputFeatureRequirementLoader: Final[ + _Loader[MultipleInputFeatureRequirement] +] = _RecordLoader(MultipleInputFeatureRequirement, None, None) +StepInputExpressionRequirementLoader: Final[_Loader[StepInputExpressionRequirement]] = ( + _RecordLoader(StepInputExpressionRequirement, None, None) ) -LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement, None, None) -InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement, None, None) -SecretsLoader = _RecordLoader(Secrets, None, None) -TimeLimitLoader = _RecordLoader(TimeLimit, None, None) -WorkReuseLoader = _RecordLoader(WorkReuse, None, None) -NetworkAccessLoader = _RecordLoader(NetworkAccess, None, None) -ProcessGeneratorLoader = _RecordLoader(ProcessGenerator, None, None) -MPIRequirementLoader = _RecordLoader(MPIRequirement, None, None) -CUDARequirementLoader = _RecordLoader(CUDARequirement, None, None) -ShmSizeLoader = _RecordLoader(ShmSize, None, None) -array_of_strtype = _ArrayLoader(strtype) -union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( +array_of_strtype: Final[_Loader[Sequence[str]]] = _ArrayLoader(strtype) +union_of_None_type_or_strtype_or_array_of_strtype: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, array_of_strtype, ) ) -uri_strtype_True_False_None_None = _URILoader(strtype, True, False, None, None) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( +uri_strtype_True_False_None_None: Final[_Loader[str]] = _URILoader( + strtype, True, False, None, None +) +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, @@ -24435,10 +20257,41 @@ def save( strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + ] +] = _ArrayLoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, @@ -24450,51 +20303,116 @@ def save( array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, ) ) -typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _TypeDSLLoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, 2, "v1.1", ) -array_of_RecordFieldLoader = _ArrayLoader(RecordFieldLoader) -union_of_None_type_or_array_of_RecordFieldLoader = _UnionLoader( +array_of_RecordFieldLoader: Final[ + _Loader[Sequence[schema_salad.metaschema.RecordField]] +] = _ArrayLoader(RecordFieldLoader) +union_of_None_type_or_array_of_RecordFieldLoader: Final[ + _Loader[None | Sequence[schema_salad.metaschema.RecordField]] +] = _UnionLoader( ( None_type, array_of_RecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_RecordFieldLoader, "name", "type" +idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader: Final[ + _Loader[None | Sequence[schema_salad.metaschema.RecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_RecordFieldLoader, "name", "type") +Record_name: TypeAlias = Literal["record"] +Record_nameLoader: Final[_Loader[Record_name]] = _EnumLoader(("record",), "Record_name") +typedsl_Record_nameLoader_2: Final[_Loader[Record_name]] = _TypeDSLLoader( + Record_nameLoader, 2, "v1.1" ) -Record_nameLoader = _EnumLoader(("record",), "Record_name") -typedsl_Record_nameLoader_2 = _TypeDSLLoader(Record_nameLoader, 2, "v1.1") -union_of_None_type_or_strtype = _UnionLoader( +union_of_None_type_or_strtype: Final[_Loader[None | str]] = _UnionLoader( ( None_type, strtype, ) ) -uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( - union_of_None_type_or_strtype, True, False, None, None +uri_union_of_None_type_or_strtype_True_False_None_None: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, True, False, None, None) ) -uri_array_of_strtype_True_False_None_None = _URILoader( +uri_array_of_strtype_True_False_None_None: Final[_Loader[Sequence[str]]] = _URILoader( array_of_strtype, True, False, None, None ) -Enum_nameLoader = _EnumLoader(("enum",), "Enum_name") -typedsl_Enum_nameLoader_2 = _TypeDSLLoader(Enum_nameLoader, 2, "v1.1") -uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None = _URILoader( +Enum_name: TypeAlias = Literal["enum"] +Enum_nameLoader: Final[_Loader[Enum_name]] = _EnumLoader(("enum",), "Enum_name") +typedsl_Enum_nameLoader_2: Final[_Loader[Enum_name]] = _TypeDSLLoader( + Enum_nameLoader, 2, "v1.1" +) +uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _URILoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, False, True, 2, None, ) -Array_nameLoader = _EnumLoader(("array",), "Array_name") -typedsl_Array_nameLoader_2 = _TypeDSLLoader(Array_nameLoader, 2, "v1.1") -Map_nameLoader = _EnumLoader(("map",), "Map_name") -typedsl_Map_nameLoader_2 = _TypeDSLLoader(Map_nameLoader, 2, "v1.1") -Union_nameLoader = _EnumLoader(("union",), "Union_name") -typedsl_Union_nameLoader_2 = _TypeDSLLoader(Union_nameLoader, 2, "v1.1") -union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( +Array_name: TypeAlias = Literal["array"] +Array_nameLoader: Final[_Loader[Array_name]] = _EnumLoader(("array",), "Array_name") +typedsl_Array_nameLoader_2: Final[_Loader[Array_name]] = _TypeDSLLoader( + Array_nameLoader, 2, "v1.1" +) +Map_name: TypeAlias = Literal["map"] +Map_nameLoader: Final[_Loader[Map_name]] = _EnumLoader(("map",), "Map_name") +typedsl_Map_nameLoader_2: Final[_Loader[Map_name]] = _TypeDSLLoader( + Map_nameLoader, 2, "v1.1" +) +Union_name: TypeAlias = Literal["union"] +Union_nameLoader: Final[_Loader[Union_name]] = _EnumLoader(("union",), "Union_name") +typedsl_Union_nameLoader_2: Final[_Loader[Union_name]] = _TypeDSLLoader( + Union_nameLoader, 2, "v1.1" +) +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, CWLRecordSchemaLoader, @@ -24503,10 +20421,35 @@ def save( strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + ] +] = _ArrayLoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, CWLRecordSchemaLoader, @@ -24516,73 +20459,118 @@ def save( array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, ) ) -uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _URILoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, False, True, 2, None, ) -typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _TypeDSLLoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CWLRecordFieldLoader = _ArrayLoader(CWLRecordFieldLoader) -union_of_None_type_or_array_of_CWLRecordFieldLoader = _UnionLoader( +array_of_CWLRecordFieldLoader: Final[_Loader[Sequence[CWLRecordField]]] = _ArrayLoader( + CWLRecordFieldLoader +) +union_of_None_type_or_array_of_CWLRecordFieldLoader: Final[ + _Loader[None | Sequence[CWLRecordField]] +] = _UnionLoader( ( None_type, array_of_CWLRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type" -) -File_classLoader = _EnumLoader(("File",), "File_class") -uri_File_classLoader_False_True_None_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader: Final[ + _Loader[None | Sequence[CWLRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type") +File_class: TypeAlias = Literal["File"] +File_classLoader: Final[_Loader[File_class]] = _EnumLoader(("File",), "File_class") +uri_File_classLoader_False_True_None_None: Final[_Loader[File_class]] = _URILoader( File_classLoader, False, True, None, None ) -uri_union_of_None_type_or_strtype_False_False_None_None = _URILoader( - union_of_None_type_or_strtype, False, False, None, None +uri_union_of_None_type_or_strtype_False_False_None_None: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, False, False, None, None) ) -union_of_None_type_or_inttype = _UnionLoader( - ( - None_type, - inttype, +union_of_None_type_or_inttype_or_longtype: Final[_Loader[None | i32 | i64]] = ( + _UnionLoader( + ( + None_type, + inttype, + longtype, + ) ) ) -union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +union_of_FileLoader_or_DirectoryLoader: Final[_Loader[Directory | File]] = _UnionLoader( ( FileLoader, DirectoryLoader, ) ) -array_of_union_of_FileLoader_or_DirectoryLoader = _ArrayLoader( - union_of_FileLoader_or_DirectoryLoader -) -union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[Sequence[Directory | File]] +] = _ArrayLoader(union_of_FileLoader_or_DirectoryLoader) +union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[None | Sequence[Directory | File]] +] = _UnionLoader( ( None_type, array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -uri_union_of_None_type_or_strtype_True_False_None_True = _URILoader( - union_of_None_type_or_strtype, True, False, None, True +uri_union_of_None_type_or_strtype_True_False_None_True: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, True, False, None, True) ) -Directory_classLoader = _EnumLoader(("Directory",), "Directory_class") -uri_Directory_classLoader_False_True_None_None = _URILoader( - Directory_classLoader, False, True, None, None +Directory_class: TypeAlias = Literal["Directory"] +Directory_classLoader: Final[_Loader[Directory_class]] = _EnumLoader( + ("Directory",), "Directory_class" ) -union_of_strtype_or_ExpressionLoader = _UnionLoader( +uri_Directory_classLoader_False_True_None_None: Final[_Loader[Directory_class]] = ( + _URILoader(Directory_classLoader, False, True, None, None) +) +union_of_strtype_or_ExpressionLoader: Final[_Loader[str]] = _UnionLoader( ( strtype, ExpressionLoader, ) ) -array_of_union_of_strtype_or_ExpressionLoader = _ArrayLoader( - union_of_strtype_or_ExpressionLoader +array_of_union_of_strtype_or_ExpressionLoader: Final[_Loader[Sequence[str]]] = ( + _ArrayLoader(union_of_strtype_or_ExpressionLoader) ) -union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -24590,13 +20578,15 @@ def save( array_of_union_of_strtype_or_ExpressionLoader, ) ) -union_of_None_type_or_booltype = _UnionLoader( +union_of_None_type_or_booltype: Final[_Loader[None | bool]] = _UnionLoader( ( None_type, booltype, ) ) -union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] +] = _UnionLoader( ( CWLTypeLoader, InputRecordSchemaLoader, @@ -24605,10 +20595,25 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, InputRecordSchemaLoader, @@ -24618,35 +20623,65 @@ def save( array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_None_type_or_CommandLineBindingLoader = _UnionLoader( +union_of_None_type_or_CommandLineBindingLoader: Final[ + _Loader[CommandLineBinding | None] +] = _UnionLoader( ( None_type, CommandLineBindingLoader, ) ) -array_of_InputRecordFieldLoader = _ArrayLoader(InputRecordFieldLoader) -union_of_None_type_or_array_of_InputRecordFieldLoader = _UnionLoader( +array_of_InputRecordFieldLoader: Final[_Loader[Sequence[InputRecordField]]] = ( + _ArrayLoader(InputRecordFieldLoader) +) +union_of_None_type_or_array_of_InputRecordFieldLoader: Final[ + _Loader[None | Sequence[InputRecordField]] +] = _UnionLoader( ( None_type, array_of_InputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type" -) -uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader: Final[ + _Loader[None | Sequence[InputRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type") +uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] +] = _UnionLoader( ( CWLTypeLoader, OutputRecordSchemaLoader, @@ -24655,10 +20690,27 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, OutputRecordSchemaLoader, @@ -24668,35 +20720,65 @@ def save( array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_None_type_or_CommandOutputBindingLoader = _UnionLoader( +union_of_None_type_or_CommandOutputBindingLoader: Final[ + _Loader[CommandOutputBinding | None] +] = _UnionLoader( ( None_type, CommandOutputBindingLoader, ) ) -array_of_OutputRecordFieldLoader = _ArrayLoader(OutputRecordFieldLoader) -union_of_None_type_or_array_of_OutputRecordFieldLoader = _UnionLoader( +array_of_OutputRecordFieldLoader: Final[_Loader[Sequence[OutputRecordField]]] = ( + _ArrayLoader(OutputRecordFieldLoader) +) +union_of_None_type_or_array_of_OutputRecordFieldLoader: Final[ + _Loader[None | Sequence[OutputRecordField]] +] = _UnionLoader( ( None_type, array_of_OutputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type" -) -uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader: Final[ + _Loader[None | Sequence[OutputRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type") +uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -24704,14 +20786,28 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( +uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader( union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader, True, False, None, True, ) -union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | None + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( None_type, CWLTypeLoader, @@ -24722,30 +20818,65 @@ def save( array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | None + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_None_type_or_strtype_or_ExpressionLoader = _UnionLoader( - ( - None_type, - strtype, - ExpressionLoader, +union_of_None_type_or_strtype_or_ExpressionLoader: Final[_Loader[None | str]] = ( + _UnionLoader( + ( + None_type, + strtype, + ExpressionLoader, + ) ) ) -uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( +uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True: Final[ + _Loader[None | str] +] = _URILoader( union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None, True ) -array_of_InputParameterLoader = _ArrayLoader(InputParameterLoader) -idmap_inputs_array_of_InputParameterLoader = _IdMapLoader( - array_of_InputParameterLoader, "id", "type" +array_of_InputParameterLoader: Final[_Loader[Sequence[InputParameter]]] = _ArrayLoader( + InputParameterLoader +) +idmap_inputs_array_of_InputParameterLoader: Final[_Loader[Sequence[InputParameter]]] = ( + _IdMapLoader(array_of_InputParameterLoader, "id", "type") ) -array_of_OutputParameterLoader = _ArrayLoader(OutputParameterLoader) -idmap_outputs_array_of_OutputParameterLoader = _IdMapLoader( - array_of_OutputParameterLoader, "id", "type" +array_of_OutputParameterLoader: Final[_Loader[Sequence[OutputParameter]]] = ( + _ArrayLoader(OutputParameterLoader) ) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _UnionLoader( +idmap_outputs_array_of_OutputParameterLoader: Final[ + _Loader[Sequence[OutputParameter]] +] = _IdMapLoader(array_of_OutputParameterLoader, "id", "type") +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] +] = _UnionLoader( ( InlineJavascriptRequirementLoader, SchemaDefRequirementLoader, @@ -24759,32 +20890,92 @@ def save( ScatterFeatureRequirementLoader, MultipleInputFeatureRequirementLoader, StepInputExpressionRequirementLoader, - LoadListingRequirementLoader, - InplaceUpdateRequirementLoader, - SecretsLoader, - TimeLimitLoader, - WorkReuseLoader, - NetworkAccessLoader, - MPIRequirementLoader, - CUDARequirementLoader, - ShmSizeLoader, ) ) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] + ] +] = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, ) ) -idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _IdMapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, +idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] + ] +] = _IdMapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, "class", "None", ) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _UnionLoader( +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] +] = _UnionLoader( ( InlineJavascriptRequirementLoader, SchemaDefRequirementLoader, @@ -24798,72 +20989,135 @@ def save( ScatterFeatureRequirementLoader, MultipleInputFeatureRequirementLoader, StepInputExpressionRequirementLoader, - LoadListingRequirementLoader, - InplaceUpdateRequirementLoader, - SecretsLoader, - TimeLimitLoader, - WorkReuseLoader, - NetworkAccessLoader, - MPIRequirementLoader, - CUDARequirementLoader, - ShmSizeLoader, Any_type, ) ) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] + ] +] = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + None + | Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, ) ) -idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _IdMapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_LoadListingRequirementLoader_or_InplaceUpdateRequirementLoader_or_SecretsLoader_or_TimeLimitLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, +idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + None + | Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + ] + ] +] = _IdMapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, "class", "None", ) -union_of_None_type_or_CWLVersionLoader = _UnionLoader( - ( - None_type, - CWLVersionLoader, +union_of_None_type_or_CWLVersionLoader: Final[_Loader[CWLVersion | None]] = ( + _UnionLoader( + ( + None_type, + CWLVersionLoader, + ) ) ) -uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None = _URILoader( - union_of_None_type_or_CWLVersionLoader, False, True, None, None -) -InlineJavascriptRequirement_classLoader = _EnumLoader( - ("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class" +uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None: Final[ + _Loader[CWLVersion | None] +] = _URILoader(union_of_None_type_or_CWLVersionLoader, False, True, None, None) +InlineJavascriptRequirement_class: TypeAlias = Literal["InlineJavascriptRequirement"] +InlineJavascriptRequirement_classLoader: Final[ + _Loader[InlineJavascriptRequirement_class] +] = _EnumLoader(("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class") +uri_InlineJavascriptRequirement_classLoader_False_True_None_None: Final[ + _Loader[InlineJavascriptRequirement_class] +] = _URILoader(InlineJavascriptRequirement_classLoader, False, True, None, None) +union_of_None_type_or_array_of_strtype: Final[_Loader[None | Sequence[str]]] = ( + _UnionLoader( + ( + None_type, + array_of_strtype, + ) + ) ) -uri_InlineJavascriptRequirement_classLoader_False_True_None_None = _URILoader( - InlineJavascriptRequirement_classLoader, False, True, None, None +SchemaDefRequirement_class: TypeAlias = Literal["SchemaDefRequirement"] +SchemaDefRequirement_classLoader: Final[_Loader[SchemaDefRequirement_class]] = ( + _EnumLoader(("SchemaDefRequirement",), "SchemaDefRequirement_class") ) -union_of_None_type_or_array_of_strtype = _UnionLoader( +uri_SchemaDefRequirement_classLoader_False_True_None_None: Final[ + _Loader[SchemaDefRequirement_class] +] = _URILoader(SchemaDefRequirement_classLoader, False, True, None, None) +union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader: ( + Final[_Loader[InputArraySchema | InputEnumSchema | InputRecordSchema]] +) = _UnionLoader( ( - None_type, - array_of_strtype, + InputRecordSchemaLoader, + InputEnumSchemaLoader, + InputArraySchemaLoader, ) ) -SchemaDefRequirement_classLoader = _EnumLoader( - ("SchemaDefRequirement",), "SchemaDefRequirement_class" -) -uri_SchemaDefRequirement_classLoader_False_True_None_None = _URILoader( - SchemaDefRequirement_classLoader, False, True, None, None +array_of_union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader: Final[ + _Loader[Sequence[InputArraySchema | InputEnumSchema | InputRecordSchema]] +] = _ArrayLoader( + union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader ) -union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader = ( - _UnionLoader( - ( - InputRecordSchemaLoader, - InputEnumSchemaLoader, - InputArraySchemaLoader, - ) +union_of_None_type_or_inttype: Final[_Loader[None | i32]] = _UnionLoader( + ( + None_type, + inttype, ) ) -array_of_union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader = _ArrayLoader( - union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader -) -union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype = _UnionLoader( +union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -24871,7 +21125,15 @@ def save( array_of_strtype, ) ) -union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandInputRecordSchemaLoader, @@ -24880,10 +21142,35 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandInputRecordSchemaLoader, @@ -24893,31 +21180,73 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CommandInputRecordFieldLoader = _ArrayLoader(CommandInputRecordFieldLoader) -union_of_None_type_or_array_of_CommandInputRecordFieldLoader = _UnionLoader( +array_of_CommandInputRecordFieldLoader: Final[ + _Loader[Sequence[CommandInputRecordField]] +] = _ArrayLoader(CommandInputRecordFieldLoader) +union_of_None_type_or_array_of_CommandInputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandInputRecordField]] +] = _UnionLoader( ( None_type, array_of_CommandInputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader = ( - _IdMapLoader( - union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" - ) +idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandInputRecordField]] +] = _IdMapLoader( + union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandOutputRecordSchemaLoader, @@ -24926,10 +21255,35 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandOutputRecordSchemaLoader, @@ -24939,31 +21293,81 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CommandOutputRecordFieldLoader = _ArrayLoader(CommandOutputRecordFieldLoader) -union_of_None_type_or_array_of_CommandOutputRecordFieldLoader = _UnionLoader( +array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[Sequence[CommandOutputRecordField]] +] = _ArrayLoader(CommandOutputRecordFieldLoader) +union_of_None_type_or_array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandOutputRecordField]] +] = _UnionLoader( ( None_type, array_of_CommandOutputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader = ( - _IdMapLoader( - union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" - ) +idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandOutputRecordField]] +] = _IdMapLoader( + union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | None + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( None_type, CWLTypeLoader, @@ -24974,12 +21378,46 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | None + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | None + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | stderr + | stdout + | str + ] +] = _UnionLoader( ( None_type, CWLTypeLoader, @@ -24992,72 +21430,110 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | None + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | stderr + | stdout + | str + ] +] = _TypeDSLLoader( union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -CommandLineTool_classLoader = _EnumLoader(("CommandLineTool",), "CommandLineTool_class") -uri_CommandLineTool_classLoader_False_True_None_None = _URILoader( - CommandLineTool_classLoader, False, True, None, None -) -array_of_CommandInputParameterLoader = _ArrayLoader(CommandInputParameterLoader) -idmap_inputs_array_of_CommandInputParameterLoader = _IdMapLoader( - array_of_CommandInputParameterLoader, "id", "type" +CommandLineTool_class: TypeAlias = Literal["CommandLineTool"] +CommandLineTool_classLoader: Final[_Loader[CommandLineTool_class]] = _EnumLoader( + ("CommandLineTool",), "CommandLineTool_class" ) -array_of_CommandOutputParameterLoader = _ArrayLoader(CommandOutputParameterLoader) -idmap_outputs_array_of_CommandOutputParameterLoader = _IdMapLoader( - array_of_CommandOutputParameterLoader, "id", "type" -) -union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = _UnionLoader( +uri_CommandLineTool_classLoader_False_True_None_None: Final[ + _Loader[CommandLineTool_class] +] = _URILoader(CommandLineTool_classLoader, False, True, None, None) +array_of_CommandInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter]] +] = _ArrayLoader(CommandInputParameterLoader) +idmap_inputs_array_of_CommandInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter]] +] = _IdMapLoader(array_of_CommandInputParameterLoader, "id", "type") +array_of_CommandOutputParameterLoader: Final[ + _Loader[Sequence[CommandOutputParameter]] +] = _ArrayLoader(CommandOutputParameterLoader) +idmap_outputs_array_of_CommandOutputParameterLoader: Final[ + _Loader[Sequence[CommandOutputParameter]] +] = _IdMapLoader(array_of_CommandOutputParameterLoader, "id", "type") +union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[CommandLineBinding | str] +] = _UnionLoader( ( strtype, ExpressionLoader, CommandLineBindingLoader, ) ) -array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = ( - _ArrayLoader(union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader) -) -union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = _UnionLoader( +array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[Sequence[CommandLineBinding | str]] +] = _ArrayLoader(union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader) +union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[None | Sequence[CommandLineBinding | str]] +] = _UnionLoader( ( None_type, array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, ) ) -array_of_inttype = _ArrayLoader(inttype) -union_of_None_type_or_array_of_inttype = _UnionLoader( - ( - None_type, - array_of_inttype, +array_of_inttype: Final[_Loader[Sequence[i32]]] = _ArrayLoader(inttype) +union_of_None_type_or_array_of_inttype: Final[_Loader[None | Sequence[i32]]] = ( + _UnionLoader( + ( + None_type, + array_of_inttype, + ) ) ) -DockerRequirement_classLoader = _EnumLoader( +DockerRequirement_class: TypeAlias = Literal["DockerRequirement"] +DockerRequirement_classLoader: Final[_Loader[DockerRequirement_class]] = _EnumLoader( ("DockerRequirement",), "DockerRequirement_class" ) -uri_DockerRequirement_classLoader_False_True_None_None = _URILoader( - DockerRequirement_classLoader, False, True, None, None -) -SoftwareRequirement_classLoader = _EnumLoader( - ("SoftwareRequirement",), "SoftwareRequirement_class" +uri_DockerRequirement_classLoader_False_True_None_None: Final[ + _Loader[DockerRequirement_class] +] = _URILoader(DockerRequirement_classLoader, False, True, None, None) +SoftwareRequirement_class: TypeAlias = Literal["SoftwareRequirement"] +SoftwareRequirement_classLoader: Final[_Loader[SoftwareRequirement_class]] = ( + _EnumLoader(("SoftwareRequirement",), "SoftwareRequirement_class") ) -uri_SoftwareRequirement_classLoader_False_True_None_None = _URILoader( - SoftwareRequirement_classLoader, False, True, None, None +uri_SoftwareRequirement_classLoader_False_True_None_None: Final[ + _Loader[SoftwareRequirement_class] +] = _URILoader(SoftwareRequirement_classLoader, False, True, None, None) +array_of_SoftwarePackageLoader: Final[_Loader[Sequence[SoftwarePackage]]] = ( + _ArrayLoader(SoftwarePackageLoader) ) -array_of_SoftwarePackageLoader = _ArrayLoader(SoftwarePackageLoader) -idmap_packages_array_of_SoftwarePackageLoader = _IdMapLoader( - array_of_SoftwarePackageLoader, "package", "specs" -) -uri_union_of_None_type_or_array_of_strtype_False_False_None_True = _URILoader( - union_of_None_type_or_array_of_strtype, False, False, None, True -) -InitialWorkDirRequirement_classLoader = _EnumLoader( - ("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class" -) -uri_InitialWorkDirRequirement_classLoader_False_True_None_None = _URILoader( - InitialWorkDirRequirement_classLoader, False, True, None, None -) -union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader = _UnionLoader( +idmap_packages_array_of_SoftwarePackageLoader: Final[ + _Loader[Sequence[SoftwarePackage]] +] = _IdMapLoader(array_of_SoftwarePackageLoader, "package", "specs") +uri_union_of_None_type_or_array_of_strtype_False_False_None_True: Final[ + _Loader[None | Sequence[str]] +] = _URILoader(union_of_None_type_or_array_of_strtype, False, False, None, True) +InitialWorkDirRequirement_class: TypeAlias = Literal["InitialWorkDirRequirement"] +InitialWorkDirRequirement_classLoader: Final[ + _Loader[InitialWorkDirRequirement_class] +] = _EnumLoader(("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class") +uri_InitialWorkDirRequirement_classLoader_False_True_None_None: Final[ + _Loader[InitialWorkDirRequirement_class] +] = _URILoader(InitialWorkDirRequirement_classLoader, False, True, None, None) +union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader: ( + Final[_Loader[Directory | Dirent | File | str]] +) = _UnionLoader( ( FileLoader, DirectoryLoader, @@ -25066,39 +21542,61 @@ def save( ExpressionLoader, ) ) -array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader = _ArrayLoader( +array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader: Final[ + _Loader[Sequence[Directory | Dirent | File | str]] +] = _ArrayLoader( union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader ) -union_of_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader_or_strtype_or_ExpressionLoader = _UnionLoader( +union_of_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader_or_strtype_or_ExpressionLoader: Final[ + _Loader[Sequence[Directory | Dirent | File | str] | str] +] = _UnionLoader( ( array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader, strtype, ExpressionLoader, ) ) -EnvVarRequirement_classLoader = _EnumLoader( +EnvVarRequirement_class: TypeAlias = Literal["EnvVarRequirement"] +EnvVarRequirement_classLoader: Final[_Loader[EnvVarRequirement_class]] = _EnumLoader( ("EnvVarRequirement",), "EnvVarRequirement_class" ) -uri_EnvVarRequirement_classLoader_False_True_None_None = _URILoader( - EnvVarRequirement_classLoader, False, True, None, None +uri_EnvVarRequirement_classLoader_False_True_None_None: Final[ + _Loader[EnvVarRequirement_class] +] = _URILoader(EnvVarRequirement_classLoader, False, True, None, None) +array_of_EnvironmentDefLoader: Final[_Loader[Sequence[EnvironmentDef]]] = _ArrayLoader( + EnvironmentDefLoader ) -array_of_EnvironmentDefLoader = _ArrayLoader(EnvironmentDefLoader) -idmap_envDef_array_of_EnvironmentDefLoader = _IdMapLoader( - array_of_EnvironmentDefLoader, "envName", "envValue" +idmap_envDef_array_of_EnvironmentDefLoader: Final[_Loader[Sequence[EnvironmentDef]]] = ( + _IdMapLoader(array_of_EnvironmentDefLoader, "envName", "envValue") ) -ShellCommandRequirement_classLoader = _EnumLoader( - ("ShellCommandRequirement",), "ShellCommandRequirement_class" +ShellCommandRequirement_class: TypeAlias = Literal["ShellCommandRequirement"] +ShellCommandRequirement_classLoader: Final[_Loader[ShellCommandRequirement_class]] = ( + _EnumLoader(("ShellCommandRequirement",), "ShellCommandRequirement_class") ) -uri_ShellCommandRequirement_classLoader_False_True_None_None = _URILoader( - ShellCommandRequirement_classLoader, False, True, None, None +uri_ShellCommandRequirement_classLoader_False_True_None_None: Final[ + _Loader[ShellCommandRequirement_class] +] = _URILoader(ShellCommandRequirement_classLoader, False, True, None, None) +ResourceRequirement_class: TypeAlias = Literal["ResourceRequirement"] +ResourceRequirement_classLoader: Final[_Loader[ResourceRequirement_class]] = ( + _EnumLoader(("ResourceRequirement",), "ResourceRequirement_class") ) -ResourceRequirement_classLoader = _EnumLoader( - ("ResourceRequirement",), "ResourceRequirement_class" -) -uri_ResourceRequirement_classLoader_False_True_None_None = _URILoader( - ResourceRequirement_classLoader, False, True, None, None +uri_ResourceRequirement_classLoader_False_True_None_None: Final[ + _Loader[ResourceRequirement_class] +] = _URILoader(ResourceRequirement_classLoader, False, True, None, None) +union_of_None_type_or_inttype_or_longtype_or_strtype_or_ExpressionLoader: Final[ + _Loader[None | i32 | i64 | str] +] = _UnionLoader( + ( + None_type, + inttype, + longtype, + strtype, + ExpressionLoader, + ) ) -union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader: Final[ + _Loader[None | i32 | str] +] = _UnionLoader( ( None_type, inttype, @@ -25106,7 +21604,29 @@ def save( ExpressionLoader, ) ) -union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_None_type_or_longtype_or_strtype_or_ExpressionLoader: Final[ + _Loader[None | i64 | str] +] = _UnionLoader( + ( + None_type, + longtype, + strtype, + ExpressionLoader, + ) +) +union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | None + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( None_type, CWLTypeLoader, @@ -25117,193 +21637,213 @@ def save( array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | None + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -ExpressionTool_classLoader = _EnumLoader(("ExpressionTool",), "ExpressionTool_class") -uri_ExpressionTool_classLoader_False_True_None_None = _URILoader( - ExpressionTool_classLoader, False, True, None, None -) -array_of_ExpressionToolOutputParameterLoader = _ArrayLoader( - ExpressionToolOutputParameterLoader +ExpressionTool_class: TypeAlias = Literal["ExpressionTool"] +ExpressionTool_classLoader: Final[_Loader[ExpressionTool_class]] = _EnumLoader( + ("ExpressionTool",), "ExpressionTool_class" ) -idmap_outputs_array_of_ExpressionToolOutputParameterLoader = _IdMapLoader( - array_of_ExpressionToolOutputParameterLoader, "id", "type" -) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None -) -union_of_None_type_or_LinkMergeMethodLoader = _UnionLoader( - ( - None_type, - LinkMergeMethodLoader, +uri_ExpressionTool_classLoader_False_True_None_None: Final[ + _Loader[ExpressionTool_class] +] = _URILoader(ExpressionTool_classLoader, False, True, None, None) +array_of_ExpressionToolOutputParameterLoader: Final[ + _Loader[Sequence[ExpressionToolOutputParameter]] +] = _ArrayLoader(ExpressionToolOutputParameterLoader) +idmap_outputs_array_of_ExpressionToolOutputParameterLoader: Final[ + _Loader[Sequence[ExpressionToolOutputParameter]] +] = _IdMapLoader(array_of_ExpressionToolOutputParameterLoader, "id", "type") +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None) +union_of_None_type_or_LinkMergeMethodLoader: Final[_Loader[LinkMergeMethod | None]] = ( + _UnionLoader( + ( + None_type, + LinkMergeMethodLoader, + ) ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None -) -array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader) -idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader( - array_of_WorkflowStepInputLoader, "id", "source" +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None) +array_of_WorkflowStepInputLoader: Final[_Loader[Sequence[WorkflowStepInput]]] = ( + _ArrayLoader(WorkflowStepInputLoader) ) -union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( +idmap_in__array_of_WorkflowStepInputLoader: Final[ + _Loader[Sequence[WorkflowStepInput]] +] = _IdMapLoader(array_of_WorkflowStepInputLoader, "id", "source") +union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[WorkflowStepOutput | str] +] = _UnionLoader( ( strtype, WorkflowStepOutputLoader, ) ) -array_of_union_of_strtype_or_WorkflowStepOutputLoader = _ArrayLoader( - union_of_strtype_or_WorkflowStepOutputLoader -) -union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( - (array_of_union_of_strtype_or_WorkflowStepOutputLoader,) -) -uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None = _URILoader( +array_of_union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _ArrayLoader(union_of_strtype_or_WorkflowStepOutputLoader) +union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _UnionLoader((array_of_union_of_strtype_or_WorkflowStepOutputLoader,)) +uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _URILoader( union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, True, False, None, None, ) -array_of_Any_type = _ArrayLoader(Any_type) -union_of_None_type_or_array_of_Any_type = _UnionLoader( - ( - None_type, - array_of_Any_type, +array_of_Any_type: Final[_Loader[Sequence[Any]]] = _ArrayLoader(Any_type) +union_of_None_type_or_array_of_Any_type: Final[_Loader[None | Sequence[Any]]] = ( + _UnionLoader( + ( + None_type, + array_of_Any_type, + ) ) ) -idmap_hints_union_of_None_type_or_array_of_Any_type = _IdMapLoader( - union_of_None_type_or_array_of_Any_type, "class", "None" -) -union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _UnionLoader( +idmap_hints_union_of_None_type_or_array_of_Any_type: Final[ + _Loader[None | Sequence[Any]] +] = _IdMapLoader(union_of_None_type_or_array_of_Any_type, "class", "None") +union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: ( + Final[_Loader[CommandLineTool | ExpressionTool | Workflow | str]] +) = _UnionLoader( ( strtype, CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, - ProcessGeneratorLoader, ) ) -uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_False_False_None_None = _URILoader( - union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, +uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None: Final[ + _Loader[CommandLineTool | ExpressionTool | Workflow | str] +] = _URILoader( + union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, False, False, None, None, ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None -) -union_of_None_type_or_ScatterMethodLoader = _UnionLoader( - ( - None_type, - ScatterMethodLoader, +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None) +union_of_None_type_or_ScatterMethodLoader: Final[_Loader[None | ScatterMethod]] = ( + _UnionLoader( + ( + None_type, + ScatterMethodLoader, + ) ) ) -uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None = _URILoader( - union_of_None_type_or_ScatterMethodLoader, False, True, None, None +uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None: Final[ + _Loader[None | ScatterMethod] +] = _URILoader(union_of_None_type_or_ScatterMethodLoader, False, True, None, None) +Workflow_class: TypeAlias = Literal["Workflow"] +Workflow_classLoader: Final[_Loader[Workflow_class]] = _EnumLoader( + ("Workflow",), "Workflow_class" ) -Workflow_classLoader = _EnumLoader(("Workflow",), "Workflow_class") -uri_Workflow_classLoader_False_True_None_None = _URILoader( - Workflow_classLoader, False, True, None, None +uri_Workflow_classLoader_False_True_None_None: Final[_Loader[Workflow_class]] = ( + _URILoader(Workflow_classLoader, False, True, None, None) ) -array_of_WorkflowOutputParameterLoader = _ArrayLoader(WorkflowOutputParameterLoader) -idmap_outputs_array_of_WorkflowOutputParameterLoader = _IdMapLoader( - array_of_WorkflowOutputParameterLoader, "id", "type" +array_of_WorkflowOutputParameterLoader: Final[ + _Loader[Sequence[WorkflowOutputParameter]] +] = _ArrayLoader(WorkflowOutputParameterLoader) +idmap_outputs_array_of_WorkflowOutputParameterLoader: Final[ + _Loader[Sequence[WorkflowOutputParameter]] +] = _IdMapLoader(array_of_WorkflowOutputParameterLoader, "id", "type") +array_of_WorkflowStepLoader: Final[_Loader[Sequence[WorkflowStep]]] = _ArrayLoader( + WorkflowStepLoader ) -array_of_WorkflowStepLoader = _ArrayLoader(WorkflowStepLoader) -union_of_array_of_WorkflowStepLoader = _UnionLoader((array_of_WorkflowStepLoader,)) -idmap_steps_union_of_array_of_WorkflowStepLoader = _IdMapLoader( - union_of_array_of_WorkflowStepLoader, "id", "None" +union_of_array_of_WorkflowStepLoader: Final[_Loader[Sequence[WorkflowStep]]] = ( + _UnionLoader((array_of_WorkflowStepLoader,)) ) -SubworkflowFeatureRequirement_classLoader = _EnumLoader( +idmap_steps_union_of_array_of_WorkflowStepLoader: Final[ + _Loader[Sequence[WorkflowStep]] +] = _IdMapLoader(union_of_array_of_WorkflowStepLoader, "id", "None") +SubworkflowFeatureRequirement_class: TypeAlias = Literal[ + "SubworkflowFeatureRequirement" +] +SubworkflowFeatureRequirement_classLoader: Final[ + _Loader[SubworkflowFeatureRequirement_class] +] = _EnumLoader( ("SubworkflowFeatureRequirement",), "SubworkflowFeatureRequirement_class" ) -uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None = _URILoader( - SubworkflowFeatureRequirement_classLoader, False, True, None, None -) -ScatterFeatureRequirement_classLoader = _EnumLoader( - ("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class" -) -uri_ScatterFeatureRequirement_classLoader_False_True_None_None = _URILoader( - ScatterFeatureRequirement_classLoader, False, True, None, None -) -MultipleInputFeatureRequirement_classLoader = _EnumLoader( +uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[SubworkflowFeatureRequirement_class] +] = _URILoader(SubworkflowFeatureRequirement_classLoader, False, True, None, None) +ScatterFeatureRequirement_class: TypeAlias = Literal["ScatterFeatureRequirement"] +ScatterFeatureRequirement_classLoader: Final[ + _Loader[ScatterFeatureRequirement_class] +] = _EnumLoader(("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class") +uri_ScatterFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[ScatterFeatureRequirement_class] +] = _URILoader(ScatterFeatureRequirement_classLoader, False, True, None, None) +MultipleInputFeatureRequirement_class: TypeAlias = Literal[ + "MultipleInputFeatureRequirement" +] +MultipleInputFeatureRequirement_classLoader: Final[ + _Loader[MultipleInputFeatureRequirement_class] +] = _EnumLoader( ("MultipleInputFeatureRequirement",), "MultipleInputFeatureRequirement_class" ) -uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None = _URILoader( - MultipleInputFeatureRequirement_classLoader, False, True, None, None -) -StepInputExpressionRequirement_classLoader = _EnumLoader( +uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[MultipleInputFeatureRequirement_class] +] = _URILoader(MultipleInputFeatureRequirement_classLoader, False, True, None, None) +StepInputExpressionRequirement_class: TypeAlias = Literal[ + "StepInputExpressionRequirement" +] +StepInputExpressionRequirement_classLoader: Final[ + _Loader[StepInputExpressionRequirement_class] +] = _EnumLoader( ("StepInputExpressionRequirement",), "StepInputExpressionRequirement_class" ) -uri_StepInputExpressionRequirement_classLoader_False_True_None_None = _URILoader( - StepInputExpressionRequirement_classLoader, False, True, None, None -) -uri_strtype_False_True_None_None = _URILoader(strtype, False, True, None, None) -LoadListingEnumLoader = _EnumLoader( - ( - "no_listing", - "shallow_listing", - "deep_listing", - ), - "LoadListingEnum", -) -union_of_LoadListingEnumLoader = _UnionLoader((LoadListingEnumLoader,)) -uri_array_of_strtype_False_False_0_None = _URILoader( - array_of_strtype, False, False, 0, None -) -union_of_inttype_or_strtype = _UnionLoader( - ( - inttype, - strtype, - ) -) -union_of_booltype_or_strtype = _UnionLoader( - ( - booltype, - strtype, - ) -) -union_of_inttype_or_ExpressionLoader = _UnionLoader( - ( - inttype, - ExpressionLoader, - ) -) -union_of_strtype_or_array_of_strtype = _UnionLoader( - ( - strtype, - array_of_strtype, - ) -) -union_of_None_type_or_inttype_or_ExpressionLoader = _UnionLoader( - ( - None_type, - inttype, - ExpressionLoader, - ) -) -union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _UnionLoader( +uri_StepInputExpressionRequirement_classLoader_False_True_None_None: Final[ + _Loader[StepInputExpressionRequirement_class] +] = _URILoader(StepInputExpressionRequirement_classLoader, False, True, None, None) +union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: Final[ + _Loader[CommandLineTool | ExpressionTool | Workflow] +] = _UnionLoader( ( CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, - ProcessGeneratorLoader, ) ) -array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _ArrayLoader( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader +array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: ( + Final[_Loader[Sequence[CommandLineTool | ExpressionTool | Workflow]]] +) = _ArrayLoader( + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader ) -union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _UnionLoader( +union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: Final[ + _Loader[ + CommandLineTool + | ExpressionTool + | Sequence[CommandLineTool | ExpressionTool | Workflow] + | Workflow + ] +] = _UnionLoader( ( CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, - ProcessGeneratorLoader, - array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, ) ) @@ -25319,19 +21859,45 @@ def save( map_of_union_of_None_type_or_CWLObjectTypeLoader, ) ) +CWLObjectType: TypeAlias = ( + "Directory | File | Mapping[str, CWLObjectType | None] | Sequence[CWLObjectType | None] | bool | float | i32 | str" +) + +Parameter: TypeAlias = InputParameter | OutputParameter +InputBinding: TypeAlias = CommandLineBinding +OutputBinding: TypeAlias = CommandOutputBinding +InputSchema: TypeAlias = InputArraySchema | InputEnumSchema | InputRecordSchema +OutputSchema: TypeAlias = OutputArraySchema | OutputEnumSchema | OutputRecordSchema +ProcessRequirement: TypeAlias = ( + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | MultipleInputFeatureRequirement + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement +) +Process: TypeAlias = CommandLineTool | ExpressionTool | Workflow +Sink: TypeAlias = WorkflowStepInput +SchemaBase: TypeAlias = InputSchema | OutputSchema | Parameter def load_document( doc: Any, - baseuri: Optional[str] = None, - loadingOptions: Optional[LoadingOptions] = None, + baseuri: str | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: if baseuri is None: baseuri = file_uri(os.getcwd()) + "/" if loadingOptions is None: loadingOptions = LoadingOptions() result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, doc, baseuri, loadingOptions, @@ -25341,16 +21907,16 @@ def load_document( def load_document_with_metadata( doc: Any, - baseuri: Optional[str] = None, - loadingOptions: Optional[LoadingOptions] = None, - addl_metadata_fields: Optional[MutableSequence[str]] = None, + baseuri: str | None = None, + loadingOptions: LoadingOptions | None = None, + addl_metadata_fields: MutableSequence[str] | None = None, ) -> Any: if baseuri is None: baseuri = file_uri(os.getcwd()) + "/" if loadingOptions is None: loadingOptions = LoadingOptions(fileuri=baseuri) return _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, doc, baseuri, loadingOptions, @@ -25361,7 +21927,7 @@ def load_document_with_metadata( def load_document_by_string( string: Any, uri: str, - loadingOptions: Optional[LoadingOptions] = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: yaml = yaml_no_ts() result = yaml.load(string) @@ -25371,7 +21937,7 @@ def load_document_by_string( loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, result, uri, loadingOptions, @@ -25382,7 +21948,7 @@ def load_document_by_string( def load_document_by_yaml( yaml: Any, uri: str, - loadingOptions: Optional[LoadingOptions] = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """ Shortcut to load via a YAML object. @@ -25394,7 +21960,7 @@ def load_document_by_yaml( loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, yaml, uri, loadingOptions, diff --git a/src/cwl_utils/parser/cwl_v1_0_utils.py b/src/cwl_utils/parser/cwl_v1_0_utils.py index 4f4dfd5f..74e00c91 100644 --- a/src/cwl_utils/parser/cwl_v1_0_utils.py +++ b/src/cwl_utils/parser/cwl_v1_0_utils.py @@ -2,13 +2,15 @@ import hashlib import logging from collections import namedtuple -from collections.abc import MutableMapping, MutableSequence +from collections.abc import MutableMapping, MutableSequence, Sequence, Mapping from io import StringIO from pathlib import Path -from typing import IO, Any, cast +from typing import IO, Any, TypeAlias, TypeVar from urllib.parse import urldefrag from schema_salad.exceptions import ValidationException +from schema_salad.metaschema import ArraySchema, RecordSchema, EnumSchema +from schema_salad.runtime import save, LoadingOptions, shortname, file_uri from schema_salad.sourceline import SourceLine, add_lc_filename from schema_salad.utils import aslist, json_dumps, yaml_no_ts @@ -16,6 +18,7 @@ import cwl_utils.parser.cwl_v1_0 as cwl import cwl_utils.parser.utils from cwl_utils.errors import WorkflowException +from cwl_utils.types import is_sequence from cwl_utils.utils import yaml_dumps CONTENT_LIMIT: int = 64 * 1024 @@ -24,50 +27,91 @@ SrcSink = namedtuple("SrcSink", ["src", "sink", "linkMerge", "message"]) - -def _compare_records( - src: cwl.RecordSchema, sink: cwl.RecordSchema, strict: bool = False -) -> bool: - """ - Compare two records, ensuring they have compatible fields. - - This handles normalizing record names, which will be relative to workflow - step, so that they can be compared. - """ - srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})} - sinkfields = { - cwl.shortname(field.name): field.type_ for field in (sink.fields or {}) - } - for key in sinkfields.keys(): - if ( - not can_assign_src_to_sink( - srcfields.get(key, "null"), sinkfields.get(key, "null"), strict +BasicInputTypeSchemas: TypeAlias = cwl.InputSchema | str | cwl.CWLType +InputTypeSchemas: TypeAlias = BasicInputTypeSchemas | Sequence[BasicInputTypeSchemas] +BasicCommandInputTypeSchemas: TypeAlias = ( + cwl.CommandInputArraySchema + | cwl.CommandInputEnumSchema + | cwl.CommandInputRecordSchema + | str + | cwl.CWLType +) +CommandInputTypeSchemas: TypeAlias = ( + BasicCommandInputTypeSchemas | Sequence[BasicCommandInputTypeSchemas] +) +BasicOutputTypeSchemas: TypeAlias = cwl.OutputSchema | str | cwl.CWLType +OutputTypeSchemas: TypeAlias = BasicOutputTypeSchemas | Sequence[BasicOutputTypeSchemas] +BasicCommandOutputTypeSchemas: TypeAlias = ( + cwl.CommandOutputArraySchema + | cwl.CommandOutputEnumSchema + | cwl.CommandOutputRecordSchema + | str + | cwl.CWLType +) +CommandOutputTypeSchemas: TypeAlias = ( + BasicCommandOutputTypeSchemas | Sequence[BasicCommandOutputTypeSchemas] +) +AnyTypeSchema = TypeVar( + "AnyTypeSchema", bound=InputTypeSchemas | CommandOutputTypeSchemas +) + + +def _in_output_type_schema_to_output_type_schema( + schema_type: BasicInputTypeSchemas | BasicOutputTypeSchemas, + loading_options: LoadingOptions, +) -> BasicOutputTypeSchemas: + match schema_type: + case ArraySchema(): + return cwl.OutputArraySchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, ) - and sinkfields.get(key) is not None - ): - _logger.info( - "Record comparison failure for %s and %s\n" - "Did not match fields for %s: %s and %s", - cast(cwl.InputRecordSchema | cwl.CommandOutputRecordSchema, src).name, - cast(cwl.InputRecordSchema | cwl.CommandOutputRecordSchema, sink).name, - key, - srcfields.get(key), - sinkfields.get(key), + case EnumSchema(): + return cwl.OutputEnumSchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, + ) + case RecordSchema(): + return cwl.OutputRecordSchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, ) - return False - return True + case str(): + return schema_type + raise WorkflowException(f"Unexpected output type: {schema_type}.") + + +def in_output_type_schema_to_output_type_schema( + schema_type: ( + BasicInputTypeSchemas + | BasicOutputTypeSchemas + | Sequence[BasicInputTypeSchemas | BasicOutputTypeSchemas] + ), + loading_options: LoadingOptions, +) -> OutputTypeSchemas: + if is_sequence(schema_type): + return [ + _in_output_type_schema_to_output_type_schema( + schema_type_item, loading_options + ) + for schema_type_item in schema_type + ] + return _in_output_type_schema_to_output_type_schema(schema_type, loading_options) def _compare_type(type1: Any, type2: Any) -> bool: match (type1, type1): - case cwl.ArraySchema() as t1, cwl.ArraySchema() as t2: + case ArraySchema() as t1, ArraySchema() as t2: return _compare_type(t1.items, t2.items) - case cwl.RecordSchema(), cwl.RecordSchema(): + case RecordSchema(), RecordSchema(): fields1 = { - cwl.shortname(field.name): field.type_ for field in (type1.fields or {}) + shortname(field.name): field.type_ for field in (type1.fields or {}) } fields2 = { - cwl.shortname(field.name): field.type_ for field in (type2.fields or {}) + shortname(field.name): field.type_ for field in (type2.fields or {}) } if fields1.keys() != fields2.keys(): return False @@ -85,9 +129,9 @@ def _compare_type(type1: Any, type2: Any) -> bool: def _inputfile_load( doc: str | MutableMapping[str, Any] | MutableSequence[Any], baseuri: str, - loadingOptions: cwl.LoadingOptions, + loadingOptions: LoadingOptions, addl_metadata_fields: MutableSequence[str] | None = None, -) -> tuple[Any, cwl.LoadingOptions]: +) -> tuple[Any, LoadingOptions]: loader = cwl.CWLInputFileLoader match doc: case str(): @@ -101,9 +145,7 @@ def _inputfile_load( yaml = yaml_no_ts() result = yaml.load(textIO) add_lc_filename(result, doc_url) - loadingOptions = cwl.LoadingOptions( - copyfrom=loadingOptions, fileuri=doc_url - ) + loadingOptions = LoadingOptions(copyfrom=loadingOptions, fileuri=doc_url) _inputfile_load( result, doc_url, @@ -117,7 +159,7 @@ def _inputfile_load( if mf in doc: addl_metadata[mf] = doc[mf] - loadingOptions = cwl.LoadingOptions( + loadingOptions = LoadingOptions( copyfrom=loadingOptions, baseuri=baseuri, addl_metadata=addl_metadata, @@ -144,45 +186,15 @@ def _inputfile_load( ) -def can_assign_src_to_sink(src: Any, sink: Any, strict: bool = False) -> bool: - """ - Check for identical type specifications, ignoring extra keys like inputBinding. - - src: admissible source types - sink: admissible sink types - - In non-strict comparison, at least one source type must match one sink type, - except for 'null'. - In strict comparison, all source types must match at least one sink type. - """ - if "Any" in (src, sink): - return True - if isinstance(src, cwl.ArraySchema) and isinstance(sink, cwl.ArraySchema): - return can_assign_src_to_sink(src.items, sink.items, strict) - if isinstance(src, cwl.RecordSchema) and isinstance(sink, cwl.RecordSchema): - return _compare_records(src, sink, strict) - if isinstance(src, MutableSequence): - if strict: - for this_src in src: - if not can_assign_src_to_sink(this_src, sink): - return False - return True - for this_src in src: - if this_src != "null" and can_assign_src_to_sink(this_src, sink): - return True - return False - if isinstance(sink, MutableSequence): - for this_sink in sink: - if can_assign_src_to_sink(src, this_sink): - return True - return False - return bool(src == sink) - - def check_all_types( - src_dict: dict[str, Any], - sinks: MutableSequence[cwl.WorkflowStepInput | cwl.WorkflowOutputParameter], - type_dict: dict[str, Any], + src_dict: Mapping[str, cwl.InputParameter | cwl.WorkflowStepOutput], + sinks: Sequence[cwl.WorkflowStepInput | cwl.WorkflowOutputParameter], + type_dict: Mapping[ + str, + cwl_utils.parser.utils.InputTypeSchemas + | cwl_utils.parser.utils.OutputTypeSchemas + | None, + ], ) -> dict[str, list[SrcSink]]: """Given a list of sinks, check if their types match with the types of their sources.""" validation: dict[str, list[SrcSink]] = {"warning": [], "exception": []} @@ -195,9 +207,9 @@ def check_all_types( sourceName = "source" sourceField = sink.source case _: - continue + raise WorkflowException(f"Invalid sink type {sink.__class__.__name__}") if sourceField is not None: - if isinstance(sourceField, MutableSequence): + if is_sequence(sourceField): linkMerge = sink.linkMerge or ( "merge_nested" if len(sourceField) > 1 else None ) @@ -205,7 +217,7 @@ def check_all_types( for parm_id in sourceField: srcs_of_sink += [src_dict[parm_id]] else: - parm_id = cast(str, sourceField) + parm_id = sourceField if parm_id not in src_dict: raise SourceLine(sink, sourceName, ValidationException).makeError( f"{sourceName} not found: {parm_id}" @@ -213,45 +225,17 @@ def check_all_types( srcs_of_sink = [src_dict[parm_id]] linkMerge = None for src in srcs_of_sink: - check_result = check_types( - type_dict[cast(str, src.id)], + check_result = cwl_utils.parser.utils.check_types( + type_dict[src.id], type_dict[sink.id], linkMerge, - getattr(sink, "valueFrom", None), + sink.valueFrom if isinstance(sink, cwl.WorkflowStepInput) else None, ) if check_result in ("warning", "exception"): validation[check_result].append(SrcSink(src, sink, linkMerge, None)) return validation -def check_types( - srctype: Any, - sinktype: Any, - linkMerge: str | None, - valueFrom: str | None = None, -) -> str: - """ - Check if the source and sink types are correct. - - Acceptable types are "pass", "warning", or "exception". - """ - if valueFrom is not None: - return "pass" - if linkMerge is None: - if can_assign_src_to_sink(srctype, sinktype, strict=True): - return "pass" - if can_assign_src_to_sink(srctype, sinktype, strict=False): - return "warning" - return "exception" - if linkMerge == "merge_nested": - return check_types( - cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None - ) - if linkMerge == "merge_flattened": - return check_types(merge_flatten_type(srctype), sinktype, None, None) - raise ValidationException(f"Invalid value {linkMerge} for linkMerge field.") - - def content_limit_respected_read_bytes(f: IO[bytes]) -> bytes: """ Read file content up to 64 kB as a byte array. @@ -300,13 +284,13 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: def load_inputfile( doc: Any, baseuri: str | None = None, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.0 input file from a serialized YAML string or a YAML object.""" if baseuri is None: - baseuri = cwl.file_uri(str(Path.cwd())) + "/" + baseuri = file_uri(str(Path.cwd())) + "/" if loadingOptions is None: - loadingOptions = cwl.LoadingOptions() + loadingOptions = LoadingOptions() result, metadata = _inputfile_load( doc, @@ -319,14 +303,14 @@ def load_inputfile( def load_inputfile_by_string( string: Any, uri: str, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.0 input file from a serialized YAML string.""" result = yaml_no_ts().load(string) add_lc_filename(result, uri) if loadingOptions is None: - loadingOptions = cwl.LoadingOptions(fileuri=uri) + loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _inputfile_load( result, @@ -339,13 +323,13 @@ def load_inputfile_by_string( def load_inputfile_by_yaml( yaml: Any, uri: str, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.0 input file from a YAML object.""" add_lc_filename(yaml, uri) if loadingOptions is None: - loadingOptions = cwl.LoadingOptions(fileuri=uri) + loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _inputfile_load( yaml, @@ -355,93 +339,119 @@ def load_inputfile_by_yaml( return result -def merge_flatten_type(src: Any) -> Any: - """Return the merge flattened type of the source type.""" - if isinstance(src, MutableSequence): - return [merge_flatten_type(t) for t in src] - if isinstance(src, cwl.ArraySchema): - return src - return cwl.ArraySchema(type_="array", items=src) +def to_input_array(type_: InputTypeSchemas) -> cwl.InputArraySchema: + return cwl.InputArraySchema(type_="array", items=type_) + + +def to_output_array(type_: OutputTypeSchemas) -> cwl.OutputArraySchema: + return cwl.OutputArraySchema(type_="array", items=type_) def type_for_step_input( step: cwl.WorkflowStep, in_: cwl.WorkflowStepInput, -) -> Any: +) -> cwl_utils.parser.utils.InputTypeSchemas | None: """Determine the type for the given step input.""" if in_.valueFrom is not None: return "Any" step_run = cwl_utils.parser.utils.load_step(step) cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - if step_run and step_run.inputs: - for step_input in step_run.inputs: - if cast(str, step_input.id).split("#")[-1] == in_.id.split("#")[-1]: - input_type = step_input.type_ - if step.scatter is not None and in_.id in aslist(step.scatter): - input_type = cwl.ArraySchema(items=input_type, type_="array") - return input_type + for step_input in step_run.inputs: + if step_input.id.split("#")[-1] == in_.id.split("#")[-1]: + input_type = step_input.type_ + if ( + input_type is not None + and step.scatter is not None + and in_.id in aslist(step.scatter) + ): + input_type = cwl_utils.parser.utils.to_input_array( + input_type, step_run.cwlVersion or "v1.0" + ) + return input_type return "Any" def type_for_step_output( step: cwl.WorkflowStep, sourcename: str, -) -> Any: +) -> cwl_utils.parser.utils.OutputTypeSchemas | None: """Determine the type for the given step output.""" step_run = cwl_utils.parser.utils.load_step(step) cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - if step_run and step_run.outputs: - for step_output in step_run.outputs: - if ( - step_output.id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - output_type = step_output.type_ - if step.scatter is not None: - if step.scatterMethod == "nested_crossproduct": - for _ in range(len(aslist(step.scatter))): - output_type = cwl.ArraySchema( - items=output_type, type_="array" - ) - else: - output_type = cwl.ArraySchema(items=output_type, type_="array") - return output_type + for output in step_run.outputs: + if ( + output.id.split("#")[-1].split("/")[-1] + == sourcename.split("#")[-1].split("/")[-1] + ): + output_type = output.type_ + if output_type is not None and step.scatter is not None: + if step.scatterMethod == "nested_crossproduct": + for _ in range(len(aslist(step.scatter))): + output_type = cwl_utils.parser.utils.to_output_array( + output_type, step_run.cwlVersion or "v1.0" + ) + else: + output_type = cwl_utils.parser.utils.to_output_array( + output_type, step_run.cwlVersion or "v1.0" + ) + return output_type raise ValidationException( "param {} not found in {}.".format( sourcename, - yaml_dumps(cwl.save(step)), + yaml_dumps(save(step)), ) ) def type_for_source( - process: cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool, - sourcenames: str | list[str], + process: cwl.Process, + sourcenames: str | Sequence[str], parent: cwl.Workflow | None = None, linkMerge: str | None = None, -) -> Any: +) -> ( + MutableSequence[InputTypeSchemas | OutputTypeSchemas] + | InputTypeSchemas + | OutputTypeSchemas +): """Determine the type for the given sourcenames.""" scatter_context: list[tuple[int, str] | None] = [] - params = param_for_source_id(process, sourcenames, parent, scatter_context) + params = cwl_utils.parser.utils.param_for_source_id( + process, sourcenames, parent, scatter_context + ) if not isinstance(params, MutableSequence): - new_type = params.type_ + new_type: InputTypeSchemas | OutputTypeSchemas = params.type_ if scatter_context[0] is not None: if scatter_context[0][1] == "nested_crossproduct": for _ in range(scatter_context[0][0]): - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) else: - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) elif linkMerge == "merge_flattened": - new_type = merge_flatten_type(new_type) + new_type = cwl_utils.parser.utils.merge_flatten_type(new_type) return new_type - new_type = [] + new_types: MutableSequence[InputTypeSchemas | OutputTypeSchemas] = [] for p, sc in zip(params, scatter_context): - if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type): + if isinstance(p, str) and not any(_compare_type(t, p) for t in new_types): cur_type = p elif hasattr(p, "type_") and not any( - _compare_type(t, p.type_) for t in new_type + _compare_type(t, p.type_) for t in new_types ): cur_type = p.type_ else: @@ -450,102 +460,38 @@ def type_for_source( if sc is not None: if sc[1] == "nested_crossproduct": for _ in range(sc[0]): - cur_type = cwl.ArraySchema(items=cur_type, type_="array") + cur_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + cur_type, process.loadingOptions + ), + type_="array", + ) else: - cur_type = cwl.ArraySchema(items=cur_type, type_="array") - new_type.append(cur_type) - if len(new_type) == 1: - new_type = new_type[0] + cur_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + cur_type, process.loadingOptions + ), + type_="array", + ) + new_types.append(cur_type) + if len(new_types) == 1: + final_type: ( + MutableSequence[InputTypeSchemas | OutputTypeSchemas] + | InputTypeSchemas + | OutputTypeSchemas + ) = new_types[0] + else: + final_type = new_types if linkMerge == "merge_nested": - return cwl.ArraySchema(items=new_type, type_="array") + final_type = cwl.OutputArraySchema( + items=final_type, + type_="array", + ) elif linkMerge == "merge_flattened": - return merge_flatten_type(new_type) + final_type = cwl_utils.parser.utils.merge_flatten_type(final_type) elif isinstance(sourcenames, list) and len(sourcenames) > 1: - return cwl.ArraySchema(items=new_type, type_="array") - return new_type - - -def param_for_source_id( - process: cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool, - sourcenames: str | list[str], - parent: cwl.Workflow | None = None, - scatter_context: list[tuple[int, str] | None] | None = None, -) -> ( - cwl.InputParameter - | cwl.CommandOutputParameter - | MutableSequence[cwl.InputParameter | cwl.CommandOutputParameter] -): - """Find the process input parameter that matches one of the given sourcenames.""" - if isinstance(sourcenames, str): - sourcenames = [sourcenames] - params: MutableSequence[cwl.InputParameter | cwl.CommandOutputParameter] = [] - for sourcename in sourcenames: - if not isinstance(process, cwl.Workflow): - for param in process.inputs: - if param.id.split("#")[-1] == sourcename.split("#")[-1]: - params.append(param) - if scatter_context is not None: - scatter_context.append(None) - targets = [process] - if parent: - targets.append(parent) - for target in targets: - if isinstance(target, cwl.Workflow): - for inp in target.inputs: - if inp.id.split("#")[-1] == sourcename.split("#")[-1]: - params.append(inp) - if scatter_context is not None: - scatter_context.append(None) - for step in target.steps: - if ( - "/".join(sourcename.split("#")[-1].split("/")[:-1]) - == step.id.split("#")[-1] - and step.out - ): - step_run = cwl_utils.parser.utils.load_step(step) - cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - for outp in step.out: - outp_id = outp if isinstance(outp, str) else outp.id - if ( - outp_id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - if step_run and step_run.outputs: - for output in step_run.outputs: - if ( - output.id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - params.append(output) - if scatter_context is not None: - if isinstance(step.scatter, str): - scatter_context.append( - ( - 1, - step.scatterMethod - or "dotproduct", - ) - ) - elif isinstance( - step.scatter, MutableSequence - ): - scatter_context.append( - ( - len(step.scatter), - step.scatterMethod - or "dotproduct", - ) - ) - else: - scatter_context.append(None) - if len(params) == 1: - return params[0] - elif len(params) > 1: - return params - raise WorkflowException( - "param {} not found in {}\n{}.".format( - sourcename, - yaml_dumps(cwl.save(process)), - (f" or\n {yaml_dumps(cwl.save(parent))}" if parent is not None else ""), + return cwl.OutputArraySchema( + items=final_type, + type_="array", ) - ) + return final_type diff --git a/src/cwl_utils/parser/cwl_v1_1.py b/src/cwl_utils/parser/cwl_v1_1.py index 744cba7f..3828fe70 100644 --- a/src/cwl_utils/parser/cwl_v1_1.py +++ b/src/cwl_utils/parser/cwl_v1_1.py @@ -2,460 +2,92 @@ # This file was autogenerated using schema-salad-tool --codegen=python # The code itself is released under the Apache 2.0 license and the help text is # subject to the license of the original schema. +from __future__ import annotations -import copy -import logging import os -import pathlib -import tempfile -import uuid as _uuid__ # pylint: disable=unused-import # noqa: F401 -import xml.sax # nosec -from abc import ABC, abstractmethod -from collections.abc import MutableMapping, MutableSequence, Sequence +import sys +import uuid as _uuid__ +from collections.abc import Collection +from typing import ClassVar + +from schema_salad.runtime import ( + Saveable, + file_uri, + parse_errors, + prefix_url, + save, + save_relative_uri, +) + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +import schema_salad.metaschema + +import copy +from abc import ABCMeta, abstractmethod +from collections.abc import MutableSequence, Sequence, MutableMapping from io import StringIO from itertools import chain -from typing import Any, Final, Optional, Union, cast -from urllib.parse import quote, urldefrag, urlparse, urlsplit, urlunsplit -from urllib.request import pathname2url - -from rdflib import Graph -from rdflib.plugins.parsers.notation3 import BadSyntax +from typing import Literal, TypeVar # pylint: disable=unused-import # noqa: F401 +from collections.abc import Mapping +from typing import TypeAlias # pylint: disable=unused-import # noqa: F401 +from typing import Any, Final, cast, Generic +from urllib.parse import urldefrag, urlsplit, urlunsplit + +from mypy_extensions import i32, i64 # pylint: disable=unused-import # noqa: F401 +from mypy_extensions import mypyc_attr from ruamel.yaml.comments import CommentedMap -from schema_salad.exceptions import SchemaSaladException, ValidationException -from schema_salad.fetcher import DefaultFetcher, Fetcher, MemoryCachingFetcher +from schema_salad.exceptions import ValidationException, SchemaSaladException +from schema_salad.runtime import ( + LoadingOptions, + convert_typing, + extract_type, + SaveableType, + FieldType, + EnumFieldType, +) from schema_salad.sourceline import SourceLine, add_lc_filename -from schema_salad.utils import CacheType, yaml_no_ts # requires schema-salad v8.2+ - -_vocab: dict[str, str] = {} -_rvocab: dict[str, str] = {} - -_logger: Final = logging.getLogger("salad") - - -IdxType = MutableMapping[str, tuple[Any, "LoadingOptions"]] - - -class LoadingOptions: - idx: Final[IdxType] - fileuri: Final[Optional[str]] - baseuri: Final[str] - namespaces: Final[MutableMapping[str, str]] - schemas: Final[MutableSequence[str]] - original_doc: Final[Optional[Any]] - addl_metadata: Final[MutableMapping[str, Any]] - fetcher: Final[Fetcher] - vocab: Final[dict[str, str]] - rvocab: Final[dict[str, str]] - cache: Final[CacheType] - imports: Final[list[str]] - includes: Final[list[str]] - no_link_check: Final[Optional[bool]] - container: Final[Optional[str]] - - def __init__( - self, - fetcher: Optional[Fetcher] = None, - namespaces: Optional[dict[str, str]] = None, - schemas: Optional[list[str]] = None, - fileuri: Optional[str] = None, - copyfrom: Optional["LoadingOptions"] = None, - original_doc: Optional[Any] = None, - addl_metadata: Optional[dict[str, str]] = None, - baseuri: Optional[str] = None, - idx: Optional[IdxType] = None, - imports: Optional[list[str]] = None, - includes: Optional[list[str]] = None, - no_link_check: Optional[bool] = None, - container: Optional[str] = None, - ) -> None: - """Create a LoadingOptions object.""" - self.original_doc = original_doc - - if idx is not None: - temp_idx = idx - else: - temp_idx = copyfrom.idx if copyfrom is not None else {} - self.idx = temp_idx - - if fileuri is not None: - temp_fileuri: Optional[str] = fileuri - else: - temp_fileuri = copyfrom.fileuri if copyfrom is not None else None - self.fileuri = temp_fileuri - - if baseuri is not None: - temp_baseuri = baseuri - else: - temp_baseuri = copyfrom.baseuri if copyfrom is not None else "" - self.baseuri = temp_baseuri - - if namespaces is not None: - temp_namespaces: MutableMapping[str, str] = namespaces - else: - temp_namespaces = copyfrom.namespaces if copyfrom is not None else {} - self.namespaces = temp_namespaces - - if schemas is not None: - temp_schemas: MutableSequence[str] = schemas - else: - temp_schemas = copyfrom.schemas if copyfrom is not None else [] - self.schemas = temp_schemas - - if addl_metadata is not None: - temp_addl_metadata: MutableMapping[str, Any] = addl_metadata - else: - temp_addl_metadata = copyfrom.addl_metadata if copyfrom is not None else {} - self.addl_metadata = temp_addl_metadata - - if imports is not None: - temp_imports = imports - else: - temp_imports = copyfrom.imports if copyfrom is not None else [] - self.imports = temp_imports - - if includes is not None: - temp_includes = includes - else: - temp_includes = copyfrom.includes if copyfrom is not None else [] - self.includes = temp_includes - - if no_link_check is not None: - temp_no_link_check: Optional[bool] = no_link_check - else: - temp_no_link_check = copyfrom.no_link_check if copyfrom is not None else False - self.no_link_check = temp_no_link_check - - if container is not None: - temp_container: Optional[str] = container - else: - temp_container = copyfrom.container if copyfrom is not None else None - self.container = temp_container - - if fetcher is not None: - temp_fetcher = fetcher - elif copyfrom is not None: - temp_fetcher = copyfrom.fetcher - else: - import requests - from cachecontrol.caches import SeparateBodyFileCache - from cachecontrol.wrapper import CacheControl - - root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir())) - session = CacheControl( - requests.Session(), - cache=SeparateBodyFileCache(root / ".cache" / "salad"), - ) - temp_fetcher = DefaultFetcher({}, session) - self.fetcher = temp_fetcher - - self.cache = self.fetcher.cache if isinstance(self.fetcher, MemoryCachingFetcher) else {} - - if self.namespaces != {}: - temp_vocab = _vocab.copy() - temp_rvocab = _rvocab.copy() - for k, v in self.namespaces.items(): - temp_vocab[k] = v - temp_rvocab[v] = k - else: - temp_vocab = _vocab - temp_rvocab = _rvocab - self.vocab = temp_vocab - self.rvocab = temp_rvocab - - @property - def graph(self) -> Graph: - """Generate a merged rdflib.Graph from all entries in self.schemas.""" - graph = Graph() - if not self.schemas: - return graph - key: Final = str(hash(tuple(self.schemas))) - if key in self.cache: - return cast(Graph, self.cache[key]) - for schema in self.schemas: - fetchurl = ( - self.fetcher.urljoin(self.fileuri, schema) - if self.fileuri is not None - else pathlib.Path(schema).resolve().as_uri() - ) - if fetchurl not in self.cache or self.cache[fetchurl] is True: - _logger.debug("Getting external schema %s", fetchurl) - try: - content = self.fetcher.fetch_text(fetchurl) - except Exception as e: - _logger.warning("Could not load extension schema %s: %s", fetchurl, str(e)) - continue - newGraph = Graph() - err_msg = "unknown error" - for fmt in ["xml", "turtle"]: - try: - newGraph.parse(data=content, format=fmt, publicID=str(fetchurl)) - self.cache[fetchurl] = newGraph - graph += newGraph - break - except (xml.sax.SAXParseException, TypeError, BadSyntax) as e: - err_msg = str(e) - else: - _logger.warning("Could not load extension schema %s: %s", fetchurl, err_msg) - self.cache[key] = graph - return graph +from schema_salad.utils import yaml_no_ts # requires schema-salad v8.2+ +_vocab: Final[dict[str, str]] = {} +_rvocab: Final[dict[str, str]] = {} -class Saveable(ABC): - """Mark classes than have a save() and fromDoc() function.""" - - @classmethod - @abstractmethod - def fromDoc( - cls, - _doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - ) -> "Saveable": - """Construct this object from the result of yaml.load().""" +@mypyc_attr(native_class=True) +class _Loader(Generic[FieldType], metaclass=ABCMeta): @abstractmethod - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - """Convert this object to a JSON/YAML friendly dictionary.""" - - -def load_field( - val: Union[str, dict[str, str]], - fieldtype: "_Loader", - baseuri: str, - loadingOptions: LoadingOptions, - lc: Optional[list[Any]] = None, -) -> Any: - """Load field.""" - if isinstance(val, MutableMapping): - if "$import" in val: - if loadingOptions.fileuri is None: - raise SchemaSaladException("Cannot load $import without fileuri") - url1: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$import"]) - result, metadata = _document_load_by_url( - fieldtype, - url1, - loadingOptions, - ) - loadingOptions.imports.append(url1) - return result - if "$include" in val: - if loadingOptions.fileuri is None: - raise SchemaSaladException("Cannot load $import without fileuri") - url2: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) - val = loadingOptions.fetcher.fetch_text(url2) - loadingOptions.includes.append(url2) - return fieldtype.load(val, baseuri, loadingOptions, lc=lc) - - -save_type = Optional[Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]] - - -def extract_type(val_type: type[Any]) -> str: - """Take a type of value, and extracts the value as a string.""" - val_str: Final = str(val_type) - return val_str.split("'")[1] - - -def convert_typing(val_type: str) -> str: - """Normalize type names to schema-salad types.""" - if "None" in val_type: - return "null" - if "CommentedSeq" in val_type or "list" in val_type: - return "array" - if "CommentedMap" in val_type or "dict" in val_type: - return "object" - if "False" in val_type or "True" in val_type: - return "boolean" - return val_type - - -def parse_errors(error_message: str) -> tuple[str, str, str]: - """Parse error messages from several loaders into one error message.""" - if not error_message.startswith("Expected"): - return error_message, "", "" - vals: Final = error_message.split("\n") - if len(vals) == 1: - return error_message, "", "" - types1: Final = set() - for val in vals: - individual_vals = val.split(" ") - if val == "": - continue - if individual_vals[1] == "one": - individual_vals = val.split("(")[1].split(",") - for t in individual_vals: - types1.add(t.strip(" ").strip(")\n")) - elif individual_vals[2] == "").replace("'", "")) - elif individual_vals[0] == "Value": - types1.add(individual_vals[-1].strip(".")) - else: - types1.add(individual_vals[1].replace(",", "")) - types2: Final = {val for val in types1 if val != "NoneType"} - if "str" in types2: - types3 = {convert_typing(val) for val in types2 if "'" not in val} - else: - types3 = types2 - to_print = "" - for val in types3: - if "'" in val: - to_print = "value" if len(types3) == 1 else "values" - - if to_print == "": - to_print = "type" if len(types3) == 1 else "types" - - verb_tensage: Final = "is" if len(types3) == 1 else "are" - - return str(types3).replace("{", "(").replace("}", ")").replace("'", ""), to_print, verb_tensage - - -def save( - val: Any, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, -) -> save_type: - if isinstance(val, Saveable): - return val.save(top=top, base_url=base_url, relative_uris=relative_uris) - if isinstance(val, MutableSequence): - return [save(v, top=False, base_url=base_url, relative_uris=relative_uris) for v in val] - if isinstance(val, MutableMapping): - newdict: Final = {} - for key in val: - newdict[key] = save(val[key], top=False, base_url=base_url, relative_uris=relative_uris) - return newdict - if val is None or isinstance(val, (int, float, bool, str)): - return val - raise Exception("Not Saveable: %s" % type(val)) - - -def save_with_metadata( - val: Any, - valLoadingOpts: LoadingOptions, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, -) -> save_type: - """Save and set $namespaces, $schemas, $base and any other metadata fields at the top level.""" - saved_val: Final = save(val, top, base_url, relative_uris) - newdict: MutableMapping[str, Any] = {} - if isinstance(saved_val, MutableSequence): - newdict = {"$graph": saved_val} - elif isinstance(saved_val, MutableMapping): - newdict = saved_val - - if valLoadingOpts.namespaces: - newdict["$namespaces"] = valLoadingOpts.namespaces - if valLoadingOpts.schemas: - newdict["$schemas"] = valLoadingOpts.schemas - if valLoadingOpts.baseuri: - newdict["$base"] = valLoadingOpts.baseuri - for k, v in valLoadingOpts.addl_metadata.items(): - if k not in newdict: - newdict[k] = v - - return newdict - - -def expand_url( - url: str, - base_url: str, - loadingOptions: LoadingOptions, - scoped_id: bool = False, - vocab_term: bool = False, - scoped_ref: Optional[int] = None, -) -> str: - if url in ("@id", "@type"): - return url - - if vocab_term and url in loadingOptions.vocab: - return url - - if bool(loadingOptions.vocab) and ":" in url: - prefix: Final = url.split(":")[0] - if prefix in loadingOptions.vocab: - url = loadingOptions.vocab[prefix] + url[len(prefix) + 1 :] - - split1: Final = urlsplit(url) - - if ( - (bool(split1.scheme) and split1.scheme in loadingOptions.fetcher.supported_schemes()) - or url.startswith("$(") - or url.startswith("${") - ): - pass - elif scoped_id and not bool(split1.fragment): - splitbase1: Final = urlsplit(base_url) - frg: str - if bool(splitbase1.fragment): - frg = splitbase1.fragment + "/" + split1.path - else: - frg = split1.path - pt: Final = splitbase1.path if splitbase1.path != "" else "/" - url = urlunsplit((splitbase1.scheme, splitbase1.netloc, pt, splitbase1.query, frg)) - elif scoped_ref is not None and not bool(split1.fragment): - splitbase2: Final = urlsplit(base_url) - sp = splitbase2.fragment.split("/") - n = scoped_ref - while n > 0 and len(sp) > 0: - sp.pop() - n -= 1 - sp.append(url) - url = urlunsplit( - ( - splitbase2.scheme, - splitbase2.netloc, - splitbase2.path, - splitbase2.query, - "/".join(sp), - ) - ) - else: - url = loadingOptions.fetcher.urljoin(base_url, url) - - if vocab_term: - split2: Final = urlsplit(url) - if bool(split2.scheme): - if url in loadingOptions.rvocab: - return loadingOptions.rvocab[url] - else: - raise ValidationException(f"Term {url!r} not in vocabulary") - - return url - - -class _Loader: def load( self, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: - pass + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: ... -class _AnyLoader(_Loader): +@mypyc_attr(native_class=True) +class _AnyLoader(_Loader[Any]): def load( self, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, + docRoot: str | None = None, + lc: Any | None = None, ) -> Any: if doc is not None: return doc raise ValidationException("Expected non-null") -class _PrimitiveLoader(_Loader): - def __init__(self, tp: Union[type, tuple[type[str], type[str]]]) -> None: +@mypyc_attr(native_class=True) +class _PrimitiveLoader(_Loader[FieldType]): + def __init__(self, tp: type[FieldType]) -> None: self.tp: Final = tp def load( @@ -463,9 +95,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if not isinstance(doc, self.tp): raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}") return doc @@ -474,8 +106,9 @@ def __repr__(self) -> str: return str(self.tp) -class _ArrayLoader(_Loader): - def __init__(self, items: _Loader) -> None: +@mypyc_attr(native_class=True) +class _ArrayLoader(_Loader[Sequence[FieldType]]): + def __init__(self, items: _Loader[FieldType]) -> None: self.items: Final = items def load( @@ -483,9 +116,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> list[FieldType]: if not isinstance(doc, MutableSequence): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " @@ -496,7 +129,7 @@ def load( fields: Final[list[str]] = [] for i in range(0, len(doc)): try: - lf = load_field( + lf = _load_field( doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc ) flatten = loadingOptions.container != "@list" @@ -531,13 +164,14 @@ def __repr__(self) -> str: return f"array<{self.items}>" -class _MapLoader(_Loader): +@mypyc_attr(native_class=True) +class _MapLoader(_Loader[Mapping[str, FieldType]]): def __init__( self, - values: _Loader, - name: Optional[str] = None, - container: Optional[str] = None, - no_link_check: Optional[bool] = None, + values: _Loader[FieldType], + name: str | None = None, + container: str | None = None, + no_link_check: bool | None = None, ) -> None: self.values: Final = values self.name: Final = name @@ -549,9 +183,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> dict[str, FieldType]: if not isinstance(doc, MutableMapping): raise ValidationException(f"Expected a map, was {type(doc)}") if self.container is not None or self.no_link_check is not None: @@ -562,7 +196,7 @@ def load( errors: Final[list[SchemaSaladException]] = [] for k, v in doc.items(): try: - lf = load_field(v, self.values, baseuri, loadingOptions, lc) + lf = _load_field(v, self.values, baseuri, loadingOptions, lc) r[k] = lf except ValidationException as e: errors.append(e.with_sourceline(SourceLine(doc, k, str))) @@ -574,7 +208,8 @@ def __repr__(self) -> str: return self.name if self.name is not None else f"map" -class _EnumLoader(_Loader): +@mypyc_attr(native_class=True) +class _EnumLoader(_Loader[EnumFieldType]): def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols: Final = symbols self.name: Final = name @@ -584,19 +219,20 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> EnumFieldType: if doc in self.symbols: - return doc + return cast(EnumFieldType, doc) raise ValidationException(f"Expected one of {self.symbols}") def __repr__(self) -> str: return self.name -class _SecondaryDSLLoader(_Loader): - def __init__(self, inner: _Loader) -> None: +@mypyc_attr(native_class=True) +class _SecondaryDSLLoader(_Loader[FieldType]): + def __init__(self, inner: _Loader[FieldType]) -> None: self.inner: Final = inner def load( @@ -604,75 +240,77 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: r: Final[list[dict[str, Any]]] = [] - if isinstance(doc, MutableSequence): - for d in doc: - if isinstance(d, str): - if d.endswith("?"): - r.append({"pattern": d[:-1], "required": False}) - else: - r.append({"pattern": d}) - elif isinstance(d, dict): - new_dict1: dict[str, Any] = {} - dict_copy = copy.deepcopy(d) - if "pattern" in dict_copy: - new_dict1["pattern"] = dict_copy.pop("pattern") - else: - raise ValidationException( - f"Missing pattern in secondaryFiles specification entry: {d}" + match doc: + case MutableSequence() as dlist: + for d in dlist: + if isinstance(d, str): + if d.endswith("?"): + r.append({"pattern": d[:-1], "required": False}) + else: + r.append({"pattern": d}) + elif isinstance(d, dict): + new_dict1: dict[str, Any] = {} + dict_copy = copy.deepcopy(d) + if "pattern" in dict_copy: + new_dict1["pattern"] = dict_copy.pop("pattern") + else: + raise ValidationException( + f"Missing pattern in secondaryFiles specification entry: {d}" + ) + new_dict1["required"] = ( + dict_copy.pop("required") if "required" in dict_copy else None ) - new_dict1["required"] = ( - dict_copy.pop("required") if "required" in dict_copy else None - ) - if len(dict_copy): - raise ValidationException( - "Unallowed values in secondaryFiles specification entry: {}".format( - dict_copy + if len(dict_copy): + raise ValidationException( + "Unallowed values in secondaryFiles specification entry: {}".format( + dict_copy + ) ) - ) - r.append(new_dict1) + r.append(new_dict1) + else: + raise ValidationException( + "Expected a string or sequence of (strings or mappings)." + ) + case MutableMapping() as decl: + new_dict2 = {} + doc_copy = copy.deepcopy(decl) + if "pattern" in doc_copy: + new_dict2["pattern"] = doc_copy.pop("pattern") else: raise ValidationException( - "Expected a string or sequence of (strings or mappings)." + f"Missing pattern in secondaryFiles specification entry: {decl}" ) - elif isinstance(doc, MutableMapping): - new_dict2: Final = {} - doc_copy: Final = copy.deepcopy(doc) - if "pattern" in doc_copy: - new_dict2["pattern"] = doc_copy.pop("pattern") - else: - raise ValidationException( - f"Missing pattern in secondaryFiles specification entry: {doc}" - ) - new_dict2["required"] = doc_copy.pop("required") if "required" in doc_copy else None + new_dict2["required"] = doc_copy.pop("required") if "required" in doc_copy else None - if len(doc_copy): - raise ValidationException( - f"Unallowed values in secondaryFiles specification entry: {doc_copy}" - ) - r.append(new_dict2) + if len(doc_copy): + raise ValidationException( + f"Unallowed values in secondaryFiles specification entry: {doc_copy}" + ) + r.append(new_dict2) - elif isinstance(doc, str): - if doc.endswith("?"): - r.append({"pattern": doc[:-1], "required": False}) - else: - r.append({"pattern": doc}) - else: - raise ValidationException("Expected str or sequence of str") + case str(decl): + if decl.endswith("?"): + r.append({"pattern": decl[:-1], "required": False}) + else: + r.append({"pattern": decl}) + case _: + raise ValidationException("Expected str or sequence of str") return self.inner.load(r, baseuri, loadingOptions, docRoot, lc=lc) -class _RecordLoader(_Loader): +@mypyc_attr(native_class=True) +class _RecordLoader(_Loader[SaveableType]): def __init__( self, - classtype: type[Saveable], - container: Optional[str] = None, - no_link_check: Optional[bool] = None, + classtype: type[SaveableType], + container: str | None = None, + no_link_check: bool | None = None, ) -> None: self.classtype: Final = classtype self.container: Final = container @@ -683,9 +321,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> SaveableType: if not isinstance(doc, MutableMapping): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " @@ -701,7 +339,8 @@ def __repr__(self) -> str: return str(self.classtype.__name__) -class _ExpressionLoader(_Loader): +@mypyc_attr(native_class=True) +class _ExpressionLoader(_Loader[str]): def __init__(self, items: type[str]) -> None: self.items: Final = items @@ -710,23 +349,25 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> str: if not isinstance(doc, str): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " f"but valid type for this field is a str." ) - return doc + else: + return doc -class _UnionLoader(_Loader): - def __init__(self, alternates: Sequence[_Loader], name: Optional[str] = None) -> None: +@mypyc_attr(native_class=True) +class _UnionLoader(_Loader[FieldType]): + def __init__(self, alternates: Sequence[_Loader[FieldType]], name: str | None = None) -> None: self.alternates = alternates self.name: Final = name - def add_loaders(self, loaders: Sequence[_Loader]) -> None: + def add_loaders(self, loaders: Sequence[_Loader[FieldType]]) -> None: self.alternates = tuple(loader for loader in chain(self.alternates, loaders)) def load( @@ -734,9 +375,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: errors: Final = [] if lc is None: @@ -811,14 +452,15 @@ def __repr__(self) -> str: return self.name if self.name is not None else " | ".join(str(a) for a in self.alternates) -class _URILoader(_Loader): +@mypyc_attr(native_class=True) +class _URILoader(_Loader[FieldType]): def __init__( self, - inner: _Loader, + inner: _Loader[FieldType], scoped_id: bool, vocab_term: bool, - scoped_ref: Optional[int], - no_link_check: Optional[bool], + scoped_ref: int | None, + no_link_check: bool | None, ) -> None: self.inner: Final = inner self.scoped_id: Final = scoped_id @@ -831,39 +473,40 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if self.no_link_check is not None: loadingOptions = LoadingOptions( copyfrom=loadingOptions, no_link_check=self.no_link_check ) - if isinstance(doc, MutableSequence): - newdoc: Final = [] - for i in doc: - if isinstance(i, str): - newdoc.append( - expand_url( - i, - baseuri, - loadingOptions, - self.scoped_id, - self.vocab_term, - self.scoped_ref, - ) - ) - else: - newdoc.append(i) - doc = newdoc - elif isinstance(doc, str): - doc = expand_url( - doc, - baseuri, - loadingOptions, - self.scoped_id, - self.vocab_term, - self.scoped_ref, - ) + match doc: + case MutableSequence() as decl: + newdoc: Final = [] + for i in decl: + if isinstance(i, str): + newdoc.append( + _expand_url( + i, + baseuri, + loadingOptions, + self.scoped_id, + self.vocab_term, + self.scoped_ref, + ) + ) + else: + newdoc.append(i) + doc = newdoc + case str(decl): + doc = _expand_url( + decl, + baseuri, + loadingOptions, + self.scoped_id, + self.vocab_term, + self.scoped_ref, + ) if isinstance(doc, str): if not loadingOptions.no_link_check: errors: Final = [] @@ -879,8 +522,14 @@ def load( return self.inner.load(doc, baseuri, loadingOptions, lc=lc) -class _TypeDSLLoader(_Loader): - def __init__(self, inner: _Loader, refScope: Optional[int], salad_version: str) -> None: +@mypyc_attr(native_class=True) +class _TypeDSLLoader(_Loader[FieldType]): + def __init__( + self, + inner: _Loader[FieldType], + refScope: int | None, + salad_version: str, + ) -> None: self.inner: Final = inner self.refScope: Final = refScope self.salad_version: Final = salad_version @@ -890,7 +539,7 @@ def resolve( doc: str, baseuri: str, loadingOptions: LoadingOptions, - ) -> Union[list[Union[dict[str, Any], str]], dict[str, Any], str]: + ) -> list[dict[str, Any] | str] | dict[str, Any] | str: doc_ = doc optional = False if doc_.endswith("?"): @@ -899,21 +548,42 @@ def resolve( if doc_.endswith("[]"): salad_versions: Final = [int(v) for v in self.salad_version[1:].split(".")] - items: Union[list[Union[dict[str, Any], str]], dict[str, Any], str] = "" + items: list[dict[str, Any] | str] | dict[str, Any] | str = "" rest: Final = doc_[0:-2] if salad_versions < [1, 3]: if rest.endswith("[]"): # To show the error message with the original type return doc else: - items = expand_url(rest, baseuri, loadingOptions, False, True, self.refScope) + items = _expand_url( + rest, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) else: items = self.resolve(rest, baseuri, loadingOptions) if isinstance(items, str): - items = expand_url(items, baseuri, loadingOptions, False, True, self.refScope) - expanded: Union[dict[str, Any], str] = {"type": "array", "items": items} + items = _expand_url( + items, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) + expanded: dict[str, Any] | str = {"type": "array", "items": items} else: - expanded = expand_url(doc_, baseuri, loadingOptions, False, True, self.refScope) + expanded = _expand_url( + doc_, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) if optional: return ["null", expanded] @@ -925,9 +595,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if isinstance(doc, MutableSequence): r: Final[list[Any]] = [] for d in doc: @@ -949,8 +619,10 @@ def load( return self.inner.load(doc, baseuri, loadingOptions, lc=lc) -class _IdMapLoader(_Loader): - def __init__(self, inner: _Loader, mapSubject: str, mapPredicate: Optional[str]) -> None: +class _IdMapLoader(_Loader[FieldType]): + def __init__( + self, inner: _Loader[FieldType], mapSubject: str, mapPredicate: str | None + ) -> None: self.inner: Final = inner self.mapSubject: Final = mapSubject self.mapPredicate: Final = mapPredicate @@ -960,9 +632,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if isinstance(doc, MutableMapping): r: Final[list[Any]] = [] for k in doc.keys(): @@ -989,12 +661,12 @@ def load( def _document_load( - loader: _Loader, - doc: Union[str, MutableMapping[str, Any], MutableSequence[Any]], + loader: _Loader[FieldType], + doc: str | MutableMapping[str, Any] | MutableSequence[Any], baseuri: str, loadingOptions: LoadingOptions, - addl_metadata_fields: Optional[MutableSequence[str]] = None, -) -> tuple[Any, LoadingOptions]: + addl_metadata_fields: MutableSequence[str] | None = None, +) -> tuple[FieldType, LoadingOptions]: if isinstance(doc, str): return _document_load_by_url( loader, @@ -1059,11 +731,11 @@ def _document_load( def _document_load_by_url( - loader: _Loader, + loader: _Loader[FieldType], url: str, loadingOptions: LoadingOptions, - addl_metadata_fields: Optional[MutableSequence[str]] = None, -) -> tuple[Any, LoadingOptions]: + addl_metadata_fields: MutableSequence[str] | None = None, +) -> tuple[FieldType, LoadingOptions]: if url in loadingOptions.idx: return loadingOptions.idx[url] @@ -1089,118 +761,313 @@ def _document_load_by_url( return loadingOptions.idx[url] -def file_uri(path: str, split_frag: bool = False) -> str: - """Transform a file path into a URL with file scheme.""" - if path.startswith("file://"): - return path - if split_frag: - pathsp: Final = path.split("#", 2) - frag = "#" + quote(str(pathsp[1])) if len(pathsp) == 2 else "" - urlpath = pathname2url(str(pathsp[0])) - else: - urlpath = pathname2url(path) - frag = "" - if urlpath.startswith("//"): - return f"file:{urlpath}{frag}" - return f"file://{urlpath}{frag}" - - -def prefix_url(url: str, namespaces: dict[str, str]) -> str: - """Expand short forms into full URLs using the given namespace dictionary.""" - for k, v in namespaces.items(): - if url.startswith(v): - return k + ":" + url[len(v) :] - return url - - -def save_relative_uri( - uri: Any, +def _expand_url( + url: str, base_url: str, - scoped_id: bool, - ref_scope: Optional[int], - relative_uris: bool, -) -> Any: - """Convert any URI to a relative one, obeying the scoping rules.""" - if isinstance(uri, MutableSequence): - return [save_relative_uri(u, base_url, scoped_id, ref_scope, relative_uris) for u in uri] - elif isinstance(uri, str): - if not relative_uris or uri == base_url: - return uri - urisplit: Final = urlsplit(uri) - basesplit: Final = urlsplit(base_url) - if urisplit.scheme == basesplit.scheme and urisplit.netloc == basesplit.netloc: - if urisplit.path != basesplit.path: - p = os.path.relpath(urisplit.path, os.path.dirname(basesplit.path)) - if urisplit.fragment: - p = p + "#" + urisplit.fragment - return p - - basefrag = basesplit.fragment + "/" - if ref_scope: - sp = basefrag.split("/") - i = 0 - while i < ref_scope: - sp.pop() - i += 1 - basefrag = "/".join(sp) - - if urisplit.fragment.startswith(basefrag): - return urisplit.fragment[len(basefrag) :] - return urisplit.fragment - return uri - else: - return save(uri, top=False, base_url=base_url, relative_uris=relative_uris) - - -def shortname(inputid: str) -> str: - """ - Compute the shortname of a fully qualified identifier. - - See https://w3id.org/cwl/v1.2/SchemaSalad.html#Short_names. - """ - parsed_id: Final = urlparse(inputid) - if parsed_id.fragment: - return parsed_id.fragment.split("/")[-1] - return parsed_id.path.split("/")[-1] - - -def parser_info() -> str: - return "org.w3id.cwl.v1_1" - - -class Documented(Saveable): - pass + loadingOptions: LoadingOptions, + scoped_id: bool = False, + vocab_term: bool = False, + scoped_ref: int | None = None, +) -> str: + if url in ("@id", "@type"): + return url + vocab = _vocab | loadingOptions.vocab + if vocab_term and url in vocab: + return url -class RecordField(Documented): - """ - A field of a record. - """ + if bool(vocab) and ":" in url: + prefix: Final = url.split(":")[0] + if prefix in vocab: + url = vocab[prefix] + url[len(prefix) + 1 :] - name: str + split1: Final = urlsplit(url) - def __init__( - self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions + if ( + (bool(split1.scheme) and split1.scheme in loadingOptions.fetcher.supported_schemes()) + or url.startswith("$(") + or url.startswith("${") + ): + pass + elif scoped_id and not bool(split1.fragment): + splitbase1: Final = urlsplit(base_url) + frg: str + if bool(splitbase1.fragment): + frg = splitbase1.fragment + "/" + split1.path else: - self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + frg = split1.path + pt: Final = splitbase1.path if splitbase1.path != "" else "/" + url = urlunsplit((splitbase1.scheme, splitbase1.netloc, pt, splitbase1.query, frg)) + elif scoped_ref is not None and not bool(split1.fragment): + splitbase2: Final = urlsplit(base_url) + sp = splitbase2.fragment.split("/") + n = scoped_ref + while n > 0 and len(sp) > 0: + sp.pop() + n -= 1 + sp.append(url) + url = urlunsplit( + ( + splitbase2.scheme, + splitbase2.netloc, + splitbase2.path, + splitbase2.query, + "/".join(sp), + ) + ) + else: + url = loadingOptions.fetcher.urljoin(base_url, url) + + if vocab_term: + split2: Final = urlsplit(url) + if bool(split2.scheme): + if url in (rvocab := _rvocab | loadingOptions.rvocab): + return rvocab[url] + else: + raise ValidationException(f"Term {url!r} not in vocabulary") + + return url + + +def _load_field( + val: Any | None, + fieldtype: _Loader[FieldType], + baseuri: str, + loadingOptions: LoadingOptions, + lc: Any | None = None, +) -> FieldType: + """Load field.""" + if isinstance(val, MutableMapping): + if "$import" in val: + if loadingOptions.fileuri is None: + raise SchemaSaladException("Cannot load $import without fileuri") + url1: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$import"]) + result, metadata = _document_load_by_url( + fieldtype, + url1, + loadingOptions, + ) + loadingOptions.imports.append(url1) + return result + if "$include" in val: + if loadingOptions.fileuri is None: + raise SchemaSaladException("Cannot load $import without fileuri") + url2: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) + val = loadingOptions.fetcher.fetch_text(url2) + loadingOptions.includes.append(url2) + return fieldtype.load(val, baseuri, loadingOptions, lc=lc) + + +def parser_info() -> str: + return "org.w3id.cwl.v1_1" + + +@mypyc_attr(native_class=True) +class CWLArraySchema(schema_salad.metaschema.ArraySchema): + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLArraySchema | CWLRecordSchema | PrimitiveType | Sequence[CWLArraySchema | CWLRecordSchema | PrimitiveType | schema_salad.metaschema.EnumSchema | str] | schema_salad.metaschema.EnumSchema | str, + type_: Array_name, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["items", "type"]) + + +@mypyc_attr(native_class=True) +class CWLRecordField(schema_salad.metaschema.RecordField): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, RecordField): + if isinstance(other, CWLRecordField): return bool( self.doc == other.doc and self.name == other.name @@ -1217,8 +1084,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "RecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -1228,7 +1095,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_strtype_True_False_None_None, baseuri, @@ -1273,18 +1140,18 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: + name = "" _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -1332,9 +1199,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2, + typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -1376,7 +1243,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -1384,7 +1251,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -1401,13 +1268,13 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + doc=doc, type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -1422,7 +1289,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.doc is not None: r["doc"] = save( @@ -1441,16 +1308,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type"]) - - -class RecordSchema(Saveable): def __init__( self, - type_: Any, - fields: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLArraySchema | CWLRecordSchema | PrimitiveType | Sequence[CWLArraySchema | CWLRecordSchema | PrimitiveType | schema_salad.metaschema.EnumSchema | str] | schema_salad.metaschema.EnumSchema | str, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -1460,11 +1324,17 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.doc = doc + self.name = name self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["doc", "name", "type"]) + + +@mypyc_attr(native_class=True) +class CWLRecordSchema(schema_salad.metaschema.RecordSchema): def __eq__(self, other: Any) -> bool: - if isinstance(other, RecordSchema): + if isinstance(other, CWLRecordSchema): return bool(self.fields == other.fields and self.type_ == other.type_) return False @@ -1477,8 +1347,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "RecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -1488,9 +1358,9 @@ def fromDoc( fields = None if "fields" in _doc: try: - fields = load_field( + fields = _load_field( _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader, + idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, baseuri, loadingOptions, lc=_doc.get("fields") @@ -1536,7 +1406,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, @@ -1580,7 +1450,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -1588,7 +1458,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -1640,24 +1510,12 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type"]) - - -class EnumSchema(Saveable): - """ - Define an enumerated type. - - """ - - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CWLRecordField] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -1667,21 +1525,76 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.fields = fields self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type"]) + + +@mypyc_attr(native_class=True) +class File(Saveable): + """ + Represents a file (or group of files when ``secondaryFiles`` is provided) that will be accessible by tools using standard POSIX file system call API such as open(2) and read(2). + + Files are represented as objects with ``class`` of ``File``. File objects have a number of properties that provide metadata about the file. + + The ``location`` property of a File is a URI that uniquely identifies the file. Implementations must support the file:// URI scheme and may support other schemes such as http://. The value of ``location`` may also be a relative reference, in which case it must be resolved relative to the URI of the document it appears in. Alternately to ``location``, implementations must also accept the ``path`` property on File, which must be a filesystem path available on the same host as the CWL runner (for inputs) or the runtime environment of a command line tool execution (for command line tool outputs). + + If no ``location`` or ``path`` is specified, a file object must specify ``contents`` with the UTF-8 text content of the file. This is a "file literal". File literals do not correspond to external resources, but are created on disk with ``contents`` with when needed for a executing a tool. Where appropriate, expressions can return file literals to define new files on a runtime. The maximum size of ``contents`` is 64 kilobytes. + + The ``basename`` property defines the filename on disk where the file is staged. This may differ from the resource name. If not provided, ``basename`` must be computed from the last path part of ``location`` and made available to expressions. + + The ``secondaryFiles`` property is a list of File or Directory objects that must be staged in the same directory as the primary file. It is an error for file names to be duplicated in ``secondaryFiles``. + + The ``size`` property is the size in bytes of the File. It must be computed from the resource and made available to expressions. The ``checksum`` field contains a cryptographic hash of the file content for use it verifying file contents. Implementations may, at user option, enable or disable computation of the ``checksum`` field for performance or other reasons. However, the ability to compute output checksums is required to pass the CWL conformance test suite. + + When executing a CommandLineTool, the files and secondary files may be staged to an arbitrary directory, but must use the value of ``basename`` for the filename. The ``path`` property must be file path in the context of the tool execution runtime (local to the compute node, or within the executing container). All computed properties should be available to expressions. File literals also must be staged and ``path`` must be set. + + When collecting CommandLineTool outputs, ``glob`` matching returns file paths (with the ``path`` property) and the derived properties. This can all be modified by ``outputEval``. Alternately, if the file ``cwl.output.json`` is present in the output, ``outputBinding`` is ignored. + + File objects in the output must provide either a ``location`` URI or a ``path`` property in the context of the tool execution runtime (local to the compute node, or within the executing container). + + When evaluating an ExpressionTool, file objects must be referenced via ``location`` (the expression tool does not have access to files on disk so ``path`` is meaningless) or as file literals. It is legal to return a file object with an existing ``location`` but a different ``basename``. The ``loadContents`` field of ExpressionTool inputs behaves the same as on CommandLineTool inputs, however it is not meaningful on the outputs. + + An ExpressionTool may forward file references from input to output by using the same value for ``location``. + + """ + def __eq__(self, other: Any) -> bool: - if isinstance(other, EnumSchema): + if isinstance(other, File): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ + self.class_ == other.class_ + and self.location == other.location + and self.path == other.path + and self.basename == other.basename + and self.dirname == other.dirname + and self.nameroot == other.nameroot + and self.nameext == other.nameext + and self.checksum == other.checksum + and self.size == other.size + and self.secondaryFiles == other.secondaryFiles + and self.format == other.format + and self.contents == other.contents ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_)) + return hash( + ( + self.class_, + self.location, + self.path, + self.basename, + self.dirname, + self.nameroot, + self.nameext, + self.checksum, + self.size, + self.secondaryFiles, + self.format, + self.contents, + ) + ) @classmethod def fromDoc( @@ -1689,29 +1602,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_File_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + location = None + if "location" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + location = _load_field( + _doc.get("location"), + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("location") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `location`": _errors__.append( ValidationException( str(e), @@ -1719,13 +1649,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("location") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -1737,548 +1667,519 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `location` field with value `{val}` " "is not valid because:", ) ) + path = None + if "path" in _doc: + try: + path = _load_field( + _doc.get("path"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("path") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `path`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + val = _doc.get("path") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + detailed_message=f"the `path` field with value `{val}` " + "is not valid because:", + ) + ) + basename = None + if "basename" in _doc: + try: + basename = _load_field( + _doc.get("basename"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("basename") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("basename") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + detailed_message=f"the `basename` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type"]) - - -class ArraySchema(Saveable): - def __init__( - self, - items: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ArraySchema): - return bool(self.items == other.items and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.items, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ArraySchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) + dirname = None + if "dirname" in _doc: + try: + dirname = _load_field( + _doc.get("dirname"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dirname") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `dirname`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", + val = _doc.get("dirname") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [e], + detailed_message=f"the `dirname` field with value `{val}` " + "is not valid because:", + ) + ) + nameroot = None + if "nameroot" in _doc: + try: + nameroot = _load_field( + _doc.get("nameroot"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("nameroot") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `nameroot`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("nameroot") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [e], + detailed_message=f"the `nameroot` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - items=items, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["items", "type"]) - - -class MapSchema(Saveable): - def __init__( - self, - type_: Any, - values: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.type_ = type_ - self.values = values - - def __eq__(self, other: Any) -> bool: - if isinstance(other, MapSchema): - return bool(self.type_ == other.type_ and self.values == other.values) - return False - - def __hash__(self) -> int: - return hash((self.type_, self.values)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MapSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Map_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + nameext = None + if "nameext" in _doc: + try: + nameext = _load_field( + _doc.get("nameext"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("nameext") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `nameext`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("nameext") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("values") is None: - raise ValidationException("missing required field `values`", None, []) - - values = load_field( - _doc.get("values"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("values") - ) + else: + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [e], + detailed_message=f"the `nameext` field with value `{val}` " + "is not valid because:", + ) + ) + checksum = None + if "checksum" in _doc: + try: + checksum = _load_field( + _doc.get("checksum"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("checksum") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `values`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("values") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `checksum`": _errors__.append( ValidationException( - "the `values` field is not valid because:", - SourceLine(_doc, "values", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `values` field is not valid because:", - SourceLine(_doc, "values", str), - [e], - detailed_message=f"the `values` field with value `{val}` " - "is not valid because:", + val = _doc.get("checksum") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + else: + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [e], + detailed_message=f"the `checksum` field with value `{val}` " + "is not valid because:", + ) + ) + size = None + if "size" in _doc: + try: + size = _load_field( + _doc.get("size"), + union_of_None_type_or_inttype_or_longtype, + baseuri, + loadingOptions, + lc=_doc.get("size") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `type`, `values`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") + else: + val = _doc.get("size") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + detailed_message=f"the `size` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + contents = None + if "contents" in _doc: + try: + contents = _load_field( + _doc.get("contents"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("contents") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `contents`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("contents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [e], + detailed_message=f"the `contents` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `dirname`, `nameroot`, `nameext`, `checksum`, `size`, `secondaryFiles`, `format`, `contents`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") _constructed = cls( - type_=type_, - values=values, + location=location, + path=path, + basename=basename, + dirname=dirname, + nameroot=nameroot, + nameext=nameext, + checksum=checksum, + size=size, + secondaryFiles=secondaryFiles, + format=format, + contents=contents, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -2295,13 +2196,60 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.location is not None: + u = save_relative_uri(self.location, base_url, False, None, relative_uris) + r["location"] = u + if self.path is not None: + u = save_relative_uri(self.path, base_url, False, None, relative_uris) + r["path"] = u + if self.basename is not None: + r["basename"] = save( + self.basename, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.dirname is not None: + r["dirname"] = save( + self.dirname, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.nameroot is not None: + r["nameroot"] = save( + self.nameroot, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.nameext is not None: + r["nameext"] = save( + self.nameext, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.checksum is not None: + r["checksum"] = save( + self.checksum, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, base_url, True, None, relative_uris) + r["format"] = u + if self.contents is not None: + r["contents"] = save( + self.contents, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.values is not None: - u = save_relative_uri(self.values, base_url, False, 2, relative_uris) - r["values"] = u # top refers to the directory level if top: @@ -2311,16 +2259,21 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["type", "values"]) - - -class UnionSchema(Saveable): def __init__( self, - names: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + location: None | str = None, + path: None | str = None, + basename: None | str = None, + dirname: None | str = None, + nameroot: None | str = None, + nameext: None | str = None, + checksum: None | str = None, + size: None | i32 | i64 = None, + secondaryFiles: None | Sequence[Directory | File] = None, + format: None | str = None, + contents: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2330,215 +2283,77 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.names = names - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, UnionSchema): - return bool(self.names == other.names and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.names, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "UnionSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("names") is None: - raise ValidationException("missing required field `names`", None, []) + self.class_: Final[str] = "File" + self.location = location + self.path = path + self.basename = basename + self.dirname = dirname + self.nameroot = nameroot + self.nameext = nameext + self.checksum = checksum + self.size = size + self.secondaryFiles = secondaryFiles + self.format = format + self.contents = contents - names = load_field( - _doc.get("names"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("names") - ) + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "location", + "path", + "basename", + "dirname", + "nameroot", + "nameext", + "checksum", + "size", + "secondaryFiles", + "format", + "contents", + ] + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `names`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("names") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `names` field is not valid because:", - SourceLine(_doc, "names", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `names` field is not valid because:", - SourceLine(_doc, "names", str), - [e], - detailed_message=f"the `names` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) +@mypyc_attr(native_class=True) +class Directory(Saveable): + """ + Represents a directory to present to a command line tool. - type_ = load_field( - _doc.get("type"), - typedsl_Union_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + Directories are represented as objects with ``class`` of ``Directory``. Directory objects have a number of properties that provide metadata about the directory. - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + The ``location`` property of a Directory is a URI that uniquely identifies the directory. Implementations must support the file:// URI scheme and may support other schemes such as http://. Alternately to ``location``, implementations must also accept the ``path`` property on Directory, which must be a filesystem path available on the same host as the CWL runner (for inputs) or the runtime environment of a command line tool execution (for command line tool outputs). - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `names`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) + A Directory object may have a ``listing`` field. This is a list of File and Directory objects that are contained in the Directory. For each entry in ``listing``, the ``basename`` property defines the name of the File or Subdirectory when staged to disk. If ``listing`` is not provided, the implementation must have some way of fetching the Directory listing at runtime based on the ``location`` field. - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - names=names, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed + If a Directory does not have ``location``, it is a Directory literal. A Directory literal must provide ``listing``. Directory literals must be created on disk at runtime as needed. - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + The resources in a Directory literal do not need to have any implied relationship in their ``location``. For example, a Directory listing may contain two files located on different hosts. It is the responsibility of the runtime to ensure that those files are staged to disk appropriately. Secondary files associated with files in ``listing`` must also be staged to the same Directory. - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.names is not None: - u = save_relative_uri(self.names, base_url, False, 2, relative_uris) - r["names"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) + When executing a CommandLineTool, Directories must be recursively staged first and have local values of ``path`` assigned. - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r + Directory objects in CommandLineTool output must provide either a ``location`` URI or a ``path`` property in the context of the tool execution runtime (local to the compute node, or within the executing container). - attrs = frozenset(["names", "type"]) + An ExpressionTool may forward file references from input to output by using the same value for ``location``. + Name conflicts (the same ``basename`` appearing multiple times in ``listing`` or in any entry in ``secondaryFiles`` in the listing) is a fatal error. -class CWLArraySchema(ArraySchema): - def __init__( - self, - items: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLArraySchema): - return bool(self.items == other.items and self.type_ == other.type_) + if isinstance(other, Directory): + return bool( + self.class_ == other.class_ + and self.location == other.location + and self.path == other.path + and self.basename == other.basename + and self.listing == other.listing + ) return False def __hash__(self) -> int: - return hash((self.items, self.type_)) + return hash( + (self.class_, self.location, self.path, self.basename, self.listing) + ) @classmethod def fromDoc( @@ -2546,8 +2361,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -2555,102 +2370,211 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + class_ = _load_field( + _doc.get("class"), + uri_Directory_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("class") ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) + raise e + location = None + if "location" in _doc: + try: + location = _load_field( + _doc.get("location"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("location") ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + val = _doc.get("location") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + detailed_message=f"the `location` field with value `{val}` " + "is not valid because:", + ) + ) + path = None + if "path" in _doc: + try: + path = _load_field( + _doc.get("path"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("path") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("path") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + detailed_message=f"the `path` field with value `{val}` " + "is not valid because:", + ) + ) + basename = None + if "basename" in _doc: + try: + basename = _load_field( + _doc.get("basename"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("basename") ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("basename") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + detailed_message=f"the `basename` field with value `{val}` " + "is not valid because:", + ) + ) + listing = None + if "listing" in _doc: + try: + listing = _load_field( + _doc.get("listing"), + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("listing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - extension_fields: dict[str, Any] = {} + else: + val = _doc.get("listing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + detailed_message=f"the `listing` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -2658,14 +2582,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( + "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `listing`".format( k ), SourceLine(_doc, k, str), @@ -2675,8 +2599,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, + location=location, + path=path, + basename=basename, + listing=listing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -2693,12 +2619,29 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.location is not None: + u = save_relative_uri(self.location, base_url, False, None, relative_uris) + r["location"] = u + if self.path is not None: + u = save_relative_uri(self.path, base_url, False, None, relative_uris) + r["path"] = u + if self.basename is not None: + r["basename"] = save( + self.basename, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.listing is not None: + r["listing"] = save( + self.listing, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -2709,19 +2652,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type"]) - - -class CWLRecordField(RecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + location: None | str = None, + path: None | str = None, + basename: None | str = None, + listing: None | Sequence[Directory | File] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2731,21 +2669,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.type_ = type_ + self.class_: Final[str] = "Directory" + self.location = location + self.path = path + self.basename = basename + self.listing = listing + attrs: ClassVar[Collection[str]] = frozenset( + ["class", "location", "path", "basename", "listing"] + ) + + +@mypyc_attr(native_class=True) +class InputBinding(Saveable): def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLRecordField): - return bool( - self.doc == other.doc - and self.name == other.name - and self.type_ == other.type_ - ) + if isinstance(other, InputBinding): + return bool(self.loadContents == other.loadContents) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_)) + return hash((self.loadContents)) @classmethod def fromDoc( @@ -2753,29 +2696,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + loadContents = None + if "loadContents" in _doc: try: - name = load_field( - _doc.get("name"), - uri_strtype_True_False_None_None, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -2783,13 +2726,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2801,118 +2744,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -2920,14 +2759,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( + "invalid field `{}`, expected one of: `loadContents`".format( k ), SourceLine(_doc, k, str), @@ -2937,13 +2776,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, - name=name, - type_=type_, + loadContents=loadContents, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -2957,16 +2793,12 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -2977,16 +2809,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type"]) - - -class CWLRecordSchema(RecordSchema): def __init__( self, - type_: Any, - fields: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2996,16 +2823,44 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields - self.type_ = type_ + self.loadContents = loadContents + + attrs: ClassVar[Collection[str]] = frozenset(["loadContents"]) + + +@mypyc_attr(native_class=True) +class InputRecordField(CWLRecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLRecordSchema): - return bool(self.fields == other.fields and self.type_ == other.type_) + if isinstance(other, InputRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_)) + return hash( + ( + self.doc, + self.name, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + self.loadContents, + self.loadListing, + ) + ) @classmethod def fromDoc( @@ -3013,29 +2868,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - fields = None - if "fields" in _doc: + name = None + if "name" in _doc: try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3043,13 +2898,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3061,10 +2916,66 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " + "is not valid because:", + ) + ) + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) @@ -3072,9 +2983,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Record_nameLoader_2, + typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -3116,258 +3027,21 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - fields=fields, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["fields", "type"]) - - -class File(Saveable): - """ - Represents a file (or group of files when `secondaryFiles` is provided) that - will be accessible by tools using standard POSIX file system call API such as - open(2) and read(2). - - Files are represented as objects with `class` of `File`. File objects have - a number of properties that provide metadata about the file. - - The `location` property of a File is a URI that uniquely identifies the - file. Implementations must support the file:// URI scheme and may support - other schemes such as http://. The value of `location` may also be a - relative reference, in which case it must be resolved relative to the URI - of the document it appears in. Alternately to `location`, implementations - must also accept the `path` property on File, which must be a filesystem - path available on the same host as the CWL runner (for inputs) or the - runtime environment of a command line tool execution (for command line tool - outputs). - - If no `location` or `path` is specified, a file object must specify - `contents` with the UTF-8 text content of the file. This is a "file - literal". File literals do not correspond to external resources, but are - created on disk with `contents` with when needed for a executing a tool. - Where appropriate, expressions can return file literals to define new files - on a runtime. The maximum size of `contents` is 64 kilobytes. - - The `basename` property defines the filename on disk where the file is - staged. This may differ from the resource name. If not provided, - `basename` must be computed from the last path part of `location` and made - available to expressions. - - The `secondaryFiles` property is a list of File or Directory objects that - must be staged in the same directory as the primary file. It is an error - for file names to be duplicated in `secondaryFiles`. - - The `size` property is the size in bytes of the File. It must be computed - from the resource and made available to expressions. The `checksum` field - contains a cryptographic hash of the file content for use it verifying file - contents. Implementations may, at user option, enable or disable - computation of the `checksum` field for performance or other reasons. - However, the ability to compute output checksums is required to pass the - CWL conformance test suite. - - When executing a CommandLineTool, the files and secondary files may be - staged to an arbitrary directory, but must use the value of `basename` for - the filename. The `path` property must be file path in the context of the - tool execution runtime (local to the compute node, or within the executing - container). All computed properties should be available to expressions. - File literals also must be staged and `path` must be set. - - When collecting CommandLineTool outputs, `glob` matching returns file paths - (with the `path` property) and the derived properties. This can all be - modified by `outputEval`. Alternately, if the file `cwl.output.json` is - present in the output, `outputBinding` is ignored. - - File objects in the output must provide either a `location` URI or a `path` - property in the context of the tool execution runtime (local to the compute - node, or within the executing container). - - When evaluating an ExpressionTool, file objects must be referenced via - `location` (the expression tool does not have access to files on disk so - `path` is meaningless) or as file literals. It is legal to return a file - object with an existing `location` but a different `basename`. The - `loadContents` field of ExpressionTool inputs behaves the same as on - CommandLineTool inputs, however it is not meaningful on the outputs. - - An ExpressionTool may forward file references from input to output by using - the same value for `location`. - - """ - - def __init__( - self, - location: Optional[Any] = None, - path: Optional[Any] = None, - basename: Optional[Any] = None, - dirname: Optional[Any] = None, - nameroot: Optional[Any] = None, - nameext: Optional[Any] = None, - checksum: Optional[Any] = None, - size: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - format: Optional[Any] = None, - contents: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "File" - self.location = location - self.path = path - self.basename = basename - self.dirname = dirname - self.nameroot = nameroot - self.nameext = nameext - self.checksum = checksum - self.size = size - self.secondaryFiles = secondaryFiles - self.format = format - self.contents = contents - - def __eq__(self, other: Any) -> bool: - if isinstance(other, File): - return bool( - self.class_ == other.class_ - and self.location == other.location - and self.path == other.path - and self.basename == other.basename - and self.dirname == other.dirname - and self.nameroot == other.nameroot - and self.nameext == other.nameext - and self.checksum == other.checksum - and self.size == other.size - and self.secondaryFiles == other.secondaryFiles - and self.format == other.format - and self.contents == other.contents - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.location, - self.path, - self.basename, - self.dirname, - self.nameroot, - self.nameext, - self.checksum, - self.size, - self.secondaryFiles, - self.format, - self.contents, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "File": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_File_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - location = None - if "location" in _doc: - try: - location = load_field( - _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("location") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `location`": + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -3375,13 +3049,13 @@ def fromDoc( ) ) else: - val = _doc.get("location") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3393,28 +3067,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `location` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - path = None - if "path" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - path = load_field( - _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None_None, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("path") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `path`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -3422,13 +3096,13 @@ def fromDoc( ) ) else: - val = _doc.get("path") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3440,28 +3114,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `path` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - basename = None - if "basename" in _doc: + streamable = None + if "streamable" in _doc: try: - basename = load_field( - _doc.get("basename"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("basename") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `basename`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -3469,13 +3143,13 @@ def fromDoc( ) ) else: - val = _doc.get("basename") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3487,28 +3161,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `basename` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - dirname = None - if "dirname" in _doc: + format = None + if "format" in _doc: try: - dirname = load_field( - _doc.get("dirname"), - union_of_None_type_or_strtype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("dirname") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `dirname`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -3516,13 +3190,13 @@ def fromDoc( ) ) else: - val = _doc.get("dirname") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `dirname` field is not valid because:", - SourceLine(_doc, "dirname", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3534,28 +3208,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `dirname` field is not valid because:", - SourceLine(_doc, "dirname", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `dirname` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - nameroot = None - if "nameroot" in _doc: + loadContents = None + if "loadContents" in _doc: try: - nameroot = load_field( - _doc.get("nameroot"), - union_of_None_type_or_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("nameroot") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `nameroot`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -3563,13 +3237,13 @@ def fromDoc( ) ) else: - val = _doc.get("nameroot") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `nameroot` field is not valid because:", - SourceLine(_doc, "nameroot", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3581,28 +3255,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `nameroot` field is not valid because:", - SourceLine(_doc, "nameroot", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `nameroot` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - nameext = None - if "nameext" in _doc: + loadListing = None + if "loadListing" in _doc: try: - nameext = load_field( - _doc.get("nameext"), - union_of_None_type_or_strtype, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("nameext") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `nameext`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -3610,13 +3284,13 @@ def fromDoc( ) ) else: - val = _doc.get("nameext") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `nameext` field is not valid because:", - SourceLine(_doc, "nameext", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3628,28 +3302,213 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `nameext` field is not valid because:", - SourceLine(_doc, "nameext", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `nameext` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) - checksum = None - if "checksum" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + doc=doc, + type_=type_, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + format=format, + loadContents=loadContents, + loadListing=loadListing, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.name, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + name: str, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "doc", + "name", + "type", + "label", + "secondaryFiles", + "streamable", + "format", + "loadContents", + "loadListing", + ] + ) + + +@mypyc_attr(native_class=True) +class InputRecordSchema(CWLRecordSchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InputRecordSchema): + return bool( + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + and self.name == other.name + ) + return False + + def __hash__(self) -> int: + return hash((self.fields, self.type_, self.label, self.doc, self.name)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - checksum = load_field( - _doc.get("checksum"), - union_of_None_type_or_strtype, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("checksum") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `checksum`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3657,13 +3516,13 @@ def fromDoc( ) ) else: - val = _doc.get("checksum") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `checksum` field is not valid because:", - SourceLine(_doc, "checksum", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3675,28 +3534,36 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `checksum` field is not valid because:", - SourceLine(_doc, "checksum", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `checksum` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + fields = None + if "fields" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_inttype, + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("fields") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( str(e), @@ -3704,13 +3571,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("fields") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3722,75 +3589,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `fields` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `secondaryFiles`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) - format = None - if "format" in _doc: + ) + label = None + if "label" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_True_False_None_True, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -3798,13 +3666,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3816,28 +3684,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - contents = None - if "contents" in _doc: + doc = None + if "doc" in _doc: try: - contents = load_field( - _doc.get("contents"), - union_of_None_type_or_strtype, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("contents") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `contents`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -3845,13 +3713,13 @@ def fromDoc( ) ) else: - val = _doc.get("contents") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `contents` field is not valid because:", - SourceLine(_doc, "contents", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3863,14 +3731,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `contents` field is not valid because:", - SourceLine(_doc, "contents", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `contents` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -3878,14 +3746,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `dirname`, `nameroot`, `nameext`, `checksum`, `size`, `secondaryFiles`, `format`, `contents`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( k ), SourceLine(_doc, k, str), @@ -3895,20 +3763,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - location=location, - path=path, - basename=basename, - dirname=dirname, - nameroot=nameroot, - nameext=nameext, - checksum=checksum, - size=size, - secondaryFiles=secondaryFiles, - format=format, - contents=contents, + name=name, + fields=fields, + type_=type_, + label=label, + doc=doc, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -3922,57 +3785,24 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.location is not None: - u = save_relative_uri(self.location, base_url, False, None, relative_uris) - r["location"] = u - if self.path is not None: - u = save_relative_uri(self.path, base_url, False, None, relative_uris) - r["path"] = u - if self.basename is not None: - r["basename"] = save( - self.basename, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.dirname is not None: - r["dirname"] = save( - self.dirname, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.nameroot is not None: - r["nameroot"] = save( - self.nameroot, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.nameext is not None: - r["nameext"] = save( - self.nameext, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.checksum is not None: - r["checksum"] = save( - self.checksum, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.format is not None: - u = save_relative_uri(self.format, base_url, True, None, relative_uris) - r["format"] = u - if self.contents is not None: - r["contents"] = save( - self.contents, top=False, base_url=base_url, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -3983,80 +3813,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "location", - "path", - "basename", - "dirname", - "nameroot", - "nameext", - "checksum", - "size", - "secondaryFiles", - "format", - "contents", - ] - ) - - -class Directory(Saveable): - """ - Represents a directory to present to a command line tool. - - Directories are represented as objects with `class` of `Directory`. Directory objects have - a number of properties that provide metadata about the directory. - - The `location` property of a Directory is a URI that uniquely identifies - the directory. Implementations must support the file:// URI scheme and may - support other schemes such as http://. Alternately to `location`, - implementations must also accept the `path` property on Directory, which - must be a filesystem path available on the same host as the CWL runner (for - inputs) or the runtime environment of a command line tool execution (for - command line tool outputs). - - A Directory object may have a `listing` field. This is a list of File and - Directory objects that are contained in the Directory. For each entry in - `listing`, the `basename` property defines the name of the File or - Subdirectory when staged to disk. If `listing` is not provided, the - implementation must have some way of fetching the Directory listing at - runtime based on the `location` field. - - If a Directory does not have `location`, it is a Directory literal. A - Directory literal must provide `listing`. Directory literals must be - created on disk at runtime as needed. - - The resources in a Directory literal do not need to have any implied - relationship in their `location`. For example, a Directory listing may - contain two files located on different hosts. It is the responsibility of - the runtime to ensure that those files are staged to disk appropriately. - Secondary files associated with files in `listing` must also be staged to - the same Directory. - - When executing a CommandLineTool, Directories must be recursively staged - first and have local values of `path` assigend. - - Directory objects in CommandLineTool output must provide either a - `location` URI or a `path` property in the context of the tool execution - runtime (local to the compute node, or within the executing container). - - An ExpressionTool may forward file references from input to output by using - the same value for `location`. - - Name conflicts (the same `basename` appearing multiple times in `listing` - or in any entry in `secondaryFiles` in the listing) is a fatal error. - - """ - def __init__( self, - location: Optional[Any] = None, - path: Optional[Any] = None, - basename: Optional[Any] = None, - listing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[InputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4066,73 +3831,64 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "Directory" - self.location = location - self.path = path - self.basename = basename - self.listing = listing + self.fields = fields + self.type_ = type_ + self.label = label + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - def __eq__(self, other: Any) -> bool: - if isinstance(other, Directory): - return bool( - self.class_ == other.class_ - and self.location == other.location - and self.path == other.path - and self.basename == other.basename - and self.listing == other.listing - ) - return False + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name"] + ) - def __hash__(self) -> int: - return hash( - (self.class_, self.location, self.path, self.basename, self.listing) - ) - @classmethod +@mypyc_attr(native_class=True) +class InputEnumSchema(schema_salad.metaschema.EnumSchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InputEnumSchema): + return bool( + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + ) + return False + + def __hash__(self) -> int: + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) + + @classmethod def fromDoc( cls, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Directory": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_Directory_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - location = None - if "location" in _doc: + name = None + if "name" in _doc: try: - location = load_field( - _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None_None, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("location") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `location`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -4140,13 +3896,13 @@ def fromDoc( ) ) else: - val = _doc.get("location") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4158,75 +3914,132 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `location` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - path = None - if "path" in _doc: - try: - path = load_field( - _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("path") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - if str(e) == "missing required field `path`": + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("path") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) - else: - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [e], - detailed_message=f"the `path` field with value `{val}` " - "is not valid because:", - ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Enum_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - basename = None - if "basename" in _doc: + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - basename = load_field( - _doc.get("basename"), + label = _load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("basename") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `basename`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4234,13 +4047,13 @@ def fromDoc( ) ) else: - val = _doc.get("basename") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4252,28 +4065,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `basename` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - listing = None - if "listing" in _doc: + doc = None + if "doc" in _doc: try: - listing = load_field( - _doc.get("listing"), - union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("listing") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `listing`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4281,13 +4094,13 @@ def fromDoc( ) ) else: - val = _doc.get("listing") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4299,14 +4112,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `listing` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -4314,14 +4127,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `listing`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), @@ -4331,13 +4144,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - location=location, - path=path, - basename=basename, - listing=listing, + name=name, + symbols=symbols, + type_=type_, + label=label, + doc=doc, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -4351,211 +4166,23 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.location is not None: - u = save_relative_uri(self.location, base_url, False, None, relative_uris) - r["location"] = u - if self.path is not None: - u = save_relative_uri(self.path, base_url, False, None, relative_uris) - r["path"] = u - if self.basename is not None: - r["basename"] = save( - self.basename, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.listing is not None: - r["listing"] = save( - self.listing, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "location", "path", "basename", "listing"]) - - -class Labeled(Saveable): - pass - - -class Identified(Saveable): - pass - - -class IdentifierRequired(Identified): - pass - - -class LoadContents(Saveable): - pass - - -class FieldBase(Labeled): - pass - - -class InputFormat(Saveable): - pass - - -class OutputFormat(Saveable): - pass - - -class Parameter(FieldBase, Documented, IdentifierRequired): - """ - Define an input or output parameter to a process. - - """ - - pass - - -class InputBinding(Saveable): - def __init__( - self, - loadContents: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.loadContents = loadContents - - def __eq__(self, other: Any) -> bool: - if isinstance(other, InputBinding): - return bool(self.loadContents == other.loadContents) - return False - - def __hash__(self) -> int: - return hash((self.loadContents)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputBinding": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - loadContents = None - if "loadContents" in _doc: - try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("loadContents") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadContents`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("loadContents") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], - detailed_message=f"the `loadContents` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `loadContents`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - loadContents=loadContents, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -4566,37 +4193,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["loadContents"]) - - -class IOSchema(Labeled, Documented): - pass - - -class InputSchema(IOSchema): - pass - - -class OutputSchema(IOSchema): - pass - - -class InputRecordField(CWLRecordField, FieldBase, InputFormat, LoadContents): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4606,45 +4211,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing + self.doc = doc + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc"] + ) + + +@mypyc_attr(native_class=True) +class InputArraySchema(CWLArraySchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputRecordField): + if isinstance(other, InputArraySchema): return bool( - self.doc == other.doc - and self.name == other.name + self.items == other.items and self.type_ == other.type_ and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing + and self.doc == other.doc + and self.name == other.name ) return False def __hash__(self) -> int: - return hash( - ( - self.doc, - self.name, - self.type_, - self.label, - self.secondaryFiles, - self.streamable, - self.format, - self.loadContents, - self.loadListing, - ) - ) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -4652,8 +4246,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -4663,9 +4257,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -4708,68 +4302,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -4814,7 +4408,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -4858,21 +4452,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4880,13 +4474,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4898,28 +4492,175 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + items=items, + type_=type_, + label=label, + doc=doc, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.items is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + self.label = label + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class OutputRecordField(CWLRecordField): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, OutputRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.doc, + self.name, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -4927,13 +4668,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4945,28 +4686,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4974,13 +4724,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4992,28 +4742,170 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -5021,13 +4913,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5039,28 +4931,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + format = None + if "format" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -5068,13 +4960,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5086,14 +4978,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5101,14 +4993,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`".format( k ), SourceLine(_doc, k, str), @@ -5118,19 +5010,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + doc=doc, type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, format=format, - loadContents=loadContents, - loadListing=loadListing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -5145,7 +5035,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.doc is not None: r["doc"] = save( @@ -5176,20 +5066,6 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.name, True, None, relative_uris) r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -5199,33 +5075,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "doc", - "name", - "type", - "label", - "secondaryFiles", - "streamable", - "format", - "loadContents", - "loadListing", - ] - ) - - -class InputRecordSchema(CWLRecordSchema, InputSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5235,14 +5095,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.doc = doc + self.name = name self.type_ = type_ self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format + + attrs: ClassVar[Collection[str]] = frozenset( + ["doc", "name", "type", "label", "secondaryFiles", "streamable", "format"] + ) + + +@mypyc_attr(native_class=True) +class OutputRecordSchema(CWLRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputRecordSchema): + if isinstance(other, OutputRecordSchema): return bool( self.fields == other.fields and self.type_ == other.type_ @@ -5261,8 +5132,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -5272,7 +5143,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -5317,20 +5188,19 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name fields = None if "fields" in _doc: try: - fields = load_field( + fields = _load_field( _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, + idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, baseuri, loadingOptions, lc=_doc.get("fields") @@ -5376,7 +5246,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, @@ -5423,7 +5293,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -5470,7 +5340,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -5514,7 +5384,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5522,7 +5392,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -5539,15 +5409,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, fields=fields, type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -5562,7 +5432,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.fields is not None: r["fields"] = save( @@ -5589,21 +5459,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "doc", "name"]) - - -class InputEnumSchema(EnumSchema, InputSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[OutputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5613,14 +5477,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.fields = fields self.type_ = type_ self.label = label self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class OutputEnumSchema(schema_salad.metaschema.EnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputEnumSchema): + if isinstance(other, OutputEnumSchema): return bool( self.name == other.name and self.symbols == other.symbols @@ -5639,8 +5512,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -5650,7 +5523,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -5695,19 +5568,18 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name try: if _doc.get("symbols") is None: raise ValidationException("missing required field `symbols`", None, []) - symbols = load_field( + symbols = _load_field( _doc.get("symbols"), uri_array_of_strtype_True_False_None_None, baseuri, @@ -5755,7 +5627,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, @@ -5802,7 +5674,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -5849,7 +5721,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -5893,7 +5765,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5901,7 +5773,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -5926,7 +5798,7 @@ def fromDoc( extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -5941,7 +5813,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) @@ -5967,21 +5839,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "doc"]) - - -class InputArraySchema(CWLArraySchema, InputSchema): - name: str - def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5991,14 +5857,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc"] + ) + + +@mypyc_attr(native_class=True) +class OutputArraySchema(CWLArraySchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputArraySchema): + if isinstance(other, OutputArraySchema): return bool( self.items == other.items and self.type_ == other.type_ @@ -6017,8 +5892,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -6028,7 +5903,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -6073,21 +5948,20 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name try: if _doc.get("items") is None: raise ValidationException("missing required field `items`", None, []) - items = load_field( + items = _load_field( _doc.get("items"), - uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, + uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, lc=_doc.get("items") @@ -6133,7 +6007,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Array_nameLoader_2, baseuri, @@ -6180,7 +6054,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -6227,7 +6101,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -6271,7 +6145,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -6279,7 +6153,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -6296,15 +6170,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, items=items, type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -6319,7 +6193,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.items is not None: u = save_relative_uri(self.items, self.name, False, 2, relative_uris) @@ -6345,23 +6219,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "doc", "name"]) - - -class OutputRecordField(CWLRecordField, FieldBase, OutputFormat): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -6371,39 +6237,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.items = items self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class InlineJavascriptRequirement(Saveable): + """ + Indicates that the workflow platform must support inline Javascript expressions. If this requirement is not present, the workflow platform must not perform expression interpolatation. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputRecordField): + if isinstance(other, InlineJavascriptRequirement): return bool( - self.doc == other.doc - and self.name == other.name - and self.type_ == other.type_ - and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format + self.class_ == other.class_ + and self.expressionLib == other.expressionLib ) return False def __hash__(self) -> int: - return hash( - ( - self.doc, - self.name, - self.type_, - self.label, - self.secondaryFiles, - self.streamable, - self.format, - ) - ) + return hash((self.class_, self.expressionLib)) @classmethod def fromDoc( @@ -6411,85 +6272,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) + class_ = _load_field( + _doc.get("class"), + uri_InlineJavascriptRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + expressionLib = None + if "expressionLib" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + expressionLib = _load_field( + _doc.get("expressionLib"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("expressionLib") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `expressionLib`": _errors__.append( ValidationException( str(e), @@ -6497,13 +6319,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("expressionLib") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6515,286 +6337,43 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `expressionLib` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + "invalid field `{}`, expected one of: `class`, `expressionLib`".format( + k + ), + SourceLine(_doc, k, str), ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `secondaryFiles`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - doc=doc, - name=name, - type_=type_, - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - format=format, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + expressionLib=expressionLib, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed def save( self, top: bool = False, base_url: str = "", relative_uris: bool = True @@ -6807,38 +6386,23 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.expressionLib is not None: + r["expressionLib"] = save( + self.expressionLib, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) - if self.format is not None: - u = save_relative_uri(self.format, self.name, True, None, relative_uris) - r["format"] = u # top refers to the directory level if top: @@ -6848,23 +6412,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - ["doc", "name", "type", "label", "secondaryFiles", "streamable", "format"] - ) - - -class OutputRecordSchema(CWLRecordSchema, OutputSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + expressionLib: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -6874,25 +6426,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields - self.type_ = type_ - self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.class_: Final[str] = "InlineJavascriptRequirement" + self.expressionLib = expressionLib + + attrs: ClassVar[Collection[str]] = frozenset(["class", "expressionLib"]) + + +@mypyc_attr(native_class=True) +class SchemaDefRequirement(Saveable): + """ + This field consists of an array of type definitions which must be used when interpreting the ``inputs`` and ``outputs`` fields. When a ``type`` field contain a IRI, the implementation must check if the type is defined in ``schemaDefs`` and use that definition. If the type is not found in ``schemaDefs``, it is an error. The entries in ``schemaDefs`` must be processed in the order listed such that later schema definitions may refer to earlier schema definitions. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputRecordSchema): - return bool( - self.fields == other.fields - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc - and self.name == other.name - ) + if isinstance(other, SchemaDefRequirement): + return bool(self.class_ == other.class_ and self.types == other.types) return False def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.doc, self.name)) + return hash((self.class_, self.types)) @classmethod def fromDoc( @@ -6900,133 +6453,47 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: - try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, - baseuri, - loadingOptions, - lc=_doc.get("fields") - ) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + class_ = _load_field( + _doc.get("class"), + uri_SchemaDefRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - if str(e) == "missing required field `fields`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("fields") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [e], - detailed_message=f"the `fields` field with value `{val}` " - "is not valid because:", - ) - ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("types") is None: + raise ValidationException("missing required field `types`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, + types = _load_field( + _doc.get("types"), + array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("types") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `types`": _errors__.append( ValidationException( str(e), @@ -7034,13 +6501,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("types") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7052,108 +6519,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `types` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -7161,14 +6534,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( + "invalid field `{}`, expected one of: `class`, `types`".format( k ), SourceLine(_doc, k, str), @@ -7178,15 +6551,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, - type_=type_, - label=label, - doc=doc, - name=name, + types=types, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7200,24 +6568,19 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.types is not None: + r["types"] = save( + self.types, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7228,21 +6591,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "doc", "name"]) - - -class OutputEnumSchema(EnumSchema, OutputSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + types: Sequence[CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -7252,25 +6605,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols - self.type_ = type_ - self.label = label - self.doc = doc + self.class_: Final[str] = "SchemaDefRequirement" + self.types = types + + attrs: ClassVar[Collection[str]] = frozenset(["class", "types"]) + +@mypyc_attr(native_class=True) +class SecondaryFileSchema(Saveable): def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputEnumSchema): + if isinstance(other, SecondaryFileSchema): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc + self.pattern == other.pattern and self.required == other.required ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_, self.label, self.doc)) + return hash((self.pattern, self.required)) @classmethod def fromDoc( @@ -7278,134 +6629,30 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", - ) - ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("pattern") is None: + raise ValidationException("missing required field `pattern`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, + pattern = _load_field( + _doc.get("pattern"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("pattern") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `pattern`": _errors__.append( ValidationException( str(e), @@ -7413,13 +6660,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("pattern") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7431,75 +6678,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `pattern` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: + required = None + if "required" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + required = _load_field( + _doc.get("required"), + union_of_None_type_or_booltype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("required") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `required`": _errors__.append( ValidationException( str(e), @@ -7507,13 +6707,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("required") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7525,14 +6725,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `required` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -7540,14 +6740,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( + "invalid field `{}`, expected one of: `pattern`, `required`".format( k ), SourceLine(_doc, k, str), @@ -7557,15 +6757,11 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - label=label, - doc=doc, + pattern=pattern, + required=required, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7579,23 +6775,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + if self.pattern is not None: + r["pattern"] = save( + self.pattern, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.required is not None: + r["required"] = save( + self.required, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7606,21 +6792,12 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "doc"]) - - -class OutputArraySchema(CWLArraySchema, OutputSchema): - name: str - def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + pattern: str, + required: None | bool | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -7630,25 +6807,28 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.pattern = pattern + self.required = required + + attrs: ClassVar[Collection[str]] = frozenset(["pattern", "required"]) + + +@mypyc_attr(native_class=True) +class LoadListingRequirement(Saveable): + """ + Specify the desired behavior for loading the ``listing`` field of a Directory object for use by expressions. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputArraySchema): + if isinstance(other, LoadListingRequirement): return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc - and self.name == other.name + self.class_ == other.class_ and self.loadListing == other.loadListing ) return False def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.doc, self.name)) + return hash((self.class_, self.loadListing)) @classmethod def fromDoc( @@ -7656,29 +6836,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_LoadListingRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + loadListing = None + if "loadListing" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -7686,13 +6883,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7704,38 +6901,148 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `loadListing`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + loadListing=loadListing, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + loadListing: LoadListingEnum | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "LoadListingRequirement" + self.loadListing = loadListing + + attrs: ClassVar[Collection[str]] = frozenset(["class", "loadListing"]) + + +@mypyc_attr(native_class=True) +class EnvironmentDef(Saveable): + """ + Define an environment variable that will be set in the runtime environment by the workflow platform when executing the command line tool. May be the result of executing an expression, such as getting a parameter from input. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, EnvironmentDef): + return bool( + self.envName == other.envName and self.envValue == other.envValue + ) + return False + + def __hash__(self) -> int: + return hash((self.envName, self.envValue)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("envName") is None: + raise ValidationException("missing required field `envName`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, + envName = _load_field( + _doc.get("envName"), + strtype, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("envName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": + if str(e) == "missing required field `envName`": _errors__.append( ValidationException( str(e), @@ -7743,13 +7050,13 @@ def fromDoc( ) ) else: - val = _doc.get("items") + val = _doc.get("envName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7761,29 +7068,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), [e], - detailed_message=f"the `items` field with value `{val}` " + detailed_message=f"the `envName` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("envValue") is None: + raise ValidationException("missing required field `envValue`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, + envValue = _load_field( + _doc.get("envValue"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("envValue") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `envValue`": _errors__.append( ValidationException( str(e), @@ -7791,13 +7098,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("envValue") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7809,141 +7116,43 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `envValue` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( - k - ), - SourceLine(_doc, k, str), + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `envName`, `envValue`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, - label=label, - doc=doc, - name=name, + envName=envName, + envValue=envValue, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7957,23 +7166,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.items is not None: - u = save_relative_uri(self.items, self.name, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + if self.envName is not None: + r["envName"] = save( + self.envName, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.envValue is not None: + r["envValue"] = save( + self.envValue, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7984,78 +7183,77 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "doc", "name"]) - - -class InputParameter(Parameter, InputFormat, LoadContents): - pass - + def __init__( + self, + envName: str, + envValue: str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.envName = envName + self.envValue = envValue -class OutputParameter(Parameter, OutputFormat): - pass + attrs: ClassVar[Collection[str]] = frozenset(["envName", "envValue"]) -class ProcessRequirement(Saveable): +@mypyc_attr(native_class=True) +class CommandLineBinding(InputBinding): """ - A process requirement declares a prerequisite that may or must be fulfilled - before executing a process. See [`Process.hints`](#process) and - [`Process.requirements`](#process). + When listed under ``inputBinding`` in the input schema, the term "value" refers to the the corresponding value in the input object. For binding objects listed in ``CommandLineTool.arguments``, the term "value" refers to the effective value after evaluating ``valueFrom``. - Process requirements are the primary mechanism for specifying extensions to - the CWL core specification. + The binding behavior when building the command line depends on the data type of the value. If there is a mismatch between the type described by the input schema and the effective value, such as resulting from an expression evaluation, an implementation must use the data type of the effective value. - """ - - pass + - **string**: Add ``prefix`` and the string to the command line. + - **number**: Add ``prefix`` and decimal representation to command line. -class Process(Identified, Labeled, Documented): - """ + - **boolean**: If true, add ``prefix`` to the command line. If false, add nothing. - The base executable type in CWL is the `Process` object defined by the - document. Note that the `Process` object is abstract and cannot be - directly executed. + - **File**: Add ``prefix`` and the value of ```File.path`` <#File>`__ to the command line. - """ + - **Directory**: Add ``prefix`` and the value of ```Directory.path`` <#Directory>`__ to the command line. - pass + - **array**: If ``itemSeparator`` is specified, add ``prefix`` and the join the array into a single string with ``itemSeparator`` separating the items. Otherwise first add ``prefix``, then recursively process individual elements. If the array is empty, it does not add anything to command line. + - **object**: Add ``prefix`` only, and recursively add object fields for which ``inputBinding`` is specified. -class InlineJavascriptRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support inline Javascript expressions. - If this requirement is not present, the workflow platform must not perform expression - interpolatation. + - **null**: Add nothing. """ - def __init__( - self, - expressionLib: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "InlineJavascriptRequirement" - self.expressionLib = expressionLib - def __eq__(self, other: Any) -> bool: - if isinstance(other, InlineJavascriptRequirement): + if isinstance(other, CommandLineBinding): return bool( - self.class_ == other.class_ - and self.expressionLib == other.expressionLib + self.loadContents == other.loadContents + and self.position == other.position + and self.prefix == other.prefix + and self.separate == other.separate + and self.itemSeparator == other.itemSeparator + and self.valueFrom == other.valueFrom + and self.shellQuote == other.shellQuote ) return False def __hash__(self) -> int: - return hash((self.class_, self.expressionLib)) + return hash( + ( + self.loadContents, + self.position, + self.prefix, + self.separate, + self.itemSeparator, + self.valueFrom, + self.shellQuote, + ) + ) @classmethod def fromDoc( @@ -8063,45 +7261,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InlineJavascriptRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_InlineJavascriptRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - expressionLib = None - if "expressionLib" in _doc: + loadContents = None + if "loadContents" in _doc: try: - expressionLib = load_field( - _doc.get("expressionLib"), - union_of_None_type_or_array_of_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("expressionLib") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `expressionLib`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -8109,13 +7291,13 @@ def fromDoc( ) ) else: - val = _doc.get("expressionLib") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `expressionLib` field is not valid because:", - SourceLine(_doc, "expressionLib", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8127,39 +7309,327 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `expressionLib` field is not valid because:", - SourceLine(_doc, "expressionLib", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `expressionLib` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + position = None + if "position" in _doc: + try: + position = _load_field( + _doc.get("position"), + union_of_None_type_or_inttype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("position") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `position`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("position") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [e], + detailed_message=f"the `position` field with value `{val}` " + "is not valid because:", + ) + ) + prefix = None + if "prefix" in _doc: + try: + prefix = _load_field( + _doc.get("prefix"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("prefix") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `prefix`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `expressionLib`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None + ) + ) + else: + val = _doc.get("prefix") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [e], + detailed_message=f"the `prefix` field with value `{val}` " + "is not valid because:", + ) + ) + separate = None + if "separate" in _doc: + try: + separate = _load_field( + _doc.get("separate"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("separate") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `separate`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("separate") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [e], + detailed_message=f"the `separate` field with value `{val}` " + "is not valid because:", + ) + ) + itemSeparator = None + if "itemSeparator" in _doc: + try: + itemSeparator = _load_field( + _doc.get("itemSeparator"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("itemSeparator") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `itemSeparator`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("itemSeparator") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [e], + detailed_message=f"the `itemSeparator` field with value `{val}` " + "is not valid because:", + ) + ) + valueFrom = None + if "valueFrom" in _doc: + try: + valueFrom = _load_field( + _doc.get("valueFrom"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("valueFrom") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("valueFrom") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + detailed_message=f"the `valueFrom` field with value `{val}` " + "is not valid because:", + ) + ) + shellQuote = None + if "shellQuote" in _doc: + try: + shellQuote = _load_field( + _doc.get("shellQuote"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("shellQuote") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `shellQuote`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("shellQuote") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [e], + detailed_message=f"the `shellQuote` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `loadContents`, `position`, `prefix`, `separate`, `itemSeparator`, `valueFrom`, `shellQuote`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - expressionLib=expressionLib, + loadContents=loadContents, + position=position, + prefix=prefix, + separate=separate, + itemSeparator=itemSeparator, + valueFrom=valueFrom, + shellQuote=shellQuote, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -8176,205 +7646,45 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.expressionLib is not None: - r["expressionLib"] = save( - self.expressionLib, + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, top=False, base_url=base_url, relative_uris=relative_uris, ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "expressionLib"]) - - -class CommandInputSchema(Saveable): - pass - - -class SchemaDefRequirement(ProcessRequirement): - """ - This field consists of an array of type definitions which must be used when - interpreting the `inputs` and `outputs` fields. When a `type` field - contain a IRI, the implementation must check if the type is defined in - `schemaDefs` and use that definition. If the type is not found in - `schemaDefs`, it is an error. The entries in `schemaDefs` must be - processed in the order listed such that later schema definitions may refer - to earlier schema definitions. - - """ - - def __init__( - self, - types: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SchemaDefRequirement" - self.types = types - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SchemaDefRequirement): - return bool(self.class_ == other.class_ and self.types == other.types) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.types)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SchemaDefRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_SchemaDefRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("types") is None: - raise ValidationException("missing required field `types`", None, []) - - types = load_field( - _doc.get("types"), - array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("types") + if self.prefix is not None: + r["prefix"] = save( + self.prefix, top=False, base_url=base_url, relative_uris=relative_uris ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `types`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("types") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `types` field is not valid because:", - SourceLine(_doc, "types", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `types` field is not valid because:", - SourceLine(_doc, "types", str), - [e], - detailed_message=f"the `types` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `types`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - types=types, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.types is not None: - r["types"] = save( - self.types, top=False, base_url=base_url, relative_uris=relative_uris + if self.separate is not None: + r["separate"] = save( + self.separate, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.itemSeparator is not None: + r["itemSeparator"] = save( + self.itemSeparator, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.valueFrom is not None: + r["valueFrom"] = save( + self.valueFrom, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.shellQuote is not None: + r["shellQuote"] = save( + self.shellQuote, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -8385,16 +7695,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "types"]) - - -class SecondaryFileSchema(Saveable): def __init__( self, - pattern: Any, - required: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + position: None | i32 | str = None, + prefix: None | str = None, + separate: None | bool = None, + itemSeparator: None | str = None, + valueFrom: None | str = None, + shellQuote: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8404,18 +7715,53 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.pattern = pattern - self.required = required + self.loadContents = loadContents + self.position = position + self.prefix = prefix + self.separate = separate + self.itemSeparator = itemSeparator + self.valueFrom = valueFrom + self.shellQuote = shellQuote + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "loadContents", + "position", + "prefix", + "separate", + "itemSeparator", + "valueFrom", + "shellQuote", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputBinding(Saveable): + """ + Describes how to generate an output parameter based on the files produced by a CommandLineTool. + + The output parameter value is generated by applying these operations in the following order: + + - glob + - loadContents + - outputEval + - secondaryFiles + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, SecondaryFileSchema): + if isinstance(other, CommandOutputBinding): return bool( - self.pattern == other.pattern and self.required == other.required + self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.glob == other.glob + and self.outputEval == other.outputEval ) return False def __hash__(self) -> int: - return hash((self.pattern, self.required)) + return hash((self.loadContents, self.loadListing, self.glob, self.outputEval)) @classmethod def fromDoc( @@ -8423,77 +7769,123 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SecondaryFileSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("pattern") is None: - raise ValidationException("missing required field `pattern`", None, []) - - pattern = load_field( - _doc.get("pattern"), - union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("pattern") - ) + loadContents = None + if "loadContents" in _doc: + try: + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("loadContents") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `pattern`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("pattern") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( - "the `pattern` field is not valid because:", - SourceLine(_doc, "pattern", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("loadContents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + detailed_message=f"the `loadContents` field with value `{val}` " + "is not valid because:", + ) + ) + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( - "the `pattern` field is not valid because:", - SourceLine(_doc, "pattern", str), - [e], - detailed_message=f"the `pattern` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - required = None - if "required" in _doc: + else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + glob = None + if "glob" in _doc: try: - required = load_field( - _doc.get("required"), - union_of_None_type_or_booltype_or_ExpressionLoader, + glob = _load_field( + _doc.get("glob"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("required") + lc=_doc.get("glob") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `required`": + if str(e) == "missing required field `glob`": _errors__.append( ValidationException( str(e), @@ -8501,13 +7893,13 @@ def fromDoc( ) ) else: - val = _doc.get("required") + val = _doc.get("glob") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `required` field is not valid because:", - SourceLine(_doc, "required", str), + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8519,14 +7911,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `required` field is not valid because:", - SourceLine(_doc, "required", str), + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), [e], - detailed_message=f"the `required` field with value `{val}` " + detailed_message=f"the `glob` field with value `{val}` " + "is not valid because:", + ) + ) + outputEval = None + if "outputEval" in _doc: + try: + outputEval = _load_field( + _doc.get("outputEval"), + union_of_None_type_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputEval") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputEval`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputEval") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [e], + detailed_message=f"the `outputEval` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -8534,14 +7973,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `pattern`, `required`".format( + "invalid field `{}`, expected one of: `loadContents`, `loadListing`, `glob`, `outputEval`".format( k ), SourceLine(_doc, k, str), @@ -8551,8 +7990,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - pattern=pattern, - required=required, + loadContents=loadContents, + loadListing=loadListing, + glob=glob, + outputEval=outputEval, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -8569,13 +8010,30 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.pattern is not None: - r["pattern"] = save( - self.pattern, top=False, base_url=base_url, relative_uris=relative_uris + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) - if self.required is not None: - r["required"] = save( - self.required, top=False, base_url=base_url, relative_uris=relative_uris + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.glob is not None: + r["glob"] = save( + self.glob, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.outputEval is not None: + r["outputEval"] = save( + self.outputEval, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -8586,21 +8044,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["pattern", "required"]) - - -class LoadListingRequirement(ProcessRequirement): - """ - Specify the desired behavior for loading the `listing` field of - a Directory object for use by expressions. - - """ - def __init__( self, - loadListing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + glob: None | Sequence[str] | str = None, + outputEval: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8610,18 +8061,51 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "LoadListingRequirement" + self.loadContents = loadContents self.loadListing = loadListing + self.glob = glob + self.outputEval = outputEval + + attrs: ClassVar[Collection[str]] = frozenset( + ["loadContents", "loadListing", "glob", "outputEval"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputRecordField(InputRecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, LoadListingRequirement): + if isinstance(other, CommandInputRecordField): return bool( - self.class_ == other.class_ and self.loadListing == other.loadListing + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.class_, self.loadListing)) + return hash( + ( + self.doc, + self.name, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + self.loadContents, + self.loadListing, + self.inputBinding, + ) + ) @classmethod def fromDoc( @@ -8629,45 +8113,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "LoadListingRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_LoadListingRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - loadListing = None - if "loadListing" in _doc: + name = None + if "name" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -8675,13 +8143,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8693,196 +8161,85 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `loadListing`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - loadListing=loadListing, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" + if name is None: + if docRoot is not None: + name = docRoot else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "loadListing"]) - - -class EnvironmentDef(Saveable): - """ - Define an environment variable that will be set in the runtime environment - by the workflow platform when executing the command line tool. May be the - result of executing an expression, such as getting a parameter from input. - - """ - - def __init__( - self, - envName: Any, - envValue: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions + name = "" + _errors__.append(ValidationException("missing name")) else: - self.loadingOptions = LoadingOptions() - self.envName = envName - self.envValue = envValue - - def __eq__(self, other: Any) -> bool: - if isinstance(other, EnvironmentDef): - return bool( - self.envName == other.envName and self.envValue == other.envValue - ) - return False - - def __hash__(self) -> int: - return hash((self.envName, self.envValue)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnvironmentDef": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("envName") is None: - raise ValidationException("missing required field `envName`", None, []) - - envName = load_field( - _doc.get("envName"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("envName") - ) + baseuri = name + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `envName`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("envName") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - "the `envName` field is not valid because:", - SourceLine(_doc, "envName", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `envName` field is not valid because:", - SourceLine(_doc, "envName", str), - [e], - detailed_message=f"the `envName` field with value `{val}` " - "is not valid because:", + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) ) - ) try: - if _doc.get("envValue") is None: - raise ValidationException("missing required field `envValue`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - envValue = load_field( - _doc.get("envValue"), - union_of_strtype_or_ExpressionLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("envValue") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `envValue`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -8890,13 +8247,13 @@ def fromDoc( ) ) else: - val = _doc.get("envValue") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `envValue` field is not valid because:", - SourceLine(_doc, "envValue", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8908,213 +8265,42 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `envValue` field is not valid because:", - SourceLine(_doc, "envValue", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `envValue` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `envName`, `envValue`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - envName=envName, - envValue=envValue, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.envName is not None: - r["envName"] = save( - self.envName, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.envValue is not None: - r["envValue"] = save( - self.envValue, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["envName", "envValue"]) - - -class CommandLineBinding(InputBinding): - """ - - When listed under `inputBinding` in the input schema, the term - "value" refers to the the corresponding value in the input object. For - binding objects listed in `CommandLineTool.arguments`, the term "value" - refers to the effective value after evaluating `valueFrom`. - - The binding behavior when building the command line depends on the data - type of the value. If there is a mismatch between the type described by - the input schema and the effective value, such as resulting from an - expression evaluation, an implementation must use the data type of the - effective value. - - - **string**: Add `prefix` and the string to the command line. - - - **number**: Add `prefix` and decimal representation to command line. - - - **boolean**: If true, add `prefix` to the command line. If false, add - nothing. - - - **File**: Add `prefix` and the value of - [`File.path`](#File) to the command line. - - - **Directory**: Add `prefix` and the value of - [`Directory.path`](#Directory) to the command line. - - - **array**: If `itemSeparator` is specified, add `prefix` and the join - the array into a single string with `itemSeparator` separating the - items. Otherwise first add `prefix`, then recursively process - individual elements. - If the array is empty, it does not add anything to command line. - - - **object**: Add `prefix` only, and recursively add object fields for - which `inputBinding` is specified. - - - **null**: Add nothing. - - """ - - def __init__( - self, - loadContents: Optional[Any] = None, - position: Optional[Any] = None, - prefix: Optional[Any] = None, - separate: Optional[Any] = None, - itemSeparator: Optional[Any] = None, - valueFrom: Optional[Any] = None, - shellQuote: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.loadContents = loadContents - self.position = position - self.prefix = prefix - self.separate = separate - self.itemSeparator = itemSeparator - self.valueFrom = valueFrom - self.shellQuote = shellQuote - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandLineBinding): - return bool( - self.loadContents == other.loadContents - and self.position == other.position - and self.prefix == other.prefix - and self.separate == other.separate - and self.itemSeparator == other.itemSeparator - and self.valueFrom == other.valueFrom - and self.shellQuote == other.shellQuote - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.loadContents, - self.position, - self.prefix, - self.separate, - self.itemSeparator, - self.valueFrom, - self.shellQuote, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandLineBinding": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - loadContents = None - if "loadContents" in _doc: - try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("loadContents") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadContents`": - _errors__.append( - ValidationException( - str(e), - None + str(e), + None ) ) else: - val = _doc.get("loadContents") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9126,28 +8312,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - position = None - if "position" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_inttype_or_ExpressionLoader, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -9155,13 +8341,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9173,28 +8359,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - prefix = None - if "prefix" in _doc: + streamable = None + if "streamable" in _doc: try: - prefix = load_field( - _doc.get("prefix"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("prefix") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `prefix`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -9202,13 +8388,13 @@ def fromDoc( ) ) else: - val = _doc.get("prefix") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `prefix` field is not valid because:", - SourceLine(_doc, "prefix", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9220,28 +8406,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `prefix` field is not valid because:", - SourceLine(_doc, "prefix", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `prefix` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - separate = None - if "separate" in _doc: + format = None + if "format" in _doc: try: - separate = load_field( - _doc.get("separate"), - union_of_None_type_or_booltype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("separate") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `separate`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -9249,13 +8435,13 @@ def fromDoc( ) ) else: - val = _doc.get("separate") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `separate` field is not valid because:", - SourceLine(_doc, "separate", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9267,28 +8453,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `separate` field is not valid because:", - SourceLine(_doc, "separate", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `separate` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - itemSeparator = None - if "itemSeparator" in _doc: + loadContents = None + if "loadContents" in _doc: try: - itemSeparator = load_field( - _doc.get("itemSeparator"), - union_of_None_type_or_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("itemSeparator") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `itemSeparator`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -9296,13 +8482,13 @@ def fromDoc( ) ) else: - val = _doc.get("itemSeparator") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `itemSeparator` field is not valid because:", - SourceLine(_doc, "itemSeparator", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9314,28 +8500,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `itemSeparator` field is not valid because:", - SourceLine(_doc, "itemSeparator", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `itemSeparator` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + loadListing = None + if "loadListing" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -9343,13 +8529,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9361,28 +8547,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) - shellQuote = None - if "shellQuote" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - shellQuote = load_field( - _doc.get("shellQuote"), - union_of_None_type_or_booltype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("shellQuote") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `shellQuote`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -9390,13 +8576,13 @@ def fromDoc( ) ) else: - val = _doc.get("shellQuote") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `shellQuote` field is not valid because:", - SourceLine(_doc, "shellQuote", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9408,14 +8594,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `shellQuote` field is not valid because:", - SourceLine(_doc, "shellQuote", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `shellQuote` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -9423,14 +8609,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `loadContents`, `position`, `prefix`, `separate`, `itemSeparator`, `valueFrom`, `shellQuote`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -9440,16 +8626,20 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, + doc=doc, + type_=type_, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + format=format, loadContents=loadContents, - position=position, - prefix=prefix, - separate=separate, - itemSeparator=itemSeparator, - valueFrom=valueFrom, - shellQuote=shellQuote, + loadListing=loadListing, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -9463,44 +8653,57 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.prefix is not None: - r["prefix"] = save( - self.prefix, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.separate is not None: - r["separate"] = save( - self.separate, top=False, base_url=base_url, relative_uris=relative_uris + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - if self.itemSeparator is not None: - r["itemSeparator"] = save( - self.itemSeparator, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, + if self.format is not None: + u = save_relative_uri(self.format, self.name, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) - if self.shellQuote is not None: - r["shellQuote"] = save( - self.shellQuote, + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, top=False, - base_url=base_url, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, relative_uris=relative_uris, ) @@ -9512,42 +8715,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "loadContents", - "position", - "prefix", - "separate", - "itemSeparator", - "valueFrom", - "shellQuote", - ] - ) - - -class CommandOutputBinding(LoadContents): - """ - Describes how to generate an output parameter based on the files produced - by a CommandLineTool. - - The output parameter value is generated by applying these operations in the - following order: - - - glob - - loadContents - - outputEval - - secondaryFiles - - """ - def __init__( self, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - glob: Optional[Any] = None, - outputEval: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -9557,23 +8738,60 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format self.loadContents = loadContents self.loadListing = loadListing - self.glob = glob - self.outputEval = outputEval + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "doc", + "name", + "type", + "label", + "secondaryFiles", + "streamable", + "format", + "loadContents", + "loadListing", + "inputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandInputRecordSchema(InputRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputBinding): + if isinstance(other, CommandInputRecordSchema): return bool( - self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.glob == other.glob - and self.outputEval == other.outputEval + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + and self.name == other.name + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.loadContents, self.loadListing, self.glob, self.outputEval)) + return hash( + ( + self.fields, + self.type_, + self.label, + self.doc, + self.name, + self.inputBinding, + ) + ) @classmethod def fromDoc( @@ -9581,29 +8799,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputBinding": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - loadContents = None - if "loadContents" in _doc: + name = None + if "name" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -9611,13 +8829,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9629,28 +8847,36 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + fields = None + if "fields" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("fields") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( str(e), @@ -9658,13 +8884,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("fields") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9676,42 +8902,90 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `fields` field with value `{val}` " "is not valid because:", ) ) - glob = None - if "glob" in _doc: - try: - glob = load_field( - _doc.get("glob"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("glob") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `glob`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("glob") + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `glob` field is not valid because:", - SourceLine(_doc, "glob", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9723,28 +8997,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `glob` field is not valid because:", - SourceLine(_doc, "glob", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `glob` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - outputEval = None - if "outputEval" in _doc: + doc = None + if "doc" in _doc: try: - outputEval = load_field( - _doc.get("outputEval"), - union_of_None_type_or_ExpressionLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("outputEval") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputEval`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -9752,13 +9026,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputEval") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputEval` field is not valid because:", - SourceLine(_doc, "outputEval", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9770,14 +9044,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputEval` field is not valid because:", - SourceLine(_doc, "outputEval", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `outputEval` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -9785,14 +9106,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `loadContents`, `loadListing`, `glob`, `outputEval`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -9802,13 +9123,16 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - loadContents=loadContents, - loadListing=loadListing, - glob=glob, - outputEval=outputEval, + name=name, + fields=fields, + type_=type_, + label=label, + doc=doc, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -9822,29 +9146,30 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.glob is not None: - r["glob"] = save( - self.glob, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.outputEval is not None: - r["outputEval"] = save( - self.outputEval, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) @@ -9856,30 +9181,16 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["loadContents", "loadListing", "glob", "outputEval"]) - - -class CommandLineBindable(Saveable): - pass - - -class CommandInputRecordField(InputRecordField, CommandLineBindable): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CommandInputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -9889,29 +9200,30 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.fields = fields self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) self.inputBinding = inputBinding + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputEnumSchema(InputEnumSchema): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputRecordField): + if isinstance(other, CommandInputEnumSchema): return bool( - self.doc == other.doc - and self.name == other.name + self.name == other.name + and self.symbols == other.symbols and self.type_ == other.type_ and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing + and self.doc == other.doc and self.inputBinding == other.inputBinding ) return False @@ -9919,15 +9231,11 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( ( - self.doc, self.name, + self.symbols, self.type_, self.label, - self.secondaryFiles, - self.streamable, - self.format, - self.loadContents, - self.loadListing, + self.doc, self.inputBinding, ) ) @@ -9938,8 +9246,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -9949,9 +9257,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -9994,68 +9302,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -10100,7 +9408,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -10144,21 +9452,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -10166,13 +9474,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10184,28 +9492,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -10213,13 +9521,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10231,28 +9539,176 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`, `inputBinding`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + symbols=symbols, + type_=type_, + label=label, + doc=doc, + inputBinding=inputBinding, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols + self.type_ = type_ + self.label = label + self.doc = doc + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputArraySchema(InputArraySchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CommandInputArraySchema): + return bool( + self.items == other.items + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + and self.name == other.name + and self.inputBinding == other.inputBinding + ) + return False + + def __hash__(self) -> int: + return hash( + (self.items, self.type_, self.label, self.doc, self.name, self.inputBinding) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -10260,13 +9716,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10278,28 +9734,132 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -10307,13 +9867,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10325,28 +9885,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + doc = None + if "doc" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -10354,13 +9914,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10372,17 +9932,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) inputBinding = None if "inputBinding" in _doc: try: - inputBinding = load_field( + inputBinding = _load_field( _doc.get("inputBinding"), union_of_None_type_or_CommandLineBindingLoader, baseuri, @@ -10426,7 +9986,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -10434,14 +9994,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`, `inputBinding`".format( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -10451,20 +10011,16 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + items=items, type_=type_, label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - format=format, - loadContents=loadContents, - loadListing=loadListing, + doc=doc, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -10479,12 +10035,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.items is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -10493,36 +10048,9 @@ def save( r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.name, True, None, relative_uris) - r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -10540,37 +10068,16 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "doc", - "name", - "type", - "label", - "secondaryFiles", - "streamable", - "format", - "loadContents", - "loadListing", - "inputBinding", - ] - ) - - -class CommandInputRecordSchema( - InputRecordSchema, CommandInputSchema, CommandLineBindable -): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -10580,34 +10087,47 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.items = items self.type_ = type_ self.label = label self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) self.inputBinding = inputBinding + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputRecordField(OutputRecordField): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputRecordSchema): + if isinstance(other, CommandOutputRecordField): return bool( - self.fields == other.fields + self.doc == other.doc + and self.name == other.name and self.type_ == other.type_ and self.label == other.label - and self.doc == other.doc - and self.name == other.name - and self.inputBinding == other.inputBinding + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: return hash( ( - self.fields, - self.type_, - self.label, self.doc, self.name, - self.inputBinding, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + self.outputBinding, ) ) @@ -10617,8 +10137,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -10628,9 +10148,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -10673,29 +10193,29 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: - try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -10703,13 +10223,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10721,10 +10241,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) @@ -10732,9 +10252,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Record_nameLoader_2, + typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -10779,7 +10299,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -10823,21 +10343,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -10845,13 +10365,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10863,28 +10383,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + streamable = None + if "streamable" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -10892,13 +10412,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10910,14 +10430,108 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + outputBinding = None + if "outputBinding" in _doc: + try: + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -10925,14 +10539,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -10942,16 +10556,18 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, + name=name, + doc=doc, type_=type_, label=label, - doc=doc, - name=name, - inputBinding=inputBinding, + secondaryFiles=secondaryFiles, + streamable=streamable, + format=format, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -10966,11 +10582,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) if self.type_ is not None: r["type"] = save( @@ -10980,13 +10596,26 @@ def save( r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.name, True, None, relative_uris) + r["format"] = u + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, top=False, base_url=self.name, relative_uris=relative_uris, @@ -11000,22 +10629,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "doc", "name", "inputBinding"]) - - -class CommandInputEnumSchema(InputEnumSchema, CommandInputSchema, CommandLineBindable): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11025,36 +10650,46 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.doc = doc + self.name = name self.type_ = type_ self.label = label - self.doc = doc - self.inputBinding = inputBinding + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "doc", + "name", + "type", + "label", + "secondaryFiles", + "streamable", + "format", + "outputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputRecordSchema(OutputRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputEnumSchema): + if isinstance(other, CommandOutputRecordSchema): return bool( - self.name == other.name - and self.symbols == other.symbols + self.fields == other.fields and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.inputBinding == other.inputBinding + and self.name == other.name ) return False def __hash__(self) -> int: - return hash( - ( - self.name, - self.symbols, - self.type_, - self.label, - self.doc, - self.inputBinding, - ) - ) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -11062,8 +10697,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -11073,7 +10708,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -11118,69 +10753,67 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) + else: + baseuri = name + fields = None + if "fields" in _doc: + try: + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, + baseuri, + loadingOptions, + lc=_doc.get("fields") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + val = _doc.get("fields") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + detailed_message=f"the `fields` field with value `{val}` " + "is not valid because:", + ) ) - ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Enum_nameLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -11225,7 +10858,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -11272,7 +10905,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -11316,54 +10949,7 @@ def fromDoc( "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -11371,14 +10957,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`, `inputBinding`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( k ), SourceLine(_doc, k, str), @@ -11389,15 +10975,14 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( name=name, - symbols=symbols, + fields=fields, type_=type_, label=label, doc=doc, - inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -11412,11 +10997,12 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris + ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -11429,13 +11015,6 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -11445,24 +11024,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "doc", "inputBinding"]) - - -class CommandInputArraySchema( - InputArraySchema, CommandInputSchema, CommandLineBindable -): - name: str - def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CommandOutputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11472,29 +11042,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items + self.fields = fields self.type_ = type_ self.label = label self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputEnumSchema(OutputEnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputArraySchema): + if isinstance(other, CommandOutputEnumSchema): return bool( - self.items == other.items + self.name == other.name + and self.symbols == other.symbols and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.name == other.name - and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash( - (self.items, self.type_, self.label, self.doc, self.name, self.inputBinding) - ) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -11502,8 +11077,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -11513,7 +11088,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -11558,30 +11133,29 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("symbols") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": + if str(e) == "missing required field `symbols`": _errors__.append( ValidationException( str(e), @@ -11589,13 +11163,13 @@ def fromDoc( ) ) else: - val = _doc.get("items") + val = _doc.get("symbols") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11607,10 +11181,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), [e], - detailed_message=f"the `items` field with value `{val}` " + detailed_message=f"the `symbols` field with value `{val}` " "is not valid because:", ) ) @@ -11618,9 +11192,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Array_nameLoader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -11665,7 +11239,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -11712,7 +11286,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -11756,54 +11330,7 @@ def fromDoc( "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -11811,14 +11338,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), @@ -11828,16 +11355,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, + name=name, + symbols=symbols, type_=type_, label=label, doc=doc, - name=name, - inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -11852,11 +11378,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.items is not None: - u = save_relative_uri(self.items, self.name, False, 2, relative_uris) - r["items"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -11869,13 +11395,6 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -11885,24 +11404,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "doc", "name", "inputBinding"]) - - -class CommandOutputRecordField(OutputRecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11912,42 +11422,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format - self.outputBinding = outputBinding + self.doc = doc + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputArraySchema(OutputArraySchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputRecordField): + if isinstance(other, CommandOutputArraySchema): return bool( - self.doc == other.doc - and self.name == other.name + self.items == other.items and self.type_ == other.type_ and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format - and self.outputBinding == other.outputBinding + and self.doc == other.doc + and self.name == other.name ) return False def __hash__(self) -> int: - return hash( - ( - self.doc, - self.name, - self.type_, - self.label, - self.secondaryFiles, - self.streamable, - self.format, - self.outputBinding, - ) - ) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -11955,8 +11457,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -11966,9 +11468,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -12011,68 +11513,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -12117,7 +11619,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -12161,21 +11663,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -12183,13 +11685,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12201,191 +11703,47 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + items=items, type_=type_, label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - format=format, - outputBinding=outputBinding, + doc=doc, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -12400,12 +11758,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.items is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -12414,29 +11771,9 @@ def save( r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.name, True, None, relative_uris) - r["format"] = u - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -12447,32 +11784,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "doc", - "name", - "type", - "label", - "secondaryFiles", - "streamable", - "format", - "outputBinding", - ] - ) - - -class CommandOutputRecordSchema(OutputRecordSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -12482,25 +11802,59 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.items = items self.type_ = type_ self.label = label self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputParameter(Saveable): + """ + An input parameter for a CommandLineTool. + + """ + + id: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputRecordSchema): + if isinstance(other, CommandInputParameter): return bool( - self.fields == other.fields - and self.type_ == other.type_ - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.name == other.name + and self.id == other.id + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.default == other.default + and self.type_ == other.type_ + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.doc, self.name)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.loadContents, + self.loadListing, + self.default, + self.type_, + self.inputBinding, + ) + ) @classmethod def fromDoc( @@ -12508,29 +11862,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -12538,13 +11892,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12556,37 +11910,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -12594,13 +11948,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12612,76 +11966,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - label = None - if "label" in _doc: + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -12689,13 +12042,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12707,17 +12060,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -12761,154 +12114,68 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - fields=fields, - type_=type_, - label=label, - doc=doc, - name=name, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["fields", "type", "label", "doc", "name"]) - - -class CommandOutputEnumSchema(OutputEnumSchema): - name: str - - def __init__( - self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols - self.type_ = type_ - self.label = label - self.doc = doc - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputEnumSchema): - return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc - ) - return False - - def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_, self.label, self.doc)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputEnumSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - name = None - if "name" in _doc: + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + loadContents = None + if "loadContents" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -12916,13 +12183,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12934,77 +12201,114 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) + else: + val = _doc.get("default") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + detailed_message=f"the `default` field with value `{val}` " + "is not valid because:", + ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Enum_nameLoader_2, + typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -13046,68 +12350,21 @@ def fromDoc( "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -13115,13 +12372,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13133,14 +12390,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -13148,14 +12405,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -13165,15 +12422,21 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - symbols=symbols, - type_=type_, + id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, doc=doc, + format=format, + loadContents=loadContents, + loadListing=loadListing, + default=default, + type_=type_, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -13187,76 +12450,161 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.label is not None: r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) if self.doc is not None: r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type", "label", "doc"]) - - -class CommandOutputArraySchema(OutputArraySchema): - name: str - - def __init__( - self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + id: str, + type_: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | stdin | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + default: CWLObjectType | None = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + self.default = default + self.type_ = type_ + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "loadContents", + "loadListing", + "default", + "type", + "inputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputParameter(Saveable): + """ + An output parameter for a CommandLineTool. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputArraySchema): + if isinstance(other, CommandOutputParameter): return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.name == other.name + and self.id == other.id + and self.format == other.format + and self.type_ == other.type_ + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.doc, self.name)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.type_, + self.outputBinding, + ) + ) @classmethod def fromDoc( @@ -13264,29 +12612,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -13294,13 +12642,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13312,122 +12660,26 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) + id = docRoot else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -13471,21 +12723,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -13493,13 +12745,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13511,196 +12763,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - items=items, - type_=type_, - label=label, - doc=doc, - name=name, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.items is not None: - u = save_relative_uri(self.items, self.name, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["items", "type", "label", "doc", "name"]) - - -class CommandInputParameter(InputParameter): - """ - An input parameter for a CommandLineTool. - """ - - id: str - - def __init__( - self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - default: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing - self.default = default - self.type_ = type_ - self.inputBinding = inputBinding - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputParameter): - return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.default == other.default - and self.type_ == other.type_ - and self.inputBinding == other.inputBinding - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.loadContents, - self.loadListing, - self.default, - self.type_, - self.inputBinding, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputParameter": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + streamable = None + if "streamable" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -13708,13 +12792,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13726,37 +12810,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + doc = None + if "doc" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -13764,13 +12839,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13782,28 +12857,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + format = None + if "format" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -13811,13 +12886,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13829,169 +12904,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - loadContents = None - if "loadContents" in _doc: + outputBinding = None + if "outputBinding" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -13999,13 +12981,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14017,242 +12999,50 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: - try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, - baseuri, - loadingOptions, - lc=_doc.get("loadListing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadListing`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("loadListing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], - detailed_message=f"the `loadListing` field with value `{val}` " - "is not valid because:", - ) - ) - default = None - if "default" in _doc: - try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, - baseuri, - loadingOptions, - lc=_doc.get("default") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `default`": _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("default") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [e], - detailed_message=f"the `default` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`, `outputBinding`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, label=label, secondaryFiles=secondaryFiles, streamable=streamable, doc=doc, - id=id, format=format, - loadContents=loadContents, - loadListing=loadListing, - default=default, type_=type_, - inputBinding=inputBinding, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -14267,7 +13057,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.label is not None: r["label"] = save( @@ -14294,31 +13084,13 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, top=False, base_url=self.id, relative_uris=relative_uris, @@ -14332,42 +13104,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "loadContents", - "loadListing", - "default", - "type", - "inputBinding", - ] - ) - - -class CommandOutputParameter(OutputParameter): - """ - An output parameter for a CommandLineTool. - """ - - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | stderr | stdout | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -14381,36 +13129,77 @@ def __init__( self.secondaryFiles = secondaryFiles self.streamable = streamable self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.id = id self.format = format self.type_ = type_ self.outputBinding = outputBinding + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "type", + "outputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandLineTool(Saveable): + """ + This defines the schema of the CWL Command Line Tool Description document. + + """ + + id: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputParameter): + if isinstance(other, CommandLineTool): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable + self.id == other.id + and self.label == other.label and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.type_ == other.type_ - and self.outputBinding == other.outputBinding + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.requirements == other.requirements + and self.hints == other.hints + and self.cwlVersion == other.cwlVersion + and self.class_ == other.class_ + and self.baseCommand == other.baseCommand + and self.arguments == other.arguments + and self.stdin == other.stdin + and self.stderr == other.stderr + and self.stdout == other.stdout + and self.successCodes == other.successCodes + and self.temporaryFailCodes == other.temporaryFailCodes + and self.permanentFailCodes == other.permanentFailCodes ) return False def __hash__(self) -> int: return hash( ( + self.id, self.label, - self.secondaryFiles, - self.streamable, self.doc, - self.id, - self.format, - self.type_, - self.outputBinding, + self.inputs, + self.outputs, + self.requirements, + self.hints, + self.cwlVersion, + self.class_, + self.baseCommand, + self.arguments, + self.stdin, + self.stderr, + self.stdout, + self.successCodes, + self.temporaryFailCodes, + self.permanentFailCodes, ) ) @@ -14420,8 +13209,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -14431,9 +13220,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -14476,18 +13265,34 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + id = "_:" + str(_uuid__.uuid4()) + else: + baseuri = id + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_CommandLineTool_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -14531,21 +13336,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -14553,13 +13358,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14571,28 +13376,124 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_CommandInputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + detailed_message=f"the `inputs` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_CommandOutputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + detailed_message=f"the `outputs` field with value `{val}` " + "is not valid because:", + ) + ) + requirements = None + if "requirements" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("requirements") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `requirements`": _errors__.append( ValidationException( str(e), @@ -14600,13 +13501,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("requirements") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14618,28 +13519,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `requirements` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + hints = None + if "hints" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -14647,13 +13548,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14665,28 +13566,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + cwlVersion = None + if "cwlVersion" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("cwlVersion") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( str(e), @@ -14694,13 +13595,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("cwlVersion") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14712,76 +13613,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `cwlVersion` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: + baseCommand = None + if "baseCommand" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + baseCommand = _load_field( + _doc.get("baseCommand"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("baseCommand") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `baseCommand`": _errors__.append( ValidationException( str(e), @@ -14789,13 +13642,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("baseCommand") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14807,255 +13660,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `baseCommand` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - type_=type_, - outputBinding=outputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "type", - "outputBinding", - ] - ) - - -class CommandLineTool(Process): - """ - This defines the schema of the CWL Command Line Tool Description document. - - """ - - id: str - - def __init__( - self, - inputs: Any, - outputs: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - baseCommand: Optional[Any] = None, - arguments: Optional[Any] = None, - stdin: Optional[Any] = None, - stderr: Optional[Any] = None, - stdout: Optional[Any] = None, - successCodes: Optional[Any] = None, - temporaryFailCodes: Optional[Any] = None, - permanentFailCodes: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.class_ = "CommandLineTool" - self.baseCommand = baseCommand - self.arguments = arguments - self.stdin = stdin - self.stderr = stderr - self.stdout = stdout - self.successCodes = successCodes - self.temporaryFailCodes = temporaryFailCodes - self.permanentFailCodes = permanentFailCodes - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandLineTool): - return bool( - self.id == other.id - and self.label == other.label - and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.class_ == other.class_ - and self.baseCommand == other.baseCommand - and self.arguments == other.arguments - and self.stdin == other.stdin - and self.stderr == other.stderr - and self.stdout == other.stdout - and self.successCodes == other.successCodes - and self.temporaryFailCodes == other.temporaryFailCodes - and self.permanentFailCodes == other.permanentFailCodes - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.id, - self.label, - self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.class_, - self.baseCommand, - self.arguments, - self.stdin, - self.stderr, - self.stdout, - self.successCodes, - self.temporaryFailCodes, - self.permanentFailCodes, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandLineTool": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + arguments = None + if "arguments" in _doc: try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + arguments = _load_field( + _doc.get("arguments"), + union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("arguments") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `arguments`": _errors__.append( ValidationException( str(e), @@ -15063,13 +13689,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("arguments") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15081,53 +13707,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `arguments` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_CommandLineTool_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - label = None - if "label" in _doc: + stdin = None + if "stdin" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + stdin = _load_field( + _doc.get("stdin"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("stdin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `stdin`": _errors__.append( ValidationException( str(e), @@ -15135,13 +13736,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("stdin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15153,28 +13754,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `stdin` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + stderr = None + if "stderr" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + stderr = _load_field( + _doc.get("stderr"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("stderr") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `stderr`": _errors__.append( ValidationException( str(e), @@ -15182,13 +13783,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("stderr") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15200,124 +13801,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `stderr` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_CommandInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_CommandOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + stdout = None + if "stdout" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + stdout = _load_field( + _doc.get("stdout"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("stdout") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `stdout`": _errors__.append( ValidationException( str(e), @@ -15325,13 +13830,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("stdout") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15343,28 +13848,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `stdout` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + successCodes = None + if "successCodes" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + successCodes = _load_field( + _doc.get("successCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("successCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `successCodes`": _errors__.append( ValidationException( str(e), @@ -15372,13 +13877,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("successCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15390,28 +13895,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `successCodes` field with value `{val}` " "is not valid because:", ) ) - cwlVersion = None - if "cwlVersion" in _doc: + temporaryFailCodes = None + if "temporaryFailCodes" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + temporaryFailCodes = _load_field( + _doc.get("temporaryFailCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("temporaryFailCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `temporaryFailCodes`": _errors__.append( ValidationException( str(e), @@ -15419,13 +13924,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("temporaryFailCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15437,28 +13942,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `temporaryFailCodes` field with value `{val}` " "is not valid because:", ) ) - baseCommand = None - if "baseCommand" in _doc: + permanentFailCodes = None + if "permanentFailCodes" in _doc: try: - baseCommand = load_field( - _doc.get("baseCommand"), - union_of_None_type_or_strtype_or_array_of_strtype, + permanentFailCodes = _load_field( + _doc.get("permanentFailCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("baseCommand") + lc=_doc.get("permanentFailCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `baseCommand`": + if str(e) == "missing required field `permanentFailCodes`": _errors__.append( ValidationException( str(e), @@ -15466,13 +13971,13 @@ def fromDoc( ) ) else: - val = _doc.get("baseCommand") + val = _doc.get("permanentFailCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `baseCommand` field is not valid because:", - SourceLine(_doc, "baseCommand", str), + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15484,1894 +13989,58 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `baseCommand` field is not valid because:", - SourceLine(_doc, "baseCommand", str), + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), [e], - detailed_message=f"the `baseCommand` field with value `{val}` " + detailed_message=f"the `permanentFailCodes` field with value `{val}` " "is not valid because:", ) ) - arguments = None - if "arguments" in _doc: - try: - arguments = load_field( - _doc.get("arguments"), - union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("arguments") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `arguments`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("arguments") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `arguments` field is not valid because:", - SourceLine(_doc, "arguments", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `arguments` field is not valid because:", - SourceLine(_doc, "arguments", str), - [e], - detailed_message=f"the `arguments` field with value `{val}` " - "is not valid because:", - ) - ) - stdin = None - if "stdin" in _doc: - try: - stdin = load_field( - _doc.get("stdin"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stdin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stdin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stdin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stdin` field is not valid because:", - SourceLine(_doc, "stdin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stdin` field is not valid because:", - SourceLine(_doc, "stdin", str), - [e], - detailed_message=f"the `stdin` field with value `{val}` " - "is not valid because:", - ) - ) - stderr = None - if "stderr" in _doc: - try: - stderr = load_field( - _doc.get("stderr"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stderr") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stderr`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stderr") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stderr` field is not valid because:", - SourceLine(_doc, "stderr", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stderr` field is not valid because:", - SourceLine(_doc, "stderr", str), - [e], - detailed_message=f"the `stderr` field with value `{val}` " - "is not valid because:", - ) - ) - stdout = None - if "stdout" in _doc: - try: - stdout = load_field( - _doc.get("stdout"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stdout") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stdout`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stdout") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stdout` field is not valid because:", - SourceLine(_doc, "stdout", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stdout` field is not valid because:", - SourceLine(_doc, "stdout", str), - [e], - detailed_message=f"the `stdout` field with value `{val}` " - "is not valid because:", - ) - ) - successCodes = None - if "successCodes" in _doc: - try: - successCodes = load_field( - _doc.get("successCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("successCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `successCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("successCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `successCodes` field is not valid because:", - SourceLine(_doc, "successCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `successCodes` field is not valid because:", - SourceLine(_doc, "successCodes", str), - [e], - detailed_message=f"the `successCodes` field with value `{val}` " - "is not valid because:", - ) - ) - temporaryFailCodes = None - if "temporaryFailCodes" in _doc: - try: - temporaryFailCodes = load_field( - _doc.get("temporaryFailCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("temporaryFailCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `temporaryFailCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("temporaryFailCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `temporaryFailCodes` field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `temporaryFailCodes` field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [e], - detailed_message=f"the `temporaryFailCodes` field with value `{val}` " - "is not valid because:", - ) - ) - permanentFailCodes = None - if "permanentFailCodes" in _doc: - try: - permanentFailCodes = load_field( - _doc.get("permanentFailCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("permanentFailCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `permanentFailCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("permanentFailCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `permanentFailCodes` field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `permanentFailCodes` field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [e], - detailed_message=f"the `permanentFailCodes` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `baseCommand`, `arguments`, `stdin`, `stderr`, `stdout`, `successCodes`, `temporaryFailCodes`, `permanentFailCodes`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - label=label, - doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - baseCommand=baseCommand, - arguments=arguments, - stdin=stdin, - stderr=stderr, - stdout=stdout, - successCodes=successCodes, - temporaryFailCodes=temporaryFailCodes, - permanentFailCodes=permanentFailCodes, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.baseCommand is not None: - r["baseCommand"] = save( - self.baseCommand, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.arguments is not None: - r["arguments"] = save( - self.arguments, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stdin is not None: - r["stdin"] = save( - self.stdin, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stderr is not None: - r["stderr"] = save( - self.stderr, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stdout is not None: - r["stdout"] = save( - self.stdout, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.successCodes is not None: - r["successCodes"] = save( - self.successCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.temporaryFailCodes is not None: - r["temporaryFailCodes"] = save( - self.temporaryFailCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.permanentFailCodes is not None: - r["permanentFailCodes"] = save( - self.permanentFailCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "class", - "baseCommand", - "arguments", - "stdin", - "stderr", - "stdout", - "successCodes", - "temporaryFailCodes", - "permanentFailCodes", - ] - ) - - -class DockerRequirement(ProcessRequirement): - """ - Indicates that a workflow component should be run in a - [Docker](http://docker.com) or Docker-compatible (such as - [Singularity](https://www.sylabs.io/) and [udocker](https://github.com/indigo-dc/udocker)) container environment and - specifies how to fetch or build the image. - - If a CommandLineTool lists `DockerRequirement` under - `hints` (or `requirements`), it may (or must) be run in the specified Docker - container. - - The platform must first acquire or install the correct Docker image as - specified by `dockerPull`, `dockerImport`, `dockerLoad` or `dockerFile`. - - The platform must execute the tool in the container using `docker run` with - the appropriate Docker image and tool command line. - - The workflow platform may provide input files and the designated output - directory through the use of volume bind mounts. The platform should rewrite - file paths in the input object to correspond to the Docker bind mounted - locations. That is, the platform should rewrite values in the parameter context - such as `runtime.outdir`, `runtime.tmpdir` and others to be valid paths - within the container. The platform must ensure that `runtime.outdir` and - `runtime.tmpdir` are distinct directories. - - When running a tool contained in Docker, the workflow platform must not - assume anything about the contents of the Docker container, such as the - presence or absence of specific software, except to assume that the - generated command line represents a valid command within the runtime - environment of the container. - - A container image may specify an - [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) - and/or - [CMD](https://docs.docker.com/engine/reference/builder/#cmd). - Command line arguments will be appended after all elements of - ENTRYPOINT, and will override all elements specified using CMD (in - other words, CMD is only used when the CommandLineTool definition - produces an empty command line). - - Use of implicit ENTRYPOINT or CMD are discouraged due to reproducibility - concerns of the implicit hidden execution point (For further discussion, see - [https://doi.org/10.12688/f1000research.15140.1](https://doi.org/10.12688/f1000research.15140.1)). Portable - CommandLineTool wrappers in which use of a container is optional must not rely on ENTRYPOINT or CMD. - CommandLineTools which do rely on ENTRYPOINT or CMD must list `DockerRequirement` in the - `requirements` section. - - ## Interaction with other requirements - - If [EnvVarRequirement](#EnvVarRequirement) is specified alongside a - DockerRequirement, the environment variables must be provided to Docker - using `--env` or `--env-file` and interact with the container's preexisting - environment as defined by Docker. - - """ - - def __init__( - self, - dockerPull: Optional[Any] = None, - dockerLoad: Optional[Any] = None, - dockerFile: Optional[Any] = None, - dockerImport: Optional[Any] = None, - dockerImageId: Optional[Any] = None, - dockerOutputDirectory: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "DockerRequirement" - self.dockerPull = dockerPull - self.dockerLoad = dockerLoad - self.dockerFile = dockerFile - self.dockerImport = dockerImport - self.dockerImageId = dockerImageId - self.dockerOutputDirectory = dockerOutputDirectory - - def __eq__(self, other: Any) -> bool: - if isinstance(other, DockerRequirement): - return bool( - self.class_ == other.class_ - and self.dockerPull == other.dockerPull - and self.dockerLoad == other.dockerLoad - and self.dockerFile == other.dockerFile - and self.dockerImport == other.dockerImport - and self.dockerImageId == other.dockerImageId - and self.dockerOutputDirectory == other.dockerOutputDirectory - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.dockerPull, - self.dockerLoad, - self.dockerFile, - self.dockerImport, - self.dockerImageId, - self.dockerOutputDirectory, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "DockerRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_DockerRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - dockerPull = None - if "dockerPull" in _doc: - try: - dockerPull = load_field( - _doc.get("dockerPull"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerPull") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerPull`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerPull") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerPull` field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerPull` field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [e], - detailed_message=f"the `dockerPull` field with value `{val}` " - "is not valid because:", - ) - ) - dockerLoad = None - if "dockerLoad" in _doc: - try: - dockerLoad = load_field( - _doc.get("dockerLoad"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerLoad") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerLoad`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerLoad") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerLoad` field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerLoad` field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [e], - detailed_message=f"the `dockerLoad` field with value `{val}` " - "is not valid because:", - ) - ) - dockerFile = None - if "dockerFile" in _doc: - try: - dockerFile = load_field( - _doc.get("dockerFile"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerFile") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerFile`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerFile") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerFile` field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerFile` field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [e], - detailed_message=f"the `dockerFile` field with value `{val}` " - "is not valid because:", - ) - ) - dockerImport = None - if "dockerImport" in _doc: - try: - dockerImport = load_field( - _doc.get("dockerImport"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerImport") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerImport`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerImport") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerImport` field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerImport` field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [e], - detailed_message=f"the `dockerImport` field with value `{val}` " - "is not valid because:", - ) - ) - dockerImageId = None - if "dockerImageId" in _doc: - try: - dockerImageId = load_field( - _doc.get("dockerImageId"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerImageId") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerImageId`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerImageId") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerImageId` field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerImageId` field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [e], - detailed_message=f"the `dockerImageId` field with value `{val}` " - "is not valid because:", - ) - ) - dockerOutputDirectory = None - if "dockerOutputDirectory" in _doc: - try: - dockerOutputDirectory = load_field( - _doc.get("dockerOutputDirectory"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerOutputDirectory") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerOutputDirectory`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerOutputDirectory") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerOutputDirectory` field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerOutputDirectory` field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [e], - detailed_message=f"the `dockerOutputDirectory` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `dockerPull`, `dockerLoad`, `dockerFile`, `dockerImport`, `dockerImageId`, `dockerOutputDirectory`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - dockerPull=dockerPull, - dockerLoad=dockerLoad, - dockerFile=dockerFile, - dockerImport=dockerImport, - dockerImageId=dockerImageId, - dockerOutputDirectory=dockerOutputDirectory, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.dockerPull is not None: - r["dockerPull"] = save( - self.dockerPull, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerLoad is not None: - r["dockerLoad"] = save( - self.dockerLoad, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerFile is not None: - r["dockerFile"] = save( - self.dockerFile, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerImport is not None: - r["dockerImport"] = save( - self.dockerImport, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerImageId is not None: - r["dockerImageId"] = save( - self.dockerImageId, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerOutputDirectory is not None: - r["dockerOutputDirectory"] = save( - self.dockerOutputDirectory, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "class", - "dockerPull", - "dockerLoad", - "dockerFile", - "dockerImport", - "dockerImageId", - "dockerOutputDirectory", - ] - ) - - -class SoftwareRequirement(ProcessRequirement): - """ - A list of software packages that should be configured in the environment of - the defined process. - - """ - - def __init__( - self, - packages: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SoftwareRequirement" - self.packages = packages - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SoftwareRequirement): - return bool(self.class_ == other.class_ and self.packages == other.packages) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.packages)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SoftwareRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_SoftwareRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("packages") is None: - raise ValidationException("missing required field `packages`", None, []) - - packages = load_field( - _doc.get("packages"), - idmap_packages_array_of_SoftwarePackageLoader, - baseuri, - loadingOptions, - lc=_doc.get("packages") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `packages`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("packages") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `packages` field is not valid because:", - SourceLine(_doc, "packages", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `packages` field is not valid because:", - SourceLine(_doc, "packages", str), - [e], - detailed_message=f"the `packages` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `packages`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - packages=packages, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.packages is not None: - r["packages"] = save( - self.packages, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "packages"]) - - -class SoftwarePackage(Saveable): - def __init__( - self, - package: Any, - version: Optional[Any] = None, - specs: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.package = package - self.version = version - self.specs = specs - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SoftwarePackage): - return bool( - self.package == other.package - and self.version == other.version - and self.specs == other.specs - ) - return False - - def __hash__(self) -> int: - return hash((self.package, self.version, self.specs)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SoftwarePackage": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("package") is None: - raise ValidationException("missing required field `package`", None, []) - - package = load_field( - _doc.get("package"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("package") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `package`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("package") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `package` field is not valid because:", - SourceLine(_doc, "package", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `package` field is not valid because:", - SourceLine(_doc, "package", str), - [e], - detailed_message=f"the `package` field with value `{val}` " - "is not valid because:", - ) - ) - version = None - if "version" in _doc: - try: - version = load_field( - _doc.get("version"), - union_of_None_type_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("version") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `version`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("version") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `version` field is not valid because:", - SourceLine(_doc, "version", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `version` field is not valid because:", - SourceLine(_doc, "version", str), - [e], - detailed_message=f"the `version` field with value `{val}` " - "is not valid because:", - ) - ) - specs = None - if "specs" in _doc: - try: - specs = load_field( - _doc.get("specs"), - uri_union_of_None_type_or_array_of_strtype_False_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("specs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `specs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("specs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `specs` field is not valid because:", - SourceLine(_doc, "specs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `specs` field is not valid because:", - SourceLine(_doc, "specs", str), - [e], - detailed_message=f"the `specs` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `package`, `version`, `specs`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - package=package, - version=version, - specs=specs, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.package is not None: - r["package"] = save( - self.package, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.version is not None: - r["version"] = save( - self.version, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.specs is not None: - u = save_relative_uri(self.specs, base_url, False, None, relative_uris) - r["specs"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["package", "version", "specs"]) - - -class Dirent(Saveable): - """ - Define a file or subdirectory that must be placed in the designated output - directory prior to executing the command line tool. May be the result of - executing an expression, such as building a configuration file from a - template. - - """ - - def __init__( - self, - entry: Any, - entryname: Optional[Any] = None, - writable: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.entryname = entryname - self.entry = entry - self.writable = writable - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Dirent): - return bool( - self.entryname == other.entryname - and self.entry == other.entry - and self.writable == other.writable - ) - return False - - def __hash__(self) -> int: - return hash((self.entryname, self.entry, self.writable)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Dirent": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - entryname = None - if "entryname" in _doc: - try: - entryname = load_field( - _doc.get("entryname"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("entryname") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `entryname`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("entryname") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `entryname` field is not valid because:", - SourceLine(_doc, "entryname", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `entryname` field is not valid because:", - SourceLine(_doc, "entryname", str), - [e], - detailed_message=f"the `entryname` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("entry") is None: - raise ValidationException("missing required field `entry`", None, []) - - entry = load_field( - _doc.get("entry"), - union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("entry") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `entry`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("entry") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `entry` field is not valid because:", - SourceLine(_doc, "entry", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `entry` field is not valid because:", - SourceLine(_doc, "entry", str), - [e], - detailed_message=f"the `entry` field with value `{val}` " - "is not valid because:", - ) - ) - writable = None - if "writable" in _doc: - try: - writable = load_field( - _doc.get("writable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("writable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `writable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("writable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `writable` field is not valid because:", - SourceLine(_doc, "writable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `writable` field is not valid because:", - SourceLine(_doc, "writable", str), - [e], - detailed_message=f"the `writable` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `entryname`, `entry`, `writable`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - entryname=entryname, - entry=entry, - writable=writable, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.entryname is not None: - r["entryname"] = save( - self.entryname, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.entry is not None: - r["entry"] = save( - self.entry, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.writable is not None: - r["writable"] = save( - self.writable, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["entryname", "entry", "writable"]) - - -class InitialWorkDirRequirement(ProcessRequirement): - """ - Define a list of files and subdirectories that must be created by the workflow platform in the designated output directory prior to executing the command line tool. - """ - - def __init__( - self, - listing: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "InitialWorkDirRequirement" - self.listing = listing - - def __eq__(self, other: Any) -> bool: - if isinstance(other, InitialWorkDirRequirement): - return bool(self.class_ == other.class_ and self.listing == other.listing) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.listing)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InitialWorkDirRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_InitialWorkDirRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("listing") is None: - raise ValidationException("missing required field `listing`", None, []) - - listing = load_field( - _doc.get("listing"), - union_of_array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("listing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `listing`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("listing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), - [e], - detailed_message=f"the `listing` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `listing`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `baseCommand`, `arguments`, `stdin`, `stderr`, `stdout`, `successCodes`, `temporaryFailCodes`, `permanentFailCodes`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - listing=listing, + id=id, + label=label, + doc=doc, + inputs=inputs, + outputs=outputs, + requirements=requirements, + hints=hints, + cwlVersion=cwlVersion, + baseCommand=baseCommand, + arguments=arguments, + stdin=stdin, + stderr=stderr, + stdout=stdout, + successCodes=successCodes, + temporaryFailCodes=temporaryFailCodes, + permanentFailCodes=permanentFailCodes, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -17385,17 +14054,92 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) + u = save_relative_uri(uri, self.id, False, None, relative_uris) r["class"] = u - if self.listing is not None: - r["listing"] = save( - self.listing, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.requirements is not None: + r["requirements"] = save( + self.requirements, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.baseCommand is not None: + r["baseCommand"] = save( + self.baseCommand, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.arguments is not None: + r["arguments"] = save( + self.arguments, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stdin is not None: + r["stdin"] = save( + self.stdin, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stderr is not None: + r["stderr"] = save( + self.stderr, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stdout is not None: + r["stdout"] = save( + self.stdout, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.successCodes is not None: + r["successCodes"] = save( + self.successCodes, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.temporaryFailCodes is not None: + r["temporaryFailCodes"] = save( + self.temporaryFailCodes, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.permanentFailCodes is not None: + r["permanentFailCodes"] = save( + self.permanentFailCodes, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) # top refers to the directory level @@ -17406,21 +14150,26 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "listing"]) - - -class EnvVarRequirement(ProcessRequirement): - """ - Define a list of environment variables which will be set in the - execution environment of the tool. See `EnvironmentDef` for details. - - """ - def __init__( self, - envDef: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + inputs: Sequence[CommandInputParameter], + outputs: Sequence[CommandOutputParameter], + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + baseCommand: None | Sequence[str] | str = None, + arguments: None | Sequence[CommandLineBinding | str] = None, + stdin: None | str = None, + stderr: None | str = None, + stdout: None | str = None, + successCodes: None | Sequence[i32] = None, + temporaryFailCodes: None | Sequence[i32] = None, + permanentFailCodes: None | Sequence[i32] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -17430,16 +14179,98 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "EnvVarRequirement" - self.envDef = envDef + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.doc = doc + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.cwlVersion = cwlVersion + self.class_: Final[str] = "CommandLineTool" + self.baseCommand = baseCommand + self.arguments = arguments + self.stdin = stdin + self.stderr = stderr + self.stdout = stdout + self.successCodes = successCodes + self.temporaryFailCodes = temporaryFailCodes + self.permanentFailCodes = permanentFailCodes + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "inputs", + "outputs", + "requirements", + "hints", + "cwlVersion", + "class", + "baseCommand", + "arguments", + "stdin", + "stderr", + "stdout", + "successCodes", + "temporaryFailCodes", + "permanentFailCodes", + ] + ) + + +@mypyc_attr(native_class=True) +class DockerRequirement(Saveable): + """ + Indicates that a workflow component should be run in a `Docker `__ or Docker-compatible (such as `Singularity `__ and `udocker `__) container environment and specifies how to fetch or build the image. + + If a CommandLineTool lists ``DockerRequirement`` under ``hints`` (or ``requirements``), it may (or must) be run in the specified Docker container. + + The platform must first acquire or install the correct Docker image as specified by ``dockerPull``, ``dockerImport``, ``dockerLoad`` or ``dockerFile``. + + The platform must execute the tool in the container using ``docker run`` with the appropriate Docker image and tool command line. + + The workflow platform may provide input files and the designated output directory through the use of volume bind mounts. The platform should rewrite file paths in the input object to correspond to the Docker bind mounted locations. That is, the platform should rewrite values in the parameter context such as ``runtime.outdir``, ``runtime.tmpdir`` and others to be valid paths within the container. The platform must ensure that ``runtime.outdir`` and ``runtime.tmpdir`` are distinct directories. + + When running a tool contained in Docker, the workflow platform must not assume anything about the contents of the Docker container, such as the presence or absence of specific software, except to assume that the generated command line represents a valid command within the runtime environment of the container. + + A container image may specify an `ENTRYPOINT `__ and/or `CMD `__. Command line arguments will be appended after all elements of ENTRYPOINT, and will override all elements specified using CMD (in other words, CMD is only used when the CommandLineTool definition produces an empty command line). + + Use of implicit ENTRYPOINT or CMD are discouraged due to reproducibility concerns of the implicit hidden execution point (For further discussion, see `https://doi.org/10.12688/f1000research.15140.1 `__). Portable CommandLineTool wrappers in which use of a container is optional must not rely on ENTRYPOINT or CMD. CommandLineTools which do rely on ENTRYPOINT or CMD must list ``DockerRequirement`` in the ``requirements`` section. + + Interaction with other requirements + ----------------------------------- + + If `EnvVarRequirement <#EnvVarRequirement>`__ is specified alongside a DockerRequirement, the environment variables must be provided to Docker using ``--env`` or ``--env-file`` and interact with the container's preexisting environment as defined by Docker. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, EnvVarRequirement): - return bool(self.class_ == other.class_ and self.envDef == other.envDef) + if isinstance(other, DockerRequirement): + return bool( + self.class_ == other.class_ + and self.dockerPull == other.dockerPull + and self.dockerLoad == other.dockerLoad + and self.dockerFile == other.dockerFile + and self.dockerImport == other.dockerImport + and self.dockerImageId == other.dockerImageId + and self.dockerOutputDirectory == other.dockerOutputDirectory + ) return False def __hash__(self) -> int: - return hash((self.class_, self.envDef)) + return hash( + ( + self.class_, + self.dockerPull, + self.dockerLoad, + self.dockerFile, + self.dockerImport, + self.dockerImageId, + self.dockerOutputDirectory, + ) + ) @classmethod def fromDoc( @@ -17447,8 +14278,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnvVarRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -17459,67 +14290,302 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_EnvVarRequirement_classLoader_False_True_None_None, + uri_DockerRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e - try: - if _doc.get("envDef") is None: - raise ValidationException("missing required field `envDef`", None, []) + raise e + dockerPull = None + if "dockerPull" in _doc: + try: + dockerPull = _load_field( + _doc.get("dockerPull"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerPull") + ) - envDef = load_field( - _doc.get("envDef"), - idmap_envDef_array_of_EnvironmentDefLoader, - baseuri, - loadingOptions, - lc=_doc.get("envDef") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerPull`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("dockerPull") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [e], + detailed_message=f"the `dockerPull` field with value `{val}` " + "is not valid because:", + ) + ) + dockerLoad = None + if "dockerLoad" in _doc: + try: + dockerLoad = _load_field( + _doc.get("dockerLoad"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerLoad") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerLoad`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("dockerLoad") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [e], + detailed_message=f"the `dockerLoad` field with value `{val}` " + "is not valid because:", + ) + ) + dockerFile = None + if "dockerFile" in _doc: + try: + dockerFile = _load_field( + _doc.get("dockerFile"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerFile") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `envDef`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `dockerFile`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("dockerFile") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [e], + detailed_message=f"the `dockerFile` field with value `{val}` " + "is not valid because:", + ) + ) + dockerImport = None + if "dockerImport" in _doc: + try: + dockerImport = _load_field( + _doc.get("dockerImport"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerImport") ) - else: - val = _doc.get("envDef") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImport`": _errors__.append( ValidationException( - "the `envDef` field is not valid because:", - SourceLine(_doc, "envDef", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("dockerImport") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [e], + detailed_message=f"the `dockerImport` field with value `{val}` " + "is not valid because:", + ) + ) + dockerImageId = None + if "dockerImageId" in _doc: + try: + dockerImageId = _load_field( + _doc.get("dockerImageId"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerImageId") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImageId`": _errors__.append( ValidationException( - "the `envDef` field is not valid because:", - SourceLine(_doc, "envDef", str), - [e], - detailed_message=f"the `envDef` field with value `{val}` " - "is not valid because:", + str(e), + None + ) + ) + else: + val = _doc.get("dockerImageId") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [e], + detailed_message=f"the `dockerImageId` field with value `{val}` " + "is not valid because:", + ) + ) + dockerOutputDirectory = None + if "dockerOutputDirectory" in _doc: + try: + dockerOutputDirectory = _load_field( + _doc.get("dockerOutputDirectory"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerOutputDirectory") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerOutputDirectory`": + _errors__.append( + ValidationException( + str(e), + None ) ) - extension_fields: dict[str, Any] = {} + else: + val = _doc.get("dockerOutputDirectory") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [e], + detailed_message=f"the `dockerOutputDirectory` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -17527,14 +14593,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `envDef`".format( + "invalid field `{}`, expected one of: `class`, `dockerPull`, `dockerLoad`, `dockerFile`, `dockerImport`, `dockerImageId`, `dockerOutputDirectory`".format( k ), SourceLine(_doc, k, str), @@ -17544,7 +14610,12 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - envDef=envDef, + dockerPull=dockerPull, + dockerLoad=dockerLoad, + dockerFile=dockerFile, + dockerImport=dockerImport, + dockerImageId=dockerImageId, + dockerOutputDirectory=dockerOutputDirectory, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -17562,16 +14633,56 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.envDef is not None: - r["envDef"] = save( - self.envDef, top=False, base_url=base_url, relative_uris=relative_uris + if self.dockerPull is not None: + r["dockerPull"] = save( + self.dockerPull, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerLoad is not None: + r["dockerLoad"] = save( + self.dockerLoad, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerFile is not None: + r["dockerFile"] = save( + self.dockerFile, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerImport is not None: + r["dockerImport"] = save( + self.dockerImport, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerImageId is not None: + r["dockerImageId"] = save( + self.dockerImageId, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerOutputDirectory is not None: + r["dockerOutputDirectory"] = save( + self.dockerOutputDirectory, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -17582,25 +14693,16 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "envDef"]) - - -class ShellCommandRequirement(ProcessRequirement): - """ - Modify the behavior of CommandLineTool to generate a single string - containing a shell command line. Each item in the argument list must be - joined into a string separated by single spaces and quoted to prevent - intepretation by the shell, unless `CommandLineBinding` for that argument - contains `shellQuote: false`. If `shellQuote: false` is specified, the - argument is joined into the command string without quoting, which allows - the use of shell metacharacters such as `|` for pipes. - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + dockerPull: None | str = None, + dockerLoad: None | str = None, + dockerFile: None | str = None, + dockerImport: None | str = None, + dockerImageId: None | str = None, + dockerOutputDirectory: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -17610,15 +14712,41 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ShellCommandRequirement" + self.class_: Final[str] = "DockerRequirement" + self.dockerPull = dockerPull + self.dockerLoad = dockerLoad + self.dockerFile = dockerFile + self.dockerImport = dockerImport + self.dockerImageId = dockerImageId + self.dockerOutputDirectory = dockerOutputDirectory + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "dockerPull", + "dockerLoad", + "dockerFile", + "dockerImport", + "dockerImageId", + "dockerOutputDirectory", + ] + ) + + +@mypyc_attr(native_class=True) +class SoftwareRequirement(Saveable): + """ + A list of software packages that should be configured in the environment of the defined process. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ShellCommandRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, SoftwareRequirement): + return bool(self.class_ == other.class_ and self.packages == other.packages) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash((self.class_, self.packages)) @classmethod def fromDoc( @@ -17626,8 +14754,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ShellCommandRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -17638,19 +14766,68 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_ShellCommandRequirement_classLoader_False_True_None_None, + uri_SoftwareRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("packages") is None: + raise ValidationException("missing required field `packages`", None, []) + + packages = _load_field( + _doc.get("packages"), + idmap_packages_array_of_SoftwarePackageLoader, + baseuri, + loadingOptions, + lc=_doc.get("packages") + ) + except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `packages`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("packages") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [e], + detailed_message=f"the `packages` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -17658,14 +14835,16 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), + "invalid field `{}`, expected one of: `class`, `packages`".format( + k + ), SourceLine(_doc, k, str), ) ) @@ -17673,6 +14852,7 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + packages=packages, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -17690,13 +14870,19 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u + if self.packages is not None: + r["packages"] = save( + self.packages, top=False, base_url=base_url, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -17706,46 +14892,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class"]) - - -class ResourceRequirement(ProcessRequirement): - """ - Specify basic hardware resource requirements. - - "min" is the minimum amount of a resource that must be reserved to schedule - a job. If "min" cannot be satisfied, the job should not be run. - - "max" is the maximum amount of a resource that the job shall be permitted - to use. If a node has sufficient resources, multiple jobs may be scheduled - on a single node provided each job's "max" resource requirements are - met. If a job attempts to exceed its "max" resource allocation, an - implementation may deny additional resources, which may result in job - failure. - - If "min" is specified but "max" is not, then "max" == "min" - If "max" is specified by "min" is not, then "min" == "max". - - It is an error if max < min. - - It is an error if the value of any of these fields is negative. - - If neither "min" nor "max" is specified for a resource, use the default values below. - - """ - def __init__( self, - coresMin: Optional[Any] = None, - coresMax: Optional[Any] = None, - ramMin: Optional[Any] = None, - ramMax: Optional[Any] = None, - tmpdirMin: Optional[Any] = None, - tmpdirMax: Optional[Any] = None, - outdirMin: Optional[Any] = None, - outdirMax: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + packages: Sequence[SoftwarePackage], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -17755,373 +14906,103 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ResourceRequirement" - self.coresMin = coresMin - self.coresMax = coresMax - self.ramMin = ramMin - self.ramMax = ramMax - self.tmpdirMin = tmpdirMin - self.tmpdirMax = tmpdirMax - self.outdirMin = outdirMin - self.outdirMax = outdirMax - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ResourceRequirement): - return bool( - self.class_ == other.class_ - and self.coresMin == other.coresMin - and self.coresMax == other.coresMax - and self.ramMin == other.ramMin - and self.ramMax == other.ramMax - and self.tmpdirMin == other.tmpdirMin - and self.tmpdirMax == other.tmpdirMax - and self.outdirMin == other.outdirMin - and self.outdirMax == other.outdirMax - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.coresMin, - self.coresMax, - self.ramMin, - self.ramMax, - self.tmpdirMin, - self.tmpdirMax, - self.outdirMin, - self.outdirMax, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ResourceRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ResourceRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - coresMin = None - if "coresMin" in _doc: - try: - coresMin = load_field( - _doc.get("coresMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("coresMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + self.class_: Final[str] = "SoftwareRequirement" + self.packages = packages - if str(e) == "missing required field `coresMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("coresMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `coresMin` field is not valid because:", - SourceLine(_doc, "coresMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `coresMin` field is not valid because:", - SourceLine(_doc, "coresMin", str), - [e], - detailed_message=f"the `coresMin` field with value `{val}` " - "is not valid because:", - ) - ) - coresMax = None - if "coresMax" in _doc: - try: - coresMax = load_field( - _doc.get("coresMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("coresMax") - ) + attrs: ClassVar[Collection[str]] = frozenset(["class", "packages"]) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `coresMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("coresMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `coresMax` field is not valid because:", - SourceLine(_doc, "coresMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `coresMax` field is not valid because:", - SourceLine(_doc, "coresMax", str), - [e], - detailed_message=f"the `coresMax` field with value `{val}` " - "is not valid because:", - ) - ) - ramMin = None - if "ramMin" in _doc: - try: - ramMin = load_field( - _doc.get("ramMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("ramMin") - ) +@mypyc_attr(native_class=True) +class SoftwarePackage(Saveable): + def __eq__(self, other: Any) -> bool: + if isinstance(other, SoftwarePackage): + return bool( + self.package == other.package + and self.version == other.version + and self.specs == other.specs + ) + return False - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + def __hash__(self) -> int: + return hash((self.package, self.version, self.specs)) - if str(e) == "missing required field `ramMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("ramMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `ramMin` field is not valid because:", - SourceLine(_doc, "ramMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `ramMin` field is not valid because:", - SourceLine(_doc, "ramMin", str), - [e], - detailed_message=f"the `ramMin` field with value `{val}` " - "is not valid because:", - ) - ) - ramMax = None - if "ramMax" in _doc: - try: - ramMax = load_field( - _doc.get("ramMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("ramMax") - ) + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("package") is None: + raise ValidationException("missing required field `package`", None, []) - if str(e) == "missing required field `ramMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("ramMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `ramMax` field is not valid because:", - SourceLine(_doc, "ramMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `ramMax` field is not valid because:", - SourceLine(_doc, "ramMax", str), - [e], - detailed_message=f"the `ramMax` field with value `{val}` " - "is not valid because:", - ) - ) - tmpdirMin = None - if "tmpdirMin" in _doc: - try: - tmpdirMin = load_field( - _doc.get("tmpdirMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("tmpdirMin") - ) + package = _load_field( + _doc.get("package"), + strtype, + baseuri, + loadingOptions, + lc=_doc.get("package") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tmpdirMin`": + if str(e) == "missing required field `package`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("package") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("tmpdirMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `tmpdirMin` field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `tmpdirMin` field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [e], - detailed_message=f"the `tmpdirMin` field with value `{val}` " - "is not valid because:", - ) - ) - tmpdirMax = None - if "tmpdirMax" in _doc: - try: - tmpdirMax = load_field( - _doc.get("tmpdirMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("tmpdirMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `tmpdirMax`": _errors__.append( ValidationException( - str(e), - None + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [e], + detailed_message=f"the `package` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("tmpdirMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `tmpdirMax` field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `tmpdirMax` field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [e], - detailed_message=f"the `tmpdirMax` field with value `{val}` " - "is not valid because:", - ) - ) - outdirMin = None - if "outdirMin" in _doc: + version = None + if "version" in _doc: try: - outdirMin = load_field( - _doc.get("outdirMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, + version = _load_field( + _doc.get("version"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("outdirMin") + lc=_doc.get("version") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outdirMin`": + if str(e) == "missing required field `version`": _errors__.append( ValidationException( str(e), @@ -18129,13 +15010,13 @@ def fromDoc( ) ) else: - val = _doc.get("outdirMin") + val = _doc.get("version") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outdirMin` field is not valid because:", - SourceLine(_doc, "outdirMin", str), + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18147,28 +15028,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outdirMin` field is not valid because:", - SourceLine(_doc, "outdirMin", str), + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), [e], - detailed_message=f"the `outdirMin` field with value `{val}` " + detailed_message=f"the `version` field with value `{val}` " "is not valid because:", ) ) - outdirMax = None - if "outdirMax" in _doc: + specs = None + if "specs" in _doc: try: - outdirMax = load_field( - _doc.get("outdirMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, + specs = _load_field( + _doc.get("specs"), + uri_union_of_None_type_or_array_of_strtype_False_False_None_True, baseuri, loadingOptions, - lc=_doc.get("outdirMax") + lc=_doc.get("specs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outdirMax`": + if str(e) == "missing required field `specs`": _errors__.append( ValidationException( str(e), @@ -18176,13 +15057,13 @@ def fromDoc( ) ) else: - val = _doc.get("outdirMax") + val = _doc.get("specs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outdirMax` field is not valid because:", - SourceLine(_doc, "outdirMax", str), + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18194,14 +15075,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outdirMax` field is not valid because:", - SourceLine(_doc, "outdirMax", str), + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), [e], - detailed_message=f"the `outdirMax` field with value `{val}` " + detailed_message=f"the `specs` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18209,14 +15090,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `coresMin`, `coresMax`, `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, `outdirMax`".format( + "invalid field `{}`, expected one of: `package`, `version`, `specs`".format( k ), SourceLine(_doc, k, str), @@ -18226,14 +15107,9 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - coresMin=coresMin, - coresMax=coresMax, - ramMin=ramMin, - ramMax=ramMax, - tmpdirMin=tmpdirMin, - tmpdirMax=tmpdirMax, - outdirMin=outdirMin, - outdirMax=outdirMax, + package=package, + version=version, + specs=specs, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -18250,58 +15126,17 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.coresMin is not None: - r["coresMin"] = save( - self.coresMin, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.coresMax is not None: - r["coresMax"] = save( - self.coresMax, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.ramMin is not None: - r["ramMin"] = save( - self.ramMin, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.ramMax is not None: - r["ramMax"] = save( - self.ramMax, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.tmpdirMin is not None: - r["tmpdirMin"] = save( - self.tmpdirMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.tmpdirMax is not None: - r["tmpdirMax"] = save( - self.tmpdirMax, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.outdirMin is not None: - r["outdirMin"] = save( - self.outdirMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.package is not None: + r["package"] = save( + self.package, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.outdirMax is not None: - r["outdirMax"] = save( - self.outdirMax, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.version is not None: + r["version"] = save( + self.version, top=False, base_url=base_url, relative_uris=relative_uris ) + if self.specs is not None: + u = save_relative_uri(self.specs, base_url, False, None, relative_uris) + r["specs"] = u # top refers to the directory level if top: @@ -18311,40 +15146,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "coresMin", - "coresMax", - "ramMin", - "ramMax", - "tmpdirMin", - "tmpdirMax", - "outdirMin", - "outdirMax", - ] - ) - - -class WorkReuse(ProcessRequirement): - """ - For implementations that support reusing output from past work (on - the assumption that same code and same input produce same - results), control whether to enable or disable the reuse behavior - for a particular tool or step (to accomodate situations where that - assumption is incorrect). A reused step is not executed but - instead returns the same output as the original execution. - - If `enableReuse` is not specified, correct tools should assume it - is enabled by default. - - """ - def __init__( self, - enableReuse: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + package: str, + version: None | Sequence[str] = None, + specs: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -18354,18 +15162,31 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "WorkReuse" - self.enableReuse = enableReuse + self.package = package + self.version = version + self.specs = specs + + attrs: ClassVar[Collection[str]] = frozenset(["package", "version", "specs"]) + + +@mypyc_attr(native_class=True) +class Dirent(Saveable): + """ + Define a file or subdirectory that must be placed in the designated output directory prior to executing the command line tool. May be the result of executing an expression, such as building a configuration file from a template. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkReuse): + if isinstance(other, Dirent): return bool( - self.class_ == other.class_ and self.enableReuse == other.enableReuse + self.entryname == other.entryname + and self.entry == other.entry + and self.writable == other.writable ) return False def __hash__(self) -> int: - return hash((self.class_, self.enableReuse)) + return hash((self.entryname, self.entry, self.writable)) @classmethod def fromDoc( @@ -18373,46 +15194,77 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkReuse": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + entryname = None + if "entryname" in _doc: + try: + entryname = _load_field( + _doc.get("entryname"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("entryname") + ) - class_ = load_field( - _doc.get("class"), - uri_WorkReuse_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + if str(e) == "missing required field `entryname`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("entryname") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [e], + detailed_message=f"the `entryname` field with value `{val}` " + "is not valid because:", + ) + ) try: - if _doc.get("enableReuse") is None: - raise ValidationException("missing required field `enableReuse`", None, []) + if _doc.get("entry") is None: + raise ValidationException("missing required field `entry`", None, []) - enableReuse = load_field( - _doc.get("enableReuse"), - union_of_booltype_or_ExpressionLoader, + entry = _load_field( + _doc.get("entry"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("enableReuse") + lc=_doc.get("entry") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `enableReuse`": + if str(e) == "missing required field `entry`": _errors__.append( ValidationException( str(e), @@ -18420,13 +15272,13 @@ def fromDoc( ) ) else: - val = _doc.get("enableReuse") + val = _doc.get("entry") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `enableReuse` field is not valid because:", - SourceLine(_doc, "enableReuse", str), + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18438,14 +15290,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `enableReuse` field is not valid because:", - SourceLine(_doc, "enableReuse", str), + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), [e], - detailed_message=f"the `enableReuse` field with value `{val}` " + detailed_message=f"the `entry` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + writable = None + if "writable" in _doc: + try: + writable = _load_field( + _doc.get("writable"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("writable") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `writable`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("writable") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [e], + detailed_message=f"the `writable` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18453,14 +15352,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `enableReuse`".format( + "invalid field `{}`, expected one of: `entryname`, `entry`, `writable`".format( k ), SourceLine(_doc, k, str), @@ -18470,7 +15369,9 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - enableReuse=enableReuse, + entryname=entryname, + entry=entry, + writable=writable, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -18484,24 +15385,24 @@ def save( if relative_uris: for ef in self.extension_fields: r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.enableReuse is not None: - r["enableReuse"] = save( - self.enableReuse, + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.entryname is not None: + r["entryname"] = save( + self.entryname, top=False, base_url=base_url, relative_uris=relative_uris, ) + if self.entry is not None: + r["entry"] = save( + self.entry, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.writable is not None: + r["writable"] = save( + self.writable, top=False, base_url=base_url, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -18511,34 +15412,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "enableReuse"]) - - -class NetworkAccess(ProcessRequirement): - """ - Indicate whether a process requires outgoing IPv4/IPv6 network - access. Choice of IPv4 or IPv6 is implementation and site - specific, correct tools must support both. - - If `networkAccess` is false or not specified, tools must not - assume network access, except for localhost (the loopback device). - - If `networkAccess` is true, the tool must be able to make outgoing - connections to network resources. Resources may be on a private - subnet or the public Internet. However, implementations and sites - may apply their own security policies to restrict what is - accessible by the tool. - - Enabling network access does not imply a publically routable IP - address or the ability to accept inbound connections. - - """ - def __init__( self, - networkAccess: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + entry: str, + entryname: None | str = None, + writable: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -18548,19 +15428,27 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "NetworkAccess" - self.networkAccess = networkAccess + self.entryname = entryname + self.entry = entry + self.writable = writable + + attrs: ClassVar[Collection[str]] = frozenset(["entryname", "entry", "writable"]) + + +@mypyc_attr(native_class=True) +class InitialWorkDirRequirement(Saveable): + """ + Define a list of files and subdirectories that must be created by the workflow platform in the designated output directory prior to executing the command line tool. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, NetworkAccess): - return bool( - self.class_ == other.class_ - and self.networkAccess == other.networkAccess - ) + if isinstance(other, InitialWorkDirRequirement): + return bool(self.class_ == other.class_ and self.listing == other.listing) return False def __hash__(self) -> int: - return hash((self.class_, self.networkAccess)) + return hash((self.class_, self.listing)) @classmethod def fromDoc( @@ -18568,8 +15456,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NetworkAccess": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -18580,34 +15468,35 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_NetworkAccess_classLoader_False_True_None_None, + uri_InitialWorkDirRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + raise e try: - if _doc.get("networkAccess") is None: - raise ValidationException("missing required field `networkAccess`", None, []) + if _doc.get("listing") is None: + raise ValidationException("missing required field `listing`", None, []) - networkAccess = load_field( - _doc.get("networkAccess"), - union_of_booltype_or_ExpressionLoader, + listing = _load_field( + _doc.get("listing"), + union_of_array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("networkAccess") + lc=_doc.get("listing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `networkAccess`": + if str(e) == "missing required field `listing`": _errors__.append( ValidationException( str(e), @@ -18615,13 +15504,13 @@ def fromDoc( ) ) else: - val = _doc.get("networkAccess") + val = _doc.get("listing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `networkAccess` field is not valid because:", - SourceLine(_doc, "networkAccess", str), + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18633,14 +15522,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `networkAccess` field is not valid because:", - SourceLine(_doc, "networkAccess", str), + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), [e], - detailed_message=f"the `networkAccess` field with value `{val}` " + detailed_message=f"the `listing` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18648,14 +15537,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `networkAccess`".format( + "invalid field `{}`, expected one of: `class`, `listing`".format( k ), SourceLine(_doc, k, str), @@ -18665,7 +15554,7 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - networkAccess=networkAccess, + listing=listing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -18683,19 +15572,18 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.networkAccess is not None: - r["networkAccess"] = save( - self.networkAccess, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.listing is not None: + r["listing"] = save( + self.listing, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -18706,49 +15594,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "networkAccess"]) - - -class InplaceUpdateRequirement(ProcessRequirement): - """ - - If `inplaceUpdate` is true, then an implementation supporting this - feature may permit tools to directly update files with `writable: - true` in InitialWorkDirRequirement. That is, as an optimization, - files may be destructively modified in place as opposed to copied - and updated. - - An implementation must ensure that only one workflow step may - access a writable file at a time. It is an error if a file which - is writable by one workflow step file is accessed (for reading or - writing) by any other workflow step running independently. - However, a file which has been updated in a previous completed - step may be used as input to multiple steps, provided it is - read-only in every step. - - Workflow steps which modify a file must produce the modified file - as output. Downstream steps which futher process the file must - use the output of previous steps, and not refer to a common input - (this is necessary for both ordering and correctness). - - Workflow authors should provide this in the `hints` section. The - intent of this feature is that workflows produce the same results - whether or not InplaceUpdateRequirement is supported by the - implementation, and this feature is primarily available as an - optimization for particular environments. - - Users and implementers should be aware that workflows that - destructively modify inputs may not be repeatable or reproducible. - In particular, enabling this feature implies that WorkReuse should - not be enabled. - - """ - def __init__( self, - inplaceUpdate: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + listing: Sequence[Directory | Dirent | File | None | Sequence[Directory | File] | str] | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -18758,19 +15608,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "InplaceUpdateRequirement" - self.inplaceUpdate = inplaceUpdate + self.class_: Final[str] = "InitialWorkDirRequirement" + self.listing = listing + + attrs: ClassVar[Collection[str]] = frozenset(["class", "listing"]) + + +@mypyc_attr(native_class=True) +class EnvVarRequirement(Saveable): + """ + Define a list of environment variables which will be set in the execution environment of the tool. See ``EnvironmentDef`` for details. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, InplaceUpdateRequirement): - return bool( - self.class_ == other.class_ - and self.inplaceUpdate == other.inplaceUpdate - ) + if isinstance(other, EnvVarRequirement): + return bool(self.class_ == other.class_ and self.envDef == other.envDef) return False def __hash__(self) -> int: - return hash((self.class_, self.inplaceUpdate)) + return hash((self.class_, self.envDef)) @classmethod def fromDoc( @@ -18778,8 +15635,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InplaceUpdateRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -18790,34 +15647,35 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_InplaceUpdateRequirement_classLoader_False_True_None_None, + uri_EnvVarRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + raise e try: - if _doc.get("inplaceUpdate") is None: - raise ValidationException("missing required field `inplaceUpdate`", None, []) + if _doc.get("envDef") is None: + raise ValidationException("missing required field `envDef`", None, []) - inplaceUpdate = load_field( - _doc.get("inplaceUpdate"), - booltype, + envDef = _load_field( + _doc.get("envDef"), + idmap_envDef_array_of_EnvironmentDefLoader, baseuri, loadingOptions, - lc=_doc.get("inplaceUpdate") + lc=_doc.get("envDef") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inplaceUpdate`": + if str(e) == "missing required field `envDef`": _errors__.append( ValidationException( str(e), @@ -18825,13 +15683,13 @@ def fromDoc( ) ) else: - val = _doc.get("inplaceUpdate") + val = _doc.get("envDef") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inplaceUpdate` field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18843,14 +15701,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inplaceUpdate` field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), [e], - detailed_message=f"the `inplaceUpdate` field with value `{val}` " + detailed_message=f"the `envDef` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18858,14 +15716,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `inplaceUpdate`".format( + "invalid field `{}`, expected one of: `class`, `envDef`".format( k ), SourceLine(_doc, k, str), @@ -18875,7 +15733,7 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - inplaceUpdate=inplaceUpdate, + envDef=envDef, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -18893,19 +15751,18 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.inplaceUpdate is not None: - r["inplaceUpdate"] = save( - self.inplaceUpdate, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.envDef is not None: + r["envDef"] = save( + self.envDef, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -18916,26 +15773,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "inplaceUpdate"]) - - -class ToolTimeLimit(ProcessRequirement): - """ - Set an upper limit on the execution time of a CommandLineTool. - A CommandLineTool whose execution duration exceeds the time - limit may be preemptively terminated and considered failed. - May also be used by batch systems to make scheduling decisions. - The execution duration excludes external operations, such as - staging of files, pulling a docker image etc, and only counts - wall-time for the execution of the command line itself. - - """ - def __init__( self, - timelimit: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + envDef: Sequence[EnvironmentDef], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -18945,18 +15787,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ToolTimeLimit" - self.timelimit = timelimit + self.class_: Final[str] = "EnvVarRequirement" + self.envDef = envDef + + attrs: ClassVar[Collection[str]] = frozenset(["class", "envDef"]) + + +@mypyc_attr(native_class=True) +class ShellCommandRequirement(Saveable): + """ + Modify the behavior of CommandLineTool to generate a single string containing a shell command line. Each item in the argument list must be joined into a string separated by single spaces and quoted to prevent interpretation by the shell, unless ``CommandLineBinding`` for that argument contains ``shellQuote: false``. If ``shellQuote: false`` is specified, the argument is joined into the command string without quoting, which allows the use of shell metacharacters such as ``|`` for pipes. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ToolTimeLimit): - return bool( - self.class_ == other.class_ and self.timelimit == other.timelimit - ) + if isinstance(other, ShellCommandRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash((self.class_, self.timelimit)) + return hash((self.class_)) @classmethod def fromDoc( @@ -18964,8 +15814,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ToolTimeLimit": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -18976,67 +15826,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_ToolTimeLimit_classLoader_False_True_None_None, + uri_ShellCommandRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("timelimit") is None: - raise ValidationException("missing required field `timelimit`", None, []) - - timelimit = load_field( - _doc.get("timelimit"), - union_of_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("timelimit") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `timelimit`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("timelimit") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `timelimit` field is not valid because:", - SourceLine(_doc, "timelimit", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `timelimit` field is not valid because:", - SourceLine(_doc, "timelimit", str), - [e], - detailed_message=f"the `timelimit` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -19044,16 +15847,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `timelimit`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -19061,7 +15862,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - timelimit=timelimit, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -19079,20 +15879,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.timelimit is not None: - r["timelimit"] = save( - self.timelimit, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -19102,23 +15897,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "timelimit"]) - - -class ExpressionToolOutputParameter(OutputParameter): - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -19128,37 +15910,57 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.type_ = type_ + self.class_: Final[str] = "ShellCommandRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class ResourceRequirement(Saveable): + """ + Specify basic hardware resource requirements. + + "min" is the minimum amount of a resource that must be reserved to schedule a job. If "min" cannot be satisfied, the job should not be run. + + "max" is the maximum amount of a resource that the job shall be permitted to use. If a node has sufficient resources, multiple jobs may be scheduled on a single node provided each job's "max" resource requirements are met. If a job attempts to exceed its "max" resource allocation, an implementation may deny additional resources, which may result in job failure. + + If "min" is specified but "max" is not, then "max" == "min" If "max" is specified by "min" is not, then "min" == "max". + + It is an error if max < min. + + It is an error if the value of any of these fields is negative. + + If neither "min" nor "max" is specified for a resource, use the default values below. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ExpressionToolOutputParameter): + if isinstance(other, ResourceRequirement): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.type_ == other.type_ + self.class_ == other.class_ + and self.coresMin == other.coresMin + and self.coresMax == other.coresMax + and self.ramMin == other.ramMin + and self.ramMax == other.ramMax + and self.tmpdirMin == other.tmpdirMin + and self.tmpdirMax == other.tmpdirMax + and self.outdirMin == other.outdirMin + and self.outdirMax == other.outdirMax ) return False def __hash__(self) -> int: return hash( ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.type_, + self.class_, + self.coresMin, + self.coresMax, + self.ramMin, + self.ramMax, + self.tmpdirMin, + self.tmpdirMax, + self.outdirMin, + self.outdirMax, ) ) @@ -19168,29 +15970,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ExpressionToolOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ResourceRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + coresMin = None + if "coresMin" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + coresMin = _load_field( + _doc.get("coresMin"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("coresMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `coresMin`": _errors__.append( ValidationException( str(e), @@ -19198,13 +16017,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("coresMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19216,37 +16035,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `coresMin` field with value `{val}` " "is not valid because:", ) ) + coresMax = None + if "coresMax" in _doc: + try: + coresMax = _load_field( + _doc.get("coresMax"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("coresMax") + ) - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMax`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("coresMax") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [e], + detailed_message=f"the `coresMax` field with value `{val}` " + "is not valid because:", + ) + ) + ramMin = None + if "ramMin" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + ramMin = _load_field( + _doc.get("ramMin"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("ramMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `ramMin`": _errors__.append( ValidationException( str(e), @@ -19254,13 +16111,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("ramMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19272,28 +16129,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `ramMin` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + ramMax = None + if "ramMax" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + ramMax = _load_field( + _doc.get("ramMax"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("ramMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `ramMax`": _errors__.append( ValidationException( str(e), @@ -19301,13 +16158,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("ramMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19319,28 +16176,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `ramMax` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + tmpdirMin = None + if "tmpdirMin" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + tmpdirMin = _load_field( + _doc.get("tmpdirMin"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("tmpdirMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `tmpdirMin`": _errors__.append( ValidationException( str(e), @@ -19348,13 +16205,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("tmpdirMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19366,28 +16223,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `tmpdirMin` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + tmpdirMax = None + if "tmpdirMax" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + tmpdirMax = _load_field( + _doc.get("tmpdirMax"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("tmpdirMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `tmpdirMax`": _errors__.append( ValidationException( str(e), @@ -19395,13 +16252,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("tmpdirMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19413,28 +16270,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `tmpdirMax` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + outdirMin = None + if "outdirMin" in _doc: + try: + outdirMin = _load_field( + _doc.get("outdirMin"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("outdirMin") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outdirMin") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [e], + detailed_message=f"the `outdirMin` field with value `{val}` " + "is not valid because:", + ) + ) + outdirMax = None + if "outdirMax" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + outdirMax = _load_field( + _doc.get("outdirMax"), + union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("outdirMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `outdirMax`": _errors__.append( ValidationException( str(e), @@ -19442,13 +16346,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("outdirMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19460,29 +16364,237 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `outdirMax` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `coresMin`, `coresMax`, `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, `outdirMax`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + coresMin=coresMin, + coresMax=coresMax, + ramMin=ramMin, + ramMax=ramMax, + tmpdirMin=tmpdirMin, + tmpdirMax=tmpdirMax, + outdirMin=outdirMin, + outdirMax=outdirMax, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.coresMin is not None: + r["coresMin"] = save( + self.coresMin, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.coresMax is not None: + r["coresMax"] = save( + self.coresMax, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.ramMin is not None: + r["ramMin"] = save( + self.ramMin, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.ramMax is not None: + r["ramMax"] = save( + self.ramMax, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.tmpdirMin is not None: + r["tmpdirMin"] = save( + self.tmpdirMin, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.tmpdirMax is not None: + r["tmpdirMax"] = save( + self.tmpdirMax, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.outdirMin is not None: + r["outdirMin"] = save( + self.outdirMin, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.outdirMax is not None: + r["outdirMax"] = save( + self.outdirMax, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + coresMin: None | i32 | i64 | str = None, + coresMax: None | i32 | i64 | str = None, + ramMin: None | i32 | i64 | str = None, + ramMax: None | i32 | i64 | str = None, + tmpdirMin: None | i32 | i64 | str = None, + tmpdirMax: None | i32 | i64 | str = None, + outdirMin: None | i32 | i64 | str = None, + outdirMax: None | i32 | i64 | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "ResourceRequirement" + self.coresMin = coresMin + self.coresMax = coresMax + self.ramMin = ramMin + self.ramMax = ramMax + self.tmpdirMin = tmpdirMin + self.tmpdirMax = tmpdirMax + self.outdirMin = outdirMin + self.outdirMax = outdirMax + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "coresMin", + "coresMax", + "ramMin", + "ramMax", + "tmpdirMin", + "tmpdirMax", + "outdirMin", + "outdirMax", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkReuse(Saveable): + """ + For implementations that support reusing output from past work (on the assumption that same code and same input produce same results), control whether to enable or disable the reuse behavior for a particular tool or step (to accommodate situations where that assumption is incorrect). A reused step is not executed but instead returns the same output as the original execution. + + If ``enableReuse`` is not specified, correct tools should assume it is enabled by default. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, WorkReuse): + return bool( + self.class_ == other.class_ and self.enableReuse == other.enableReuse + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.enableReuse)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + class_ = _load_field( + _doc.get("class"), + uri_WorkReuse_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("enableReuse") is None: + raise ValidationException("missing required field `enableReuse`", None, []) + + enableReuse = _load_field( + _doc.get("enableReuse"), + union_of_booltype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("enableReuse") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `enableReuse`": _errors__.append( ValidationException( str(e), @@ -19490,13 +16602,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("enableReuse") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19508,14 +16620,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `enableReuse` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -19523,14 +16635,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`".format( + "invalid field `{}`, expected one of: `class`, `enableReuse`".format( k ), SourceLine(_doc, k, str), @@ -19540,62 +16652,40 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - type_=type_, + enableReuse=enableReuse, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( self, top: bool = False, base_url: str = "", relative_uris: bool = True ) -> dict[str, Any]: r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.enableReuse is not None: + r["enableReuse"] = save( + self.enableReuse, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -19605,29 +16695,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - ["label", "secondaryFiles", "streamable", "doc", "id", "format", "type"] - ) - - -class WorkflowInputParameter(InputParameter): - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - default: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + enableReuse: bool | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -19637,51 +16709,35 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing - self.default = default - self.type_ = type_ - self.inputBinding = inputBinding + self.class_: Final[str] = "WorkReuse" + self.enableReuse = enableReuse + + attrs: ClassVar[Collection[str]] = frozenset(["class", "enableReuse"]) + + +@mypyc_attr(native_class=True) +class NetworkAccess(Saveable): + """ + Indicate whether a process requires outgoing IPv4/IPv6 network access. Choice of IPv4 or IPv6 is implementation and site specific, correct tools must support both. + + If ``networkAccess`` is false or not specified, tools must not assume network access, except for localhost (the loopback device). + + If ``networkAccess`` is true, the tool must be able to make outgoing connections to network resources. Resources may be on a private subnet or the public Internet. However, implementations and sites may apply their own security policies to restrict what is accessible by the tool. + + Enabling network access does not imply a publicly routable IP address or the ability to accept inbound connections. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowInputParameter): + if isinstance(other, NetworkAccess): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.default == other.default - and self.type_ == other.type_ - and self.inputBinding == other.inputBinding + self.class_ == other.class_ + and self.networkAccess == other.networkAccess ) return False def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.loadContents, - self.loadListing, - self.default, - self.type_, - self.inputBinding, - ) - ) + return hash((self.class_, self.networkAccess)) @classmethod def fromDoc( @@ -19689,462 +16745,424 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowInputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) + class_ = _load_field( + _doc.get("class"), + uri_NetworkAccess_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("networkAccess") is None: + raise ValidationException("missing required field `networkAccess`", None, []) - if str(e) == "missing required field `secondaryFiles`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) + networkAccess = _load_field( + _doc.get("networkAccess"), + union_of_booltype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("networkAccess") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `networkAccess`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("networkAccess") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - str(e), - None + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [e], + detailed_message=f"the `networkAccess` field with value `{val}` " + "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `class`, `networkAccess`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - loadContents = None - if "loadContents" in _doc: - try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("loadContents") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + networkAccess=networkAccess, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.networkAccess is not None: + r["networkAccess"] = save( + self.networkAccess, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + networkAccess: bool | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "NetworkAccess" + self.networkAccess = networkAccess + + attrs: ClassVar[Collection[str]] = frozenset(["class", "networkAccess"]) + + +@mypyc_attr(native_class=True) +class InplaceUpdateRequirement(Saveable): + """ + If ``inplaceUpdate`` is true, then an implementation supporting this feature may permit tools to directly update files with ``writable: true`` in InitialWorkDirRequirement. That is, as an optimization, files may be destructively modified in place as opposed to copied and updated. + + An implementation must ensure that only one workflow step may access a writable file at a time. It is an error if a file which is writable by one workflow step file is accessed (for reading or writing) by any other workflow step running independently. However, a file which has been updated in a previous completed step may be used as input to multiple steps, provided it is read-only in every step. + + Workflow steps which modify a file must produce the modified file as output. Downstream steps which further process the file must use the output of previous steps, and not refer to a common input (this is necessary for both ordering and correctness). + + Workflow authors should provide this in the ``hints`` section. The intent of this feature is that workflows produce the same results whether or not InplaceUpdateRequirement is supported by the implementation, and this feature is primarily available as an optimization for particular environments. + + Users and implementers should be aware that workflows that destructively modify inputs may not be repeatable or reproducible. In particular, enabling this feature implies that WorkReuse should not be enabled. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InplaceUpdateRequirement): + return bool( + self.class_ == other.class_ + and self.inplaceUpdate == other.inplaceUpdate + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.inplaceUpdate)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_InplaceUpdateRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("inplaceUpdate") is None: + raise ValidationException("missing required field `inplaceUpdate`", None, []) - if str(e) == "missing required field `loadContents`": + inplaceUpdate = _load_field( + _doc.get("inplaceUpdate"), + booltype, + baseuri, + loadingOptions, + lc=_doc.get("inplaceUpdate") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inplaceUpdate`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inplaceUpdate") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("loadContents") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], - detailed_message=f"the `loadContents` field with value `{val}` " - "is not valid because:", - ) - ) - loadListing = None - if "loadListing" in _doc: - try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, - baseuri, - loadingOptions, - lc=_doc.get("loadListing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( - str(e), - None + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), + [e], + detailed_message=f"the `inplaceUpdate` field with value `{val}` " + "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("loadListing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], - detailed_message=f"the `loadListing` field with value `{val}` " - "is not valid because:", - ) - ) - default = None - if "default" in _doc: - try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, - baseuri, - loadingOptions, - lc=_doc.get("default") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `default`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `class`, `inplaceUpdate`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("default") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [e], - detailed_message=f"the `default` field with value `{val}` " - "is not valid because:", - ) - ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + inplaceUpdate=inplaceUpdate, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.inplaceUpdate is not None: + r["inplaceUpdate"] = save( + self.inplaceUpdate, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + inplaceUpdate: bool, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "InplaceUpdateRequirement" + self.inplaceUpdate = inplaceUpdate + + attrs: ClassVar[Collection[str]] = frozenset(["class", "inplaceUpdate"]) + + +@mypyc_attr(native_class=True) +class ToolTimeLimit(Saveable): + """ + Set an upper limit on the execution time of a CommandLineTool. A CommandLineTool whose execution duration exceeds the time limit may be preemptively terminated and considered failed. May also be used by batch systems to make scheduling decisions. The execution duration excludes external operations, such as staging of files, pulling a docker image etc, and only counts wall-time for the execution of the command line itself. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, ToolTimeLimit): + return bool( + self.class_ == other.class_ and self.timelimit == other.timelimit + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.timelimit)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ToolTimeLimit_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("timelimit") is None: + raise ValidationException("missing required field `timelimit`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + timelimit = _load_field( + _doc.get("timelimit"), + union_of_inttype_or_longtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("timelimit") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `timelimit`": _errors__.append( ValidationException( str(e), @@ -20152,13 +17170,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("timelimit") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20170,61 +17188,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `timelimit` field with value `{val}` " "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_InputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -20232,14 +17203,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( + "invalid field `{}`, expected one of: `class`, `timelimit`".format( k ), SourceLine(_doc, k, str), @@ -20249,21 +17220,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - loadContents=loadContents, - loadListing=loadListing, - default=default, - type_=type_, - inputBinding=inputBinding, + timelimit=timelimit, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -20277,61 +17237,21 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.timelimit is not None: + r["timelimit"] = save( + self.timelimit, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) @@ -20343,50 +17263,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "loadContents", - "loadListing", - "default", - "type", - "inputBinding", - ] - ) - - -class ExpressionTool(Process): - """ - An ExpressionTool is a type of Process object that can be run by itself - or as a Workflow step. It executes a pure Javascript expression that has - access to the same input parameters as a workflow. It is meant to be used - sparingly as a way to isolate complex Javascript expressions that need to - operate on input data and produce some result; perhaps just a - rearrangement of the inputs. No Docker software container is required - or allowed. - - """ - - id: str - def __init__( self, - inputs: Any, - outputs: Any, - expression: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + timelimit: i32 | i64 | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -20396,46 +17277,39 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.class_ = "ExpressionTool" - self.expression = expression + self.class_: Final[str] = "ToolTimeLimit" + self.timelimit = timelimit + + attrs: ClassVar[Collection[str]] = frozenset(["class", "timelimit"]) + + +@mypyc_attr(native_class=True) +class ExpressionToolOutputParameter(Saveable): + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, ExpressionTool): + if isinstance(other, ExpressionToolOutputParameter): return bool( - self.id == other.id - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.class_ == other.class_ - and self.expression == other.expression + and self.id == other.id + and self.format == other.format + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( ( - self.id, self.label, + self.secondaryFiles, + self.streamable, self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.class_, - self.expression, + self.id, + self.format, + self.type_, ) ) @@ -20445,8 +17319,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ExpressionTool": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -20456,9 +17330,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -20501,34 +17375,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ExpressionTool_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -20572,21 +17430,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -20594,13 +17452,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20612,124 +17470,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_WorkflowInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_ExpressionToolOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + streamable = None + if "streamable" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -20737,13 +17499,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20755,28 +17517,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + doc = None + if "doc" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -20784,13 +17546,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20802,28 +17564,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - cwlVersion = None - if "cwlVersion" in _doc: + format = None + if "format" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -20831,13 +17593,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20849,29 +17611,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("expression") is None: - raise ValidationException("missing required field `expression`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - expression = load_field( - _doc.get("expression"), - ExpressionLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("expression") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `expression`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -20879,13 +17641,13 @@ def fromDoc( ) ) else: - val = _doc.get("expression") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `expression` field is not valid because:", - SourceLine(_doc, "expression", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20897,14 +17659,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `expression` field is not valid because:", - SourceLine(_doc, "expression", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `expression` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -20912,14 +17674,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `expression`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`".format( k ), SourceLine(_doc, k, str), @@ -20931,17 +17693,15 @@ def fromDoc( _constructed = cls( id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - expression=expression, + format=format, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -20956,53 +17716,37 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.expression is not None: - r["expression"] = save( - self.expression, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, base_url=self.id, relative_uris=relative_uris, ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -21012,46 +17756,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "class", - "expression", - ] - ) - - -class WorkflowOutputParameter(OutputParameter): - """ - Describe an output parameter of a workflow. The parameter must be - connected to one or more parameters defined in the workflow that - will provide the value of the output parameter. It is legal to - connect a WorkflowInputParameter to a WorkflowOutputParameter. - - """ - - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - outputSource: Optional[Any] = None, - linkMerge: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -21065,14 +17780,21 @@ def __init__( self.secondaryFiles = secondaryFiles self.streamable = streamable self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.id = id self.format = format - self.outputSource = outputSource - self.linkMerge = linkMerge self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset( + ["label", "secondaryFiles", "streamable", "doc", "id", "format", "type"] + ) + + +@mypyc_attr(native_class=True) +class WorkflowInputParameter(Saveable): + id: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowOutputParameter): + if isinstance(other, WorkflowInputParameter): return bool( self.label == other.label and self.secondaryFiles == other.secondaryFiles @@ -21080,9 +17802,11 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.outputSource == other.outputSource - and self.linkMerge == other.linkMerge + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.default == other.default and self.type_ == other.type_ + and self.inputBinding == other.inputBinding ) return False @@ -21095,9 +17819,11 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.outputSource, - self.linkMerge, + self.loadContents, + self.loadListing, + self.default, self.type_, + self.inputBinding, ) ) @@ -21107,8 +17833,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -21118,7 +17844,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_strtype_True_False_None_None, baseuri, @@ -21163,18 +17889,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: + id = "" _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -21221,7 +17947,7 @@ def fromDoc( secondaryFiles = None if "secondaryFiles" in _doc: try: - secondaryFiles = load_field( + secondaryFiles = _load_field( _doc.get("secondaryFiles"), secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, @@ -21268,7 +17994,7 @@ def fromDoc( streamable = None if "streamable" in _doc: try: - streamable = load_field( + streamable = _load_field( _doc.get("streamable"), union_of_None_type_or_booltype, baseuri, @@ -21315,7 +18041,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -21362,9 +18088,9 @@ def fromDoc( format = None if "format" in _doc: try: - format = load_field( + format = _load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, lc=_doc.get("format") @@ -21406,21 +18132,21 @@ def fromDoc( "is not valid because:", ) ) - outputSource = None - if "outputSource" in _doc: + loadContents = None + if "loadContents" in _doc: try: - outputSource = load_field( - _doc.get("outputSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("outputSource") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputSource`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -21428,13 +18154,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputSource") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -21446,28 +18172,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `outputSource` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - linkMerge = None - if "linkMerge" in _doc: + loadListing = None + if "loadListing" in _doc: try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("linkMerge") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `linkMerge`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -21475,13 +18201,13 @@ def fromDoc( ) ) else: - val = _doc.get("linkMerge") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -21493,10 +18219,57 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `linkMerge` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("default") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + detailed_message=f"the `default` field with value `{val}` " "is not valid because:", ) ) @@ -21504,9 +18277,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -21548,7 +18321,54 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_InputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -21556,14 +18376,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `outputSource`, `linkMerge`, `type`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -21573,19 +18393,21 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, label=label, secondaryFiles=secondaryFiles, streamable=streamable, doc=doc, - id=id, format=format, - outputSource=outputSource, - linkMerge=linkMerge, + loadContents=loadContents, + loadListing=loadListing, + default=default, type_=type_, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -21600,7 +18422,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.label is not None: r["label"] = save( @@ -21627,17 +18449,35 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.outputSource is not None: - u = save_relative_uri(self.outputSource, self.id, False, 1, relative_uris) - r["outputSource"] = u - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) # top refers to the directory level if top: @@ -21647,7 +18487,43 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( + def __init__( + self, + id: str, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + default: CWLObjectType | None = None, + inputBinding: InputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + self.default = default + self.type_ = type_ + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( [ "label", "secondaryFiles", @@ -21655,108 +18531,37 @@ def save( "doc", "id", "format", - "outputSource", - "linkMerge", + "loadContents", + "loadListing", + "default", "type", + "inputBinding", ] ) -class Sink(Saveable): - pass - - -class WorkflowStepInput(IdentifierRequired, Sink, LoadContents, Labeled): +@mypyc_attr(native_class=True) +class ExpressionTool(Saveable): """ - The input of a workflow step connects an upstream parameter (from the - workflow inputs, or the outputs of other workflows steps) with the input - parameters of the process specified by the `run` field. Only input parameters - declared by the target process will be passed through at runtime to the process - though additonal parameters may be specified (for use within `valueFrom` - expressions for instance) - unconnected or unused parameters do not represent an - error condition. - - ## Input object - - A WorkflowStepInput object must contain an `id` field in the form - `#fieldname` or `#prefix/fieldname`. When the `id` field contains a slash - `/` the field name consists of the characters following the final slash - (the prefix portion may contain one or more slashes to indicate scope). - This defines a field of the workflow step input object with the value of - the `source` parameter(s). - - ## Merging - - To merge multiple inbound data links, - [MultipleInputFeatureRequirement](#MultipleInputFeatureRequirement) must be specified - in the workflow or workflow step requirements. - - If the sink parameter is an array, or named in a [workflow - scatter](#WorkflowStep) operation, there may be multiple inbound data links - listed in the `source` field. The values from the input links are merged - depending on the method specified in the `linkMerge` field. If not - specified, the default method is "merge_nested". - - * **merge_nested** - - The input must be an array consisting of exactly one entry for each - input link. If "merge_nested" is specified with a single link, the value - from the link must be wrapped in a single-item list. - - * **merge_flattened** - - 1. The source and sink parameters must be compatible types, or the source - type must be compatible with single element from the "items" type of - the destination array parameter. - 2. Source parameters which are arrays are concatenated. - Source parameters which are single element types are appended as - single elements. + An ExpressionTool is a type of Process object that can be run by itself or as a Workflow step. It executes a pure Javascript expression that has access to the same input parameters as a workflow. It is meant to be used sparingly as a way to isolate complex Javascript expressions that need to operate on input data and produce some result; perhaps just a rearrangement of the inputs. No Docker software container is required or allowed. """ id: str - def __init__( - self, - id: Any, - source: Optional[Any] = None, - linkMerge: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - label: Optional[Any] = None, - default: Optional[Any] = None, - valueFrom: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.source = source - self.linkMerge = linkMerge - self.loadContents = loadContents - self.loadListing = loadListing - self.label = label - self.default = default - self.valueFrom = valueFrom - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepInput): + if isinstance(other, ExpressionTool): return bool( self.id == other.id - and self.source == other.source - and self.linkMerge == other.linkMerge - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing and self.label == other.label - and self.default == other.default - and self.valueFrom == other.valueFrom + and self.doc == other.doc + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.requirements == other.requirements + and self.hints == other.hints + and self.cwlVersion == other.cwlVersion + and self.class_ == other.class_ + and self.expression == other.expression ) return False @@ -21764,13 +18569,15 @@ def __hash__(self) -> int: return hash( ( self.id, - self.source, - self.linkMerge, - self.loadContents, - self.loadListing, self.label, - self.default, - self.valueFrom, + self.doc, + self.inputs, + self.outputs, + self.requirements, + self.hints, + self.cwlVersion, + self.class_, + self.expression, ) ) @@ -21780,8 +18587,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStepInput": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -21791,9 +18598,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -21836,29 +18643,45 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - source = None - if "source" in _doc: + id = "_:" + str(_uuid__.uuid4()) + else: + baseuri = id + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ExpressionTool_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + label = None + if "label" in _doc: try: - source = load_field( - _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("source") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `source`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -21866,13 +18689,13 @@ def fromDoc( ) ) else: - val = _doc.get("source") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -21884,28 +18707,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `source` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - linkMerge = None - if "linkMerge" in _doc: + doc = None + if "doc" in _doc: try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("linkMerge") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `linkMerge`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -21913,13 +18736,13 @@ def fromDoc( ) ) else: - val = _doc.get("linkMerge") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -21931,169 +18754,124 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `linkMerge` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: - try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("loadContents") - ) + try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_WorkflowInputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputs") + ) - if str(e) == "missing required field `loadContents`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("loadContents") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], - detailed_message=f"the `loadContents` field with value `{val}` " - "is not valid because:", - ) - ) - loadListing = None - if "loadListing" in _doc: - try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, - baseuri, - loadingOptions, - lc=_doc.get("loadListing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( - str(e), - None + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + detailed_message=f"the `inputs` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("loadListing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], - detailed_message=f"the `loadListing` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) + try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_ExpressionToolOutputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputs") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + detailed_message=f"the `outputs` field with value `{val}` " + "is not valid because:", ) - default = None - if "default" in _doc: + ) + requirements = None + if "requirements" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("requirements") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `requirements`": _errors__.append( ValidationException( str(e), @@ -22101,13 +18879,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("requirements") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22119,28 +18897,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `requirements` field with value `{val}` " "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + hints = None + if "hints" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -22148,13 +18926,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22166,190 +18944,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`, `source`, `linkMerge`, `loadContents`, `loadListing`, `label`, `default`, `valueFrom`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - source=source, - linkMerge=linkMerge, - loadContents=loadContents, - loadListing=loadListing, - label=label, - default=default, - valueFrom=valueFrom, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.source is not None: - u = save_relative_uri(self.source, self.id, False, 2, relative_uris) - r["source"] = u - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "source", - "linkMerge", - "loadContents", - "loadListing", - "label", - "default", - "valueFrom", - ] - ) - - -class WorkflowStepOutput(IdentifierRequired): - """ - Associate an output parameter of the underlying process with a workflow - parameter. The workflow parameter (given in the `id` field) be may be used - as a `source` to connect with input parameters of other workflow steps, or - with an output parameter of the process. - - A unique identifier for this workflow output parameter. This is - the identifier to use in the `source` field of `WorkflowStepInput` - to connect the output value to downstream parameters. - - """ - - id: str - - def __init__( - self, - id: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepOutput): - return bool(self.id == other.id) - return False - - def __hash__(self) -> int: - return hash((self.id)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStepOutput": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + cwlVersion = None + if "cwlVersion" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("cwlVersion") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( str(e), @@ -22357,13 +18973,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("cwlVersion") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22375,23 +18991,62 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `cwlVersion` field with value `{val}` " "is not valid because:", ) ) + try: + if _doc.get("expression") is None: + raise ValidationException("missing required field `expression`", None, []) - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot + expression = _load_field( + _doc.get("expression"), + ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("expression") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expression`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - extension_fields: dict[str, Any] = {} + val = _doc.get("expression") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [e], + detailed_message=f"the `expression` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -22399,14 +19054,16 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`".format(k), + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `expression`".format( + k + ), SourceLine(_doc, k, str), ) ) @@ -22415,10 +19072,18 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, + label=label, + doc=doc, + inputs=inputs, + outputs=outputs, + requirements=requirements, + hints=hints, + cwlVersion=cwlVersion, + expression=expression, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -22433,8 +19098,55 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.id, False, None, relative_uris) + r["class"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.requirements is not None: + r["requirements"] = save( + self.requirements, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.expression is not None: + r["expression"] = save( + self.expression, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) # top refers to the directory level if top: @@ -22444,85 +19156,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["id"]) - - -class WorkflowStep(IdentifierRequired, Labeled, Documented): - """ - A workflow step is an executable element of a workflow. It specifies the - underlying process implementation (such as `CommandLineTool` or another - `Workflow`) in the `run` field and connects the input and output parameters - of the underlying process to workflow parameters. - - # Scatter/gather - - To use scatter/gather, - [ScatterFeatureRequirement](#ScatterFeatureRequirement) must be specified - in the workflow or workflow step requirements. - - A "scatter" operation specifies that the associated workflow step or - subworkflow should execute separately over a list of input elements. Each - job making up a scatter operation is independent and may be executed - concurrently. - - The `scatter` field specifies one or more input parameters which will be - scattered. An input parameter may be listed more than once. The declared - type of each input parameter is implicitly becomes an array of items of the - input parameter type. If a parameter is listed more than once, it becomes - a nested array. As a result, upstream parameters which are connected to - scattered parameters must be arrays. - - All output parameter types are also implicitly wrapped in arrays. Each job - in the scatter results in an entry in the output array. - - If any scattered parameter runtime value is an empty array, all outputs are - set to empty arrays and no work is done for the step, according to - applicable scattering rules. - - If `scatter` declares more than one input parameter, `scatterMethod` - describes how to decompose the input into a discrete set of jobs. - - * **dotproduct** specifies that each of the input arrays are aligned and one - element taken from each array to construct each job. It is an error - if all input arrays are not the same length. - - * **nested_crossproduct** specifies the Cartesian product of the inputs, - producing a job for every combination of the scattered inputs. The - output must be nested arrays for each level of scattering, in the - order that the input arrays are listed in the `scatter` field. - - * **flat_crossproduct** specifies the Cartesian product of the inputs, - producing a job for every combination of the scattered inputs. The - output arrays must be flattened to a single level, but otherwise listed in the - order that the input arrays are listed in the `scatter` field. - - # Subworkflows - - To specify a nested workflow as part of a workflow step, - [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) must be - specified in the workflow or workflow step requirements. - - It is a fatal error if a workflow directly or indirectly invokes itself as - a subworkflow (recursive workflows are not allowed). - - """ - - id: str - def __init__( self, - id: Any, - in_: Any, - out: Any, - run: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - scatter: Optional[Any] = None, - scatterMethod: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + inputs: Sequence[WorkflowInputParameter], + outputs: Sequence[ExpressionToolOutputParameter], + expression: str, + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -22535,43 +19181,66 @@ def __init__( self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) self.label = label self.doc = doc - self.in_ = in_ - self.out = out + self.inputs = inputs + self.outputs = outputs self.requirements = requirements self.hints = hints - self.run = run - self.scatter = scatter - self.scatterMethod = scatterMethod + self.cwlVersion = cwlVersion + self.class_: Final[str] = "ExpressionTool" + self.expression = expression + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "inputs", + "outputs", + "requirements", + "hints", + "cwlVersion", + "class", + "expression", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkflowOutputParameter(Saveable): + """ + Describe an output parameter of a workflow. The parameter must be connected to one or more parameters defined in the workflow that will provide the value of the output parameter. It is legal to connect a WorkflowInputParameter to a WorkflowOutputParameter. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStep): + if isinstance(other, WorkflowOutputParameter): return bool( - self.id == other.id - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.in_ == other.in_ - and self.out == other.out - and self.requirements == other.requirements - and self.hints == other.hints - and self.run == other.run - and self.scatter == other.scatter - and self.scatterMethod == other.scatterMethod + and self.id == other.id + and self.format == other.format + and self.outputSource == other.outputSource + and self.linkMerge == other.linkMerge + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( ( - self.id, self.label, + self.secondaryFiles, + self.streamable, self.doc, - self.in_, - self.out, - self.requirements, - self.hints, - self.run, - self.scatter, - self.scatterMethod, + self.id, + self.format, + self.outputSource, + self.linkMerge, + self.type_, ) ) @@ -22581,8 +19250,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStep": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -22592,7 +19261,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_strtype_True_False_None_None, baseuri, @@ -22637,18 +19306,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: + id = "" _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -22688,25 +19357,72 @@ def fromDoc( "the `label` field is not valid because:", SourceLine(_doc, "label", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + streamable = None + if "streamable" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -22714,13 +19430,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22732,124 +19448,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("in") is None: - raise ValidationException("missing required field `in`", None, []) - - in_ = load_field( - _doc.get("in"), - idmap_in__array_of_WorkflowStepInputLoader, - baseuri, - loadingOptions, - lc=_doc.get("in") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `in`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("in") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), - [e], - detailed_message=f"the `in` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("out") is None: - raise ValidationException("missing required field `out`", None, []) - - out = load_field( - _doc.get("out"), - uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("out") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `out`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("out") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), - [e], - detailed_message=f"the `out` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + doc = None + if "doc" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -22857,13 +19477,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22875,28 +19495,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + format = None + if "format" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_Any_type, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -22904,13 +19524,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22922,78 +19542,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - - subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) - try: - if _doc.get("run") is None: - raise ValidationException("missing required field `run`", None, []) - - run = load_field( - _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_False_False_None_None, - subscope_baseuri, - loadingOptions, - lc=_doc.get("run") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `run`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("run") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [e], - detailed_message=f"the `run` field with value `{val}` " - "is not valid because:", - ) - ) - scatter = None - if "scatter" in _doc: + outputSource = None + if "outputSource" in _doc: try: - scatter = load_field( - _doc.get("scatter"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, + outputSource = _load_field( + _doc.get("outputSource"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, baseuri, loadingOptions, - lc=_doc.get("scatter") + lc=_doc.get("outputSource") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `scatter`": + if str(e) == "missing required field `outputSource`": _errors__.append( ValidationException( str(e), @@ -23001,13 +19571,13 @@ def fromDoc( ) ) else: - val = _doc.get("scatter") + val = _doc.get("outputSource") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `scatter` field is not valid because:", - SourceLine(_doc, "scatter", str), + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23019,28 +19589,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `scatter` field is not valid because:", - SourceLine(_doc, "scatter", str), + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), [e], - detailed_message=f"the `scatter` field with value `{val}` " + detailed_message=f"the `outputSource` field with value `{val}` " "is not valid because:", ) ) - scatterMethod = None - if "scatterMethod" in _doc: + linkMerge = None + if "linkMerge" in _doc: try: - scatterMethod = load_field( - _doc.get("scatterMethod"), - uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, + linkMerge = _load_field( + _doc.get("linkMerge"), + union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, - lc=_doc.get("scatterMethod") + lc=_doc.get("linkMerge") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `scatterMethod`": + if str(e) == "missing required field `linkMerge`": _errors__.append( ValidationException( str(e), @@ -23048,13 +19618,13 @@ def fromDoc( ) ) else: - val = _doc.get("scatterMethod") + val = _doc.get("linkMerge") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `scatterMethod` field is not valid because:", - SourceLine(_doc, "scatterMethod", str), + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23066,14 +19636,62 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `scatterMethod` field is not valid because:", - SourceLine(_doc, "scatterMethod", str), + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), [e], - detailed_message=f"the `scatterMethod` field with value `{val}` " + detailed_message=f"the `linkMerge` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23081,14 +19699,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `in`, `out`, `requirements`, `hints`, `run`, `scatter`, `scatterMethod`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `outputSource`, `linkMerge`, `type`".format( k ), SourceLine(_doc, k, str), @@ -23100,18 +19718,17 @@ def fromDoc( _constructed = cls( id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, doc=doc, - in_=in_, - out=out, - requirements=requirements, - hints=hints, - run=run, - scatter=scatter, - scatterMethod=scatterMethod, + format=format, + outputSource=outputSource, + linkMerge=linkMerge, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -23126,45 +19743,44 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.in_ is not None: - r["in"] = save( - self.in_, top=False, base_url=self.id, relative_uris=relative_uris + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.out is not None: - u = save_relative_uri(self.out, self.id, True, None, relative_uris) - r["out"] = u - if self.requirements is not None: - r["requirements"] = save( - self.requirements, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u - if self.scatter is not None: - u = save_relative_uri(self.scatter, self.id, False, 0, relative_uris) - r["scatter"] = u - if self.scatterMethod is not None: - u = save_relative_uri( - self.scatterMethod, self.id, False, None, relative_uris + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.outputSource is not None: + u = save_relative_uri(self.outputSource, self.id, False, 1, relative_uris) + r["outputSource"] = u + if self.linkMerge is not None: + r["linkMerge"] = save( + self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) - r["scatterMethod"] = u # top refers to the directory level if top: @@ -23174,120 +19790,94 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( + def __init__( + self, + id: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + outputSource: None | Sequence[str] | str = None, + linkMerge: LinkMergeMethod | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.outputSource = outputSource + self.linkMerge = linkMerge + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( [ - "id", "label", + "secondaryFiles", + "streamable", "doc", - "in", - "out", - "requirements", - "hints", - "run", - "scatter", - "scatterMethod", + "id", + "format", + "outputSource", + "linkMerge", + "type", ] ) -class Workflow(Process): +@mypyc_attr(native_class=True) +class WorkflowStepInput(Saveable): """ - A workflow describes a set of **steps** and the **dependencies** between - those steps. When a step produces output that will be consumed by a - second step, the first step is a dependency of the second step. - - When there is a dependency, the workflow engine must execute the preceding - step and wait for it to successfully produce output before executing the - dependent step. If two steps are defined in the workflow graph that - are not directly or indirectly dependent, these steps are **independent**, - and may execute in any order or execute concurrently. A workflow is - complete when all steps have been executed. + The input of a workflow step connects an upstream parameter (from the workflow inputs, or the outputs of other workflows steps) with the input parameters of the process specified by the ``run`` field. Only input parameters declared by the target process will be passed through at runtime to the process though additional parameters may be specified (for use within ``valueFrom`` expressions for instance) - unconnected or unused parameters do not represent an error condition. - Dependencies between parameters are expressed using the `source` field on - [workflow step input parameters](#WorkflowStepInput) and [workflow output - parameters](#WorkflowOutputParameter). + Input object + ------------ - The `source` field expresses the dependency of one parameter on another - such that when a value is associated with the parameter specified by - `source`, that value is propagated to the destination parameter. When all - data links inbound to a given step are fufilled, the step is ready to - execute. + A WorkflowStepInput object must contain an ``id`` field in the form ``#fieldname`` or ``#prefix/fieldname``. When the ``id`` field contains a slash ``/`` the field name consists of the characters following the final slash (the prefix portion may contain one or more slashes to indicate scope). This defines a field of the workflow step input object with the value of the ``source`` parameter(s). - ## Workflow success and failure + Merging + ------- - A completed step must result in one of `success`, `temporaryFailure` or - `permanentFailure` states. An implementation may choose to retry a step - execution which resulted in `temporaryFailure`. An implementation may - choose to either continue running other steps of a workflow, or terminate - immediately upon `permanentFailure`. + To merge multiple inbound data links, `MultipleInputFeatureRequirement <#MultipleInputFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. - * If any step of a workflow execution results in `permanentFailure`, then - the workflow status is `permanentFailure`. + If the sink parameter is an array, or named in a `workflow scatter <#WorkflowStep>`__ operation, there may be multiple inbound data links listed in the ``source`` field. The values from the input links are merged depending on the method specified in the ``linkMerge`` field. If not specified, the default method is "merge_nested". - * If one or more steps result in `temporaryFailure` and all other steps - complete `success` or are not executed, then the workflow status is - `temporaryFailure`. + * **merge_nested** - * If all workflow steps are executed and complete with `success`, then the - workflow status is `success`. + The input must be an array consisting of exactly one entry for each input link. If "merge_nested" is specified with a single link, the value from the link must be wrapped in a single-item list. - # Extensions + * **merge_flattened** - [ScatterFeatureRequirement](#ScatterFeatureRequirement) and - [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) are - available as standard [extensions](#Extensions_and_Metadata) to core - workflow semantics. + 1. The source and sink parameters must be compatible types, or the source type must be compatible with single element from the "items" type of the destination array parameter. + 2. Source parameters which are arrays are concatenated. Source parameters which are single element types are appended as single elements. """ id: str - def __init__( - self, - inputs: Any, - outputs: Any, - steps: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.class_ = "Workflow" - self.steps = steps - def __eq__(self, other: Any) -> bool: - if isinstance(other, Workflow): + if isinstance(other, WorkflowStepInput): return bool( self.id == other.id + and self.source == other.source + and self.linkMerge == other.linkMerge + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing and self.label == other.label - and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.class_ == other.class_ - and self.steps == other.steps + and self.default == other.default + and self.valueFrom == other.valueFrom ) return False @@ -23295,15 +19885,13 @@ def __hash__(self) -> int: return hash( ( self.id, + self.source, + self.linkMerge, + self.loadContents, + self.loadListing, self.label, - self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.class_, - self.steps, + self.default, + self.valueFrom, ) ) @@ -23313,8 +19901,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Workflow": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -23324,9 +19912,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -23369,45 +19957,76 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + source = None + if "source" in _doc: + try: + source = _load_field( + _doc.get("source"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + baseuri, + loadingOptions, + lc=_doc.get("source") + ) - class_ = load_field( - _doc.get("class"), - uri_Workflow_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - label = None - if "label" in _doc: + if str(e) == "missing required field `source`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("source") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [e], + detailed_message=f"the `source` field with value `{val}` " + "is not valid because:", + ) + ) + linkMerge = None + if "linkMerge" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + linkMerge = _load_field( + _doc.get("linkMerge"), + union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("linkMerge") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `linkMerge`": _errors__.append( ValidationException( str(e), @@ -23415,13 +20034,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("linkMerge") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23433,28 +20052,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `linkMerge` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + loadContents = None + if "loadContents" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -23462,13 +20081,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23480,124 +20099,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_WorkflowInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_WorkflowOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + loadListing = None + if "loadListing" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -23605,13 +20128,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23623,28 +20146,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + label = None + if "label" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -23652,13 +20175,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23670,28 +20193,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - cwlVersion = None - if "cwlVersion" in _doc: + default = None + if "default" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("default") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `default`": _errors__.append( ValidationException( str(e), @@ -23699,13 +20222,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("default") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23717,62 +20240,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `default` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("steps") is None: - raise ValidationException("missing required field `steps`", None, []) - - steps = load_field( - _doc.get("steps"), - idmap_steps_union_of_array_of_WorkflowStepLoader, - baseuri, - loadingOptions, - lc=_doc.get("steps") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `steps`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("steps") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + valueFrom = None + if "valueFrom" in _doc: + try: + valueFrom = _load_field( + _doc.get("valueFrom"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("valueFrom") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": _errors__.append( ValidationException( - "the `steps` field is not valid because:", - SourceLine(_doc, "steps", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `steps` field is not valid because:", - SourceLine(_doc, "steps", str), - [e], - detailed_message=f"the `steps` field with value `{val}` " - "is not valid because:", + val = _doc.get("valueFrom") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + detailed_message=f"the `valueFrom` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23780,14 +20302,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `steps`".format( + "invalid field `{}`, expected one of: `id`, `source`, `linkMerge`, `loadContents`, `loadListing`, `label`, `default`, `valueFrom`".format( k ), SourceLine(_doc, k, str), @@ -23798,18 +20320,17 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, + source=source, + linkMerge=linkMerge, + loadContents=loadContents, + loadListing=loadListing, label=label, - doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - steps=steps, + default=default, + valueFrom=valueFrom, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -23824,183 +20345,42 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris + if self.source is not None: + u = save_relative_uri(self.source, self.id, False, 2, relative_uris) + r["source"] = u + if self.linkMerge is not None: + r["linkMerge"] = save( + self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.steps is not None: - r["steps"] = save( - self.steps, top=False, base_url=self.id, relative_uris=relative_uris + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "class", - "steps", - ] - ) - - -class SubworkflowFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support nested workflows in - the `run` field of [WorkflowStep](#WorkflowStep). - - """ - - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SubworkflowFeatureRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SubworkflowFeatureRequirement): - return bool(self.class_ == other.class_) - return False - - def __hash__(self) -> int: - return hash((self.class_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SubworkflowFeatureRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") + if self.valueFrom is not None: + r["valueFrom"] = save( + self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - # top refers to the directory level if top: if self.loadingOptions.namespaces: @@ -24009,20 +20389,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class"]) - - -class ScatterFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support the `scatter` and - `scatterMethod` fields of [WorkflowStep](#WorkflowStep). - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + source: None | Sequence[str] | str = None, + linkMerge: LinkMergeMethod | None = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + label: None | str = None, + default: CWLObjectType | None = None, + valueFrom: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -24032,15 +20410,47 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ScatterFeatureRequirement" + self.id = id + self.source = source + self.linkMerge = linkMerge + self.loadContents = loadContents + self.loadListing = loadListing + self.label = label + self.default = default + self.valueFrom = valueFrom + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "source", + "linkMerge", + "loadContents", + "loadListing", + "label", + "default", + "valueFrom", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkflowStepOutput(Saveable): + """ + Associate an output parameter of the underlying process with a workflow parameter. The workflow parameter (given in the ``id`` field) be may be used as a ``source`` to connect with input parameters of other workflow steps, or with an output parameter of the process. + + A unique identifier for this workflow output parameter. This is the identifier to use in the ``source`` field of ``WorkflowStepInput`` to connect the output value to downstream parameters. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, ScatterFeatureRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, WorkflowStepOutput): + return bool(self.id == other.id) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash((self.id)) @classmethod def fromDoc( @@ -24048,31 +20458,71 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ScatterFeatureRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) - class_ = load_field( - _doc.get("class"), - uri_ScatterFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -24080,14 +20530,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), + "invalid field `{}`, expected one of: `id`".format(k), SourceLine(_doc, k, str), ) ) @@ -24095,9 +20545,11 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -24111,14 +20563,9 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u # top refers to the directory level if top: @@ -24128,20 +20575,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class"]) - - -class MultipleInputFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support multiple inbound data links - listed in the `source` field of [WorkflowStepInput](#WorkflowStepInput). - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -24151,15 +20589,79 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "MultipleInputFeatureRequirement" + self.id = id + + attrs: ClassVar[Collection[str]] = frozenset(["id"]) + + +@mypyc_attr(native_class=True) +class WorkflowStep(schema_salad.metaschema.Documented): + """ + A workflow step is an executable element of a workflow. It specifies the underlying process implementation (such as ``CommandLineTool`` or another ``Workflow``) in the ``run`` field and connects the input and output parameters of the underlying process to workflow parameters. + + Scatter/gather + ============== + + To use scatter/gather, `ScatterFeatureRequirement <#ScatterFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + A "scatter" operation specifies that the associated workflow step or subworkflow should execute separately over a list of input elements. Each job making up a scatter operation is independent and may be executed concurrently. + + The ``scatter`` field specifies one or more input parameters which will be scattered. An input parameter may be listed more than once. The declared type of each input parameter is implicitly becomes an array of items of the input parameter type. If a parameter is listed more than once, it becomes a nested array. As a result, upstream parameters which are connected to scattered parameters must be arrays. + + All output parameter types are also implicitly wrapped in arrays. Each job in the scatter results in an entry in the output array. + + If any scattered parameter runtime value is an empty array, all outputs are set to empty arrays and no work is done for the step, according to applicable scattering rules. + + If ``scatter`` declares more than one input parameter, ``scatterMethod`` describes how to decompose the input into a discrete set of jobs. + + * **dotproduct** specifies that each of the input arrays are aligned and one element taken from each array to construct each job. It is an error if all input arrays are not the same length. + + * **nested_crossproduct** specifies the Cartesian product of the inputs, producing a job for every combination of the scattered inputs. The output must be nested arrays for each level of scattering, in the order that the input arrays are listed in the ``scatter`` field. + + * **flat_crossproduct** specifies the Cartesian product of the inputs, producing a job for every combination of the scattered inputs. The output arrays must be flattened to a single level, but otherwise listed in the order that the input arrays are listed in the ``scatter`` field. + + Subworkflows + ============ + + To specify a nested workflow as part of a workflow step, `SubworkflowFeatureRequirement <#SubworkflowFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + It is a fatal error if a workflow directly or indirectly invokes itself as a subworkflow (recursive workflows are not allowed). + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, MultipleInputFeatureRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, WorkflowStep): + return bool( + self.id == other.id + and self.label == other.label + and self.doc == other.doc + and self.in_ == other.in_ + and self.out == other.out + and self.requirements == other.requirements + and self.hints == other.hints + and self.run == other.run + and self.scatter == other.scatter + and self.scatterMethod == other.scatterMethod + ) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash( + ( + self.id, + self.label, + self.doc, + self.in_, + self.out, + self.requirements, + self.hints, + self.run, + self.scatter, + self.scatterMethod, + ) + ) @classmethod def fromDoc( @@ -24167,280 +20669,372 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MultipleInputFeatureRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if _doc.get("in") is None: + raise ValidationException("missing required field `in`", None, []) - class_ = load_field( - _doc.get("class"), - uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None, + in_ = _load_field( + _doc.get("in"), + idmap_in__array_of_WorkflowStepInputLoader, baseuri, loadingOptions, - lc=_doc.get("class") + lc=_doc.get("in") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + else: + val = _doc.get("in") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + detailed_message=f"the `in` field with value `{val}` " + "is not valid because:", ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class StepInputExpressionRequirement(ProcessRequirement): - """ - Indicate that the workflow platform must support the `valueFrom` field - of [WorkflowStepInput](#WorkflowStepInput). - - """ - - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "StepInputExpressionRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, StepInputExpressionRequirement): - return bool(self.class_ == other.class_) - return False - - def __hash__(self) -> int: - return hash((self.class_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "StepInputExpressionRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if _doc.get("out") is None: + raise ValidationException("missing required field `out`", None, []) - class_ = load_field( - _doc.get("class"), - uri_StepInputExpressionRequirement_classLoader_False_True_None_None, + out = _load_field( + _doc.get("out"), + uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("class") + lc=_doc.get("out") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `out`": + _errors__.append( + ValidationException( + str(e), + None ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + else: + val = _doc.get("out") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [e], + detailed_message=f"the `out` field with value `{val}` " + "is not valid because:", ) ) + requirements = None + if "requirements" in _doc: + try: + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, + baseuri, + loadingOptions, + lc=_doc.get("requirements") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class Secrets(ProcessRequirement): - def __init__( - self, - secrets: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "Secrets" - self.secrets = secrets - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Secrets): - return bool(self.class_ == other.class_ and self.secrets == other.secrets) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.secrets)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Secrets": - _doc = copy.copy(doc) + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("requirements") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + detailed_message=f"the `requirements` field with value `{val}` " + "is not valid because:", + ) + ) + hints = None + if "hints" in _doc: + try: + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("hints") + ) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("hints") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + detailed_message=f"the `hints` field with value `{val}` " + "is not valid because:", + ) + ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + subscope_baseuri = _expand_url('run', baseuri, loadingOptions, True) try: - if _doc.get("secrets") is None: - raise ValidationException("missing required field `secrets`", None, []) + if _doc.get("run") is None: + raise ValidationException("missing required field `run`", None, []) - secrets = load_field( - _doc.get("secrets"), - uri_array_of_strtype_False_False_0_None, - baseuri, + run = _load_field( + _doc.get("run"), + uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None, + subscope_baseuri, loadingOptions, - lc=_doc.get("secrets") + lc=_doc.get("run") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secrets`": + if str(e) == "missing required field `run`": _errors__.append( ValidationException( str(e), @@ -24448,13 +21042,13 @@ def fromDoc( ) ) else: - val = _doc.get("secrets") + val = _doc.get("run") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secrets` field is not valid because:", - SourceLine(_doc, "secrets", str), + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -24466,14 +21060,108 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secrets` field is not valid because:", - SourceLine(_doc, "secrets", str), + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), [e], - detailed_message=f"the `secrets` field with value `{val}` " + detailed_message=f"the `run` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + scatter = None + if "scatter" in _doc: + try: + scatter = _load_field( + _doc.get("scatter"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, + baseuri, + loadingOptions, + lc=_doc.get("scatter") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatter`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("scatter") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [e], + detailed_message=f"the `scatter` field with value `{val}` " + "is not valid because:", + ) + ) + scatterMethod = None + if "scatterMethod" in _doc: + try: + scatterMethod = _load_field( + _doc.get("scatterMethod"), + uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("scatterMethod") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatterMethod`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("scatterMethod") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [e], + detailed_message=f"the `scatterMethod` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -24481,14 +21169,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `secrets`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `in`, `out`, `requirements`, `hints`, `run`, `scatter`, `scatterMethod`".format( k ), SourceLine(_doc, k, str), @@ -24498,10 +21186,20 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - secrets=secrets, + id=id, + label=label, + doc=doc, + in_=in_, + out=out, + requirements=requirements, + hints=hints, + run=run, + scatter=scatter, + scatterMethod=scatterMethod, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -24515,17 +21213,46 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.secrets is not None: - u = save_relative_uri(self.secrets, base_url, False, 0, relative_uris) - r["secrets"] = u + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.in_ is not None: + r["in"] = save( + self.in_, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.out is not None: + u = save_relative_uri(self.out, self.id, True, None, relative_uris) + r["out"] = u + if self.requirements is not None: + r["requirements"] = save( + self.requirements, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.run is not None: + u = save_relative_uri(self.run, self.id, False, None, relative_uris) + r["run"] = u + if self.scatter is not None: + u = save_relative_uri(self.scatter, self.id, False, 0, relative_uris) + r["scatter"] = u + if self.scatterMethod is not None: + u = save_relative_uri( + self.scatterMethod, self.id, False, None, relative_uris + ) + r["scatterMethod"] = u # top refers to the directory level if top: @@ -24535,25 +21262,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "secrets"]) - - -class ProcessGenerator(Process): - id: str - def __init__( self, - inputs: Any, - outputs: Any, - run: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + in_: Sequence[WorkflowStepInput], + out: Sequence[WorkflowStepOutput | str], + run: CommandLineTool | ExpressionTool | Workflow | str, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any] = None, + scatter: None | Sequence[str] | str = None, + scatterMethod: None | ScatterMethod = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -24563,19 +21285,66 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.id = id self.label = label self.doc = doc - self.inputs = inputs - self.outputs = outputs + self.in_ = in_ + self.out = out self.requirements = requirements self.hints = hints - self.cwlVersion = cwlVersion - self.class_ = "ProcessGenerator" self.run = run + self.scatter = scatter + self.scatterMethod = scatterMethod + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "in", + "out", + "requirements", + "hints", + "run", + "scatter", + "scatterMethod", + ] + ) + + +@mypyc_attr(native_class=True) +class Workflow(Saveable): + """ + A workflow describes a set of **steps** and the **dependencies** between those steps. When a step produces output that will be consumed by a second step, the first step is a dependency of the second step. + + When there is a dependency, the workflow engine must execute the preceding step and wait for it to successfully produce output before executing the dependent step. If two steps are defined in the workflow graph that are not directly or indirectly dependent, these steps are **independent**, and may execute in any order or execute concurrently. A workflow is complete when all steps have been executed. + + Dependencies between parameters are expressed using the ``source`` field on `workflow step input parameters <#WorkflowStepInput>`__ and `workflow output parameters <#WorkflowOutputParameter>`__. + + The ``source`` field expresses the dependency of one parameter on another such that when a value is associated with the parameter specified by ``source``, that value is propagated to the destination parameter. When all data links inbound to a given step are fulfilled, the step is ready to execute. + + Workflow success and failure + ---------------------------- + + A completed step must result in one of ``success``, ``temporaryFailure`` or ``permanentFailure`` states. An implementation may choose to retry a step execution which resulted in ``temporaryFailure``. An implementation may choose to either continue running other steps of a workflow, or terminate immediately upon ``permanentFailure``. + + * If any step of a workflow execution results in ``permanentFailure``, then the workflow status is ``permanentFailure``. + + * If one or more steps result in ``temporaryFailure`` and all other steps complete ``success`` or are not executed, then the workflow status is ``temporaryFailure``. + + * If all workflow steps are executed and complete with ``success``, then the workflow status is ``success``. + + Extensions + ========== + + `ScatterFeatureRequirement <#ScatterFeatureRequirement>`__ and `SubworkflowFeatureRequirement <#SubworkflowFeatureRequirement>`__ are available as standard `extensions <#Extensions_and_Metadata>`__ to core workflow semantics. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, ProcessGenerator): + if isinstance(other, Workflow): return bool( self.id == other.id and self.label == other.label @@ -24586,7 +21355,7 @@ def __eq__(self, other: Any) -> bool: and self.hints == other.hints and self.cwlVersion == other.cwlVersion and self.class_ == other.class_ - and self.run == other.run + and self.steps == other.steps ) return False @@ -24602,7 +21371,7 @@ def __hash__(self) -> int: self.hints, self.cwlVersion, self.class_, - self.run, + self.steps, ) ) @@ -24612,8 +21381,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ProcessGenerator": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -24623,7 +21392,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -24668,34 +21437,34 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id try: if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_Workflow_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + raise e label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -24742,7 +21511,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -24790,9 +21559,9 @@ def fromDoc( if _doc.get("inputs") is None: raise ValidationException("missing required field `inputs`", None, []) - inputs = load_field( + inputs = _load_field( _doc.get("inputs"), - idmap_inputs_array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader, + idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, lc=_doc.get("inputs") @@ -24838,9 +21607,9 @@ def fromDoc( if _doc.get("outputs") is None: raise ValidationException("missing required field `outputs`", None, []) - outputs = load_field( + outputs = _load_field( _doc.get("outputs"), - idmap_outputs_array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader, + idmap_outputs_array_of_WorkflowOutputParameterLoader, baseuri, loadingOptions, lc=_doc.get("outputs") @@ -24885,9 +21654,9 @@ def fromDoc( requirements = None if "requirements" in _doc: try: - requirements = load_field( + requirements = _load_field( _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, lc=_doc.get("requirements") @@ -24932,9 +21701,9 @@ def fromDoc( hints = None if "hints" in _doc: try: - hints = load_field( + hints = _load_field( _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, lc=_doc.get("hints") @@ -24979,7 +21748,7 @@ def fromDoc( cwlVersion = None if "cwlVersion" in _doc: try: - cwlVersion = load_field( + cwlVersion = _load_field( _doc.get("cwlVersion"), uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, @@ -25023,24 +21792,22 @@ def fromDoc( "is not valid because:", ) ) - - subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) try: - if _doc.get("run") is None: - raise ValidationException("missing required field `run`", None, []) + if _doc.get("steps") is None: + raise ValidationException("missing required field `steps`", None, []) - run = load_field( - _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_False_False_None_None, - subscope_baseuri, + steps = _load_field( + _doc.get("steps"), + idmap_steps_union_of_array_of_WorkflowStepLoader, + baseuri, loadingOptions, - lc=_doc.get("run") + lc=_doc.get("steps") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `run`": + if str(e) == "missing required field `steps`": _errors__.append( ValidationException( str(e), @@ -25048,13 +21815,13 @@ def fromDoc( ) ) else: - val = _doc.get("run") + val = _doc.get("steps") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25066,14 +21833,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), [e], - detailed_message=f"the `run` field with value `{val}` " + detailed_message=f"the `steps` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -25081,14 +21848,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `run`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `class`, `steps`".format( k ), SourceLine(_doc, k, str), @@ -25106,11 +21873,11 @@ def fromDoc( requirements=requirements, hints=hints, cwlVersion=cwlVersion, - run=run, + steps=steps, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -25125,11 +21892,13 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ @@ -25165,9 +21934,10 @@ def save( if self.cwlVersion is not None: u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) r["cwlVersion"] = u - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u + if self.steps is not None: + r["steps"] = save( + self.steps, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -25177,7 +21947,40 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( + def __init__( + self, + inputs: Sequence[WorkflowInputParameter], + outputs: Sequence[WorkflowOutputParameter], + steps: Sequence[WorkflowStep], + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.doc = doc + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.cwlVersion = cwlVersion + self.class_: Final[str] = "Workflow" + self.steps = steps + + attrs: ClassVar[Collection[str]] = frozenset( [ "id", "label", @@ -25188,22 +21991,119 @@ def save( "hints", "cwlVersion", "class", - "run", + "steps", ] ) -class MPIRequirement(ProcessRequirement): +@mypyc_attr(native_class=True) +class SubworkflowFeatureRequirement(Saveable): """ - Indicates that a process requires an MPI runtime. + Indicates that the workflow platform must support nested workflows in the ``run`` field of `WorkflowStep <#WorkflowStep>`__. """ + def __eq__(self, other: Any) -> bool: + if isinstance(other, SubworkflowFeatureRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`".format(k), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + def __init__( self, - processes: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -25213,18 +22113,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "MPIRequirement" - self.processes = processes + self.class_: Final[str] = "SubworkflowFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class ScatterFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support the ``scatter`` and ``scatterMethod`` fields of `WorkflowStep <#WorkflowStep>`__. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, MPIRequirement): - return bool( - self.class_ == other.class_ and self.processes == other.processes - ) + if isinstance(other, ScatterFeatureRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash((self.class_, self.processes)) + return hash((self.class_)) @classmethod def fromDoc( @@ -25232,8 +22139,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MPIRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -25244,67 +22151,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_ScatterFeatureRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("processes") is None: - raise ValidationException("missing required field `processes`", None, []) - - processes = load_field( - _doc.get("processes"), - union_of_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("processes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `processes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("processes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `processes` field is not valid because:", - SourceLine(_doc, "processes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `processes` field is not valid because:", - SourceLine(_doc, "processes", str), - [e], - detailed_message=f"the `processes` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -25312,16 +22172,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `processes`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -25329,7 +22187,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - processes=processes, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -25347,20 +22204,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.processes is not None: - r["processes"] = save( - self.processes, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -25370,23 +22222,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "processes"]) - - -class CUDARequirement(ProcessRequirement): - """ - Require support for NVIDA CUDA (GPU hardware acceleration). - - """ - def __init__( self, - cudaComputeCapability: Any, - cudaVersionMin: Any, - cudaDeviceCountMax: Optional[Any] = None, - cudaDeviceCountMin: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -25396,33 +22235,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "CUDARequirement" - self.cudaComputeCapability = cudaComputeCapability - self.cudaDeviceCountMax = cudaDeviceCountMax - self.cudaDeviceCountMin = cudaDeviceCountMin - self.cudaVersionMin = cudaVersionMin + self.class_: Final[str] = "ScatterFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class MultipleInputFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support multiple inbound data links listed in the ``source`` field of `WorkflowStepInput <#WorkflowStepInput>`__. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, CUDARequirement): - return bool( - self.class_ == other.class_ - and self.cudaComputeCapability == other.cudaComputeCapability - and self.cudaDeviceCountMax == other.cudaDeviceCountMax - and self.cudaDeviceCountMin == other.cudaDeviceCountMin - and self.cudaVersionMin == other.cudaVersionMin - ) + if isinstance(other, MultipleInputFeatureRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash( - ( - self.class_, - self.cudaComputeCapability, - self.cudaDeviceCountMax, - self.cudaDeviceCountMin, - self.cudaVersionMin, - ) - ) + return hash((self.class_)) @classmethod def fromDoc( @@ -25430,8 +22261,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CUDARequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -25442,209 +22273,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("cudaComputeCapability") is None: - raise ValidationException("missing required field `cudaComputeCapability`", None, []) - - cudaComputeCapability = load_field( - _doc.get("cudaComputeCapability"), - union_of_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("cudaComputeCapability") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaComputeCapability`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaComputeCapability") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaComputeCapability` field is not valid because:", - SourceLine(_doc, "cudaComputeCapability", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaComputeCapability` field is not valid because:", - SourceLine(_doc, "cudaComputeCapability", str), - [e], - detailed_message=f"the `cudaComputeCapability` field with value `{val}` " - "is not valid because:", - ) - ) - cudaDeviceCountMax = None - if "cudaDeviceCountMax" in _doc: - try: - cudaDeviceCountMax = load_field( - _doc.get("cudaDeviceCountMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("cudaDeviceCountMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaDeviceCountMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaDeviceCountMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaDeviceCountMax` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaDeviceCountMax` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMax", str), - [e], - detailed_message=f"the `cudaDeviceCountMax` field with value `{val}` " - "is not valid because:", - ) - ) - cudaDeviceCountMin = None - if "cudaDeviceCountMin" in _doc: - try: - cudaDeviceCountMin = load_field( - _doc.get("cudaDeviceCountMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("cudaDeviceCountMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaDeviceCountMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaDeviceCountMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaDeviceCountMin` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaDeviceCountMin` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMin", str), - [e], - detailed_message=f"the `cudaDeviceCountMin` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("cudaVersionMin") is None: - raise ValidationException("missing required field `cudaVersionMin`", None, []) - - cudaVersionMin = load_field( - _doc.get("cudaVersionMin"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("cudaVersionMin") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cudaVersionMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cudaVersionMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cudaVersionMin` field is not valid because:", - SourceLine(_doc, "cudaVersionMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cudaVersionMin` field is not valid because:", - SourceLine(_doc, "cudaVersionMin", str), - [e], - detailed_message=f"the `cudaVersionMin` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -25652,16 +22294,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `cudaComputeCapability`, `cudaDeviceCountMax`, `cudaDeviceCountMin`, `cudaVersionMin`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -25669,10 +22309,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - cudaComputeCapability=cudaComputeCapability, - cudaDeviceCountMax=cudaDeviceCountMax, - cudaDeviceCountMin=cudaDeviceCountMin, - cudaVersionMin=cudaVersionMin, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -25690,41 +22326,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.cudaComputeCapability is not None: - r["cudaComputeCapability"] = save( - self.cudaComputeCapability, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.cudaDeviceCountMax is not None: - r["cudaDeviceCountMax"] = save( - self.cudaDeviceCountMax, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.cudaDeviceCountMin is not None: - r["cudaDeviceCountMin"] = save( - self.cudaDeviceCountMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.cudaVersionMin is not None: - r["cudaVersionMin"] = save( - self.cudaVersionMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -25734,23 +22344,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "cudaComputeCapability", - "cudaDeviceCountMax", - "cudaDeviceCountMin", - "cudaVersionMin", - ] - ) - - -class ShmSize(ProcessRequirement): def __init__( self, - shmSize: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -25760,16 +22357,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ShmSize" - self.shmSize = shmSize + self.class_: Final[str] = "MultipleInputFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class StepInputExpressionRequirement(Saveable): + """ + Indicate that the workflow platform must support the ``valueFrom`` field of `WorkflowStepInput <#WorkflowStepInput>`__. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ShmSize): - return bool(self.class_ == other.class_ and self.shmSize == other.shmSize) + if isinstance(other, StepInputExpressionRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash((self.class_, self.shmSize)) + return hash((self.class_)) @classmethod def fromDoc( @@ -25777,8 +22383,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ShmSize": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -25789,67 +22395,20 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_StepInputExpressionRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("shmSize") is None: - raise ValidationException("missing required field `shmSize`", None, []) - - shmSize = load_field( - _doc.get("shmSize"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("shmSize") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `shmSize`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("shmSize") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `shmSize` field is not valid because:", - SourceLine(_doc, "shmSize", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `shmSize` field is not valid because:", - SourceLine(_doc, "shmSize", str), - [e], - detailed_message=f"the `shmSize` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -25857,16 +22416,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `shmSize`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -25874,7 +22431,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - shmSize=shmSize, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -25892,17 +22448,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.shmSize is not None: - r["shmSize"] = save( - self.shmSize, top=False, base_url=base_url, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -25912,13 +22466,27 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "shmSize"]) + def __init__( + self, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "StepInputExpressionRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) -_vocab = { +_vocab.update({ "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", - "CUDARequirement": "http://commonwl.org/cwltool#CUDARequirement", "CWLArraySchema": "https://w3id.org/cwl/cwl#CWLArraySchema", "CWLInputFile": "https://w3id.org/cwl/cwl#CWLInputFile", "CWLObjectType": "https://w3id.org/cwl/cwl#CWLObjectType", @@ -25973,7 +22541,6 @@ def save( "LoadContents": "https://w3id.org/cwl/cwl#LoadContents", "LoadListingEnum": "https://w3id.org/cwl/cwl#LoadListingEnum", "LoadListingRequirement": "https://w3id.org/cwl/cwl#LoadListingRequirement", - "MPIRequirement": "http://commonwl.org/cwltool#MPIRequirement", "MapSchema": "https://w3id.org/cwl/salad#MapSchema", "MultipleInputFeatureRequirement": "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement", "NetworkAccess": "https://w3id.org/cwl/cwl#NetworkAccess", @@ -25987,7 +22554,6 @@ def save( "Parameter": "https://w3id.org/cwl/cwl#Parameter", "PrimitiveType": "https://w3id.org/cwl/salad#PrimitiveType", "Process": "https://w3id.org/cwl/cwl#Process", - "ProcessGenerator": "http://commonwl.org/cwltool#ProcessGenerator", "ProcessRequirement": "https://w3id.org/cwl/cwl#ProcessRequirement", "RecordField": "https://w3id.org/cwl/salad#RecordField", "RecordSchema": "https://w3id.org/cwl/salad#RecordSchema", @@ -25996,9 +22562,7 @@ def save( "ScatterMethod": "https://w3id.org/cwl/cwl#ScatterMethod", "SchemaDefRequirement": "https://w3id.org/cwl/cwl#SchemaDefRequirement", "SecondaryFileSchema": "https://w3id.org/cwl/cwl#SecondaryFileSchema", - "Secrets": "http://commonwl.org/cwltool#Secrets", "ShellCommandRequirement": "https://w3id.org/cwl/cwl#ShellCommandRequirement", - "ShmSize": "http://commonwl.org/cwltool#ShmSize", "Sink": "https://w3id.org/cwl/cwl#Sink", "SoftwarePackage": "https://w3id.org/cwl/cwl#SoftwarePackage", "SoftwareRequirement": "https://w3id.org/cwl/cwl#SoftwareRequirement", @@ -26018,16 +22582,6 @@ def save( "deep_listing": "https://w3id.org/cwl/cwl#LoadListingEnum/deep_listing", "dotproduct": "https://w3id.org/cwl/cwl#ScatterMethod/dotproduct", "double": "http://www.w3.org/2001/XMLSchema#double", - "draft-2": "https://w3id.org/cwl/cwl#draft-2", - "draft-3": "https://w3id.org/cwl/cwl#draft-3", - "draft-3.dev1": "https://w3id.org/cwl/cwl#draft-3.dev1", - "draft-3.dev2": "https://w3id.org/cwl/cwl#draft-3.dev2", - "draft-3.dev3": "https://w3id.org/cwl/cwl#draft-3.dev3", - "draft-3.dev4": "https://w3id.org/cwl/cwl#draft-3.dev4", - "draft-3.dev5": "https://w3id.org/cwl/cwl#draft-3.dev5", - "draft-4.dev1": "https://w3id.org/cwl/cwl#draft-4.dev1", - "draft-4.dev2": "https://w3id.org/cwl/cwl#draft-4.dev2", - "draft-4.dev3": "https://w3id.org/cwl/cwl#draft-4.dev3", "enum": "https://w3id.org/cwl/salad#enum", "flat_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/flat_crossproduct", "float": "http://www.w3.org/2001/XMLSchema#float", @@ -26046,15 +22600,11 @@ def save( "stdout": "https://w3id.org/cwl/cwl#stdout", "string": "http://www.w3.org/2001/XMLSchema#string", "union": "https://w3id.org/cwl/salad#union", - "v1.0": "https://w3id.org/cwl/cwl#v1.0", - "v1.0.dev4": "https://w3id.org/cwl/cwl#v1.0.dev4", "v1.1": "https://w3id.org/cwl/cwl#v1.1", - "v1.1.0-dev1": "https://w3id.org/cwl/cwl#v1.1.0-dev1", -} -_rvocab = { +}) +_rvocab.update({ "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", - "http://commonwl.org/cwltool#CUDARequirement": "CUDARequirement", "https://w3id.org/cwl/cwl#CWLArraySchema": "CWLArraySchema", "https://w3id.org/cwl/cwl#CWLInputFile": "CWLInputFile", "https://w3id.org/cwl/cwl#CWLObjectType": "CWLObjectType", @@ -26109,7 +22659,6 @@ def save( "https://w3id.org/cwl/cwl#LoadContents": "LoadContents", "https://w3id.org/cwl/cwl#LoadListingEnum": "LoadListingEnum", "https://w3id.org/cwl/cwl#LoadListingRequirement": "LoadListingRequirement", - "http://commonwl.org/cwltool#MPIRequirement": "MPIRequirement", "https://w3id.org/cwl/salad#MapSchema": "MapSchema", "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement": "MultipleInputFeatureRequirement", "https://w3id.org/cwl/cwl#NetworkAccess": "NetworkAccess", @@ -26123,7 +22672,6 @@ def save( "https://w3id.org/cwl/cwl#Parameter": "Parameter", "https://w3id.org/cwl/salad#PrimitiveType": "PrimitiveType", "https://w3id.org/cwl/cwl#Process": "Process", - "http://commonwl.org/cwltool#ProcessGenerator": "ProcessGenerator", "https://w3id.org/cwl/cwl#ProcessRequirement": "ProcessRequirement", "https://w3id.org/cwl/salad#RecordField": "RecordField", "https://w3id.org/cwl/salad#RecordSchema": "RecordSchema", @@ -26132,9 +22680,7 @@ def save( "https://w3id.org/cwl/cwl#ScatterMethod": "ScatterMethod", "https://w3id.org/cwl/cwl#SchemaDefRequirement": "SchemaDefRequirement", "https://w3id.org/cwl/cwl#SecondaryFileSchema": "SecondaryFileSchema", - "http://commonwl.org/cwltool#Secrets": "Secrets", "https://w3id.org/cwl/cwl#ShellCommandRequirement": "ShellCommandRequirement", - "http://commonwl.org/cwltool#ShmSize": "ShmSize", "https://w3id.org/cwl/cwl#Sink": "Sink", "https://w3id.org/cwl/cwl#SoftwarePackage": "SoftwarePackage", "https://w3id.org/cwl/cwl#SoftwareRequirement": "SoftwareRequirement", @@ -26154,16 +22700,6 @@ def save( "https://w3id.org/cwl/cwl#LoadListingEnum/deep_listing": "deep_listing", "https://w3id.org/cwl/cwl#ScatterMethod/dotproduct": "dotproduct", "http://www.w3.org/2001/XMLSchema#double": "double", - "https://w3id.org/cwl/cwl#draft-2": "draft-2", - "https://w3id.org/cwl/cwl#draft-3": "draft-3", - "https://w3id.org/cwl/cwl#draft-3.dev1": "draft-3.dev1", - "https://w3id.org/cwl/cwl#draft-3.dev2": "draft-3.dev2", - "https://w3id.org/cwl/cwl#draft-3.dev3": "draft-3.dev3", - "https://w3id.org/cwl/cwl#draft-3.dev4": "draft-3.dev4", - "https://w3id.org/cwl/cwl#draft-3.dev5": "draft-3.dev5", - "https://w3id.org/cwl/cwl#draft-4.dev1": "draft-4.dev1", - "https://w3id.org/cwl/cwl#draft-4.dev2": "draft-4.dev2", - "https://w3id.org/cwl/cwl#draft-4.dev3": "draft-4.dev3", "https://w3id.org/cwl/salad#enum": "enum", "https://w3id.org/cwl/cwl#ScatterMethod/flat_crossproduct": "flat_crossproduct", "http://www.w3.org/2001/XMLSchema#float": "float", @@ -26182,19 +22718,20 @@ def save( "https://w3id.org/cwl/cwl#stdout": "stdout", "http://www.w3.org/2001/XMLSchema#string": "string", "https://w3id.org/cwl/salad#union": "union", - "https://w3id.org/cwl/cwl#v1.0": "v1.0", - "https://w3id.org/cwl/cwl#v1.0.dev4": "v1.0.dev4", "https://w3id.org/cwl/cwl#v1.1": "v1.1", - "https://w3id.org/cwl/cwl#v1.1.0-dev1": "v1.1.0-dev1", -} - -strtype = _PrimitiveLoader(str) -inttype = _PrimitiveLoader(int) -floattype = _PrimitiveLoader(float) -booltype = _PrimitiveLoader(bool) -None_type = _PrimitiveLoader(type(None)) -Any_type = _AnyLoader() -PrimitiveTypeLoader = _EnumLoader( +}) + +strtype: Final[_Loader[str]] = _PrimitiveLoader(str) +inttype: Final[_Loader[i32]] = _PrimitiveLoader(i32) +longtype: Final[_Loader[i64]] = _PrimitiveLoader(i64) +floattype: Final[_Loader[float]] = _PrimitiveLoader(float) +booltype: Final[_Loader[bool]] = _PrimitiveLoader(bool) +None_type: Final[_Loader[None]] = _PrimitiveLoader(type(None)) +Any_type: Final[_Loader[Any]] = _AnyLoader() +PrimitiveType: TypeAlias = Literal[ + "null", "boolean", "int", "long", "float", "double", "string" +] +PrimitiveTypeLoader: Final[_Loader[PrimitiveType]] = _EnumLoader( ( "null", "boolean", @@ -26209,28 +22746,49 @@ def save( """ Names of salad data types (based on Avro schema declarations). -Refer to the [Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for -detailed information. +Refer to the `Avro schema declaration documentation `__ for detailed information. null: no value + boolean: a binary value + int: 32-bit signed integer + long: 64-bit signed integer + float: single precision (32-bit) IEEE 754 floating-point number + double: double precision (64-bit) IEEE 754 floating-point number + string: Unicode character sequence """ -AnyLoader = _EnumLoader(("Any",), "Any") +Any_: TypeAlias = Literal["Any"] +Any_Loader: Final[_Loader[Any_]] = _EnumLoader(("Any",), "Any_") """ The **Any** type validates for any non-null value. """ -RecordFieldLoader = _RecordLoader(RecordField, None, None) -RecordSchemaLoader = _RecordLoader(RecordSchema, None, None) -EnumSchemaLoader = _RecordLoader(EnumSchema, None, None) -ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) -MapSchemaLoader = _RecordLoader(MapSchema, None, None) -UnionSchemaLoader = _RecordLoader(UnionSchema, None, None) -CWLTypeLoader = _EnumLoader( +RecordFieldLoader: Final[_Loader[schema_salad.metaschema.RecordField]] = _RecordLoader( + schema_salad.metaschema.RecordField, None, None +) +RecordSchemaLoader: Final[_Loader[schema_salad.metaschema.RecordSchema]] = ( + _RecordLoader(schema_salad.metaschema.RecordSchema, None, None) +) +EnumSchemaLoader: Final[_Loader[schema_salad.metaschema.EnumSchema]] = _RecordLoader( + schema_salad.metaschema.EnumSchema, None, None +) +ArraySchemaLoader: Final[_Loader[schema_salad.metaschema.ArraySchema]] = _RecordLoader( + schema_salad.metaschema.ArraySchema, None, None +) +MapSchemaLoader: Final[_Loader[schema_salad.metaschema.MapSchema]] = _RecordLoader( + schema_salad.metaschema.MapSchema, None, None +) +UnionSchemaLoader: Final[_Loader[schema_salad.metaschema.UnionSchema]] = _RecordLoader( + schema_salad.metaschema.UnionSchema, None, None +) +CWLType: TypeAlias = Literal[ + "null", "boolean", "int", "long", "float", "double", "string", "File", "Directory" +] +CWLTypeLoader: Final[_Loader[CWLType]] = _EnumLoader( ( "null", "boolean", @@ -26246,57 +22804,107 @@ def save( ) """ Extends primitive types with the concept of a file and directory as a builtin type. + File: A File object + Directory: A Directory object """ -CWLArraySchemaLoader = _RecordLoader(CWLArraySchema, None, None) -CWLRecordFieldLoader = _RecordLoader(CWLRecordField, None, None) -CWLRecordSchemaLoader = _RecordLoader(CWLRecordSchema, None, None) -FileLoader = _RecordLoader(File, None, None) -DirectoryLoader = _RecordLoader(Directory, None, None) -CWLObjectTypeLoader = _UnionLoader((), "CWLObjectTypeLoader") -union_of_None_type_or_CWLObjectTypeLoader = _UnionLoader( - ( - None_type, - CWLObjectTypeLoader, +CWLArraySchemaLoader: Final[_Loader[CWLArraySchema]] = _RecordLoader( + CWLArraySchema, None, None +) +CWLRecordFieldLoader: Final[_Loader[CWLRecordField]] = _RecordLoader( + CWLRecordField, None, None +) +CWLRecordSchemaLoader: Final[_Loader[CWLRecordSchema]] = _RecordLoader( + CWLRecordSchema, None, None +) +FileLoader: Final[_Loader[File]] = _RecordLoader(File, None, None) +DirectoryLoader: Final[_Loader[Directory]] = _RecordLoader(Directory, None, None) +CWLObjectTypeLoader: Final[_UnionLoader[Any]] = _UnionLoader((), "CWLObjectTypeLoader") +union_of_None_type_or_CWLObjectTypeLoader: Final[_Loader[CWLObjectType | None]] = ( + _UnionLoader( + ( + None_type, + CWLObjectTypeLoader, + ) ) ) -array_of_union_of_None_type_or_CWLObjectTypeLoader = _ArrayLoader( - union_of_None_type_or_CWLObjectTypeLoader +array_of_union_of_None_type_or_CWLObjectTypeLoader: Final[ + _Loader[Sequence[CWLObjectType | None]] +] = _ArrayLoader(union_of_None_type_or_CWLObjectTypeLoader) +map_of_union_of_None_type_or_CWLObjectTypeLoader: Final[ + _Loader[Mapping[str, CWLObjectType | None]] +] = _MapLoader(union_of_None_type_or_CWLObjectTypeLoader, "None", None, None) +InlineJavascriptRequirementLoader: Final[_Loader[InlineJavascriptRequirement]] = ( + _RecordLoader(InlineJavascriptRequirement, None, None) +) +SchemaDefRequirementLoader: Final[_Loader[SchemaDefRequirement]] = _RecordLoader( + SchemaDefRequirement, None, None +) +LoadListingRequirementLoader: Final[_Loader[LoadListingRequirement]] = _RecordLoader( + LoadListingRequirement, None, None +) +DockerRequirementLoader: Final[_Loader[DockerRequirement]] = _RecordLoader( + DockerRequirement, None, None +) +SoftwareRequirementLoader: Final[_Loader[SoftwareRequirement]] = _RecordLoader( + SoftwareRequirement, None, None +) +InitialWorkDirRequirementLoader: Final[_Loader[InitialWorkDirRequirement]] = ( + _RecordLoader(InitialWorkDirRequirement, None, None) +) +EnvVarRequirementLoader: Final[_Loader[EnvVarRequirement]] = _RecordLoader( + EnvVarRequirement, None, None ) -map_of_union_of_None_type_or_CWLObjectTypeLoader = _MapLoader( - union_of_None_type_or_CWLObjectTypeLoader, "None", None, None +ShellCommandRequirementLoader: Final[_Loader[ShellCommandRequirement]] = _RecordLoader( + ShellCommandRequirement, None, None ) -InlineJavascriptRequirementLoader = _RecordLoader( - InlineJavascriptRequirement, None, None +ResourceRequirementLoader: Final[_Loader[ResourceRequirement]] = _RecordLoader( + ResourceRequirement, None, None ) -SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement, None, None) -LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement, None, None) -DockerRequirementLoader = _RecordLoader(DockerRequirement, None, None) -SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement, None, None) -InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement, None, None) -EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement, None, None) -ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement, None, None) -ResourceRequirementLoader = _RecordLoader(ResourceRequirement, None, None) -WorkReuseLoader = _RecordLoader(WorkReuse, None, None) -NetworkAccessLoader = _RecordLoader(NetworkAccess, None, None) -InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement, None, None) -ToolTimeLimitLoader = _RecordLoader(ToolTimeLimit, None, None) -SubworkflowFeatureRequirementLoader = _RecordLoader( - SubworkflowFeatureRequirement, None, None +WorkReuseLoader: Final[_Loader[WorkReuse]] = _RecordLoader(WorkReuse, None, None) +NetworkAccessLoader: Final[_Loader[NetworkAccess]] = _RecordLoader( + NetworkAccess, None, None ) -ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement, None, None) -MultipleInputFeatureRequirementLoader = _RecordLoader( - MultipleInputFeatureRequirement, None, None +InplaceUpdateRequirementLoader: Final[_Loader[InplaceUpdateRequirement]] = ( + _RecordLoader(InplaceUpdateRequirement, None, None) ) -StepInputExpressionRequirementLoader = _RecordLoader( - StepInputExpressionRequirement, None, None +ToolTimeLimitLoader: Final[_Loader[ToolTimeLimit]] = _RecordLoader( + ToolTimeLimit, None, None ) -SecretsLoader = _RecordLoader(Secrets, None, None) -MPIRequirementLoader = _RecordLoader(MPIRequirement, None, None) -CUDARequirementLoader = _RecordLoader(CUDARequirement, None, None) -ShmSizeLoader = _RecordLoader(ShmSize, None, None) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _UnionLoader( +SubworkflowFeatureRequirementLoader: Final[_Loader[SubworkflowFeatureRequirement]] = ( + _RecordLoader(SubworkflowFeatureRequirement, None, None) +) +ScatterFeatureRequirementLoader: Final[_Loader[ScatterFeatureRequirement]] = ( + _RecordLoader(ScatterFeatureRequirement, None, None) +) +MultipleInputFeatureRequirementLoader: Final[ + _Loader[MultipleInputFeatureRequirement] +] = _RecordLoader(MultipleInputFeatureRequirement, None, None) +StepInputExpressionRequirementLoader: Final[_Loader[StepInputExpressionRequirement]] = ( + _RecordLoader(StepInputExpressionRequirement, None, None) +) +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] +] = _UnionLoader( ( InlineJavascriptRequirementLoader, SchemaDefRequirementLoader, @@ -26315,52 +22923,132 @@ def save( ScatterFeatureRequirementLoader, MultipleInputFeatureRequirementLoader, StepInputExpressionRequirementLoader, - SecretsLoader, - MPIRequirementLoader, - CUDARequirementLoader, - ShmSizeLoader, ) ) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader: Final[ + _Loader[ + CWLObjectType + | None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, CWLObjectTypeLoader, ) ) -map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader = _MapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader, +map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader: Final[ + _Loader[ + Mapping[ + str, + CWLObjectType + | None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ], + ] + ] +] = _MapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader, "CWLInputFile", "@list", True, ) -CWLInputFileLoader = map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader -CWLVersionLoader = _EnumLoader( - ( - "draft-2", - "draft-3.dev1", - "draft-3.dev2", - "draft-3.dev3", - "draft-3.dev4", - "draft-3.dev5", - "draft-3", - "draft-4.dev1", - "draft-4.dev2", - "draft-4.dev3", - "v1.0.dev4", - "v1.0", - "v1.1.0-dev1", - "v1.1", - ), - "CWLVersion", -) +CWLInputFileLoader: Final[ + _Loader[ + Mapping[ + str, + CWLObjectType + | None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ], + ] + ] +] = map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader +CWLVersion: TypeAlias = Literal["v1.1"] +CWLVersionLoader: Final[_Loader[CWLVersion]] = _EnumLoader(("v1.1",), "CWLVersion") """ -Version symbols for published CWL document versions. +Current version symbol for CWL documents. """ -LoadListingEnumLoader = _EnumLoader( +LoadListingEnum: TypeAlias = Literal["no_listing", "shallow_listing", "deep_listing"] +LoadListingEnumLoader: Final[_Loader[LoadListingEnum]] = _EnumLoader( ( "no_listing", "shallow_listing", @@ -26369,156 +23057,232 @@ def save( "LoadListingEnum", ) """ -Specify the desired behavior for loading the `listing` field of -a Directory object for use by expressions. +Specify the desired behavior for loading the ``listing`` field of a Directory object for use by expressions. no_listing: Do not load the directory listing. + shallow_listing: Only load the top level listing, do not recurse into subdirectories. + deep_listing: Load the directory listing and recursively load all subdirectories as well. """ -ExpressionLoader = _ExpressionLoader(str) -InputBindingLoader = _RecordLoader(InputBinding, None, None) -InputRecordFieldLoader = _RecordLoader(InputRecordField, None, None) -InputRecordSchemaLoader = _RecordLoader(InputRecordSchema, None, None) -InputEnumSchemaLoader = _RecordLoader(InputEnumSchema, None, None) -InputArraySchemaLoader = _RecordLoader(InputArraySchema, None, None) -OutputRecordFieldLoader = _RecordLoader(OutputRecordField, None, None) -OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema, None, None) -OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema, None, None) -OutputArraySchemaLoader = _RecordLoader(OutputArraySchema, None, None) -SecondaryFileSchemaLoader = _RecordLoader(SecondaryFileSchema, None, None) -EnvironmentDefLoader = _RecordLoader(EnvironmentDef, None, None) -CommandLineBindingLoader = _RecordLoader(CommandLineBinding, None, None) -CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding, None, None) -CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField, None, None) -CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema, None, None) -CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema, None, None) -CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema, None, None) -CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField, None, None) -CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema, None, None) -CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema, None, None) -CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema, None, None) -CommandInputParameterLoader = _RecordLoader(CommandInputParameter, None, None) -CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter, None, None) -stdinLoader = _EnumLoader(("stdin",), "stdin") +Expression: TypeAlias = Literal["ExpressionPlaceholder"] +ExpressionLoader: Final[_Loader[str]] = _ExpressionLoader(str) +InputBindingLoader: Final[_Loader[InputBinding]] = _RecordLoader( + InputBinding, None, None +) +InputRecordFieldLoader: Final[_Loader[InputRecordField]] = _RecordLoader( + InputRecordField, None, None +) +InputRecordSchemaLoader: Final[_Loader[InputRecordSchema]] = _RecordLoader( + InputRecordSchema, None, None +) +InputEnumSchemaLoader: Final[_Loader[InputEnumSchema]] = _RecordLoader( + InputEnumSchema, None, None +) +InputArraySchemaLoader: Final[_Loader[InputArraySchema]] = _RecordLoader( + InputArraySchema, None, None +) +OutputRecordFieldLoader: Final[_Loader[OutputRecordField]] = _RecordLoader( + OutputRecordField, None, None +) +OutputRecordSchemaLoader: Final[_Loader[OutputRecordSchema]] = _RecordLoader( + OutputRecordSchema, None, None +) +OutputEnumSchemaLoader: Final[_Loader[OutputEnumSchema]] = _RecordLoader( + OutputEnumSchema, None, None +) +OutputArraySchemaLoader: Final[_Loader[OutputArraySchema]] = _RecordLoader( + OutputArraySchema, None, None +) +SecondaryFileSchemaLoader: Final[_Loader[SecondaryFileSchema]] = _RecordLoader( + SecondaryFileSchema, None, None +) +EnvironmentDefLoader: Final[_Loader[EnvironmentDef]] = _RecordLoader( + EnvironmentDef, None, None +) +CommandLineBindingLoader: Final[_Loader[CommandLineBinding]] = _RecordLoader( + CommandLineBinding, None, None +) +CommandOutputBindingLoader: Final[_Loader[CommandOutputBinding]] = _RecordLoader( + CommandOutputBinding, None, None +) +CommandInputRecordFieldLoader: Final[_Loader[CommandInputRecordField]] = _RecordLoader( + CommandInputRecordField, None, None +) +CommandInputRecordSchemaLoader: Final[_Loader[CommandInputRecordSchema]] = ( + _RecordLoader(CommandInputRecordSchema, None, None) +) +CommandInputEnumSchemaLoader: Final[_Loader[CommandInputEnumSchema]] = _RecordLoader( + CommandInputEnumSchema, None, None +) +CommandInputArraySchemaLoader: Final[_Loader[CommandInputArraySchema]] = _RecordLoader( + CommandInputArraySchema, None, None +) +CommandOutputRecordFieldLoader: Final[_Loader[CommandOutputRecordField]] = ( + _RecordLoader(CommandOutputRecordField, None, None) +) +CommandOutputRecordSchemaLoader: Final[_Loader[CommandOutputRecordSchema]] = ( + _RecordLoader(CommandOutputRecordSchema, None, None) +) +CommandOutputEnumSchemaLoader: Final[_Loader[CommandOutputEnumSchema]] = _RecordLoader( + CommandOutputEnumSchema, None, None +) +CommandOutputArraySchemaLoader: Final[_Loader[CommandOutputArraySchema]] = ( + _RecordLoader(CommandOutputArraySchema, None, None) +) +CommandInputParameterLoader: Final[_Loader[CommandInputParameter]] = _RecordLoader( + CommandInputParameter, None, None +) +CommandOutputParameterLoader: Final[_Loader[CommandOutputParameter]] = _RecordLoader( + CommandOutputParameter, None, None +) +stdin: TypeAlias = Literal["stdin"] +stdinLoader: Final[_Loader[stdin]] = _EnumLoader(("stdin",), "stdin") """ -Only valid as a `type` for a `CommandLineTool` input with no -`inputBinding` set. `stdin` must not be specified at the `CommandLineTool` -level. +Only valid as a ``type`` for a ``CommandLineTool`` input with no ``inputBinding`` set. ``stdin`` must not be specified at the ``CommandLineTool`` level. The following -``` -inputs: - an_input_name: - type: stdin -``` + +:: + + inputs: + an_input_name: + type: stdin + + is equivalent to -``` -inputs: - an_input_name: - type: File - streamable: true - -stdin: ${inputs.an_input_name.path} -``` + +:: + + inputs: + an_input_name: + type: File + streamable: true + + stdin: ${inputs.an_input_name.path} """ -stdoutLoader = _EnumLoader(("stdout",), "stdout") +stdout: TypeAlias = Literal["stdout"] +stdoutLoader: Final[_Loader[stdout]] = _EnumLoader(("stdout",), "stdout") """ -Only valid as a `type` for a `CommandLineTool` output with no -`outputBinding` set. +Only valid as a ``type`` for a ``CommandLineTool`` output with no ``outputBinding`` set. The following -``` -outputs: - an_output_name: - type: stdout -stdout: a_stdout_file -``` +:: + + outputs: + an_output_name: + type: stdout + + stdout: a_stdout_file + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: a_stdout_file - -stdout: a_stdout_file -``` - -If there is no `stdout` name provided, a random filename will be created. -For example, the following -``` -outputs: - an_output_name: - type: stdout -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: a_stdout_file + + stdout: a_stdout_file + + +If there is no ``stdout`` name provided, a random filename will be created. For example, the following + +:: + + outputs: + an_output_name: + type: stdout + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: random_stdout_filenameABCDEFG - -stdout: random_stdout_filenameABCDEFG -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: random_stdout_filenameABCDEFG + + stdout: random_stdout_filenameABCDEFG """ -stderrLoader = _EnumLoader(("stderr",), "stderr") +stderr: TypeAlias = Literal["stderr"] +stderrLoader: Final[_Loader[stderr]] = _EnumLoader(("stderr",), "stderr") """ -Only valid as a `type` for a `CommandLineTool` output with no -`outputBinding` set. +Only valid as a ``type`` for a ``CommandLineTool`` output with no ``outputBinding`` set. The following -``` -outputs: - an_output_name: - type: stderr -stderr: a_stderr_file -``` +:: + + outputs: + an_output_name: + type: stderr + + stderr: a_stderr_file + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: a_stderr_file - -stderr: a_stderr_file -``` - -If there is no `stderr` name provided, a random filename will be created. -For example, the following -``` -outputs: - an_output_name: - type: stderr -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: a_stderr_file + + stderr: a_stderr_file + + +If there is no ``stderr`` name provided, a random filename will be created. For example, the following + +:: + + outputs: + an_output_name: + type: stderr + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: random_stderr_filenameABCDEFG - -stderr: random_stderr_filenameABCDEFG -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: random_stderr_filenameABCDEFG + + stderr: random_stderr_filenameABCDEFG """ -CommandLineToolLoader = _RecordLoader(CommandLineTool, None, None) -SoftwarePackageLoader = _RecordLoader(SoftwarePackage, None, None) -DirentLoader = _RecordLoader(Dirent, None, None) -ExpressionToolOutputParameterLoader = _RecordLoader( - ExpressionToolOutputParameter, None, None +CommandLineToolLoader: Final[_Loader[CommandLineTool]] = _RecordLoader( + CommandLineTool, None, None +) +SoftwarePackageLoader: Final[_Loader[SoftwarePackage]] = _RecordLoader( + SoftwarePackage, None, None +) +DirentLoader: Final[_Loader[Dirent]] = _RecordLoader(Dirent, None, None) +ExpressionToolOutputParameterLoader: Final[_Loader[ExpressionToolOutputParameter]] = ( + _RecordLoader(ExpressionToolOutputParameter, None, None) ) -WorkflowInputParameterLoader = _RecordLoader(WorkflowInputParameter, None, None) -ExpressionToolLoader = _RecordLoader(ExpressionTool, None, None) -LinkMergeMethodLoader = _EnumLoader( +WorkflowInputParameterLoader: Final[_Loader[WorkflowInputParameter]] = _RecordLoader( + WorkflowInputParameter, None, None +) +ExpressionToolLoader: Final[_Loader[ExpressionTool]] = _RecordLoader( + ExpressionTool, None, None +) +LinkMergeMethod: TypeAlias = Literal["merge_nested", "merge_flattened"] +LinkMergeMethodLoader: Final[_Loader[LinkMergeMethod]] = _EnumLoader( ( "merge_nested", "merge_flattened", @@ -26526,12 +23290,21 @@ def save( "LinkMergeMethod", ) """ -The input link merge method, described in [WorkflowStepInput](#WorkflowStepInput). +The input link merge method, described in `WorkflowStepInput <#WorkflowStepInput>`__. """ -WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter, None, None) -WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput, None, None) -WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput, None, None) -ScatterMethodLoader = _EnumLoader( +WorkflowOutputParameterLoader: Final[_Loader[WorkflowOutputParameter]] = _RecordLoader( + WorkflowOutputParameter, None, None +) +WorkflowStepInputLoader: Final[_Loader[WorkflowStepInput]] = _RecordLoader( + WorkflowStepInput, None, None +) +WorkflowStepOutputLoader: Final[_Loader[WorkflowStepOutput]] = _RecordLoader( + WorkflowStepOutput, None, None +) +ScatterMethod: TypeAlias = Literal[ + "dotproduct", "nested_crossproduct", "flat_crossproduct" +] +ScatterMethodLoader: Final[_Loader[ScatterMethod]] = _EnumLoader( ( "dotproduct", "nested_crossproduct", @@ -26540,21 +23313,36 @@ def save( "ScatterMethod", ) """ -The scatter method, as described in [workflow step scatter](#WorkflowStep). +The scatter method, as described in `workflow step scatter <#WorkflowStep>`__. """ -WorkflowStepLoader = _RecordLoader(WorkflowStep, None, None) -WorkflowLoader = _RecordLoader(Workflow, None, None) -ProcessGeneratorLoader = _RecordLoader(ProcessGenerator, None, None) -array_of_strtype = _ArrayLoader(strtype) -union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( +WorkflowStepLoader: Final[_Loader[WorkflowStep]] = _RecordLoader( + WorkflowStep, None, None +) +WorkflowLoader: Final[_Loader[Workflow]] = _RecordLoader(Workflow, None, None) +array_of_strtype: Final[_Loader[Sequence[str]]] = _ArrayLoader(strtype) +union_of_None_type_or_strtype_or_array_of_strtype: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, array_of_strtype, ) ) -uri_strtype_True_False_None_None = _URILoader(strtype, True, False, None, None) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( +uri_strtype_True_False_None_None: Final[_Loader[str]] = _URILoader( + strtype, True, False, None, None +) +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, @@ -26565,10 +23353,41 @@ def save( strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + ] +] = _ArrayLoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, @@ -26580,51 +23399,116 @@ def save( array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, ) ) -typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _TypeDSLLoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, 2, "v1.1", ) -array_of_RecordFieldLoader = _ArrayLoader(RecordFieldLoader) -union_of_None_type_or_array_of_RecordFieldLoader = _UnionLoader( +array_of_RecordFieldLoader: Final[ + _Loader[Sequence[schema_salad.metaschema.RecordField]] +] = _ArrayLoader(RecordFieldLoader) +union_of_None_type_or_array_of_RecordFieldLoader: Final[ + _Loader[None | Sequence[schema_salad.metaschema.RecordField]] +] = _UnionLoader( ( None_type, array_of_RecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_RecordFieldLoader, "name", "type" +idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader: Final[ + _Loader[None | Sequence[schema_salad.metaschema.RecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_RecordFieldLoader, "name", "type") +Record_name: TypeAlias = Literal["record"] +Record_nameLoader: Final[_Loader[Record_name]] = _EnumLoader(("record",), "Record_name") +typedsl_Record_nameLoader_2: Final[_Loader[Record_name]] = _TypeDSLLoader( + Record_nameLoader, 2, "v1.1" ) -Record_nameLoader = _EnumLoader(("record",), "Record_name") -typedsl_Record_nameLoader_2 = _TypeDSLLoader(Record_nameLoader, 2, "v1.1") -union_of_None_type_or_strtype = _UnionLoader( +union_of_None_type_or_strtype: Final[_Loader[None | str]] = _UnionLoader( ( None_type, strtype, ) ) -uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( - union_of_None_type_or_strtype, True, False, None, None +uri_union_of_None_type_or_strtype_True_False_None_None: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, True, False, None, None) ) -uri_array_of_strtype_True_False_None_None = _URILoader( +uri_array_of_strtype_True_False_None_None: Final[_Loader[Sequence[str]]] = _URILoader( array_of_strtype, True, False, None, None ) -Enum_nameLoader = _EnumLoader(("enum",), "Enum_name") -typedsl_Enum_nameLoader_2 = _TypeDSLLoader(Enum_nameLoader, 2, "v1.1") -uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None = _URILoader( +Enum_name: TypeAlias = Literal["enum"] +Enum_nameLoader: Final[_Loader[Enum_name]] = _EnumLoader(("enum",), "Enum_name") +typedsl_Enum_nameLoader_2: Final[_Loader[Enum_name]] = _TypeDSLLoader( + Enum_nameLoader, 2, "v1.1" +) +uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _URILoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, False, True, 2, None, ) -Array_nameLoader = _EnumLoader(("array",), "Array_name") -typedsl_Array_nameLoader_2 = _TypeDSLLoader(Array_nameLoader, 2, "v1.1") -Map_nameLoader = _EnumLoader(("map",), "Map_name") -typedsl_Map_nameLoader_2 = _TypeDSLLoader(Map_nameLoader, 2, "v1.1") -Union_nameLoader = _EnumLoader(("union",), "Union_name") -typedsl_Union_nameLoader_2 = _TypeDSLLoader(Union_nameLoader, 2, "v1.1") -union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( +Array_name: TypeAlias = Literal["array"] +Array_nameLoader: Final[_Loader[Array_name]] = _EnumLoader(("array",), "Array_name") +typedsl_Array_nameLoader_2: Final[_Loader[Array_name]] = _TypeDSLLoader( + Array_nameLoader, 2, "v1.1" +) +Map_name: TypeAlias = Literal["map"] +Map_nameLoader: Final[_Loader[Map_name]] = _EnumLoader(("map",), "Map_name") +typedsl_Map_nameLoader_2: Final[_Loader[Map_name]] = _TypeDSLLoader( + Map_nameLoader, 2, "v1.1" +) +Union_name: TypeAlias = Literal["union"] +Union_nameLoader: Final[_Loader[Union_name]] = _EnumLoader(("union",), "Union_name") +typedsl_Union_nameLoader_2: Final[_Loader[Union_name]] = _TypeDSLLoader( + Union_nameLoader, 2, "v1.1" +) +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, CWLRecordSchemaLoader, @@ -26633,10 +23517,35 @@ def save( strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + ] +] = _ArrayLoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, CWLRecordSchemaLoader, @@ -26646,57 +23555,99 @@ def save( array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, ) ) -uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _URILoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, False, True, 2, None, ) -typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _TypeDSLLoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CWLRecordFieldLoader = _ArrayLoader(CWLRecordFieldLoader) -union_of_None_type_or_array_of_CWLRecordFieldLoader = _UnionLoader( +array_of_CWLRecordFieldLoader: Final[_Loader[Sequence[CWLRecordField]]] = _ArrayLoader( + CWLRecordFieldLoader +) +union_of_None_type_or_array_of_CWLRecordFieldLoader: Final[ + _Loader[None | Sequence[CWLRecordField]] +] = _UnionLoader( ( None_type, array_of_CWLRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type" -) -File_classLoader = _EnumLoader(("File",), "File_class") -uri_File_classLoader_False_True_None_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader: Final[ + _Loader[None | Sequence[CWLRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type") +File_class: TypeAlias = Literal["File"] +File_classLoader: Final[_Loader[File_class]] = _EnumLoader(("File",), "File_class") +uri_File_classLoader_False_True_None_None: Final[_Loader[File_class]] = _URILoader( File_classLoader, False, True, None, None ) -uri_union_of_None_type_or_strtype_False_False_None_None = _URILoader( - union_of_None_type_or_strtype, False, False, None, None +uri_union_of_None_type_or_strtype_False_False_None_None: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, False, False, None, None) ) -union_of_None_type_or_inttype = _UnionLoader( - ( - None_type, - inttype, +union_of_None_type_or_inttype_or_longtype: Final[_Loader[None | i32 | i64]] = ( + _UnionLoader( + ( + None_type, + inttype, + longtype, + ) ) ) -union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +union_of_FileLoader_or_DirectoryLoader: Final[_Loader[Directory | File]] = _UnionLoader( ( FileLoader, DirectoryLoader, ) ) -array_of_union_of_FileLoader_or_DirectoryLoader = _ArrayLoader( - union_of_FileLoader_or_DirectoryLoader -) -union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[Sequence[Directory | File]] +] = _ArrayLoader(union_of_FileLoader_or_DirectoryLoader) +union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[None | Sequence[Directory | File]] +] = _UnionLoader( ( None_type, array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[None | Sequence[Directory | File]] +] = _UnionLoader( ( _SecondaryDSLLoader( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader @@ -26704,34 +23655,45 @@ def save( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -uri_union_of_None_type_or_strtype_True_False_None_True = _URILoader( - union_of_None_type_or_strtype, True, False, None, True +uri_union_of_None_type_or_strtype_True_False_None_True: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, True, False, None, True) ) -Directory_classLoader = _EnumLoader(("Directory",), "Directory_class") -uri_Directory_classLoader_False_True_None_None = _URILoader( - Directory_classLoader, False, True, None, None +Directory_class: TypeAlias = Literal["Directory"] +Directory_classLoader: Final[_Loader[Directory_class]] = _EnumLoader( + ("Directory",), "Directory_class" ) -union_of_None_type_or_booltype = _UnionLoader( +uri_Directory_classLoader_False_True_None_None: Final[_Loader[Directory_class]] = ( + _URILoader(Directory_classLoader, False, True, None, None) +) +union_of_None_type_or_booltype: Final[_Loader[None | bool]] = _UnionLoader( ( None_type, booltype, ) ) -union_of_None_type_or_LoadListingEnumLoader = _UnionLoader( - ( - None_type, - LoadListingEnumLoader, +union_of_None_type_or_LoadListingEnumLoader: Final[_Loader[LoadListingEnum | None]] = ( + _UnionLoader( + ( + None_type, + LoadListingEnumLoader, + ) ) ) -array_of_SecondaryFileSchemaLoader = _ArrayLoader(SecondaryFileSchemaLoader) -union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _UnionLoader( +array_of_SecondaryFileSchemaLoader: Final[_Loader[Sequence[SecondaryFileSchema]]] = ( + _ArrayLoader(SecondaryFileSchemaLoader) +) +union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader: ( + Final[_Loader[None | SecondaryFileSchema | Sequence[SecondaryFileSchema]]] +) = _UnionLoader( ( None_type, SecondaryFileSchemaLoader, array_of_SecondaryFileSchemaLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _UnionLoader( +secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader: Final[ + _Loader[None | SecondaryFileSchema | Sequence[SecondaryFileSchema]] +] = _UnionLoader( ( _SecondaryDSLLoader( union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader @@ -26739,7 +23701,9 @@ def save( union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, ) ) -union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -26747,24 +23711,32 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( +uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader( union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader, True, False, None, True, ) -union_of_None_type_or_strtype_or_ExpressionLoader = _UnionLoader( - ( - None_type, - strtype, - ExpressionLoader, +union_of_None_type_or_strtype_or_ExpressionLoader: Final[_Loader[None | str]] = ( + _UnionLoader( + ( + None_type, + strtype, + ExpressionLoader, + ) ) ) -uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( +uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True: Final[ + _Loader[None | str] +] = _URILoader( union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None, True ) -union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] +] = _UnionLoader( ( CWLTypeLoader, InputRecordSchemaLoader, @@ -26773,10 +23745,25 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, InputRecordSchemaLoader, @@ -26786,29 +23773,57 @@ def save( array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_InputRecordFieldLoader = _ArrayLoader(InputRecordFieldLoader) -union_of_None_type_or_array_of_InputRecordFieldLoader = _UnionLoader( +array_of_InputRecordFieldLoader: Final[_Loader[Sequence[InputRecordField]]] = ( + _ArrayLoader(InputRecordFieldLoader) +) +union_of_None_type_or_array_of_InputRecordFieldLoader: Final[ + _Loader[None | Sequence[InputRecordField]] +] = _UnionLoader( ( None_type, array_of_InputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type" -) -uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader: Final[ + _Loader[None | Sequence[InputRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type") +uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] +] = _UnionLoader( ( CWLTypeLoader, OutputRecordSchemaLoader, @@ -26817,10 +23832,27 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, OutputRecordSchemaLoader, @@ -26830,69 +23862,186 @@ def save( array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_OutputRecordFieldLoader = _ArrayLoader(OutputRecordFieldLoader) -union_of_None_type_or_array_of_OutputRecordFieldLoader = _UnionLoader( +array_of_OutputRecordFieldLoader: Final[_Loader[Sequence[OutputRecordField]]] = ( + _ArrayLoader(OutputRecordFieldLoader) +) +union_of_None_type_or_array_of_OutputRecordFieldLoader: Final[ + _Loader[None | Sequence[OutputRecordField]] +] = _UnionLoader( ( None_type, array_of_OutputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type" -) -uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader: Final[ + _Loader[None | Sequence[OutputRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type") +uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader = _UnionLoader( +union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader: Final[ + _Loader[CommandInputParameter | WorkflowInputParameter] +] = _UnionLoader( ( CommandInputParameterLoader, WorkflowInputParameterLoader, ) ) -array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader = ( - _ArrayLoader(union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader) -) -idmap_inputs_array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader = _IdMapLoader( +array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter | WorkflowInputParameter]] +] = _ArrayLoader(union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader) +idmap_inputs_array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter | WorkflowInputParameter]] +] = _IdMapLoader( array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader, "id", "type", ) -union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader = _UnionLoader( +union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader: Final[ + _Loader[ + CommandOutputParameter | ExpressionToolOutputParameter | WorkflowOutputParameter + ] +] = _UnionLoader( ( CommandOutputParameterLoader, ExpressionToolOutputParameterLoader, WorkflowOutputParameterLoader, ) ) -array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader = _ArrayLoader( +array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader: Final[ + _Loader[ + Sequence[ + CommandOutputParameter + | ExpressionToolOutputParameter + | WorkflowOutputParameter + ] + ] +] = _ArrayLoader( union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader ) -idmap_outputs_array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader = _IdMapLoader( +idmap_outputs_array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader: Final[ + _Loader[ + Sequence[ + CommandOutputParameter + | ExpressionToolOutputParameter + | WorkflowOutputParameter + ] + ] +] = _IdMapLoader( array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader, "id", "type", ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, ) ) -idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader = _IdMapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader, +idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _IdMapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, "class", "None", ) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _UnionLoader( +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] +] = _UnionLoader( ( InlineJavascriptRequirementLoader, SchemaDefRequirementLoader, @@ -26911,91 +24060,179 @@ def save( ScatterFeatureRequirementLoader, MultipleInputFeatureRequirementLoader, StepInputExpressionRequirementLoader, - SecretsLoader, - MPIRequirementLoader, - CUDARequirementLoader, - ShmSizeLoader, Any_type, ) ) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + None + | Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, ) ) -idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type = _IdMapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_ShmSizeLoader_or_Any_type, +idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + None + | Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _IdMapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, "class", "None", ) -union_of_None_type_or_CWLVersionLoader = _UnionLoader( - ( - None_type, - CWLVersionLoader, +union_of_None_type_or_CWLVersionLoader: Final[_Loader[CWLVersion | None]] = ( + _UnionLoader( + ( + None_type, + CWLVersionLoader, + ) ) ) -uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None = _URILoader( - union_of_None_type_or_CWLVersionLoader, False, True, None, None -) -InlineJavascriptRequirement_classLoader = _EnumLoader( - ("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class" -) -uri_InlineJavascriptRequirement_classLoader_False_True_None_None = _URILoader( - InlineJavascriptRequirement_classLoader, False, True, None, None -) -union_of_None_type_or_array_of_strtype = _UnionLoader( - ( - None_type, - array_of_strtype, +uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None: Final[ + _Loader[CWLVersion | None] +] = _URILoader(union_of_None_type_or_CWLVersionLoader, False, True, None, None) +InlineJavascriptRequirement_class: TypeAlias = Literal["InlineJavascriptRequirement"] +InlineJavascriptRequirement_classLoader: Final[ + _Loader[InlineJavascriptRequirement_class] +] = _EnumLoader(("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class") +uri_InlineJavascriptRequirement_classLoader_False_True_None_None: Final[ + _Loader[InlineJavascriptRequirement_class] +] = _URILoader(InlineJavascriptRequirement_classLoader, False, True, None, None) +union_of_None_type_or_array_of_strtype: Final[_Loader[None | Sequence[str]]] = ( + _UnionLoader( + ( + None_type, + array_of_strtype, + ) ) ) -SchemaDefRequirement_classLoader = _EnumLoader( - ("SchemaDefRequirement",), "SchemaDefRequirement_class" -) -uri_SchemaDefRequirement_classLoader_False_True_None_None = _URILoader( - SchemaDefRequirement_classLoader, False, True, None, None +SchemaDefRequirement_class: TypeAlias = Literal["SchemaDefRequirement"] +SchemaDefRequirement_classLoader: Final[_Loader[SchemaDefRequirement_class]] = ( + _EnumLoader(("SchemaDefRequirement",), "SchemaDefRequirement_class") ) -union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader = _UnionLoader( +uri_SchemaDefRequirement_classLoader_False_True_None_None: Final[ + _Loader[SchemaDefRequirement_class] +] = _URILoader(SchemaDefRequirement_classLoader, False, True, None, None) +union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader: Final[ + _Loader[CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema] +] = _UnionLoader( ( CommandInputRecordSchemaLoader, CommandInputEnumSchemaLoader, CommandInputArraySchemaLoader, ) ) -array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader = _ArrayLoader( +array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader: Final[ + _Loader[ + Sequence[ + CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema + ] + ] +] = _ArrayLoader( union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader ) -union_of_strtype_or_ExpressionLoader = _UnionLoader( +union_of_strtype_or_ExpressionLoader: Final[_Loader[str]] = _UnionLoader( ( strtype, ExpressionLoader, ) ) -union_of_None_type_or_booltype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_booltype_or_ExpressionLoader: Final[ + _Loader[None | bool | str] +] = _UnionLoader( ( None_type, booltype, ExpressionLoader, ) ) -LoadListingRequirement_classLoader = _EnumLoader( - ("LoadListingRequirement",), "LoadListingRequirement_class" -) -uri_LoadListingRequirement_classLoader_False_True_None_None = _URILoader( - LoadListingRequirement_classLoader, False, True, None, None +LoadListingRequirement_class: TypeAlias = Literal["LoadListingRequirement"] +LoadListingRequirement_classLoader: Final[_Loader[LoadListingRequirement_class]] = ( + _EnumLoader(("LoadListingRequirement",), "LoadListingRequirement_class") ) -union_of_None_type_or_inttype_or_ExpressionLoader = _UnionLoader( - ( - None_type, - inttype, - ExpressionLoader, +uri_LoadListingRequirement_classLoader_False_True_None_None: Final[ + _Loader[LoadListingRequirement_class] +] = _URILoader(LoadListingRequirement_classLoader, False, True, None, None) +union_of_None_type_or_inttype_or_ExpressionLoader: Final[_Loader[None | i32 | str]] = ( + _UnionLoader( + ( + None_type, + inttype, + ExpressionLoader, + ) ) ) -union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype = _UnionLoader( +union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -27003,19 +24240,29 @@ def save( array_of_strtype, ) ) -union_of_None_type_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_ExpressionLoader: Final[_Loader[None | str]] = _UnionLoader( ( None_type, ExpressionLoader, ) ) -union_of_None_type_or_CommandLineBindingLoader = _UnionLoader( +union_of_None_type_or_CommandLineBindingLoader: Final[ + _Loader[CommandLineBinding | None] +] = _UnionLoader( ( None_type, CommandLineBindingLoader, ) ) -union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandInputRecordSchemaLoader, @@ -27024,10 +24271,35 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandInputRecordSchemaLoader, @@ -27037,31 +24309,73 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CommandInputRecordFieldLoader = _ArrayLoader(CommandInputRecordFieldLoader) -union_of_None_type_or_array_of_CommandInputRecordFieldLoader = _UnionLoader( +array_of_CommandInputRecordFieldLoader: Final[ + _Loader[Sequence[CommandInputRecordField]] +] = _ArrayLoader(CommandInputRecordFieldLoader) +union_of_None_type_or_array_of_CommandInputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandInputRecordField]] +] = _UnionLoader( ( None_type, array_of_CommandInputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader = ( - _IdMapLoader( - union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" - ) +idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandInputRecordField]] +] = _IdMapLoader( + union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandOutputRecordSchemaLoader, @@ -27070,10 +24384,35 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandOutputRecordSchemaLoader, @@ -27083,37 +24422,89 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_None_type_or_CommandOutputBindingLoader = _UnionLoader( +union_of_None_type_or_CommandOutputBindingLoader: Final[ + _Loader[CommandOutputBinding | None] +] = _UnionLoader( ( None_type, CommandOutputBindingLoader, ) ) -array_of_CommandOutputRecordFieldLoader = _ArrayLoader(CommandOutputRecordFieldLoader) -union_of_None_type_or_array_of_CommandOutputRecordFieldLoader = _UnionLoader( +array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[Sequence[CommandOutputRecordField]] +] = _ArrayLoader(CommandOutputRecordFieldLoader) +union_of_None_type_or_array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandOutputRecordField]] +] = _UnionLoader( ( None_type, array_of_CommandOutputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader = ( - _IdMapLoader( - union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" - ) +idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandOutputRecordField]] +] = _IdMapLoader( + union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | stdin + | str + ] +] = _UnionLoader( ( CWLTypeLoader, stdinLoader, @@ -27124,12 +24515,45 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | stdin + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | stderr + | stdout + | str + ] +] = _UnionLoader( ( CWLTypeLoader, stdoutLoader, @@ -27141,72 +24565,109 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | stderr + | stdout + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -CommandLineTool_classLoader = _EnumLoader(("CommandLineTool",), "CommandLineTool_class") -uri_CommandLineTool_classLoader_False_True_None_None = _URILoader( - CommandLineTool_classLoader, False, True, None, None -) -array_of_CommandInputParameterLoader = _ArrayLoader(CommandInputParameterLoader) -idmap_inputs_array_of_CommandInputParameterLoader = _IdMapLoader( - array_of_CommandInputParameterLoader, "id", "type" +CommandLineTool_class: TypeAlias = Literal["CommandLineTool"] +CommandLineTool_classLoader: Final[_Loader[CommandLineTool_class]] = _EnumLoader( + ("CommandLineTool",), "CommandLineTool_class" ) -array_of_CommandOutputParameterLoader = _ArrayLoader(CommandOutputParameterLoader) -idmap_outputs_array_of_CommandOutputParameterLoader = _IdMapLoader( - array_of_CommandOutputParameterLoader, "id", "type" -) -union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = _UnionLoader( +uri_CommandLineTool_classLoader_False_True_None_None: Final[ + _Loader[CommandLineTool_class] +] = _URILoader(CommandLineTool_classLoader, False, True, None, None) +array_of_CommandInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter]] +] = _ArrayLoader(CommandInputParameterLoader) +idmap_inputs_array_of_CommandInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter]] +] = _IdMapLoader(array_of_CommandInputParameterLoader, "id", "type") +array_of_CommandOutputParameterLoader: Final[ + _Loader[Sequence[CommandOutputParameter]] +] = _ArrayLoader(CommandOutputParameterLoader) +idmap_outputs_array_of_CommandOutputParameterLoader: Final[ + _Loader[Sequence[CommandOutputParameter]] +] = _IdMapLoader(array_of_CommandOutputParameterLoader, "id", "type") +union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[CommandLineBinding | str] +] = _UnionLoader( ( strtype, ExpressionLoader, CommandLineBindingLoader, ) ) -array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = ( - _ArrayLoader(union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader) -) -union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = _UnionLoader( +array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[Sequence[CommandLineBinding | str]] +] = _ArrayLoader(union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader) +union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[None | Sequence[CommandLineBinding | str]] +] = _UnionLoader( ( None_type, array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, ) ) -array_of_inttype = _ArrayLoader(inttype) -union_of_None_type_or_array_of_inttype = _UnionLoader( - ( - None_type, - array_of_inttype, +array_of_inttype: Final[_Loader[Sequence[i32]]] = _ArrayLoader(inttype) +union_of_None_type_or_array_of_inttype: Final[_Loader[None | Sequence[i32]]] = ( + _UnionLoader( + ( + None_type, + array_of_inttype, + ) ) ) -DockerRequirement_classLoader = _EnumLoader( +DockerRequirement_class: TypeAlias = Literal["DockerRequirement"] +DockerRequirement_classLoader: Final[_Loader[DockerRequirement_class]] = _EnumLoader( ("DockerRequirement",), "DockerRequirement_class" ) -uri_DockerRequirement_classLoader_False_True_None_None = _URILoader( - DockerRequirement_classLoader, False, True, None, None -) -SoftwareRequirement_classLoader = _EnumLoader( - ("SoftwareRequirement",), "SoftwareRequirement_class" -) -uri_SoftwareRequirement_classLoader_False_True_None_None = _URILoader( - SoftwareRequirement_classLoader, False, True, None, None -) -array_of_SoftwarePackageLoader = _ArrayLoader(SoftwarePackageLoader) -idmap_packages_array_of_SoftwarePackageLoader = _IdMapLoader( - array_of_SoftwarePackageLoader, "package", "specs" +uri_DockerRequirement_classLoader_False_True_None_None: Final[ + _Loader[DockerRequirement_class] +] = _URILoader(DockerRequirement_classLoader, False, True, None, None) +SoftwareRequirement_class: TypeAlias = Literal["SoftwareRequirement"] +SoftwareRequirement_classLoader: Final[_Loader[SoftwareRequirement_class]] = ( + _EnumLoader(("SoftwareRequirement",), "SoftwareRequirement_class") ) -uri_union_of_None_type_or_array_of_strtype_False_False_None_True = _URILoader( - union_of_None_type_or_array_of_strtype, False, False, None, True +uri_SoftwareRequirement_classLoader_False_True_None_None: Final[ + _Loader[SoftwareRequirement_class] +] = _URILoader(SoftwareRequirement_classLoader, False, True, None, None) +array_of_SoftwarePackageLoader: Final[_Loader[Sequence[SoftwarePackage]]] = ( + _ArrayLoader(SoftwarePackageLoader) ) -InitialWorkDirRequirement_classLoader = _EnumLoader( - ("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class" -) -uri_InitialWorkDirRequirement_classLoader_False_True_None_None = _URILoader( - InitialWorkDirRequirement_classLoader, False, True, None, None -) -union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader = _UnionLoader( +idmap_packages_array_of_SoftwarePackageLoader: Final[ + _Loader[Sequence[SoftwarePackage]] +] = _IdMapLoader(array_of_SoftwarePackageLoader, "package", "specs") +uri_union_of_None_type_or_array_of_strtype_False_False_None_True: Final[ + _Loader[None | Sequence[str]] +] = _URILoader(union_of_None_type_or_array_of_strtype, False, False, None, True) +InitialWorkDirRequirement_class: TypeAlias = Literal["InitialWorkDirRequirement"] +InitialWorkDirRequirement_classLoader: Final[ + _Loader[InitialWorkDirRequirement_class] +] = _EnumLoader(("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class") +uri_InitialWorkDirRequirement_classLoader_False_True_None_None: Final[ + _Loader[InitialWorkDirRequirement_class] +] = _URILoader(InitialWorkDirRequirement_classLoader, False, True, None, None) +union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader: Final[ + _Loader[Directory | Dirent | File | None | Sequence[Directory | File] | str] +] = _UnionLoader( ( None_type, FileLoader, @@ -27216,225 +24677,308 @@ def save( ExpressionLoader, ) ) -array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader = _ArrayLoader( +array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader: Final[ + _Loader[ + Sequence[Directory | Dirent | File | None | Sequence[Directory | File] | str] + ] +] = _ArrayLoader( union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader ) -union_of_array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader_or_ExpressionLoader = _UnionLoader( +union_of_array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader_or_ExpressionLoader: Final[ + _Loader[ + Sequence[Directory | Dirent | File | None | Sequence[Directory | File] | str] + | str + ] +] = _UnionLoader( ( array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader, ExpressionLoader, ) ) -EnvVarRequirement_classLoader = _EnumLoader( +EnvVarRequirement_class: TypeAlias = Literal["EnvVarRequirement"] +EnvVarRequirement_classLoader: Final[_Loader[EnvVarRequirement_class]] = _EnumLoader( ("EnvVarRequirement",), "EnvVarRequirement_class" ) -uri_EnvVarRequirement_classLoader_False_True_None_None = _URILoader( - EnvVarRequirement_classLoader, False, True, None, None -) -array_of_EnvironmentDefLoader = _ArrayLoader(EnvironmentDefLoader) -idmap_envDef_array_of_EnvironmentDefLoader = _IdMapLoader( - array_of_EnvironmentDefLoader, "envName", "envValue" -) -ShellCommandRequirement_classLoader = _EnumLoader( - ("ShellCommandRequirement",), "ShellCommandRequirement_class" +uri_EnvVarRequirement_classLoader_False_True_None_None: Final[ + _Loader[EnvVarRequirement_class] +] = _URILoader(EnvVarRequirement_classLoader, False, True, None, None) +array_of_EnvironmentDefLoader: Final[_Loader[Sequence[EnvironmentDef]]] = _ArrayLoader( + EnvironmentDefLoader ) -uri_ShellCommandRequirement_classLoader_False_True_None_None = _URILoader( - ShellCommandRequirement_classLoader, False, True, None, None +idmap_envDef_array_of_EnvironmentDefLoader: Final[_Loader[Sequence[EnvironmentDef]]] = ( + _IdMapLoader(array_of_EnvironmentDefLoader, "envName", "envValue") ) -ResourceRequirement_classLoader = _EnumLoader( - ("ResourceRequirement",), "ResourceRequirement_class" +ShellCommandRequirement_class: TypeAlias = Literal["ShellCommandRequirement"] +ShellCommandRequirement_classLoader: Final[_Loader[ShellCommandRequirement_class]] = ( + _EnumLoader(("ShellCommandRequirement",), "ShellCommandRequirement_class") ) -uri_ResourceRequirement_classLoader_False_True_None_None = _URILoader( - ResourceRequirement_classLoader, False, True, None, None +uri_ShellCommandRequirement_classLoader_False_True_None_None: Final[ + _Loader[ShellCommandRequirement_class] +] = _URILoader(ShellCommandRequirement_classLoader, False, True, None, None) +ResourceRequirement_class: TypeAlias = Literal["ResourceRequirement"] +ResourceRequirement_classLoader: Final[_Loader[ResourceRequirement_class]] = ( + _EnumLoader(("ResourceRequirement",), "ResourceRequirement_class") ) -WorkReuse_classLoader = _EnumLoader(("WorkReuse",), "WorkReuse_class") -uri_WorkReuse_classLoader_False_True_None_None = _URILoader( - WorkReuse_classLoader, False, True, None, None -) -union_of_booltype_or_ExpressionLoader = _UnionLoader( +uri_ResourceRequirement_classLoader_False_True_None_None: Final[ + _Loader[ResourceRequirement_class] +] = _URILoader(ResourceRequirement_classLoader, False, True, None, None) +union_of_None_type_or_inttype_or_longtype_or_ExpressionLoader: Final[ + _Loader[None | i32 | i64 | str] +] = _UnionLoader( ( - booltype, + None_type, + inttype, + longtype, ExpressionLoader, ) ) -NetworkAccess_classLoader = _EnumLoader(("NetworkAccess",), "NetworkAccess_class") -uri_NetworkAccess_classLoader_False_True_None_None = _URILoader( - NetworkAccess_classLoader, False, True, None, None +WorkReuse_class: TypeAlias = Literal["WorkReuse"] +WorkReuse_classLoader: Final[_Loader[WorkReuse_class]] = _EnumLoader( + ("WorkReuse",), "WorkReuse_class" ) -InplaceUpdateRequirement_classLoader = _EnumLoader( - ("InplaceUpdateRequirement",), "InplaceUpdateRequirement_class" +uri_WorkReuse_classLoader_False_True_None_None: Final[_Loader[WorkReuse_class]] = ( + _URILoader(WorkReuse_classLoader, False, True, None, None) ) -uri_InplaceUpdateRequirement_classLoader_False_True_None_None = _URILoader( - InplaceUpdateRequirement_classLoader, False, True, None, None -) -ToolTimeLimit_classLoader = _EnumLoader(("ToolTimeLimit",), "ToolTimeLimit_class") -uri_ToolTimeLimit_classLoader_False_True_None_None = _URILoader( - ToolTimeLimit_classLoader, False, True, None, None -) -union_of_inttype_or_ExpressionLoader = _UnionLoader( +union_of_booltype_or_ExpressionLoader: Final[_Loader[bool | str]] = _UnionLoader( ( - inttype, + booltype, ExpressionLoader, ) ) -union_of_None_type_or_InputBindingLoader = _UnionLoader( - ( - None_type, - InputBindingLoader, - ) +NetworkAccess_class: TypeAlias = Literal["NetworkAccess"] +NetworkAccess_classLoader: Final[_Loader[NetworkAccess_class]] = _EnumLoader( + ("NetworkAccess",), "NetworkAccess_class" ) -ExpressionTool_classLoader = _EnumLoader(("ExpressionTool",), "ExpressionTool_class") -uri_ExpressionTool_classLoader_False_True_None_None = _URILoader( - ExpressionTool_classLoader, False, True, None, None +uri_NetworkAccess_classLoader_False_True_None_None: Final[ + _Loader[NetworkAccess_class] +] = _URILoader(NetworkAccess_classLoader, False, True, None, None) +InplaceUpdateRequirement_class: TypeAlias = Literal["InplaceUpdateRequirement"] +InplaceUpdateRequirement_classLoader: Final[_Loader[InplaceUpdateRequirement_class]] = ( + _EnumLoader(("InplaceUpdateRequirement",), "InplaceUpdateRequirement_class") ) -array_of_WorkflowInputParameterLoader = _ArrayLoader(WorkflowInputParameterLoader) -idmap_inputs_array_of_WorkflowInputParameterLoader = _IdMapLoader( - array_of_WorkflowInputParameterLoader, "id", "type" +uri_InplaceUpdateRequirement_classLoader_False_True_None_None: Final[ + _Loader[InplaceUpdateRequirement_class] +] = _URILoader(InplaceUpdateRequirement_classLoader, False, True, None, None) +ToolTimeLimit_class: TypeAlias = Literal["ToolTimeLimit"] +ToolTimeLimit_classLoader: Final[_Loader[ToolTimeLimit_class]] = _EnumLoader( + ("ToolTimeLimit",), "ToolTimeLimit_class" ) -array_of_ExpressionToolOutputParameterLoader = _ArrayLoader( - ExpressionToolOutputParameterLoader +uri_ToolTimeLimit_classLoader_False_True_None_None: Final[ + _Loader[ToolTimeLimit_class] +] = _URILoader(ToolTimeLimit_classLoader, False, True, None, None) +union_of_inttype_or_longtype_or_ExpressionLoader: Final[_Loader[i32 | i64 | str]] = ( + _UnionLoader( + ( + inttype, + longtype, + ExpressionLoader, + ) + ) ) -idmap_outputs_array_of_ExpressionToolOutputParameterLoader = _IdMapLoader( - array_of_ExpressionToolOutputParameterLoader, "id", "type" +union_of_None_type_or_InputBindingLoader: Final[_Loader[InputBinding | None]] = ( + _UnionLoader( + ( + None_type, + InputBindingLoader, + ) + ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None +ExpressionTool_class: TypeAlias = Literal["ExpressionTool"] +ExpressionTool_classLoader: Final[_Loader[ExpressionTool_class]] = _EnumLoader( + ("ExpressionTool",), "ExpressionTool_class" ) -union_of_None_type_or_LinkMergeMethodLoader = _UnionLoader( - ( - None_type, - LinkMergeMethodLoader, +uri_ExpressionTool_classLoader_False_True_None_None: Final[ + _Loader[ExpressionTool_class] +] = _URILoader(ExpressionTool_classLoader, False, True, None, None) +array_of_WorkflowInputParameterLoader: Final[ + _Loader[Sequence[WorkflowInputParameter]] +] = _ArrayLoader(WorkflowInputParameterLoader) +idmap_inputs_array_of_WorkflowInputParameterLoader: Final[ + _Loader[Sequence[WorkflowInputParameter]] +] = _IdMapLoader(array_of_WorkflowInputParameterLoader, "id", "type") +array_of_ExpressionToolOutputParameterLoader: Final[ + _Loader[Sequence[ExpressionToolOutputParameter]] +] = _ArrayLoader(ExpressionToolOutputParameterLoader) +idmap_outputs_array_of_ExpressionToolOutputParameterLoader: Final[ + _Loader[Sequence[ExpressionToolOutputParameter]] +] = _IdMapLoader(array_of_ExpressionToolOutputParameterLoader, "id", "type") +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None) +union_of_None_type_or_LinkMergeMethodLoader: Final[_Loader[LinkMergeMethod | None]] = ( + _UnionLoader( + ( + None_type, + LinkMergeMethodLoader, + ) ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None) +array_of_WorkflowStepInputLoader: Final[_Loader[Sequence[WorkflowStepInput]]] = ( + _ArrayLoader(WorkflowStepInputLoader) ) -array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader) -idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader( - array_of_WorkflowStepInputLoader, "id", "source" -) -union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( +idmap_in__array_of_WorkflowStepInputLoader: Final[ + _Loader[Sequence[WorkflowStepInput]] +] = _IdMapLoader(array_of_WorkflowStepInputLoader, "id", "source") +union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[WorkflowStepOutput | str] +] = _UnionLoader( ( strtype, WorkflowStepOutputLoader, ) ) -array_of_union_of_strtype_or_WorkflowStepOutputLoader = _ArrayLoader( - union_of_strtype_or_WorkflowStepOutputLoader -) -union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( - (array_of_union_of_strtype_or_WorkflowStepOutputLoader,) -) -uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None = _URILoader( +array_of_union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _ArrayLoader(union_of_strtype_or_WorkflowStepOutputLoader) +union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _UnionLoader((array_of_union_of_strtype_or_WorkflowStepOutputLoader,)) +uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _URILoader( union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, True, False, None, None, ) -array_of_Any_type = _ArrayLoader(Any_type) -union_of_None_type_or_array_of_Any_type = _UnionLoader( - ( - None_type, - array_of_Any_type, +array_of_Any_type: Final[_Loader[Sequence[Any]]] = _ArrayLoader(Any_type) +union_of_None_type_or_array_of_Any_type: Final[_Loader[None | Sequence[Any]]] = ( + _UnionLoader( + ( + None_type, + array_of_Any_type, + ) ) ) -idmap_hints_union_of_None_type_or_array_of_Any_type = _IdMapLoader( - union_of_None_type_or_array_of_Any_type, "class", "None" -) -union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _UnionLoader( +idmap_hints_union_of_None_type_or_array_of_Any_type: Final[ + _Loader[None | Sequence[Any]] +] = _IdMapLoader(union_of_None_type_or_array_of_Any_type, "class", "None") +union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: ( + Final[_Loader[CommandLineTool | ExpressionTool | Workflow | str]] +) = _UnionLoader( ( strtype, CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, - ProcessGeneratorLoader, ) ) -uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_False_False_None_None = _URILoader( - union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, +uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None: Final[ + _Loader[CommandLineTool | ExpressionTool | Workflow | str] +] = _URILoader( + union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, False, False, None, None, ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None -) -union_of_None_type_or_ScatterMethodLoader = _UnionLoader( - ( - None_type, - ScatterMethodLoader, +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None) +union_of_None_type_or_ScatterMethodLoader: Final[_Loader[None | ScatterMethod]] = ( + _UnionLoader( + ( + None_type, + ScatterMethodLoader, + ) ) ) -uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None = _URILoader( - union_of_None_type_or_ScatterMethodLoader, False, True, None, None +uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None: Final[ + _Loader[None | ScatterMethod] +] = _URILoader(union_of_None_type_or_ScatterMethodLoader, False, True, None, None) +Workflow_class: TypeAlias = Literal["Workflow"] +Workflow_classLoader: Final[_Loader[Workflow_class]] = _EnumLoader( + ("Workflow",), "Workflow_class" ) -Workflow_classLoader = _EnumLoader(("Workflow",), "Workflow_class") -uri_Workflow_classLoader_False_True_None_None = _URILoader( - Workflow_classLoader, False, True, None, None +uri_Workflow_classLoader_False_True_None_None: Final[_Loader[Workflow_class]] = ( + _URILoader(Workflow_classLoader, False, True, None, None) ) -array_of_WorkflowOutputParameterLoader = _ArrayLoader(WorkflowOutputParameterLoader) -idmap_outputs_array_of_WorkflowOutputParameterLoader = _IdMapLoader( - array_of_WorkflowOutputParameterLoader, "id", "type" +array_of_WorkflowOutputParameterLoader: Final[ + _Loader[Sequence[WorkflowOutputParameter]] +] = _ArrayLoader(WorkflowOutputParameterLoader) +idmap_outputs_array_of_WorkflowOutputParameterLoader: Final[ + _Loader[Sequence[WorkflowOutputParameter]] +] = _IdMapLoader(array_of_WorkflowOutputParameterLoader, "id", "type") +array_of_WorkflowStepLoader: Final[_Loader[Sequence[WorkflowStep]]] = _ArrayLoader( + WorkflowStepLoader ) -array_of_WorkflowStepLoader = _ArrayLoader(WorkflowStepLoader) -union_of_array_of_WorkflowStepLoader = _UnionLoader((array_of_WorkflowStepLoader,)) -idmap_steps_union_of_array_of_WorkflowStepLoader = _IdMapLoader( - union_of_array_of_WorkflowStepLoader, "id", "None" +union_of_array_of_WorkflowStepLoader: Final[_Loader[Sequence[WorkflowStep]]] = ( + _UnionLoader((array_of_WorkflowStepLoader,)) ) -SubworkflowFeatureRequirement_classLoader = _EnumLoader( +idmap_steps_union_of_array_of_WorkflowStepLoader: Final[ + _Loader[Sequence[WorkflowStep]] +] = _IdMapLoader(union_of_array_of_WorkflowStepLoader, "id", "None") +SubworkflowFeatureRequirement_class: TypeAlias = Literal[ + "SubworkflowFeatureRequirement" +] +SubworkflowFeatureRequirement_classLoader: Final[ + _Loader[SubworkflowFeatureRequirement_class] +] = _EnumLoader( ("SubworkflowFeatureRequirement",), "SubworkflowFeatureRequirement_class" ) -uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None = _URILoader( - SubworkflowFeatureRequirement_classLoader, False, True, None, None -) -ScatterFeatureRequirement_classLoader = _EnumLoader( - ("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class" -) -uri_ScatterFeatureRequirement_classLoader_False_True_None_None = _URILoader( - ScatterFeatureRequirement_classLoader, False, True, None, None -) -MultipleInputFeatureRequirement_classLoader = _EnumLoader( +uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[SubworkflowFeatureRequirement_class] +] = _URILoader(SubworkflowFeatureRequirement_classLoader, False, True, None, None) +ScatterFeatureRequirement_class: TypeAlias = Literal["ScatterFeatureRequirement"] +ScatterFeatureRequirement_classLoader: Final[ + _Loader[ScatterFeatureRequirement_class] +] = _EnumLoader(("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class") +uri_ScatterFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[ScatterFeatureRequirement_class] +] = _URILoader(ScatterFeatureRequirement_classLoader, False, True, None, None) +MultipleInputFeatureRequirement_class: TypeAlias = Literal[ + "MultipleInputFeatureRequirement" +] +MultipleInputFeatureRequirement_classLoader: Final[ + _Loader[MultipleInputFeatureRequirement_class] +] = _EnumLoader( ("MultipleInputFeatureRequirement",), "MultipleInputFeatureRequirement_class" ) -uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None = _URILoader( - MultipleInputFeatureRequirement_classLoader, False, True, None, None -) -StepInputExpressionRequirement_classLoader = _EnumLoader( +uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[MultipleInputFeatureRequirement_class] +] = _URILoader(MultipleInputFeatureRequirement_classLoader, False, True, None, None) +StepInputExpressionRequirement_class: TypeAlias = Literal[ + "StepInputExpressionRequirement" +] +StepInputExpressionRequirement_classLoader: Final[ + _Loader[StepInputExpressionRequirement_class] +] = _EnumLoader( ("StepInputExpressionRequirement",), "StepInputExpressionRequirement_class" ) -uri_StepInputExpressionRequirement_classLoader_False_True_None_None = _URILoader( - StepInputExpressionRequirement_classLoader, False, True, None, None -) -uri_strtype_False_True_None_None = _URILoader(strtype, False, True, None, None) -uri_array_of_strtype_False_False_0_None = _URILoader( - array_of_strtype, False, False, 0, None -) -union_of_strtype_or_array_of_strtype = _UnionLoader( - ( - strtype, - array_of_strtype, - ) -) -union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _UnionLoader( +uri_StepInputExpressionRequirement_classLoader_False_True_None_None: Final[ + _Loader[StepInputExpressionRequirement_class] +] = _URILoader(StepInputExpressionRequirement_classLoader, False, True, None, None) +union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: Final[ + _Loader[CommandLineTool | ExpressionTool | Workflow] +] = _UnionLoader( ( CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, - ProcessGeneratorLoader, ) ) -array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _ArrayLoader( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader +array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: ( + Final[_Loader[Sequence[CommandLineTool | ExpressionTool | Workflow]]] +) = _ArrayLoader( + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader ) -union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader = _UnionLoader( +union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader: Final[ + _Loader[ + CommandLineTool + | ExpressionTool + | Sequence[CommandLineTool | ExpressionTool | Workflow] + | Workflow + ] +] = _UnionLoader( ( CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, - ProcessGeneratorLoader, - array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, ) ) @@ -27450,19 +24994,72 @@ def save( map_of_union_of_None_type_or_CWLObjectTypeLoader, ) ) +CWLObjectType: TypeAlias = ( + "Directory | File | Mapping[str, CWLObjectType | None] | Sequence[CWLObjectType | None] | bool | float | i32 | str" +) + +Sink: TypeAlias = WorkflowStepInput +InputSchema: TypeAlias = InputArraySchema | InputEnumSchema | InputRecordSchema +OutputSchema: TypeAlias = OutputArraySchema | OutputEnumSchema | OutputRecordSchema +InputParameter: TypeAlias = CommandInputParameter | WorkflowInputParameter +OutputParameter: TypeAlias = ( + CommandOutputParameter | ExpressionToolOutputParameter | WorkflowOutputParameter +) +ProcessRequirement: TypeAlias = ( + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse +) +Process: TypeAlias = CommandLineTool | ExpressionTool | Workflow +CommandInputSchema: TypeAlias = ( + CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema +) +CommandLineBindable: TypeAlias = ( + CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordField + | CommandInputRecordSchema +) +IOSchema: TypeAlias = InputSchema | OutputSchema +LoadContents: TypeAlias = ( + CommandOutputBinding | InputParameter | InputRecordField | WorkflowStepInput +) +InputFormat: TypeAlias = InputParameter | InputRecordField +OutputFormat: TypeAlias = OutputParameter | OutputRecordField +Parameter: TypeAlias = InputParameter | OutputParameter +IdentifierRequired: TypeAlias = ( + Parameter | WorkflowStep | WorkflowStepInput | WorkflowStepOutput +) +FieldBase: TypeAlias = InputRecordField | OutputRecordField | Parameter +Identified: TypeAlias = IdentifierRequired | Process +Labeled: TypeAlias = FieldBase | IOSchema | Process | WorkflowStep | WorkflowStepInput def load_document( doc: Any, - baseuri: Optional[str] = None, - loadingOptions: Optional[LoadingOptions] = None, + baseuri: str | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: if baseuri is None: baseuri = file_uri(os.getcwd()) + "/" if loadingOptions is None: loadingOptions = LoadingOptions() result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, doc, baseuri, loadingOptions, @@ -27472,16 +25069,16 @@ def load_document( def load_document_with_metadata( doc: Any, - baseuri: Optional[str] = None, - loadingOptions: Optional[LoadingOptions] = None, - addl_metadata_fields: Optional[MutableSequence[str]] = None, + baseuri: str | None = None, + loadingOptions: LoadingOptions | None = None, + addl_metadata_fields: MutableSequence[str] | None = None, ) -> Any: if baseuri is None: baseuri = file_uri(os.getcwd()) + "/" if loadingOptions is None: loadingOptions = LoadingOptions(fileuri=baseuri) return _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, doc, baseuri, loadingOptions, @@ -27492,7 +25089,7 @@ def load_document_with_metadata( def load_document_by_string( string: Any, uri: str, - loadingOptions: Optional[LoadingOptions] = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: yaml = yaml_no_ts() result = yaml.load(string) @@ -27502,7 +25099,7 @@ def load_document_by_string( loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, result, uri, loadingOptions, @@ -27513,7 +25110,7 @@ def load_document_by_string( def load_document_by_yaml( yaml: Any, uri: str, - loadingOptions: Optional[LoadingOptions] = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """ Shortcut to load via a YAML object. @@ -27525,7 +25122,7 @@ def load_document_by_yaml( loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, yaml, uri, loadingOptions, diff --git a/src/cwl_utils/parser/cwl_v1_1_utils.py b/src/cwl_utils/parser/cwl_v1_1_utils.py index d1aa7169..9d2de45f 100644 --- a/src/cwl_utils/parser/cwl_v1_1_utils.py +++ b/src/cwl_utils/parser/cwl_v1_1_utils.py @@ -2,13 +2,15 @@ import hashlib import logging from collections import namedtuple -from collections.abc import MutableMapping, MutableSequence +from collections.abc import MutableMapping, MutableSequence, Sequence, Mapping from io import StringIO from pathlib import Path -from typing import IO, Any, cast +from typing import IO, Any, TypeAlias, TypeVar from urllib.parse import urldefrag from schema_salad.exceptions import ValidationException +from schema_salad.metaschema import ArraySchema, EnumSchema, RecordSchema +from schema_salad.runtime import save, shortname, LoadingOptions, file_uri from schema_salad.sourceline import SourceLine, add_lc_filename from schema_salad.utils import aslist, json_dumps, yaml_no_ts @@ -16,6 +18,7 @@ import cwl_utils.parser.cwl_v1_1 as cwl import cwl_utils.parser.utils from cwl_utils.errors import WorkflowException +from cwl_utils.types import is_sequence from cwl_utils.utils import yaml_dumps CONTENT_LIMIT: int = 64 * 1024 @@ -24,50 +27,98 @@ SrcSink = namedtuple("SrcSink", ["src", "sink", "linkMerge", "message"]) - -def _compare_records( - src: cwl.RecordSchema, sink: cwl.RecordSchema, strict: bool = False -) -> bool: - """ - Compare two records, ensuring they have compatible fields. - - This handles normalizing record names, which will be relative to workflow - step, so that they can be compared. - """ - srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})} - sinkfields = { - cwl.shortname(field.name): field.type_ for field in (sink.fields or {}) - } - for key in sinkfields.keys(): - if ( - not can_assign_src_to_sink( - srcfields.get(key, "null"), sinkfields.get(key, "null"), strict +BasicInputTypeSchemas: TypeAlias = cwl.InputSchema | str | cwl.CWLType +InputTypeSchemas: TypeAlias = ( + BasicInputTypeSchemas | cwl.stdin | Sequence[BasicInputTypeSchemas] +) +BasicCommandInputTypeSchemas: TypeAlias = ( + cwl.CommandInputArraySchema + | cwl.CommandInputEnumSchema + | cwl.CommandInputRecordSchema + | str + | cwl.CWLType +) +CommandInputTypeSchemas: TypeAlias = ( + BasicCommandInputTypeSchemas | cwl.stdin | Sequence[BasicCommandInputTypeSchemas] +) +BasicOutputTypeSchemas: TypeAlias = cwl.OutputSchema | str | cwl.CWLType +OutputTypeSchemas: TypeAlias = ( + BasicOutputTypeSchemas | cwl.stderr | cwl.stdout | Sequence[BasicOutputTypeSchemas] +) +BasicCommandOutputTypeSchemas: TypeAlias = ( + cwl.CommandOutputArraySchema + | cwl.CommandOutputEnumSchema + | cwl.CommandOutputRecordSchema + | str + | cwl.CWLType +) +CommandOutputTypeSchemas: TypeAlias = ( + BasicCommandOutputTypeSchemas + | cwl.stdout + | cwl.stderr + | Sequence[BasicCommandOutputTypeSchemas] +) +AnyTypeSchema = TypeVar( + "AnyTypeSchema", bound=InputTypeSchemas | CommandOutputTypeSchemas +) + + +def _in_output_type_schema_to_output_type_schema( + schema_type: BasicInputTypeSchemas | BasicOutputTypeSchemas, + loading_options: LoadingOptions, +) -> BasicOutputTypeSchemas: + match schema_type: + case ArraySchema(): + return cwl.OutputArraySchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, ) - and sinkfields.get(key) is not None - ): - _logger.info( - "Record comparison failure for %s and %s\n" - "Did not match fields for %s: %s and %s", - cast(cwl.InputRecordSchema | cwl.CommandOutputRecordSchema, src).name, - cast(cwl.InputRecordSchema | cwl.CommandOutputRecordSchema, sink).name, - key, - srcfields.get(key), - sinkfields.get(key), + case EnumSchema(): + return cwl.OutputEnumSchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, ) - return False - return True + case RecordSchema(): + return cwl.OutputRecordSchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, + ) + case str(): + return schema_type + raise WorkflowException(f"Unexpected output type: {schema_type}.") + + +def in_output_type_schema_to_output_type_schema( + schema_type: ( + BasicInputTypeSchemas + | BasicOutputTypeSchemas + | Sequence[BasicInputTypeSchemas | BasicOutputTypeSchemas] + ), + loading_options: LoadingOptions, +) -> OutputTypeSchemas: + if is_sequence(schema_type): + return [ + _in_output_type_schema_to_output_type_schema( + schema_type_item, loading_options + ) + for schema_type_item in schema_type + ] + return _in_output_type_schema_to_output_type_schema(schema_type, loading_options) def _compare_type(type1: Any, type2: Any) -> bool: match (type1, type1): - case cwl.ArraySchema() as t1, cwl.ArraySchema() as t2: + case ArraySchema() as t1, ArraySchema() as t2: return _compare_type(t1.items, t2.items) - case cwl.RecordSchema(), cwl.RecordSchema(): + case RecordSchema(), RecordSchema(): fields1 = { - cwl.shortname(field.name): field.type_ for field in (type1.fields or {}) + shortname(field.name): field.type_ for field in (type1.fields or {}) } fields2 = { - cwl.shortname(field.name): field.type_ for field in (type2.fields or {}) + shortname(field.name): field.type_ for field in (type2.fields or {}) } if fields1.keys() != fields2.keys(): return False @@ -85,9 +136,9 @@ def _compare_type(type1: Any, type2: Any) -> bool: def _inputfile_load( doc: str | MutableMapping[str, Any] | MutableSequence[Any], baseuri: str, - loadingOptions: cwl.LoadingOptions, + loadingOptions: LoadingOptions, addl_metadata_fields: MutableSequence[str] | None = None, -) -> tuple[Any, cwl.LoadingOptions]: +) -> tuple[Any, LoadingOptions]: loader = cwl.CWLInputFileLoader match doc: case str(): @@ -101,9 +152,7 @@ def _inputfile_load( yaml = yaml_no_ts() result = yaml.load(textIO) add_lc_filename(result, doc_url) - loadingOptions = cwl.LoadingOptions( - copyfrom=loadingOptions, fileuri=doc_url - ) + loadingOptions = LoadingOptions(copyfrom=loadingOptions, fileuri=doc_url) _inputfile_load( result, doc_url, @@ -117,7 +166,7 @@ def _inputfile_load( if mf in doc: addl_metadata[mf] = doc[mf] - loadingOptions = cwl.LoadingOptions( + loadingOptions = LoadingOptions( copyfrom=loadingOptions, baseuri=baseuri, addl_metadata=addl_metadata, @@ -144,45 +193,15 @@ def _inputfile_load( ) -def can_assign_src_to_sink(src: Any, sink: Any, strict: bool = False) -> bool: - """ - Check for identical type specifications, ignoring extra keys like inputBinding. - - src: admissible source types - sink: admissible sink types - - In non-strict comparison, at least one source type must match one sink type, - except for 'null'. - In strict comparison, all source types must match at least one sink type. - """ - if "Any" in (src, sink): - return True - if isinstance(src, cwl.ArraySchema) and isinstance(sink, cwl.ArraySchema): - return can_assign_src_to_sink(src.items, sink.items, strict) - if isinstance(src, cwl.RecordSchema) and isinstance(sink, cwl.RecordSchema): - return _compare_records(src, sink, strict) - if isinstance(src, MutableSequence): - if strict: - for this_src in src: - if not can_assign_src_to_sink(this_src, sink): - return False - return True - for this_src in src: - if this_src != "null" and can_assign_src_to_sink(this_src, sink): - return True - return False - if isinstance(sink, MutableSequence): - for this_sink in sink: - if can_assign_src_to_sink(src, this_sink): - return True - return False - return bool(src == sink) - - def check_all_types( - src_dict: dict[str, Any], - sinks: MutableSequence[cwl.WorkflowStepInput | cwl.WorkflowOutputParameter], - type_dict: dict[str, Any], + src_dict: Mapping[str, cwl.WorkflowInputParameter | cwl.WorkflowStepOutput], + sinks: Sequence[cwl.WorkflowStepInput | cwl.WorkflowOutputParameter], + type_dict: Mapping[ + str, + cwl_utils.parser.utils.InputTypeSchemas + | cwl_utils.parser.utils.OutputTypeSchemas + | None, + ], ) -> dict[str, list[SrcSink]]: """Given a list of sinks, check if their types match with the types of their sources.""" validation: dict[str, list[SrcSink]] = {"warning": [], "exception": []} @@ -195,9 +214,9 @@ def check_all_types( sourceName = "source" sourceField = sink.source case _: - continue + raise WorkflowException(f"Invalid sink type {sink.__class__.__name__}") if sourceField is not None: - if isinstance(sourceField, MutableSequence): + if is_sequence(sourceField): linkMerge = sink.linkMerge or ( "merge_nested" if len(sourceField) > 1 else None ) @@ -205,7 +224,7 @@ def check_all_types( for parm_id in sourceField: srcs_of_sink += [src_dict[parm_id]] else: - parm_id = cast(str, sourceField) + parm_id = sourceField if parm_id not in src_dict: raise SourceLine(sink, sourceName, ValidationException).makeError( f"{sourceName} not found: {parm_id}" @@ -213,45 +232,17 @@ def check_all_types( srcs_of_sink = [src_dict[parm_id]] linkMerge = None for src in srcs_of_sink: - check_result = check_types( - type_dict[cast(str, src.id)], + check_result = cwl_utils.parser.utils.check_types( + type_dict[src.id], type_dict[sink.id], linkMerge, - getattr(sink, "valueFrom", None), + sink.valueFrom if isinstance(sink, cwl.WorkflowStepInput) else None, ) if check_result in ("warning", "exception"): validation[check_result].append(SrcSink(src, sink, linkMerge, None)) return validation -def check_types( - srctype: Any, - sinktype: Any, - linkMerge: str | None, - valueFrom: str | None = None, -) -> str: - """ - Check if the source and sink types are correct. - - Acceptable types are "pass", "warning", or "exception". - """ - if valueFrom is not None: - return "pass" - if linkMerge is None: - if can_assign_src_to_sink(srctype, sinktype, strict=True): - return "pass" - if can_assign_src_to_sink(srctype, sinktype, strict=False): - return "warning" - return "exception" - if linkMerge == "merge_nested": - return check_types( - cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None - ) - if linkMerge == "merge_flattened": - return check_types(merge_flatten_type(srctype), sinktype, None, None) - raise ValidationException(f"Invalid value {linkMerge} for linkMerge field.") - - def content_limit_respected_read_bytes(f: IO[bytes]) -> bytes: """ Read file content up to 64 kB as a byte array. @@ -307,8 +298,7 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: ) else: clt.stdin = ( - "$(inputs.%s.path)" - % cast(str, inp.id).rpartition("#")[2].split("/")[-1] + "$(inputs.%s.path)" % inp.id.rpartition("#")[2].split("/")[-1] ) inp.type_ = "File" @@ -316,13 +306,13 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: def load_inputfile( doc: Any, baseuri: str | None = None, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.1 input file from a serialized YAML string or a YAML object.""" if baseuri is None: - baseuri = cwl.file_uri(str(Path.cwd())) + "/" + baseuri = file_uri(str(Path.cwd())) + "/" if loadingOptions is None: - loadingOptions = cwl.LoadingOptions() + loadingOptions = LoadingOptions() result, metadata = _inputfile_load( doc, @@ -335,14 +325,14 @@ def load_inputfile( def load_inputfile_by_string( string: Any, uri: str, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.1 input file from a serialized YAML string.""" result = yaml_no_ts().load(string) add_lc_filename(result, uri) if loadingOptions is None: - loadingOptions = cwl.LoadingOptions(fileuri=uri) + loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _inputfile_load( result, @@ -355,13 +345,13 @@ def load_inputfile_by_string( def load_inputfile_by_yaml( yaml: Any, uri: str, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.1 input file from a YAML object.""" add_lc_filename(yaml, uri) if loadingOptions is None: - loadingOptions = cwl.LoadingOptions(fileuri=uri) + loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _inputfile_load( yaml, @@ -371,93 +361,119 @@ def load_inputfile_by_yaml( return result -def merge_flatten_type(src: Any) -> Any: - """Return the merge flattened type of the source type.""" - if isinstance(src, MutableSequence): - return [merge_flatten_type(t) for t in src] - if isinstance(src, cwl.ArraySchema): - return src - return cwl.ArraySchema(type_="array", items=src) +def to_input_array(type_: InputTypeSchemas) -> cwl.InputArraySchema: + return cwl.InputArraySchema(type_="array", items=type_) + + +def to_output_array(type_: OutputTypeSchemas) -> cwl.OutputArraySchema: + return cwl.OutputArraySchema(type_="array", items=type_) def type_for_step_input( step: cwl.WorkflowStep, in_: cwl.WorkflowStepInput, -) -> Any: +) -> cwl_utils.parser.utils.InputTypeSchemas | None: """Determine the type for the given step input.""" if in_.valueFrom is not None: return "Any" step_run = cwl_utils.parser.utils.load_step(step) cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - if step_run and step_run.inputs: - for step_input in step_run.inputs: - if cast(str, step_input.id).split("#")[-1] == in_.id.split("#")[-1]: - input_type = step_input.type_ - if step.scatter is not None and in_.id in aslist(step.scatter): - input_type = cwl.ArraySchema(items=input_type, type_="array") - return input_type + for step_input in step_run.inputs: + if step_input.id.split("#")[-1] == in_.id.split("#")[-1]: + input_type = step_input.type_ + if ( + input_type is not None + and step.scatter is not None + and in_.id in aslist(step.scatter) + ): + input_type = cwl_utils.parser.utils.to_input_array( + input_type, step_run.cwlVersion or "v1.1" + ) + return input_type return "Any" def type_for_step_output( step: cwl.WorkflowStep, sourcename: str, -) -> Any: +) -> cwl_utils.parser.utils.OutputTypeSchemas | None: """Determine the type for the given step output.""" step_run = cwl_utils.parser.utils.load_step(step) cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - if step_run and step_run.outputs: - for output in step_run.outputs: - if ( - output.id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - output_type = output.type_ - if step.scatter is not None: - if step.scatterMethod == "nested_crossproduct": - for _ in range(len(aslist(step.scatter))): - output_type = cwl.ArraySchema( - items=output_type, type_="array" - ) - else: - output_type = cwl.ArraySchema(items=output_type, type_="array") - return output_type + for output in step_run.outputs: + if ( + output.id.split("#")[-1].split("/")[-1] + == sourcename.split("#")[-1].split("/")[-1] + ): + output_type = output.type_ + if output_type is not None and step.scatter is not None: + if step.scatterMethod == "nested_crossproduct": + for _ in range(len(aslist(step.scatter))): + output_type = cwl_utils.parser.utils.to_output_array( + output_type, step_run.cwlVersion or "v1.1" + ) + else: + output_type = cwl_utils.parser.utils.to_output_array( + output_type, step_run.cwlVersion or "v1.1" + ) + return output_type raise ValidationException( "param {} not found in {}.".format( sourcename, - yaml_dumps(cwl.save(step)), + yaml_dumps(save(step)), ) ) def type_for_source( - process: cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool, - sourcenames: str | list[str], + process: cwl.Process, + sourcenames: str | Sequence[str], parent: cwl.Workflow | None = None, linkMerge: str | None = None, -) -> Any: +) -> ( + MutableSequence[InputTypeSchemas | OutputTypeSchemas] + | InputTypeSchemas + | OutputTypeSchemas +): """Determine the type for the given sourcenames.""" scatter_context: list[tuple[int, str] | None] = [] - params = param_for_source_id(process, sourcenames, parent, scatter_context) + params = cwl_utils.parser.utils.param_for_source_id( + process, sourcenames, parent, scatter_context + ) if not isinstance(params, MutableSequence): - new_type = params.type_ + new_type: InputTypeSchemas | OutputTypeSchemas = params.type_ if scatter_context[0] is not None: if scatter_context[0][1] == "nested_crossproduct": for _ in range(scatter_context[0][0]): - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) else: - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) elif linkMerge == "merge_flattened": - new_type = merge_flatten_type(new_type) + new_type = cwl_utils.parser.utils.merge_flatten_type(new_type) return new_type - new_type = [] + new_types: MutableSequence[InputTypeSchemas | OutputTypeSchemas] = [] for p, sc in zip(params, scatter_context): - if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type): + if isinstance(p, str) and not any(_compare_type(t, p) for t in new_types): cur_type = p elif hasattr(p, "type_") and not any( - _compare_type(t, p.type_) for t in new_type + _compare_type(t, p.type_) for t in new_types ): cur_type = p.type_ else: @@ -466,113 +482,38 @@ def type_for_source( if sc is not None: if sc[1] == "nested_crossproduct": for _ in range(sc[0]): - cur_type = cwl.ArraySchema(items=cur_type, type_="array") + cur_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + cur_type, process.loadingOptions + ), + type_="array", + ) else: - cur_type = cwl.ArraySchema(items=cur_type, type_="array") - new_type.append(cur_type) - if len(new_type) == 1: - new_type = new_type[0] + cur_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + cur_type, process.loadingOptions + ), + type_="array", + ) + new_types.append(cur_type) + if len(new_types) == 1: + final_type: ( + MutableSequence[InputTypeSchemas | OutputTypeSchemas] + | InputTypeSchemas + | OutputTypeSchemas + ) = new_types[0] + else: + final_type = new_types if linkMerge == "merge_nested": - return cwl.ArraySchema(items=new_type, type_="array") + final_type = cwl.OutputArraySchema( + items=final_type, + type_="array", + ) elif linkMerge == "merge_flattened": - return merge_flatten_type(new_type) + final_type = cwl_utils.parser.utils.merge_flatten_type(final_type) elif isinstance(sourcenames, list) and len(sourcenames) > 1: - return cwl.ArraySchema(items=new_type, type_="array") - else: - return new_type - - -def param_for_source_id( - process: cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool, - sourcenames: str | list[str], - parent: cwl.Workflow | None = None, - scatter_context: list[tuple[int, str] | None] | None = None, -) -> ( - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter - | MutableSequence[ - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter - ] -): - """Find the process input parameter that matches one of the given sourcenames.""" - if isinstance(sourcenames, str): - sourcenames = [sourcenames] - params: MutableSequence[ - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter - ] = [] - for sourcename in sourcenames: - if not isinstance(process, cwl.Workflow): - for param in process.inputs: - if param.id.split("#")[-1] == sourcename.split("#")[-1]: - params.append(param) - if scatter_context is not None: - scatter_context.append(None) - targets = [process] - if parent: - targets.append(parent) - for target in targets: - if isinstance(target, cwl.Workflow): - for inp in target.inputs: - if inp.id.split("#")[-1] == sourcename.split("#")[-1]: - params.append(inp) - if scatter_context is not None: - scatter_context.append(None) - for step in target.steps: - if ( - "/".join(sourcename.split("#")[-1].split("/")[:-1]) - == step.id.split("#")[-1] - and step.out - ): - step_run = cwl_utils.parser.utils.load_step(step) - cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - for outp in step.out: - outp_id = outp if isinstance(outp, str) else outp.id - if ( - outp_id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - if step_run and step_run.outputs: - for output in step_run.outputs: - if ( - output.id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - params.append(output) - if scatter_context is not None: - if scatter_context is not None: - if isinstance(step.scatter, str): - scatter_context.append( - ( - 1, - step.scatterMethod - or "dotproduct", - ) - ) - elif isinstance( - step.scatter, MutableSequence - ): - scatter_context.append( - ( - len(step.scatter), - step.scatterMethod - or "dotproduct", - ) - ) - else: - scatter_context.append(None) - if len(params) == 1: - return params[0] - elif len(params) > 1: - return params - raise WorkflowException( - "param {} not found in {}\n{}.".format( - sourcename, - yaml_dumps(cwl.save(process)), - (f" or\n {yaml_dumps(cwl.save(parent))}" if parent is not None else ""), + return cwl.OutputArraySchema( + items=final_type, + type_="array", ) - ) + return final_type diff --git a/src/cwl_utils/parser/cwl_v1_2.py b/src/cwl_utils/parser/cwl_v1_2.py index 85f744fc..9a5a175d 100644 --- a/src/cwl_utils/parser/cwl_v1_2.py +++ b/src/cwl_utils/parser/cwl_v1_2.py @@ -2,460 +2,92 @@ # This file was autogenerated using schema-salad-tool --codegen=python # The code itself is released under the Apache 2.0 license and the help text is # subject to the license of the original schema. +from __future__ import annotations -import copy -import logging import os -import pathlib -import tempfile -import uuid as _uuid__ # pylint: disable=unused-import # noqa: F401 -import xml.sax # nosec -from abc import ABC, abstractmethod -from collections.abc import MutableMapping, MutableSequence, Sequence +import sys +import uuid as _uuid__ +from collections.abc import Collection +from typing import ClassVar + +from schema_salad.runtime import ( + Saveable, + file_uri, + parse_errors, + prefix_url, + save, + save_relative_uri, +) + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +import schema_salad.metaschema + +import copy +from abc import ABCMeta, abstractmethod +from collections.abc import MutableSequence, Sequence, MutableMapping from io import StringIO from itertools import chain -from typing import Any, Final, Optional, Union, cast -from urllib.parse import quote, urldefrag, urlparse, urlsplit, urlunsplit -from urllib.request import pathname2url - -from rdflib import Graph -from rdflib.plugins.parsers.notation3 import BadSyntax +from typing import Literal, TypeVar # pylint: disable=unused-import # noqa: F401 +from collections.abc import Mapping +from typing import TypeAlias # pylint: disable=unused-import # noqa: F401 +from typing import Any, Final, cast, Generic +from urllib.parse import urldefrag, urlsplit, urlunsplit + +from mypy_extensions import i32, i64 # pylint: disable=unused-import # noqa: F401 +from mypy_extensions import mypyc_attr from ruamel.yaml.comments import CommentedMap -from schema_salad.exceptions import SchemaSaladException, ValidationException -from schema_salad.fetcher import DefaultFetcher, Fetcher, MemoryCachingFetcher +from schema_salad.exceptions import ValidationException, SchemaSaladException +from schema_salad.runtime import ( + LoadingOptions, + convert_typing, + extract_type, + SaveableType, + FieldType, + EnumFieldType, +) from schema_salad.sourceline import SourceLine, add_lc_filename -from schema_salad.utils import CacheType, yaml_no_ts # requires schema-salad v8.2+ - -_vocab: dict[str, str] = {} -_rvocab: dict[str, str] = {} - -_logger: Final = logging.getLogger("salad") - - -IdxType = MutableMapping[str, tuple[Any, "LoadingOptions"]] - - -class LoadingOptions: - idx: Final[IdxType] - fileuri: Final[Optional[str]] - baseuri: Final[str] - namespaces: Final[MutableMapping[str, str]] - schemas: Final[MutableSequence[str]] - original_doc: Final[Optional[Any]] - addl_metadata: Final[MutableMapping[str, Any]] - fetcher: Final[Fetcher] - vocab: Final[dict[str, str]] - rvocab: Final[dict[str, str]] - cache: Final[CacheType] - imports: Final[list[str]] - includes: Final[list[str]] - no_link_check: Final[Optional[bool]] - container: Final[Optional[str]] - - def __init__( - self, - fetcher: Optional[Fetcher] = None, - namespaces: Optional[dict[str, str]] = None, - schemas: Optional[list[str]] = None, - fileuri: Optional[str] = None, - copyfrom: Optional["LoadingOptions"] = None, - original_doc: Optional[Any] = None, - addl_metadata: Optional[dict[str, str]] = None, - baseuri: Optional[str] = None, - idx: Optional[IdxType] = None, - imports: Optional[list[str]] = None, - includes: Optional[list[str]] = None, - no_link_check: Optional[bool] = None, - container: Optional[str] = None, - ) -> None: - """Create a LoadingOptions object.""" - self.original_doc = original_doc - - if idx is not None: - temp_idx = idx - else: - temp_idx = copyfrom.idx if copyfrom is not None else {} - self.idx = temp_idx - - if fileuri is not None: - temp_fileuri: Optional[str] = fileuri - else: - temp_fileuri = copyfrom.fileuri if copyfrom is not None else None - self.fileuri = temp_fileuri - - if baseuri is not None: - temp_baseuri = baseuri - else: - temp_baseuri = copyfrom.baseuri if copyfrom is not None else "" - self.baseuri = temp_baseuri - - if namespaces is not None: - temp_namespaces: MutableMapping[str, str] = namespaces - else: - temp_namespaces = copyfrom.namespaces if copyfrom is not None else {} - self.namespaces = temp_namespaces - - if schemas is not None: - temp_schemas: MutableSequence[str] = schemas - else: - temp_schemas = copyfrom.schemas if copyfrom is not None else [] - self.schemas = temp_schemas - - if addl_metadata is not None: - temp_addl_metadata: MutableMapping[str, Any] = addl_metadata - else: - temp_addl_metadata = copyfrom.addl_metadata if copyfrom is not None else {} - self.addl_metadata = temp_addl_metadata - - if imports is not None: - temp_imports = imports - else: - temp_imports = copyfrom.imports if copyfrom is not None else [] - self.imports = temp_imports - - if includes is not None: - temp_includes = includes - else: - temp_includes = copyfrom.includes if copyfrom is not None else [] - self.includes = temp_includes - - if no_link_check is not None: - temp_no_link_check: Optional[bool] = no_link_check - else: - temp_no_link_check = copyfrom.no_link_check if copyfrom is not None else False - self.no_link_check = temp_no_link_check - - if container is not None: - temp_container: Optional[str] = container - else: - temp_container = copyfrom.container if copyfrom is not None else None - self.container = temp_container - - if fetcher is not None: - temp_fetcher = fetcher - elif copyfrom is not None: - temp_fetcher = copyfrom.fetcher - else: - import requests - from cachecontrol.caches import SeparateBodyFileCache - from cachecontrol.wrapper import CacheControl - - root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir())) - session = CacheControl( - requests.Session(), - cache=SeparateBodyFileCache(root / ".cache" / "salad"), - ) - temp_fetcher = DefaultFetcher({}, session) - self.fetcher = temp_fetcher - - self.cache = self.fetcher.cache if isinstance(self.fetcher, MemoryCachingFetcher) else {} - - if self.namespaces != {}: - temp_vocab = _vocab.copy() - temp_rvocab = _rvocab.copy() - for k, v in self.namespaces.items(): - temp_vocab[k] = v - temp_rvocab[v] = k - else: - temp_vocab = _vocab - temp_rvocab = _rvocab - self.vocab = temp_vocab - self.rvocab = temp_rvocab - - @property - def graph(self) -> Graph: - """Generate a merged rdflib.Graph from all entries in self.schemas.""" - graph = Graph() - if not self.schemas: - return graph - key: Final = str(hash(tuple(self.schemas))) - if key in self.cache: - return cast(Graph, self.cache[key]) - for schema in self.schemas: - fetchurl = ( - self.fetcher.urljoin(self.fileuri, schema) - if self.fileuri is not None - else pathlib.Path(schema).resolve().as_uri() - ) - if fetchurl not in self.cache or self.cache[fetchurl] is True: - _logger.debug("Getting external schema %s", fetchurl) - try: - content = self.fetcher.fetch_text(fetchurl) - except Exception as e: - _logger.warning("Could not load extension schema %s: %s", fetchurl, str(e)) - continue - newGraph = Graph() - err_msg = "unknown error" - for fmt in ["xml", "turtle"]: - try: - newGraph.parse(data=content, format=fmt, publicID=str(fetchurl)) - self.cache[fetchurl] = newGraph - graph += newGraph - break - except (xml.sax.SAXParseException, TypeError, BadSyntax) as e: - err_msg = str(e) - else: - _logger.warning("Could not load extension schema %s: %s", fetchurl, err_msg) - self.cache[key] = graph - return graph +from schema_salad.utils import yaml_no_ts # requires schema-salad v8.2+ +_vocab: Final[dict[str, str]] = {} +_rvocab: Final[dict[str, str]] = {} -class Saveable(ABC): - """Mark classes than have a save() and fromDoc() function.""" - - @classmethod - @abstractmethod - def fromDoc( - cls, - _doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - ) -> "Saveable": - """Construct this object from the result of yaml.load().""" +@mypyc_attr(native_class=True) +class _Loader(Generic[FieldType], metaclass=ABCMeta): @abstractmethod - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - """Convert this object to a JSON/YAML friendly dictionary.""" - - -def load_field( - val: Union[str, dict[str, str]], - fieldtype: "_Loader", - baseuri: str, - loadingOptions: LoadingOptions, - lc: Optional[list[Any]] = None, -) -> Any: - """Load field.""" - if isinstance(val, MutableMapping): - if "$import" in val: - if loadingOptions.fileuri is None: - raise SchemaSaladException("Cannot load $import without fileuri") - url1: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$import"]) - result, metadata = _document_load_by_url( - fieldtype, - url1, - loadingOptions, - ) - loadingOptions.imports.append(url1) - return result - if "$include" in val: - if loadingOptions.fileuri is None: - raise SchemaSaladException("Cannot load $import without fileuri") - url2: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) - val = loadingOptions.fetcher.fetch_text(url2) - loadingOptions.includes.append(url2) - return fieldtype.load(val, baseuri, loadingOptions, lc=lc) - - -save_type = Optional[Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]] - - -def extract_type(val_type: type[Any]) -> str: - """Take a type of value, and extracts the value as a string.""" - val_str: Final = str(val_type) - return val_str.split("'")[1] - - -def convert_typing(val_type: str) -> str: - """Normalize type names to schema-salad types.""" - if "None" in val_type: - return "null" - if "CommentedSeq" in val_type or "list" in val_type: - return "array" - if "CommentedMap" in val_type or "dict" in val_type: - return "object" - if "False" in val_type or "True" in val_type: - return "boolean" - return val_type - - -def parse_errors(error_message: str) -> tuple[str, str, str]: - """Parse error messages from several loaders into one error message.""" - if not error_message.startswith("Expected"): - return error_message, "", "" - vals: Final = error_message.split("\n") - if len(vals) == 1: - return error_message, "", "" - types1: Final = set() - for val in vals: - individual_vals = val.split(" ") - if val == "": - continue - if individual_vals[1] == "one": - individual_vals = val.split("(")[1].split(",") - for t in individual_vals: - types1.add(t.strip(" ").strip(")\n")) - elif individual_vals[2] == "").replace("'", "")) - elif individual_vals[0] == "Value": - types1.add(individual_vals[-1].strip(".")) - else: - types1.add(individual_vals[1].replace(",", "")) - types2: Final = {val for val in types1 if val != "NoneType"} - if "str" in types2: - types3 = {convert_typing(val) for val in types2 if "'" not in val} - else: - types3 = types2 - to_print = "" - for val in types3: - if "'" in val: - to_print = "value" if len(types3) == 1 else "values" - - if to_print == "": - to_print = "type" if len(types3) == 1 else "types" - - verb_tensage: Final = "is" if len(types3) == 1 else "are" - - return str(types3).replace("{", "(").replace("}", ")").replace("'", ""), to_print, verb_tensage - - -def save( - val: Any, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, -) -> save_type: - if isinstance(val, Saveable): - return val.save(top=top, base_url=base_url, relative_uris=relative_uris) - if isinstance(val, MutableSequence): - return [save(v, top=False, base_url=base_url, relative_uris=relative_uris) for v in val] - if isinstance(val, MutableMapping): - newdict: Final = {} - for key in val: - newdict[key] = save(val[key], top=False, base_url=base_url, relative_uris=relative_uris) - return newdict - if val is None or isinstance(val, (int, float, bool, str)): - return val - raise Exception("Not Saveable: %s" % type(val)) - - -def save_with_metadata( - val: Any, - valLoadingOpts: LoadingOptions, - top: bool = True, - base_url: str = "", - relative_uris: bool = True, -) -> save_type: - """Save and set $namespaces, $schemas, $base and any other metadata fields at the top level.""" - saved_val: Final = save(val, top, base_url, relative_uris) - newdict: MutableMapping[str, Any] = {} - if isinstance(saved_val, MutableSequence): - newdict = {"$graph": saved_val} - elif isinstance(saved_val, MutableMapping): - newdict = saved_val - - if valLoadingOpts.namespaces: - newdict["$namespaces"] = valLoadingOpts.namespaces - if valLoadingOpts.schemas: - newdict["$schemas"] = valLoadingOpts.schemas - if valLoadingOpts.baseuri: - newdict["$base"] = valLoadingOpts.baseuri - for k, v in valLoadingOpts.addl_metadata.items(): - if k not in newdict: - newdict[k] = v - - return newdict - - -def expand_url( - url: str, - base_url: str, - loadingOptions: LoadingOptions, - scoped_id: bool = False, - vocab_term: bool = False, - scoped_ref: Optional[int] = None, -) -> str: - if url in ("@id", "@type"): - return url - - if vocab_term and url in loadingOptions.vocab: - return url - - if bool(loadingOptions.vocab) and ":" in url: - prefix: Final = url.split(":")[0] - if prefix in loadingOptions.vocab: - url = loadingOptions.vocab[prefix] + url[len(prefix) + 1 :] - - split1: Final = urlsplit(url) - - if ( - (bool(split1.scheme) and split1.scheme in loadingOptions.fetcher.supported_schemes()) - or url.startswith("$(") - or url.startswith("${") - ): - pass - elif scoped_id and not bool(split1.fragment): - splitbase1: Final = urlsplit(base_url) - frg: str - if bool(splitbase1.fragment): - frg = splitbase1.fragment + "/" + split1.path - else: - frg = split1.path - pt: Final = splitbase1.path if splitbase1.path != "" else "/" - url = urlunsplit((splitbase1.scheme, splitbase1.netloc, pt, splitbase1.query, frg)) - elif scoped_ref is not None and not bool(split1.fragment): - splitbase2: Final = urlsplit(base_url) - sp = splitbase2.fragment.split("/") - n = scoped_ref - while n > 0 and len(sp) > 0: - sp.pop() - n -= 1 - sp.append(url) - url = urlunsplit( - ( - splitbase2.scheme, - splitbase2.netloc, - splitbase2.path, - splitbase2.query, - "/".join(sp), - ) - ) - else: - url = loadingOptions.fetcher.urljoin(base_url, url) - - if vocab_term: - split2: Final = urlsplit(url) - if bool(split2.scheme): - if url in loadingOptions.rvocab: - return loadingOptions.rvocab[url] - else: - raise ValidationException(f"Term {url!r} not in vocabulary") - - return url - - -class _Loader: def load( self, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: - pass + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: ... -class _AnyLoader(_Loader): +@mypyc_attr(native_class=True) +class _AnyLoader(_Loader[Any]): def load( self, doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, + docRoot: str | None = None, + lc: Any | None = None, ) -> Any: if doc is not None: return doc raise ValidationException("Expected non-null") -class _PrimitiveLoader(_Loader): - def __init__(self, tp: Union[type, tuple[type[str], type[str]]]) -> None: +@mypyc_attr(native_class=True) +class _PrimitiveLoader(_Loader[FieldType]): + def __init__(self, tp: type[FieldType]) -> None: self.tp: Final = tp def load( @@ -463,9 +95,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if not isinstance(doc, self.tp): raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}") return doc @@ -474,8 +106,9 @@ def __repr__(self) -> str: return str(self.tp) -class _ArrayLoader(_Loader): - def __init__(self, items: _Loader) -> None: +@mypyc_attr(native_class=True) +class _ArrayLoader(_Loader[Sequence[FieldType]]): + def __init__(self, items: _Loader[FieldType]) -> None: self.items: Final = items def load( @@ -483,9 +116,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> list[FieldType]: if not isinstance(doc, MutableSequence): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " @@ -496,7 +129,7 @@ def load( fields: Final[list[str]] = [] for i in range(0, len(doc)): try: - lf = load_field( + lf = _load_field( doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc ) flatten = loadingOptions.container != "@list" @@ -531,13 +164,14 @@ def __repr__(self) -> str: return f"array<{self.items}>" -class _MapLoader(_Loader): +@mypyc_attr(native_class=True) +class _MapLoader(_Loader[Mapping[str, FieldType]]): def __init__( self, - values: _Loader, - name: Optional[str] = None, - container: Optional[str] = None, - no_link_check: Optional[bool] = None, + values: _Loader[FieldType], + name: str | None = None, + container: str | None = None, + no_link_check: bool | None = None, ) -> None: self.values: Final = values self.name: Final = name @@ -549,9 +183,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> dict[str, FieldType]: if not isinstance(doc, MutableMapping): raise ValidationException(f"Expected a map, was {type(doc)}") if self.container is not None or self.no_link_check is not None: @@ -562,7 +196,7 @@ def load( errors: Final[list[SchemaSaladException]] = [] for k, v in doc.items(): try: - lf = load_field(v, self.values, baseuri, loadingOptions, lc) + lf = _load_field(v, self.values, baseuri, loadingOptions, lc) r[k] = lf except ValidationException as e: errors.append(e.with_sourceline(SourceLine(doc, k, str))) @@ -574,7 +208,8 @@ def __repr__(self) -> str: return self.name if self.name is not None else f"map" -class _EnumLoader(_Loader): +@mypyc_attr(native_class=True) +class _EnumLoader(_Loader[EnumFieldType]): def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols: Final = symbols self.name: Final = name @@ -584,19 +219,20 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> EnumFieldType: if doc in self.symbols: - return doc + return cast(EnumFieldType, doc) raise ValidationException(f"Expected one of {self.symbols}") def __repr__(self) -> str: return self.name -class _SecondaryDSLLoader(_Loader): - def __init__(self, inner: _Loader) -> None: +@mypyc_attr(native_class=True) +class _SecondaryDSLLoader(_Loader[FieldType]): + def __init__(self, inner: _Loader[FieldType]) -> None: self.inner: Final = inner def load( @@ -604,75 +240,77 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: r: Final[list[dict[str, Any]]] = [] - if isinstance(doc, MutableSequence): - for d in doc: - if isinstance(d, str): - if d.endswith("?"): - r.append({"pattern": d[:-1], "required": False}) - else: - r.append({"pattern": d}) - elif isinstance(d, dict): - new_dict1: dict[str, Any] = {} - dict_copy = copy.deepcopy(d) - if "pattern" in dict_copy: - new_dict1["pattern"] = dict_copy.pop("pattern") - else: - raise ValidationException( - f"Missing pattern in secondaryFiles specification entry: {d}" + match doc: + case MutableSequence() as dlist: + for d in dlist: + if isinstance(d, str): + if d.endswith("?"): + r.append({"pattern": d[:-1], "required": False}) + else: + r.append({"pattern": d}) + elif isinstance(d, dict): + new_dict1: dict[str, Any] = {} + dict_copy = copy.deepcopy(d) + if "pattern" in dict_copy: + new_dict1["pattern"] = dict_copy.pop("pattern") + else: + raise ValidationException( + f"Missing pattern in secondaryFiles specification entry: {d}" + ) + new_dict1["required"] = ( + dict_copy.pop("required") if "required" in dict_copy else None ) - new_dict1["required"] = ( - dict_copy.pop("required") if "required" in dict_copy else None - ) - if len(dict_copy): - raise ValidationException( - "Unallowed values in secondaryFiles specification entry: {}".format( - dict_copy + if len(dict_copy): + raise ValidationException( + "Unallowed values in secondaryFiles specification entry: {}".format( + dict_copy + ) ) - ) - r.append(new_dict1) + r.append(new_dict1) + else: + raise ValidationException( + "Expected a string or sequence of (strings or mappings)." + ) + case MutableMapping() as decl: + new_dict2 = {} + doc_copy = copy.deepcopy(decl) + if "pattern" in doc_copy: + new_dict2["pattern"] = doc_copy.pop("pattern") else: raise ValidationException( - "Expected a string or sequence of (strings or mappings)." + f"Missing pattern in secondaryFiles specification entry: {decl}" ) - elif isinstance(doc, MutableMapping): - new_dict2: Final = {} - doc_copy: Final = copy.deepcopy(doc) - if "pattern" in doc_copy: - new_dict2["pattern"] = doc_copy.pop("pattern") - else: - raise ValidationException( - f"Missing pattern in secondaryFiles specification entry: {doc}" - ) - new_dict2["required"] = doc_copy.pop("required") if "required" in doc_copy else None + new_dict2["required"] = doc_copy.pop("required") if "required" in doc_copy else None - if len(doc_copy): - raise ValidationException( - f"Unallowed values in secondaryFiles specification entry: {doc_copy}" - ) - r.append(new_dict2) + if len(doc_copy): + raise ValidationException( + f"Unallowed values in secondaryFiles specification entry: {doc_copy}" + ) + r.append(new_dict2) - elif isinstance(doc, str): - if doc.endswith("?"): - r.append({"pattern": doc[:-1], "required": False}) - else: - r.append({"pattern": doc}) - else: - raise ValidationException("Expected str or sequence of str") + case str(decl): + if decl.endswith("?"): + r.append({"pattern": decl[:-1], "required": False}) + else: + r.append({"pattern": decl}) + case _: + raise ValidationException("Expected str or sequence of str") return self.inner.load(r, baseuri, loadingOptions, docRoot, lc=lc) -class _RecordLoader(_Loader): +@mypyc_attr(native_class=True) +class _RecordLoader(_Loader[SaveableType]): def __init__( self, - classtype: type[Saveable], - container: Optional[str] = None, - no_link_check: Optional[bool] = None, + classtype: type[SaveableType], + container: str | None = None, + no_link_check: bool | None = None, ) -> None: self.classtype: Final = classtype self.container: Final = container @@ -683,9 +321,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> SaveableType: if not isinstance(doc, MutableMapping): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " @@ -701,7 +339,8 @@ def __repr__(self) -> str: return str(self.classtype.__name__) -class _ExpressionLoader(_Loader): +@mypyc_attr(native_class=True) +class _ExpressionLoader(_Loader[str]): def __init__(self, items: type[str]) -> None: self.items: Final = items @@ -710,23 +349,25 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> str: if not isinstance(doc, str): raise ValidationException( f"Value is a {convert_typing(extract_type(type(doc)))}, " f"but valid type for this field is a str." ) - return doc + else: + return doc -class _UnionLoader(_Loader): - def __init__(self, alternates: Sequence[_Loader], name: Optional[str] = None) -> None: +@mypyc_attr(native_class=True) +class _UnionLoader(_Loader[FieldType]): + def __init__(self, alternates: Sequence[_Loader[FieldType]], name: str | None = None) -> None: self.alternates = alternates self.name: Final = name - def add_loaders(self, loaders: Sequence[_Loader]) -> None: + def add_loaders(self, loaders: Sequence[_Loader[FieldType]]) -> None: self.alternates = tuple(loader for loader in chain(self.alternates, loaders)) def load( @@ -734,9 +375,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: errors: Final = [] if lc is None: @@ -811,14 +452,15 @@ def __repr__(self) -> str: return self.name if self.name is not None else " | ".join(str(a) for a in self.alternates) -class _URILoader(_Loader): +@mypyc_attr(native_class=True) +class _URILoader(_Loader[FieldType]): def __init__( self, - inner: _Loader, + inner: _Loader[FieldType], scoped_id: bool, vocab_term: bool, - scoped_ref: Optional[int], - no_link_check: Optional[bool], + scoped_ref: int | None, + no_link_check: bool | None, ) -> None: self.inner: Final = inner self.scoped_id: Final = scoped_id @@ -831,39 +473,40 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if self.no_link_check is not None: loadingOptions = LoadingOptions( copyfrom=loadingOptions, no_link_check=self.no_link_check ) - if isinstance(doc, MutableSequence): - newdoc: Final = [] - for i in doc: - if isinstance(i, str): - newdoc.append( - expand_url( - i, - baseuri, - loadingOptions, - self.scoped_id, - self.vocab_term, - self.scoped_ref, - ) - ) - else: - newdoc.append(i) - doc = newdoc - elif isinstance(doc, str): - doc = expand_url( - doc, - baseuri, - loadingOptions, - self.scoped_id, - self.vocab_term, - self.scoped_ref, - ) + match doc: + case MutableSequence() as decl: + newdoc: Final = [] + for i in decl: + if isinstance(i, str): + newdoc.append( + _expand_url( + i, + baseuri, + loadingOptions, + self.scoped_id, + self.vocab_term, + self.scoped_ref, + ) + ) + else: + newdoc.append(i) + doc = newdoc + case str(decl): + doc = _expand_url( + decl, + baseuri, + loadingOptions, + self.scoped_id, + self.vocab_term, + self.scoped_ref, + ) if isinstance(doc, str): if not loadingOptions.no_link_check: errors: Final = [] @@ -879,8 +522,14 @@ def load( return self.inner.load(doc, baseuri, loadingOptions, lc=lc) -class _TypeDSLLoader(_Loader): - def __init__(self, inner: _Loader, refScope: Optional[int], salad_version: str) -> None: +@mypyc_attr(native_class=True) +class _TypeDSLLoader(_Loader[FieldType]): + def __init__( + self, + inner: _Loader[FieldType], + refScope: int | None, + salad_version: str, + ) -> None: self.inner: Final = inner self.refScope: Final = refScope self.salad_version: Final = salad_version @@ -890,7 +539,7 @@ def resolve( doc: str, baseuri: str, loadingOptions: LoadingOptions, - ) -> Union[list[Union[dict[str, Any], str]], dict[str, Any], str]: + ) -> list[dict[str, Any] | str] | dict[str, Any] | str: doc_ = doc optional = False if doc_.endswith("?"): @@ -899,21 +548,42 @@ def resolve( if doc_.endswith("[]"): salad_versions: Final = [int(v) for v in self.salad_version[1:].split(".")] - items: Union[list[Union[dict[str, Any], str]], dict[str, Any], str] = "" + items: list[dict[str, Any] | str] | dict[str, Any] | str = "" rest: Final = doc_[0:-2] if salad_versions < [1, 3]: if rest.endswith("[]"): # To show the error message with the original type return doc else: - items = expand_url(rest, baseuri, loadingOptions, False, True, self.refScope) + items = _expand_url( + rest, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) else: items = self.resolve(rest, baseuri, loadingOptions) if isinstance(items, str): - items = expand_url(items, baseuri, loadingOptions, False, True, self.refScope) - expanded: Union[dict[str, Any], str] = {"type": "array", "items": items} + items = _expand_url( + items, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) + expanded: dict[str, Any] | str = {"type": "array", "items": items} else: - expanded = expand_url(doc_, baseuri, loadingOptions, False, True, self.refScope) + expanded = _expand_url( + doc_, + baseuri, + loadingOptions, + False, + True, + self.refScope, + ) if optional: return ["null", expanded] @@ -925,9 +595,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if isinstance(doc, MutableSequence): r: Final[list[Any]] = [] for d in doc: @@ -949,8 +619,10 @@ def load( return self.inner.load(doc, baseuri, loadingOptions, lc=lc) -class _IdMapLoader(_Loader): - def __init__(self, inner: _Loader, mapSubject: str, mapPredicate: Optional[str]) -> None: +class _IdMapLoader(_Loader[FieldType]): + def __init__( + self, inner: _Loader[FieldType], mapSubject: str, mapPredicate: str | None + ) -> None: self.inner: Final = inner self.mapSubject: Final = mapSubject self.mapPredicate: Final = mapPredicate @@ -960,9 +632,9 @@ def load( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - lc: Optional[list[Any]] = None, - ) -> Any: + docRoot: str | None = None, + lc: Any | None = None, + ) -> FieldType: if isinstance(doc, MutableMapping): r: Final[list[Any]] = [] for k in doc.keys(): @@ -989,12 +661,12 @@ def load( def _document_load( - loader: _Loader, - doc: Union[str, MutableMapping[str, Any], MutableSequence[Any]], + loader: _Loader[FieldType], + doc: str | MutableMapping[str, Any] | MutableSequence[Any], baseuri: str, loadingOptions: LoadingOptions, - addl_metadata_fields: Optional[MutableSequence[str]] = None, -) -> tuple[Any, LoadingOptions]: + addl_metadata_fields: MutableSequence[str] | None = None, +) -> tuple[FieldType, LoadingOptions]: if isinstance(doc, str): return _document_load_by_url( loader, @@ -1059,11 +731,11 @@ def _document_load( def _document_load_by_url( - loader: _Loader, + loader: _Loader[FieldType], url: str, loadingOptions: LoadingOptions, - addl_metadata_fields: Optional[MutableSequence[str]] = None, -) -> tuple[Any, LoadingOptions]: + addl_metadata_fields: MutableSequence[str] | None = None, +) -> tuple[FieldType, LoadingOptions]: if url in loadingOptions.idx: return loadingOptions.idx[url] @@ -1089,118 +761,313 @@ def _document_load_by_url( return loadingOptions.idx[url] -def file_uri(path: str, split_frag: bool = False) -> str: - """Transform a file path into a URL with file scheme.""" - if path.startswith("file://"): - return path - if split_frag: - pathsp: Final = path.split("#", 2) - frag = "#" + quote(str(pathsp[1])) if len(pathsp) == 2 else "" - urlpath = pathname2url(str(pathsp[0])) - else: - urlpath = pathname2url(path) - frag = "" - if urlpath.startswith("//"): - return f"file:{urlpath}{frag}" - return f"file://{urlpath}{frag}" - - -def prefix_url(url: str, namespaces: dict[str, str]) -> str: - """Expand short forms into full URLs using the given namespace dictionary.""" - for k, v in namespaces.items(): - if url.startswith(v): - return k + ":" + url[len(v) :] - return url - - -def save_relative_uri( - uri: Any, +def _expand_url( + url: str, base_url: str, - scoped_id: bool, - ref_scope: Optional[int], - relative_uris: bool, -) -> Any: - """Convert any URI to a relative one, obeying the scoping rules.""" - if isinstance(uri, MutableSequence): - return [save_relative_uri(u, base_url, scoped_id, ref_scope, relative_uris) for u in uri] - elif isinstance(uri, str): - if not relative_uris or uri == base_url: - return uri - urisplit: Final = urlsplit(uri) - basesplit: Final = urlsplit(base_url) - if urisplit.scheme == basesplit.scheme and urisplit.netloc == basesplit.netloc: - if urisplit.path != basesplit.path: - p = os.path.relpath(urisplit.path, os.path.dirname(basesplit.path)) - if urisplit.fragment: - p = p + "#" + urisplit.fragment - return p - - basefrag = basesplit.fragment + "/" - if ref_scope: - sp = basefrag.split("/") - i = 0 - while i < ref_scope: - sp.pop() - i += 1 - basefrag = "/".join(sp) - - if urisplit.fragment.startswith(basefrag): - return urisplit.fragment[len(basefrag) :] - return urisplit.fragment - return uri - else: - return save(uri, top=False, base_url=base_url, relative_uris=relative_uris) - - -def shortname(inputid: str) -> str: - """ - Compute the shortname of a fully qualified identifier. - - See https://w3id.org/cwl/v1.2/SchemaSalad.html#Short_names. - """ - parsed_id: Final = urlparse(inputid) - if parsed_id.fragment: - return parsed_id.fragment.split("/")[-1] - return parsed_id.path.split("/")[-1] - - -def parser_info() -> str: - return "org.w3id.cwl.v1_2" - - -class Documented(Saveable): - pass + loadingOptions: LoadingOptions, + scoped_id: bool = False, + vocab_term: bool = False, + scoped_ref: int | None = None, +) -> str: + if url in ("@id", "@type"): + return url + vocab = _vocab | loadingOptions.vocab + if vocab_term and url in vocab: + return url -class RecordField(Documented): - """ - A field of a record. - """ + if bool(vocab) and ":" in url: + prefix: Final = url.split(":")[0] + if prefix in vocab: + url = vocab[prefix] + url[len(prefix) + 1 :] - name: str + split1: Final = urlsplit(url) - def __init__( - self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions + if ( + (bool(split1.scheme) and split1.scheme in loadingOptions.fetcher.supported_schemes()) + or url.startswith("$(") + or url.startswith("${") + ): + pass + elif scoped_id and not bool(split1.fragment): + splitbase1: Final = urlsplit(base_url) + frg: str + if bool(splitbase1.fragment): + frg = splitbase1.fragment + "/" + split1.path else: - self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.type_ = type_ + frg = split1.path + pt: Final = splitbase1.path if splitbase1.path != "" else "/" + url = urlunsplit((splitbase1.scheme, splitbase1.netloc, pt, splitbase1.query, frg)) + elif scoped_ref is not None and not bool(split1.fragment): + splitbase2: Final = urlsplit(base_url) + sp = splitbase2.fragment.split("/") + n = scoped_ref + while n > 0 and len(sp) > 0: + sp.pop() + n -= 1 + sp.append(url) + url = urlunsplit( + ( + splitbase2.scheme, + splitbase2.netloc, + splitbase2.path, + splitbase2.query, + "/".join(sp), + ) + ) + else: + url = loadingOptions.fetcher.urljoin(base_url, url) + + if vocab_term: + split2: Final = urlsplit(url) + if bool(split2.scheme): + if url in (rvocab := _rvocab | loadingOptions.rvocab): + return rvocab[url] + else: + raise ValidationException(f"Term {url!r} not in vocabulary") + + return url + + +def _load_field( + val: Any | None, + fieldtype: _Loader[FieldType], + baseuri: str, + loadingOptions: LoadingOptions, + lc: Any | None = None, +) -> FieldType: + """Load field.""" + if isinstance(val, MutableMapping): + if "$import" in val: + if loadingOptions.fileuri is None: + raise SchemaSaladException("Cannot load $import without fileuri") + url1: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$import"]) + result, metadata = _document_load_by_url( + fieldtype, + url1, + loadingOptions, + ) + loadingOptions.imports.append(url1) + return result + if "$include" in val: + if loadingOptions.fileuri is None: + raise SchemaSaladException("Cannot load $import without fileuri") + url2: Final = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) + val = loadingOptions.fetcher.fetch_text(url2) + loadingOptions.includes.append(url2) + return fieldtype.load(val, baseuri, loadingOptions, lc=lc) + + +def parser_info() -> str: + return "org.w3id.cwl.v1_2" + + +@mypyc_attr(native_class=True) +class CWLArraySchema(schema_salad.metaschema.ArraySchema): + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLArraySchema | CWLRecordSchema | PrimitiveType | Sequence[CWLArraySchema | CWLRecordSchema | PrimitiveType | schema_salad.metaschema.EnumSchema | str] | schema_salad.metaschema.EnumSchema | str, + type_: Array_name, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset(["items", "type"]) + + +@mypyc_attr(native_class=True) +class CWLRecordField(schema_salad.metaschema.RecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, RecordField): + if isinstance(other, CWLRecordField): return bool( self.doc == other.doc and self.name == other.name @@ -1217,8 +1084,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "RecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -1228,7 +1095,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_strtype_True_False_None_None, baseuri, @@ -1273,18 +1140,18 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: + name = "" _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -1332,9 +1199,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2, + typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -1376,7 +1243,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -1384,7 +1251,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -1401,13 +1268,13 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + doc=doc, type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -1422,7 +1289,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.doc is not None: r["doc"] = save( @@ -1441,16 +1308,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type"]) - - -class RecordSchema(Saveable): def __init__( self, - type_: Any, - fields: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLArraySchema | CWLRecordSchema | PrimitiveType | Sequence[CWLArraySchema | CWLRecordSchema | PrimitiveType | schema_salad.metaschema.EnumSchema | str] | schema_salad.metaschema.EnumSchema | str, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -1460,11 +1324,17 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.doc = doc + self.name = name self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["doc", "name", "type"]) + + +@mypyc_attr(native_class=True) +class CWLRecordSchema(schema_salad.metaschema.RecordSchema): def __eq__(self, other: Any) -> bool: - if isinstance(other, RecordSchema): + if isinstance(other, CWLRecordSchema): return bool(self.fields == other.fields and self.type_ == other.type_) return False @@ -1477,8 +1347,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "RecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -1488,9 +1358,9 @@ def fromDoc( fields = None if "fields" in _doc: try: - fields = load_field( + fields = _load_field( _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader, + idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, baseuri, loadingOptions, lc=_doc.get("fields") @@ -1536,7 +1406,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, @@ -1580,7 +1450,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -1588,7 +1458,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -1640,24 +1510,12 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type"]) - - -class EnumSchema(Saveable): - """ - Define an enumerated type. - - """ - - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CWLRecordField] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -1667,21 +1525,76 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.fields = fields self.type_ = type_ + attrs: ClassVar[Collection[str]] = frozenset(["fields", "type"]) + + +@mypyc_attr(native_class=True) +class File(Saveable): + """ + Represents a file (or group of files when ``secondaryFiles`` is provided) that will be accessible by tools using standard POSIX file system call API such as open(2) and read(2). + + Files are represented as objects with ``class`` of ``File``. File objects have a number of properties that provide metadata about the file. + + The ``location`` property of a File is a IRI that uniquely identifies the file. Implementations must support the ``file://`` IRI scheme and may support other schemes such as ``http://`` and ``https://``. The value of ``location`` may also be a relative reference, in which case it must be resolved relative to the IRI of the document it appears in. Alternately to ``location``, implementations must also accept the ``path`` property on File, which must be a filesystem path available on the same host as the CWL runner (for inputs) or the runtime environment of a command line tool execution (for command line tool outputs). + + If no ``location`` or ``path`` is specified, a file object must specify ``contents`` with the UTF-8 text content of the file. This is a "file literal". File literals do not correspond to external resources, but are created on disk with ``contents`` with when needed for executing a tool. Where appropriate, expressions can return file literals to define new files on a runtime. The maximum size of ``contents`` is 64 kilobytes. + + The ``basename`` property defines the filename on disk where the file is staged. This may differ from the resource name. If not provided, ``basename`` must be computed from the last path part of ``location`` and made available to expressions. + + The ``secondaryFiles`` property is a list of File or Directory objects that must be staged in the same directory as the primary file. It is an error for file names to be duplicated in ``secondaryFiles``. + + The ``size`` property is the size in bytes of the File. It must be computed from the resource and made available to expressions. The ``checksum`` field contains a cryptographic hash of the file content for use it verifying file contents. Implementations may, at user option, enable or disable computation of the ``checksum`` field for performance or other reasons. However, the ability to compute output checksums is required to pass the CWL conformance test suite. + + When executing a CommandLineTool, the files and secondary files may be staged to an arbitrary directory, but must use the value of ``basename`` for the filename. The ``path`` property must be file path in the context of the tool execution runtime (local to the compute node, or within the executing container). All computed properties should be available to expressions. File literals also must be staged and ``path`` must be set. + + When collecting CommandLineTool outputs, ``glob`` matching returns file paths (with the ``path`` property) and the derived properties. This can all be modified by ``outputEval``. Alternately, if the file ``cwl.output.json`` is present in the output, ``outputBinding`` is ignored. + + File objects in the output must provide either a ``location`` IRI or a ``path`` property in the context of the tool execution runtime (local to the compute node, or within the executing container). + + When evaluating an ExpressionTool, file objects must be referenced via ``location`` (the expression tool does not have access to files on disk so ``path`` is meaningless) or as file literals. It is legal to return a file object with an existing ``location`` but a different ``basename``. The ``loadContents`` field of ExpressionTool inputs behaves the same as on CommandLineTool inputs, however it is not meaningful on the outputs. + + An ExpressionTool may forward file references from input to output by using the same value for ``location``. + + """ + def __eq__(self, other: Any) -> bool: - if isinstance(other, EnumSchema): + if isinstance(other, File): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ + self.class_ == other.class_ + and self.location == other.location + and self.path == other.path + and self.basename == other.basename + and self.dirname == other.dirname + and self.nameroot == other.nameroot + and self.nameext == other.nameext + and self.checksum == other.checksum + and self.size == other.size + and self.secondaryFiles == other.secondaryFiles + and self.format == other.format + and self.contents == other.contents ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_)) + return hash( + ( + self.class_, + self.location, + self.path, + self.basename, + self.dirname, + self.nameroot, + self.nameext, + self.checksum, + self.size, + self.secondaryFiles, + self.format, + self.contents, + ) + ) @classmethod def fromDoc( @@ -1689,29 +1602,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_File_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + location = None + if "location" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + location = _load_field( + _doc.get("location"), + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("location") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `location`": _errors__.append( ValidationException( str(e), @@ -1719,13 +1649,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("location") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -1737,548 +1667,519 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `location` field with value `{val}` " "is not valid because:", ) ) + path = None + if "path" in _doc: + try: + path = _load_field( + _doc.get("path"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("path") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `path`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + val = _doc.get("path") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + detailed_message=f"the `path` field with value `{val}` " + "is not valid because:", + ) + ) + basename = None + if "basename" in _doc: + try: + basename = _load_field( + _doc.get("basename"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("basename") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("basename") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + detailed_message=f"the `basename` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type"]) - - -class ArraySchema(Saveable): - def __init__( - self, - items: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ArraySchema): - return bool(self.items == other.items and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.items, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ArraySchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) + dirname = None + if "dirname" in _doc: + try: + dirname = _load_field( + _doc.get("dirname"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dirname") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `dirname`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", + val = _doc.get("dirname") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + else: + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [e], + detailed_message=f"the `dirname` field with value `{val}` " + "is not valid because:", + ) + ) + nameroot = None + if "nameroot" in _doc: + try: + nameroot = _load_field( + _doc.get("nameroot"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("nameroot") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `nameroot`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("nameroot") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [e], + detailed_message=f"the `nameroot` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - items=items, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["items", "type"]) - - -class MapSchema(Saveable): - def __init__( - self, - type_: Any, - values: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.type_ = type_ - self.values = values - - def __eq__(self, other: Any) -> bool: - if isinstance(other, MapSchema): - return bool(self.type_ == other.type_ and self.values == other.values) - return False - - def __hash__(self) -> int: - return hash((self.type_, self.values)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MapSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Map_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + nameext = None + if "nameext" in _doc: + try: + nameext = _load_field( + _doc.get("nameext"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("nameext") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `nameext`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("nameext") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("values") is None: - raise ValidationException("missing required field `values`", None, []) - - values = load_field( - _doc.get("values"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("values") - ) + else: + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [e], + detailed_message=f"the `nameext` field with value `{val}` " + "is not valid because:", + ) + ) + checksum = None + if "checksum" in _doc: + try: + checksum = _load_field( + _doc.get("checksum"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("checksum") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `values`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("values") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `checksum`": _errors__.append( ValidationException( - "the `values` field is not valid because:", - SourceLine(_doc, "values", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `values` field is not valid because:", - SourceLine(_doc, "values", str), - [e], - detailed_message=f"the `values` field with value `{val}` " - "is not valid because:", + val = _doc.get("checksum") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + else: + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [e], + detailed_message=f"the `checksum` field with value `{val}` " + "is not valid because:", + ) + ) + size = None + if "size" in _doc: + try: + size = _load_field( + _doc.get("size"), + union_of_None_type_or_inttype_or_longtype, + baseuri, + loadingOptions, + lc=_doc.get("size") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `type`, `values`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - type_=type_, - values=values, + else: + val = _doc.get("size") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + detailed_message=f"the `size` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + contents = None + if "contents" in _doc: + try: + contents = _load_field( + _doc.get("contents"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("contents") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `contents`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("contents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [e], + detailed_message=f"the `contents` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `dirname`, `nameroot`, `nameext`, `checksum`, `size`, `secondaryFiles`, `format`, `contents`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + location=location, + path=path, + basename=basename, + dirname=dirname, + nameroot=nameroot, + nameext=nameext, + checksum=checksum, + size=size, + secondaryFiles=secondaryFiles, + format=format, + contents=contents, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -2295,13 +2196,60 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.location is not None: + u = save_relative_uri(self.location, base_url, False, None, relative_uris) + r["location"] = u + if self.path is not None: + u = save_relative_uri(self.path, base_url, False, None, relative_uris) + r["path"] = u + if self.basename is not None: + r["basename"] = save( + self.basename, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.dirname is not None: + r["dirname"] = save( + self.dirname, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.nameroot is not None: + r["nameroot"] = save( + self.nameroot, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.nameext is not None: + r["nameext"] = save( + self.nameext, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.checksum is not None: + r["checksum"] = save( + self.checksum, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, base_url, True, None, relative_uris) + r["format"] = u + if self.contents is not None: + r["contents"] = save( + self.contents, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.values is not None: - u = save_relative_uri(self.values, base_url, False, 2, relative_uris) - r["values"] = u # top refers to the directory level if top: @@ -2311,16 +2259,21 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["type", "values"]) - - -class UnionSchema(Saveable): def __init__( self, - names: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + location: None | str = None, + path: None | str = None, + basename: None | str = None, + dirname: None | str = None, + nameroot: None | str = None, + nameext: None | str = None, + checksum: None | str = None, + size: None | i32 | i64 = None, + secondaryFiles: None | Sequence[Directory | File] = None, + format: None | str = None, + contents: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2330,215 +2283,77 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.names = names - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, UnionSchema): - return bool(self.names == other.names and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.names, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "UnionSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("names") is None: - raise ValidationException("missing required field `names`", None, []) + self.class_: Final[str] = "File" + self.location = location + self.path = path + self.basename = basename + self.dirname = dirname + self.nameroot = nameroot + self.nameext = nameext + self.checksum = checksum + self.size = size + self.secondaryFiles = secondaryFiles + self.format = format + self.contents = contents - names = load_field( - _doc.get("names"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("names") - ) + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "location", + "path", + "basename", + "dirname", + "nameroot", + "nameext", + "checksum", + "size", + "secondaryFiles", + "format", + "contents", + ] + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `names`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("names") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `names` field is not valid because:", - SourceLine(_doc, "names", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `names` field is not valid because:", - SourceLine(_doc, "names", str), - [e], - detailed_message=f"the `names` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) +@mypyc_attr(native_class=True) +class Directory(Saveable): + """ + Represents a directory to present to a command line tool. - type_ = load_field( - _doc.get("type"), - typedsl_Union_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + Directories are represented as objects with ``class`` of ``Directory``. Directory objects have a number of properties that provide metadata about the directory. - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + The ``location`` property of a Directory is a IRI that uniquely identifies the directory. Implementations must support the file:// IRI scheme and may support other schemes such as http://. Alternately to ``location``, implementations must also accept the ``path`` property on Directory, which must be a filesystem path available on the same host as the CWL runner (for inputs) or the runtime environment of a command line tool execution (for command line tool outputs). - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `names`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) + A Directory object may have a ``listing`` field. This is a list of File and Directory objects that are contained in the Directory. For each entry in ``listing``, the ``basename`` property defines the name of the File or Subdirectory when staged to disk. If ``listing`` is not provided, the implementation must have some way of fetching the Directory listing at runtime based on the ``location`` field. - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - names=names, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed + If a Directory does not have ``location``, it is a Directory literal. A Directory literal must provide ``listing``. Directory literals must be created on disk at runtime as needed. - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + The resources in a Directory literal do not need to have any implied relationship in their ``location``. For example, a Directory listing may contain two files located on different hosts. It is the responsibility of the runtime to ensure that those files are staged to disk appropriately. Secondary files associated with files in ``listing`` must also be staged to the same Directory. - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.names is not None: - u = save_relative_uri(self.names, base_url, False, 2, relative_uris) - r["names"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) + When executing a CommandLineTool, Directories must be recursively staged first and have local values of ``path`` assigned. - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r + Directory objects in CommandLineTool output must provide either a ``location`` IRI or a ``path`` property in the context of the tool execution runtime (local to the compute node, or within the executing container). - attrs = frozenset(["names", "type"]) + An ExpressionTool may forward file references from input to output by using the same value for ``location``. + Name conflicts (the same ``basename`` appearing multiple times in ``listing`` or in any entry in ``secondaryFiles`` in the listing) is a fatal error. -class CWLArraySchema(ArraySchema): - def __init__( - self, - items: Any, - type_: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLArraySchema): - return bool(self.items == other.items and self.type_ == other.type_) + if isinstance(other, Directory): + return bool( + self.class_ == other.class_ + and self.location == other.location + and self.path == other.path + and self.basename == other.basename + and self.listing == other.listing + ) return False def __hash__(self) -> int: - return hash((self.items, self.type_)) + return hash( + (self.class_, self.location, self.path, self.basename, self.listing) + ) @classmethod def fromDoc( @@ -2546,8 +2361,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -2555,102 +2370,211 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + class_ = _load_field( + _doc.get("class"), + uri_Directory_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("class") ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) + raise e + location = None + if "location" in _doc: + try: + location = _load_field( + _doc.get("location"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("location") ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + val = _doc.get("location") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + detailed_message=f"the `location` field with value `{val}` " + "is not valid because:", + ) + ) + path = None + if "path" in _doc: + try: + path = _load_field( + _doc.get("path"), + uri_union_of_None_type_or_strtype_False_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("path") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("path") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + detailed_message=f"the `path` field with value `{val}` " + "is not valid because:", + ) + ) + basename = None + if "basename" in _doc: + try: + basename = _load_field( + _doc.get("basename"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("basename") ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("basename") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + detailed_message=f"the `basename` field with value `{val}` " + "is not valid because:", + ) + ) + listing = None + if "listing" in _doc: + try: + listing = _load_field( + _doc.get("listing"), + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("listing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - extension_fields: dict[str, Any] = {} + else: + val = _doc.get("listing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + detailed_message=f"the `listing` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -2658,14 +2582,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( + "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `listing`".format( k ), SourceLine(_doc, k, str), @@ -2675,8 +2599,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, + location=location, + path=path, + basename=basename, + listing=listing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -2693,12 +2619,29 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.location is not None: + u = save_relative_uri(self.location, base_url, False, None, relative_uris) + r["location"] = u + if self.path is not None: + u = save_relative_uri(self.path, base_url, False, None, relative_uris) + r["path"] = u + if self.basename is not None: + r["basename"] = save( + self.basename, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.listing is not None: + r["listing"] = save( + self.listing, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -2709,19 +2652,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type"]) - - -class CWLRecordField(RecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + location: None | str = None, + path: None | str = None, + basename: None | str = None, + listing: None | Sequence[Directory | File] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2731,21 +2669,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.type_ = type_ + self.class_: Final[str] = "Directory" + self.location = location + self.path = path + self.basename = basename + self.listing = listing + + attrs: ClassVar[Collection[str]] = frozenset( + ["class", "location", "path", "basename", "listing"] + ) + +@mypyc_attr(native_class=True) +class InputBinding(Saveable): def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLRecordField): - return bool( - self.doc == other.doc - and self.name == other.name - and self.type_ == other.type_ - ) + if isinstance(other, InputBinding): + return bool(self.loadContents == other.loadContents) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type_)) + return hash((self.loadContents)) @classmethod def fromDoc( @@ -2753,29 +2696,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + loadContents = None + if "loadContents" in _doc: try: - name = load_field( - _doc.get("name"), - uri_strtype_True_False_None_None, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -2783,13 +2726,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2801,118 +2744,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -2920,14 +2759,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( + "invalid field `{}`, expected one of: `loadContents`".format( k ), SourceLine(_doc, k, str), @@ -2937,13 +2776,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, - name=name, - type_=type_, + loadContents=loadContents, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -2957,16 +2793,12 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -2977,16 +2809,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["doc", "name", "type"]) - - -class CWLRecordSchema(RecordSchema): def __init__( self, - type_: Any, - fields: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -2996,16 +2823,44 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields - self.type_ = type_ + self.loadContents = loadContents + + attrs: ClassVar[Collection[str]] = frozenset(["loadContents"]) + + +@mypyc_attr(native_class=True) +class InputRecordField(CWLRecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CWLRecordSchema): - return bool(self.fields == other.fields and self.type_ == other.type_) + if isinstance(other, InputRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_)) + return hash( + ( + self.doc, + self.name, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + self.loadContents, + self.loadListing, + ) + ) @classmethod def fromDoc( @@ -3013,29 +2868,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CWLRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - fields = None - if "fields" in _doc: + name = None + if "name" in _doc: try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3043,13 +2898,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3061,10 +2916,66 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " + "is not valid because:", + ) + ) + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) @@ -3072,9 +2983,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Record_nameLoader_2, + typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -3116,258 +3027,21 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - fields=fields, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["fields", "type"]) - - -class File(Saveable): - """ - Represents a file (or group of files when `secondaryFiles` is provided) that - will be accessible by tools using standard POSIX file system call API such as - open(2) and read(2). - - Files are represented as objects with `class` of `File`. File objects have - a number of properties that provide metadata about the file. - - The `location` property of a File is a IRI that uniquely identifies the - file. Implementations must support the `file://` IRI scheme and may support - other schemes such as `http://` and `https://`. The value of `location` may also be a - relative reference, in which case it must be resolved relative to the IRI - of the document it appears in. Alternately to `location`, implementations - must also accept the `path` property on File, which must be a filesystem - path available on the same host as the CWL runner (for inputs) or the - runtime environment of a command line tool execution (for command line tool - outputs). - - If no `location` or `path` is specified, a file object must specify - `contents` with the UTF-8 text content of the file. This is a "file - literal". File literals do not correspond to external resources, but are - created on disk with `contents` with when needed for executing a tool. - Where appropriate, expressions can return file literals to define new files - on a runtime. The maximum size of `contents` is 64 kilobytes. - - The `basename` property defines the filename on disk where the file is - staged. This may differ from the resource name. If not provided, - `basename` must be computed from the last path part of `location` and made - available to expressions. - - The `secondaryFiles` property is a list of File or Directory objects that - must be staged in the same directory as the primary file. It is an error - for file names to be duplicated in `secondaryFiles`. - - The `size` property is the size in bytes of the File. It must be computed - from the resource and made available to expressions. The `checksum` field - contains a cryptographic hash of the file content for use it verifying file - contents. Implementations may, at user option, enable or disable - computation of the `checksum` field for performance or other reasons. - However, the ability to compute output checksums is required to pass the - CWL conformance test suite. - - When executing a CommandLineTool, the files and secondary files may be - staged to an arbitrary directory, but must use the value of `basename` for - the filename. The `path` property must be file path in the context of the - tool execution runtime (local to the compute node, or within the executing - container). All computed properties should be available to expressions. - File literals also must be staged and `path` must be set. - - When collecting CommandLineTool outputs, `glob` matching returns file paths - (with the `path` property) and the derived properties. This can all be - modified by `outputEval`. Alternately, if the file `cwl.output.json` is - present in the output, `outputBinding` is ignored. - - File objects in the output must provide either a `location` IRI or a `path` - property in the context of the tool execution runtime (local to the compute - node, or within the executing container). - - When evaluating an ExpressionTool, file objects must be referenced via - `location` (the expression tool does not have access to files on disk so - `path` is meaningless) or as file literals. It is legal to return a file - object with an existing `location` but a different `basename`. The - `loadContents` field of ExpressionTool inputs behaves the same as on - CommandLineTool inputs, however it is not meaningful on the outputs. - - An ExpressionTool may forward file references from input to output by using - the same value for `location`. - - """ - - def __init__( - self, - location: Optional[Any] = None, - path: Optional[Any] = None, - basename: Optional[Any] = None, - dirname: Optional[Any] = None, - nameroot: Optional[Any] = None, - nameext: Optional[Any] = None, - checksum: Optional[Any] = None, - size: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - format: Optional[Any] = None, - contents: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "File" - self.location = location - self.path = path - self.basename = basename - self.dirname = dirname - self.nameroot = nameroot - self.nameext = nameext - self.checksum = checksum - self.size = size - self.secondaryFiles = secondaryFiles - self.format = format - self.contents = contents - - def __eq__(self, other: Any) -> bool: - if isinstance(other, File): - return bool( - self.class_ == other.class_ - and self.location == other.location - and self.path == other.path - and self.basename == other.basename - and self.dirname == other.dirname - and self.nameroot == other.nameroot - and self.nameext == other.nameext - and self.checksum == other.checksum - and self.size == other.size - and self.secondaryFiles == other.secondaryFiles - and self.format == other.format - and self.contents == other.contents - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.location, - self.path, - self.basename, - self.dirname, - self.nameroot, - self.nameext, - self.checksum, - self.size, - self.secondaryFiles, - self.format, - self.contents, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "File": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_File_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - location = None - if "location" in _doc: - try: - location = load_field( - _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("location") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `location`": + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -3375,13 +3049,13 @@ def fromDoc( ) ) else: - val = _doc.get("location") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3393,28 +3067,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `location` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - path = None - if "path" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - path = load_field( - _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None_None, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("path") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `path`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -3422,13 +3096,13 @@ def fromDoc( ) ) else: - val = _doc.get("path") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3440,28 +3114,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `path` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - basename = None - if "basename" in _doc: + streamable = None + if "streamable" in _doc: try: - basename = load_field( - _doc.get("basename"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("basename") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `basename`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -3469,13 +3143,13 @@ def fromDoc( ) ) else: - val = _doc.get("basename") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3487,28 +3161,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `basename` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - dirname = None - if "dirname" in _doc: + format = None + if "format" in _doc: try: - dirname = load_field( - _doc.get("dirname"), - union_of_None_type_or_strtype, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("dirname") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `dirname`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -3516,13 +3190,13 @@ def fromDoc( ) ) else: - val = _doc.get("dirname") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `dirname` field is not valid because:", - SourceLine(_doc, "dirname", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3534,28 +3208,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `dirname` field is not valid because:", - SourceLine(_doc, "dirname", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `dirname` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - nameroot = None - if "nameroot" in _doc: + loadContents = None + if "loadContents" in _doc: try: - nameroot = load_field( - _doc.get("nameroot"), - union_of_None_type_or_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("nameroot") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `nameroot`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -3563,13 +3237,13 @@ def fromDoc( ) ) else: - val = _doc.get("nameroot") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `nameroot` field is not valid because:", - SourceLine(_doc, "nameroot", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3581,28 +3255,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `nameroot` field is not valid because:", - SourceLine(_doc, "nameroot", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `nameroot` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - nameext = None - if "nameext" in _doc: + loadListing = None + if "loadListing" in _doc: try: - nameext = load_field( - _doc.get("nameext"), - union_of_None_type_or_strtype, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("nameext") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `nameext`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -3610,13 +3284,13 @@ def fromDoc( ) ) else: - val = _doc.get("nameext") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `nameext` field is not valid because:", - SourceLine(_doc, "nameext", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3628,28 +3302,213 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `nameext` field is not valid because:", - SourceLine(_doc, "nameext", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `nameext` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) - checksum = None - if "checksum" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + doc=doc, + type_=type_, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + format=format, + loadContents=loadContents, + loadListing=loadListing, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.name, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + name: str, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "doc", + "name", + "type", + "label", + "secondaryFiles", + "streamable", + "format", + "loadContents", + "loadListing", + ] + ) + + +@mypyc_attr(native_class=True) +class InputRecordSchema(CWLRecordSchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InputRecordSchema): + return bool( + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + and self.name == other.name + ) + return False + + def __hash__(self) -> int: + return hash((self.fields, self.type_, self.label, self.doc, self.name)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - checksum = load_field( - _doc.get("checksum"), - union_of_None_type_or_strtype, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("checksum") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `checksum`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3657,13 +3516,13 @@ def fromDoc( ) ) else: - val = _doc.get("checksum") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `checksum` field is not valid because:", - SourceLine(_doc, "checksum", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3675,28 +3534,36 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `checksum` field is not valid because:", - SourceLine(_doc, "checksum", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `checksum` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + fields = None + if "fields" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_inttype, + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("fields") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( str(e), @@ -3704,13 +3571,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("fields") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3722,75 +3589,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `fields` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `secondaryFiles`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) - format = None - if "format" in _doc: + ) + label = None + if "label" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_True_False_None_True, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -3798,13 +3666,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3816,28 +3684,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - contents = None - if "contents" in _doc: + doc = None + if "doc" in _doc: try: - contents = load_field( - _doc.get("contents"), - union_of_None_type_or_strtype, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("contents") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `contents`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -3845,13 +3713,13 @@ def fromDoc( ) ) else: - val = _doc.get("contents") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `contents` field is not valid because:", - SourceLine(_doc, "contents", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3863,14 +3731,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `contents` field is not valid because:", - SourceLine(_doc, "contents", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `contents` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -3878,14 +3746,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `dirname`, `nameroot`, `nameext`, `checksum`, `size`, `secondaryFiles`, `format`, `contents`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( k ), SourceLine(_doc, k, str), @@ -3895,20 +3763,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - location=location, - path=path, - basename=basename, - dirname=dirname, - nameroot=nameroot, - nameext=nameext, - checksum=checksum, - size=size, - secondaryFiles=secondaryFiles, - format=format, - contents=contents, + name=name, + fields=fields, + type_=type_, + label=label, + doc=doc, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -3922,57 +3785,24 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.location is not None: - u = save_relative_uri(self.location, base_url, False, None, relative_uris) - r["location"] = u - if self.path is not None: - u = save_relative_uri(self.path, base_url, False, None, relative_uris) - r["path"] = u - if self.basename is not None: - r["basename"] = save( - self.basename, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.dirname is not None: - r["dirname"] = save( - self.dirname, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.nameroot is not None: - r["nameroot"] = save( - self.nameroot, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.nameext is not None: - r["nameext"] = save( - self.nameext, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.checksum is not None: - r["checksum"] = save( - self.checksum, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.format is not None: - u = save_relative_uri(self.format, base_url, True, None, relative_uris) - r["format"] = u - if self.contents is not None: - r["contents"] = save( - self.contents, top=False, base_url=base_url, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -3983,80 +3813,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "location", - "path", - "basename", - "dirname", - "nameroot", - "nameext", - "checksum", - "size", - "secondaryFiles", - "format", - "contents", - ] - ) - - -class Directory(Saveable): - """ - Represents a directory to present to a command line tool. - - Directories are represented as objects with `class` of `Directory`. Directory objects have - a number of properties that provide metadata about the directory. - - The `location` property of a Directory is a IRI that uniquely identifies - the directory. Implementations must support the file:// IRI scheme and may - support other schemes such as http://. Alternately to `location`, - implementations must also accept the `path` property on Directory, which - must be a filesystem path available on the same host as the CWL runner (for - inputs) or the runtime environment of a command line tool execution (for - command line tool outputs). - - A Directory object may have a `listing` field. This is a list of File and - Directory objects that are contained in the Directory. For each entry in - `listing`, the `basename` property defines the name of the File or - Subdirectory when staged to disk. If `listing` is not provided, the - implementation must have some way of fetching the Directory listing at - runtime based on the `location` field. - - If a Directory does not have `location`, it is a Directory literal. A - Directory literal must provide `listing`. Directory literals must be - created on disk at runtime as needed. - - The resources in a Directory literal do not need to have any implied - relationship in their `location`. For example, a Directory listing may - contain two files located on different hosts. It is the responsibility of - the runtime to ensure that those files are staged to disk appropriately. - Secondary files associated with files in `listing` must also be staged to - the same Directory. - - When executing a CommandLineTool, Directories must be recursively staged - first and have local values of `path` assigned. - - Directory objects in CommandLineTool output must provide either a - `location` IRI or a `path` property in the context of the tool execution - runtime (local to the compute node, or within the executing container). - - An ExpressionTool may forward file references from input to output by using - the same value for `location`. - - Name conflicts (the same `basename` appearing multiple times in `listing` - or in any entry in `secondaryFiles` in the listing) is a fatal error. - - """ - def __init__( self, - location: Optional[Any] = None, - path: Optional[Any] = None, - basename: Optional[Any] = None, - listing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[InputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4066,27 +3831,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "Directory" - self.location = location - self.path = path - self.basename = basename - self.listing = listing + self.fields = fields + self.type_ = type_ + self.label = label + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - def __eq__(self, other: Any) -> bool: - if isinstance(other, Directory): - return bool( - self.class_ == other.class_ - and self.location == other.location - and self.path == other.path - and self.basename == other.basename - and self.listing == other.listing - ) - return False + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name"] + ) - def __hash__(self) -> int: - return hash( - (self.class_, self.location, self.path, self.basename, self.listing) - ) + +@mypyc_attr(native_class=True) +class InputEnumSchema(schema_salad.metaschema.EnumSchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InputEnumSchema): + return bool( + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + ) + return False + + def __hash__(self) -> int: + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -4094,45 +3866,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Directory": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_Directory_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - location = None - if "location" in _doc: + name = None + if "name" in _doc: try: - location = load_field( - _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None_None, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("location") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `location`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -4140,13 +3896,13 @@ def fromDoc( ) ) else: - val = _doc.get("location") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4158,75 +3914,132 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `location` field is not valid because:", - SourceLine(_doc, "location", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `location` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - path = None - if "path" in _doc: - try: - path = load_field( - _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("path") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - if str(e) == "missing required field `path`": + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("path") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) - else: - _errors__.append( - ValidationException( - "the `path` field is not valid because:", - SourceLine(_doc, "path", str), - [e], - detailed_message=f"the `path` field with value `{val}` " - "is not valid because:", - ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Enum_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - basename = None - if "basename" in _doc: + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - basename = load_field( - _doc.get("basename"), + label = _load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("basename") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `basename`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4234,13 +4047,13 @@ def fromDoc( ) ) else: - val = _doc.get("basename") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4252,28 +4065,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `basename` field is not valid because:", - SourceLine(_doc, "basename", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `basename` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - listing = None - if "listing" in _doc: + doc = None + if "doc" in _doc: try: - listing = load_field( - _doc.get("listing"), - union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("listing") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `listing`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4281,13 +4094,13 @@ def fromDoc( ) ) else: - val = _doc.get("listing") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4299,14 +4112,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `listing` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -4314,14 +4127,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `location`, `path`, `basename`, `listing`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), @@ -4331,13 +4144,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - location=location, - path=path, - basename=basename, - listing=listing, + name=name, + symbols=symbols, + type_=type_, + label=label, + doc=doc, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -4351,211 +4166,23 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.location is not None: - u = save_relative_uri(self.location, base_url, False, None, relative_uris) - r["location"] = u - if self.path is not None: - u = save_relative_uri(self.path, base_url, False, None, relative_uris) - r["path"] = u - if self.basename is not None: - r["basename"] = save( - self.basename, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.listing is not None: - r["listing"] = save( - self.listing, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "location", "path", "basename", "listing"]) - - -class Labeled(Saveable): - pass - - -class Identified(Saveable): - pass - - -class IdentifierRequired(Identified): - pass - - -class LoadContents(Saveable): - pass - - -class FieldBase(Labeled): - pass - - -class InputFormat(Saveable): - pass - - -class OutputFormat(Saveable): - pass - - -class Parameter(FieldBase, Documented, IdentifierRequired): - """ - Define an input or output parameter to a process. - - """ - - pass - - -class InputBinding(Saveable): - def __init__( - self, - loadContents: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.loadContents = loadContents - - def __eq__(self, other: Any) -> bool: - if isinstance(other, InputBinding): - return bool(self.loadContents == other.loadContents) - return False - - def __hash__(self) -> int: - return hash((self.loadContents)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputBinding": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - loadContents = None - if "loadContents" in _doc: - try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("loadContents") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadContents`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("loadContents") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], - detailed_message=f"the `loadContents` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `loadContents`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - loadContents=loadContents, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -4566,37 +4193,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["loadContents"]) - - -class IOSchema(Labeled, Documented): - pass - - -class InputSchema(IOSchema): - pass - - -class OutputSchema(IOSchema): - pass - - -class InputRecordField(CWLRecordField, FieldBase, InputFormat, LoadContents): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -4606,45 +4211,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing + self.doc = doc + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc"] + ) + + +@mypyc_attr(native_class=True) +class InputArraySchema(CWLArraySchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputRecordField): + if isinstance(other, InputArraySchema): return bool( - self.doc == other.doc - and self.name == other.name + self.items == other.items and self.type_ == other.type_ and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing + and self.doc == other.doc + and self.name == other.name ) return False def __hash__(self) -> int: - return hash( - ( - self.doc, - self.name, - self.type_, - self.label, - self.secondaryFiles, - self.streamable, - self.format, - self.loadContents, - self.loadListing, - ) - ) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -4652,8 +4246,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -4663,9 +4257,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -4708,68 +4302,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -4814,7 +4408,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -4858,21 +4452,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4880,13 +4474,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4898,28 +4492,175 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + items=items, + type_=type_, + label=label, + doc=doc, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.items is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + items: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + self.label = label + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class OutputRecordField(CWLRecordField): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, OutputRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.doc, + self.name, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -4927,13 +4668,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4945,28 +4686,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4974,13 +4724,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4992,28 +4742,170 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -5021,13 +4913,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5039,28 +4931,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + format = None + if "format" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -5068,13 +4960,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5086,14 +4978,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5101,14 +4993,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`".format( k ), SourceLine(_doc, k, str), @@ -5118,19 +5010,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + doc=doc, type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, format=format, - loadContents=loadContents, - loadListing=loadListing, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -5145,7 +5035,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.doc is not None: r["doc"] = save( @@ -5176,20 +5066,6 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.name, True, None, relative_uris) r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -5199,33 +5075,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "doc", - "name", - "type", - "label", - "secondaryFiles", - "streamable", - "format", - "loadContents", - "loadListing", - ] - ) - - -class InputRecordSchema(CWLRecordSchema, InputSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5235,14 +5095,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.doc = doc + self.name = name self.type_ = type_ self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format + + attrs: ClassVar[Collection[str]] = frozenset( + ["doc", "name", "type", "label", "secondaryFiles", "streamable", "format"] + ) + + +@mypyc_attr(native_class=True) +class OutputRecordSchema(CWLRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputRecordSchema): + if isinstance(other, OutputRecordSchema): return bool( self.fields == other.fields and self.type_ == other.type_ @@ -5261,8 +5132,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -5272,7 +5143,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -5317,20 +5188,19 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name fields = None if "fields" in _doc: try: - fields = load_field( + fields = _load_field( _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, + idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, baseuri, loadingOptions, lc=_doc.get("fields") @@ -5376,7 +5246,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, @@ -5423,7 +5293,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -5470,7 +5340,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -5514,7 +5384,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5522,7 +5392,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -5539,15 +5409,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, fields=fields, type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -5562,7 +5432,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.fields is not None: r["fields"] = save( @@ -5589,21 +5459,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "doc", "name"]) - - -class InputEnumSchema(EnumSchema, InputSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[OutputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5613,14 +5477,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.fields = fields self.type_ = type_ self.label = label self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class OutputEnumSchema(schema_salad.metaschema.EnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputEnumSchema): + if isinstance(other, OutputEnumSchema): return bool( self.name == other.name and self.symbols == other.symbols @@ -5639,8 +5512,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -5650,7 +5523,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -5695,19 +5568,18 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name try: if _doc.get("symbols") is None: raise ValidationException("missing required field `symbols`", None, []) - symbols = load_field( + symbols = _load_field( _doc.get("symbols"), uri_array_of_strtype_True_False_None_None, baseuri, @@ -5755,7 +5627,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, @@ -5802,7 +5674,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -5849,7 +5721,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -5893,7 +5765,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -5901,7 +5773,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -5926,7 +5798,7 @@ def fromDoc( extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -5941,7 +5813,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) @@ -5967,21 +5839,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "doc"]) - - -class InputArraySchema(CWLArraySchema, InputSchema): - name: str - def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -5991,14 +5857,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc"] + ) + + +@mypyc_attr(native_class=True) +class OutputArraySchema(CWLArraySchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, InputArraySchema): + if isinstance(other, OutputArraySchema): return bool( self.items == other.items and self.type_ == other.type_ @@ -6017,8 +5892,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -6028,7 +5903,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -6073,21 +5948,20 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name try: if _doc.get("items") is None: raise ValidationException("missing required field `items`", None, []) - items = load_field( + items = _load_field( _doc.get("items"), - uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, + uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, lc=_doc.get("items") @@ -6133,7 +6007,7 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_Array_nameLoader_2, baseuri, @@ -6180,7 +6054,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -6227,7 +6101,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -6271,7 +6145,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -6279,7 +6153,7 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] @@ -6296,15 +6170,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, items=items, type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -6319,7 +6193,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u if self.items is not None: u = save_relative_uri(self.items, self.name, False, 2, relative_uris) @@ -6345,23 +6219,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "doc", "name"]) - - -class OutputRecordField(CWLRecordField, FieldBase, OutputFormat): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -6371,39 +6237,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.items = items self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class InlineJavascriptRequirement(Saveable): + """ + Indicates that the workflow platform must support inline Javascript expressions. If this requirement is not present, the workflow platform must not perform expression interpolation. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputRecordField): + if isinstance(other, InlineJavascriptRequirement): return bool( - self.doc == other.doc - and self.name == other.name - and self.type_ == other.type_ - and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format + self.class_ == other.class_ + and self.expressionLib == other.expressionLib ) return False def __hash__(self) -> int: - return hash( - ( - self.doc, - self.name, - self.type_, - self.label, - self.secondaryFiles, - self.streamable, - self.format, - ) - ) + return hash((self.class_, self.expressionLib)) @classmethod def fromDoc( @@ -6411,85 +6272,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) + class_ = _load_field( + _doc.get("class"), + uri_InlineJavascriptRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + expressionLib = None + if "expressionLib" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + expressionLib = _load_field( + _doc.get("expressionLib"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("expressionLib") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `expressionLib`": _errors__.append( ValidationException( str(e), @@ -6497,13 +6319,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("expressionLib") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6515,286 +6337,43 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `expressionLib` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + "invalid field `{}`, expected one of: `class`, `expressionLib`".format( + k + ), + SourceLine(_doc, k, str), ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `secondaryFiles`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - doc=doc, - name=name, - type_=type_, - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - format=format, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + expressionLib=expressionLib, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed def save( self, top: bool = False, base_url: str = "", relative_uris: bool = True @@ -6807,38 +6386,23 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.expressionLib is not None: + r["expressionLib"] = save( + self.expressionLib, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) - if self.format is not None: - u = save_relative_uri(self.format, self.name, True, None, relative_uris) - r["format"] = u # top refers to the directory level if top: @@ -6848,23 +6412,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - ["doc", "name", "type", "label", "secondaryFiles", "streamable", "format"] - ) - - -class OutputRecordSchema(CWLRecordSchema, OutputSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + expressionLib: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -6874,25 +6426,30 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields - self.type_ = type_ - self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.class_: Final[str] = "InlineJavascriptRequirement" + self.expressionLib = expressionLib + + attrs: ClassVar[Collection[str]] = frozenset(["class", "expressionLib"]) + + +@mypyc_attr(native_class=True) +class SchemaDefRequirement(Saveable): + """ + This field consists of an array of type definitions which must be used when interpreting the ``inputs`` and ``outputs`` fields. When a ``type`` field contains a IRI, the implementation must check if the type is defined in ``schemaDefs`` and use that definition. If the type is not found in ``schemaDefs``, it is an error. The entries in ``schemaDefs`` must be processed in the order listed such that later schema definitions may refer to earlier schema definitions. + + - **Type definitions are allowed for ``enum`` and ``record`` types only.** + - Type definitions may be shared by defining them in a file and then ``$include``-ing them in the ``types`` field. + - A file can contain a list of type definitions + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputRecordSchema): - return bool( - self.fields == other.fields - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc - and self.name == other.name - ) + if isinstance(other, SchemaDefRequirement): + return bool(self.class_ == other.class_ and self.types == other.types) return False def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.doc, self.name)) + return hash((self.class_, self.types)) @classmethod def fromDoc( @@ -6900,133 +6457,47 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: - try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, - baseuri, - loadingOptions, - lc=_doc.get("fields") - ) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + class_ = _load_field( + _doc.get("class"), + uri_SchemaDefRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - if str(e) == "missing required field `fields`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("fields") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), - [e], - detailed_message=f"the `fields` field with value `{val}` " - "is not valid because:", - ) - ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("types") is None: + raise ValidationException("missing required field `types`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, + types = _load_field( + _doc.get("types"), + array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("types") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `types`": _errors__.append( ValidationException( str(e), @@ -7034,13 +6505,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("types") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7052,108 +6523,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `types` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -7161,14 +6538,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( + "invalid field `{}`, expected one of: `class`, `types`".format( k ), SourceLine(_doc, k, str), @@ -7178,15 +6555,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, - type_=type_, - label=label, - doc=doc, - name=name, + types=types, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7200,24 +6572,19 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.types is not None: + r["types"] = save( + self.types, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7228,21 +6595,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "doc", "name"]) - - -class OutputEnumSchema(EnumSchema, OutputSchema): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + types: Sequence[CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -7252,25 +6609,35 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols - self.type_ = type_ - self.label = label - self.doc = doc + self.class_: Final[str] = "SchemaDefRequirement" + self.types = types + + attrs: ClassVar[Collection[str]] = frozenset(["class", "types"]) + + +@mypyc_attr(native_class=True) +class SecondaryFileSchema(Saveable): + """ + Secondary files are specified using the following micro-DSL for secondary files: + + * If the value is a string, it is transformed to an object with two fields ``pattern`` and ``required`` + * By default, the value of ``required`` is ``null`` (this indicates default behavior, which may be based on the context) + * If the value ends with a question mark ``?`` the question mark is stripped off and the value of the field ``required`` is set to ``False`` + * The remaining value is assigned to the field ``pattern`` + + For implementation details and examples, please see `this section `__ in the Schema Salad specification. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputEnumSchema): + if isinstance(other, SecondaryFileSchema): return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc + self.pattern == other.pattern and self.required == other.required ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_, self.label, self.doc)) + return hash((self.pattern, self.required)) @classmethod def fromDoc( @@ -7278,134 +6645,30 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", - ) - ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("pattern") is None: + raise ValidationException("missing required field `pattern`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Enum_nameLoader_2, + pattern = _load_field( + _doc.get("pattern"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("pattern") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `pattern`": _errors__.append( ValidationException( str(e), @@ -7413,13 +6676,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("pattern") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7431,75 +6694,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `pattern` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: + required = None + if "required" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + required = _load_field( + _doc.get("required"), + union_of_None_type_or_booltype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("required") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `required`": _errors__.append( ValidationException( str(e), @@ -7507,13 +6723,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("required") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7525,14 +6741,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `required` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -7540,14 +6756,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( + "invalid field `{}`, expected one of: `pattern`, `required`".format( k ), SourceLine(_doc, k, str), @@ -7557,15 +6773,11 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - symbols=symbols, - type_=type_, - label=label, - doc=doc, + pattern=pattern, + required=required, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7579,23 +6791,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + if self.pattern is not None: + r["pattern"] = save( + self.pattern, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.required is not None: + r["required"] = save( + self.required, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7606,21 +6808,12 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "doc"]) - - -class OutputArraySchema(CWLArraySchema, OutputSchema): - name: str - def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + pattern: str, + required: None | bool | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -7630,25 +6823,28 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - + self.pattern = pattern + self.required = required + + attrs: ClassVar[Collection[str]] = frozenset(["pattern", "required"]) + + +@mypyc_attr(native_class=True) +class LoadListingRequirement(Saveable): + """ + Specify the desired behavior for loading the ``listing`` field of a Directory object for use by expressions. + + """ + def __eq__(self, other: Any) -> bool: - if isinstance(other, OutputArraySchema): + if isinstance(other, LoadListingRequirement): return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc - and self.name == other.name + self.class_ == other.class_ and self.loadListing == other.loadListing ) return False def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.doc, self.name)) + return hash((self.class_, self.loadListing)) @classmethod def fromDoc( @@ -7656,29 +6852,46 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OutputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_LoadListingRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + loadListing = None + if "loadListing" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("loadListing") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( str(e), @@ -7686,13 +6899,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("loadListing") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7704,38 +6917,148 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `loadListing`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + loadListing=loadListing, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + loadListing: LoadListingEnum | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "LoadListingRequirement" + self.loadListing = loadListing + + attrs: ClassVar[Collection[str]] = frozenset(["class", "loadListing"]) + + +@mypyc_attr(native_class=True) +class EnvironmentDef(Saveable): + """ + Define an environment variable that will be set in the runtime environment by the workflow platform when executing the command line tool. May be the result of executing an expression, such as getting a parameter from input. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, EnvironmentDef): + return bool( + self.envName == other.envName and self.envValue == other.envValue + ) + return False + + def __hash__(self) -> int: + return hash((self.envName, self.envValue)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("envName") is None: + raise ValidationException("missing required field `envName`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, + envName = _load_field( + _doc.get("envName"), + strtype, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("envName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": + if str(e) == "missing required field `envName`": _errors__.append( ValidationException( str(e), @@ -7743,13 +7066,13 @@ def fromDoc( ) ) else: - val = _doc.get("items") + val = _doc.get("envName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7761,29 +7084,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), [e], - detailed_message=f"the `items` field with value `{val}` " + detailed_message=f"the `envName` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("envValue") is None: + raise ValidationException("missing required field `envValue`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, + envValue = _load_field( + _doc.get("envValue"), + union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("envValue") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `envValue`": _errors__.append( ValidationException( str(e), @@ -7791,13 +7114,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("envValue") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7809,141 +7132,43 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `envValue` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( - k - ), - SourceLine(_doc, k, str), + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `envName`, `envValue`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type_=type_, - label=label, - doc=doc, - name=name, + envName=envName, + envValue=envValue, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7957,23 +7182,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.items is not None: - u = save_relative_uri(self.items, self.name, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + if self.envName is not None: + r["envName"] = save( + self.envName, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.envValue is not None: + r["envValue"] = save( + self.envValue, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -7984,78 +7199,77 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "doc", "name"]) - - -class InputParameter(Parameter, InputFormat, LoadContents): - pass - + def __init__( + self, + envName: str, + envValue: str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.envName = envName + self.envValue = envValue -class OutputParameter(Parameter, OutputFormat): - pass + attrs: ClassVar[Collection[str]] = frozenset(["envName", "envValue"]) -class ProcessRequirement(Saveable): +@mypyc_attr(native_class=True) +class CommandLineBinding(InputBinding): """ - A process requirement declares a prerequisite that may or must be fulfilled - before executing a process. See [`Process.hints`](#process) and - [`Process.requirements`](#process). + When listed under ``inputBinding`` in the input schema, the term "value" refers to the corresponding value in the input object. For binding objects listed in ``CommandLineTool.arguments``, the term "value" refers to the effective value after evaluating ``valueFrom``. - Process requirements are the primary mechanism for specifying extensions to - the CWL core specification. - - """ + The binding behavior when building the command line depends on the data type of the value. If there is a mismatch between the type described by the input schema and the effective value, such as resulting from an expression evaluation, an implementation must use the data type of the effective value. - pass + - **string**: Add ``prefix`` and the string to the command line. + - **number**: Add ``prefix`` and decimal representation to command line. -class Process(Identified, Labeled, Documented): - """ + - **boolean**: If true, add ``prefix`` to the command line. If false, add nothing. - The base executable type in CWL is the `Process` object defined by the - document. Note that the `Process` object is abstract and cannot be - directly executed. + - **File**: Add ``prefix`` and the value of ```File.path`` <#File>`__ to the command line. - """ + - **Directory**: Add ``prefix`` and the value of ```Directory.path`` <#Directory>`__ to the command line. - pass + - **array**: If ``itemSeparator`` is specified, add ``prefix`` and the join the array into a single string with ``itemSeparator`` separating the items. Otherwise, first add ``prefix``, then recursively process individual elements. If the array is empty, it does not add anything to command line. + - **object**: Add ``prefix`` only, and recursively add object fields for which ``inputBinding`` is specified. -class InlineJavascriptRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support inline Javascript expressions. - If this requirement is not present, the workflow platform must not perform expression - interpolation. + - **null**: Add nothing. """ - def __init__( - self, - expressionLib: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "InlineJavascriptRequirement" - self.expressionLib = expressionLib - def __eq__(self, other: Any) -> bool: - if isinstance(other, InlineJavascriptRequirement): + if isinstance(other, CommandLineBinding): return bool( - self.class_ == other.class_ - and self.expressionLib == other.expressionLib + self.loadContents == other.loadContents + and self.position == other.position + and self.prefix == other.prefix + and self.separate == other.separate + and self.itemSeparator == other.itemSeparator + and self.valueFrom == other.valueFrom + and self.shellQuote == other.shellQuote ) return False def __hash__(self) -> int: - return hash((self.class_, self.expressionLib)) + return hash( + ( + self.loadContents, + self.position, + self.prefix, + self.separate, + self.itemSeparator, + self.valueFrom, + self.shellQuote, + ) + ) @classmethod def fromDoc( @@ -8063,45 +7277,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InlineJavascriptRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_InlineJavascriptRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - expressionLib = None - if "expressionLib" in _doc: + loadContents = None + if "loadContents" in _doc: try: - expressionLib = load_field( - _doc.get("expressionLib"), - union_of_None_type_or_array_of_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("expressionLib") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `expressionLib`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -8109,13 +7307,13 @@ def fromDoc( ) ) else: - val = _doc.get("expressionLib") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `expressionLib` field is not valid because:", - SourceLine(_doc, "expressionLib", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8127,395 +7325,263 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `expressionLib` field is not valid because:", - SourceLine(_doc, "expressionLib", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `expressionLib` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + position = None + if "position" in _doc: + try: + position = _load_field( + _doc.get("position"), + union_of_None_type_or_inttype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("position") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `position`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `expressionLib`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("position") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [e], + detailed_message=f"the `position` field with value `{val}` " + "is not valid because:", + ) + ) + prefix = None + if "prefix" in _doc: + try: + prefix = _load_field( + _doc.get("prefix"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("prefix") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - expressionLib=expressionLib, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.expressionLib is not None: - r["expressionLib"] = save( - self.expressionLib, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "expressionLib"]) - - -class CommandInputSchema(Saveable): - pass - - -class SchemaDefRequirement(ProcessRequirement): - """ - This field consists of an array of type definitions which must be used when - interpreting the `inputs` and `outputs` fields. When a `type` field - contains a IRI, the implementation must check if the type is defined in - `schemaDefs` and use that definition. If the type is not found in - `schemaDefs`, it is an error. The entries in `schemaDefs` must be - processed in the order listed such that later schema definitions may refer - to earlier schema definitions. - - - **Type definitions are allowed for `enum` and `record` types only.** - - Type definitions may be shared by defining them in a file and then - `$include`-ing them in the `types` field. - - A file can contain a list of type definitions - - """ - - def __init__( - self, - types: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SchemaDefRequirement" - self.types = types - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SchemaDefRequirement): - return bool(self.class_ == other.class_ and self.types == other.types) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.types)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SchemaDefRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_SchemaDefRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("types") is None: - raise ValidationException("missing required field `types`", None, []) - - types = load_field( - _doc.get("types"), - array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("types") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `types`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("types") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `prefix`": _errors__.append( ValidationException( - "the `types` field is not valid because:", - SourceLine(_doc, "types", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("prefix") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [e], + detailed_message=f"the `prefix` field with value `{val}` " + "is not valid because:", + ) + ) + separate = None + if "separate" in _doc: + try: + separate = _load_field( + _doc.get("separate"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("separate") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `separate`": _errors__.append( ValidationException( - "the `types` field is not valid because:", - SourceLine(_doc, "types", str), - [e], - detailed_message=f"the `types` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("separate") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [e], + detailed_message=f"the `separate` field with value `{val}` " + "is not valid because:", + ) + ) + itemSeparator = None + if "itemSeparator" in _doc: + try: + itemSeparator = _load_field( + _doc.get("itemSeparator"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("itemSeparator") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `itemSeparator`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `types`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("itemSeparator") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [e], + detailed_message=f"the `itemSeparator` field with value `{val}` " + "is not valid because:", + ) + ) + valueFrom = None + if "valueFrom" in _doc: + try: + valueFrom = _load_field( + _doc.get("valueFrom"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("valueFrom") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - types=types, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.types is not None: - r["types"] = save( - self.types, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "types"]) - - -class SecondaryFileSchema(Saveable): - """ - Secondary files are specified using the following micro-DSL for secondary files: - - * If the value is a string, it is transformed to an object with two fields - `pattern` and `required` - * By default, the value of `required` is `null` - (this indicates default behavior, which may be based on the context) - * If the value ends with a question mark `?` the question mark is - stripped off and the value of the field `required` is set to `False` - * The remaining value is assigned to the field `pattern` - - For implementation details and examples, please see - [this section](SchemaSalad.html#Domain_Specific_Language_for_secondary_files) - in the Schema Salad specification. - - """ - - def __init__( - self, - pattern: Any, - required: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.pattern = pattern - self.required = required - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SecondaryFileSchema): - return bool( - self.pattern == other.pattern and self.required == other.required - ) - return False - - def __hash__(self) -> int: - return hash((self.pattern, self.required)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SecondaryFileSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("pattern") is None: - raise ValidationException("missing required field `pattern`", None, []) - - pattern = load_field( - _doc.get("pattern"), - union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("pattern") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `pattern`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("pattern") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `valueFrom`": _errors__.append( ValidationException( - "the `pattern` field is not valid because:", - SourceLine(_doc, "pattern", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `pattern` field is not valid because:", - SourceLine(_doc, "pattern", str), - [e], - detailed_message=f"the `pattern` field with value `{val}` " - "is not valid because:", + val = _doc.get("valueFrom") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - required = None - if "required" in _doc: + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + detailed_message=f"the `valueFrom` field with value `{val}` " + "is not valid because:", + ) + ) + shellQuote = None + if "shellQuote" in _doc: try: - required = load_field( - _doc.get("required"), - union_of_None_type_or_booltype_or_ExpressionLoader, + shellQuote = _load_field( + _doc.get("shellQuote"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("required") + lc=_doc.get("shellQuote") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `required`": + if str(e) == "missing required field `shellQuote`": _errors__.append( ValidationException( str(e), @@ -8523,13 +7589,13 @@ def fromDoc( ) ) else: - val = _doc.get("required") + val = _doc.get("shellQuote") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `required` field is not valid because:", - SourceLine(_doc, "required", str), + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8541,14 +7607,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `required` field is not valid because:", - SourceLine(_doc, "required", str), + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), [e], - detailed_message=f"the `required` field with value `{val}` " + detailed_message=f"the `shellQuote` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -8556,14 +7622,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `pattern`, `required`".format( + "invalid field `{}`, expected one of: `loadContents`, `position`, `prefix`, `separate`, `itemSeparator`, `valueFrom`, `shellQuote`".format( k ), SourceLine(_doc, k, str), @@ -8573,8 +7639,13 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - pattern=pattern, - required=required, + loadContents=loadContents, + position=position, + prefix=prefix, + separate=separate, + itemSeparator=itemSeparator, + valueFrom=valueFrom, + shellQuote=shellQuote, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -8591,13 +7662,45 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.pattern is not None: - r["pattern"] = save( - self.pattern, top=False, base_url=base_url, relative_uris=relative_uris + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) - if self.required is not None: - r["required"] = save( - self.required, top=False, base_url=base_url, relative_uris=relative_uris + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.prefix is not None: + r["prefix"] = save( + self.prefix, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.separate is not None: + r["separate"] = save( + self.separate, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.itemSeparator is not None: + r["itemSeparator"] = save( + self.itemSeparator, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.valueFrom is not None: + r["valueFrom"] = save( + self.valueFrom, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.shellQuote is not None: + r["shellQuote"] = save( + self.shellQuote, + top=False, + base_url=base_url, + relative_uris=relative_uris, ) # top refers to the directory level @@ -8608,21 +7711,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["pattern", "required"]) - - -class LoadListingRequirement(ProcessRequirement): - """ - Specify the desired behavior for loading the `listing` field of - a Directory object for use by expressions. - - """ - def __init__( self, - loadListing: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + position: None | i32 | str = None, + prefix: None | str = None, + separate: None | bool = None, + itemSeparator: None | str = None, + valueFrom: None | str = None, + shellQuote: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8632,18 +7731,53 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "LoadListingRequirement" - self.loadListing = loadListing + self.loadContents = loadContents + self.position = position + self.prefix = prefix + self.separate = separate + self.itemSeparator = itemSeparator + self.valueFrom = valueFrom + self.shellQuote = shellQuote + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "loadContents", + "position", + "prefix", + "separate", + "itemSeparator", + "valueFrom", + "shellQuote", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputBinding(Saveable): + """ + Describes how to generate an output parameter based on the files produced by a CommandLineTool. + + The output parameter value is generated by applying these operations in the following order: + + - glob + - loadContents + - outputEval + - secondaryFiles + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, LoadListingRequirement): + if isinstance(other, CommandOutputBinding): return bool( - self.class_ == other.class_ and self.loadListing == other.loadListing + self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.glob == other.glob + and self.outputEval == other.outputEval ) return False def __hash__(self) -> int: - return hash((self.class_, self.loadListing)) + return hash((self.loadContents, self.loadListing, self.glob, self.outputEval)) @classmethod def fromDoc( @@ -8651,34 +7785,65 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "LoadListingRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + loadContents = None + if "loadContents" in _doc: + try: + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("loadContents") + ) - class_ = load_field( - _doc.get("class"), - uri_LoadListingRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("loadContents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + detailed_message=f"the `loadContents` field with value `{val}` " + "is not valid because:", + ) + ) loadListing = None if "loadListing" in _doc: try: - loadListing = load_field( + loadListing = _load_field( _doc.get("loadListing"), union_of_None_type_or_LoadListingEnumLoader, baseuri, @@ -8722,7 +7887,101 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + glob = None + if "glob" in _doc: + try: + glob = _load_field( + _doc.get("glob"), + union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("glob") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `glob`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("glob") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [e], + detailed_message=f"the `glob` field with value `{val}` " + "is not valid because:", + ) + ) + outputEval = None + if "outputEval" in _doc: + try: + outputEval = _load_field( + _doc.get("outputEval"), + union_of_None_type_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputEval") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputEval`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputEval") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [e], + detailed_message=f"the `outputEval` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -8730,14 +7989,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `loadListing`".format( + "invalid field `{}`, expected one of: `loadContents`, `loadListing`, `glob`, `outputEval`".format( k ), SourceLine(_doc, k, str), @@ -8747,7 +8006,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + loadContents=loadContents, loadListing=loadListing, + glob=glob, + outputEval=outputEval, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -8764,14 +8026,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) if self.loadListing is not None: r["loadListing"] = save( self.loadListing, @@ -8779,6 +8040,17 @@ def save( base_url=base_url, relative_uris=relative_uris, ) + if self.glob is not None: + r["glob"] = save( + self.glob, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.outputEval is not None: + r["outputEval"] = save( + self.outputEval, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) # top refers to the directory level if top: @@ -8788,23 +8060,14 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "loadListing"]) - - -class EnvironmentDef(Saveable): - """ - Define an environment variable that will be set in the runtime environment - by the workflow platform when executing the command line tool. May be the - result of executing an expression, such as getting a parameter from input. - - """ - def __init__( self, - envName: Any, - envValue: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + glob: None | Sequence[str] | str = None, + outputEval: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -8814,283 +8077,49 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.envName = envName - self.envValue = envValue + self.loadContents = loadContents + self.loadListing = loadListing + self.glob = glob + self.outputEval = outputEval + + attrs: ClassVar[Collection[str]] = frozenset( + ["loadContents", "loadListing", "glob", "outputEval"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputRecordField(InputRecordField): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, EnvironmentDef): + if isinstance(other, CommandInputRecordField): return bool( - self.envName == other.envName and self.envValue == other.envValue - ) - return False - - def __hash__(self) -> int: - return hash((self.envName, self.envValue)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnvironmentDef": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("envName") is None: - raise ValidationException("missing required field `envName`", None, []) - - envName = load_field( - _doc.get("envName"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("envName") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `envName`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("envName") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `envName` field is not valid because:", - SourceLine(_doc, "envName", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `envName` field is not valid because:", - SourceLine(_doc, "envName", str), - [e], - detailed_message=f"the `envName` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("envValue") is None: - raise ValidationException("missing required field `envValue`", None, []) - - envValue = load_field( - _doc.get("envValue"), - union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("envValue") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `envValue`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("envValue") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `envValue` field is not valid because:", - SourceLine(_doc, "envValue", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `envValue` field is not valid because:", - SourceLine(_doc, "envValue", str), - [e], - detailed_message=f"the `envValue` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `envName`, `envValue`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - envName=envName, - envValue=envValue, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.envName is not None: - r["envName"] = save( - self.envName, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.envValue is not None: - r["envValue"] = save( - self.envValue, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["envName", "envValue"]) - - -class CommandLineBinding(InputBinding): - """ - - When listed under `inputBinding` in the input schema, the term - "value" refers to the corresponding value in the input object. For - binding objects listed in `CommandLineTool.arguments`, the term "value" - refers to the effective value after evaluating `valueFrom`. - - The binding behavior when building the command line depends on the data - type of the value. If there is a mismatch between the type described by - the input schema and the effective value, such as resulting from an - expression evaluation, an implementation must use the data type of the - effective value. - - - **string**: Add `prefix` and the string to the command line. - - - **number**: Add `prefix` and decimal representation to command line. - - - **boolean**: If true, add `prefix` to the command line. If false, add - nothing. - - - **File**: Add `prefix` and the value of - [`File.path`](#File) to the command line. - - - **Directory**: Add `prefix` and the value of - [`Directory.path`](#Directory) to the command line. - - - **array**: If `itemSeparator` is specified, add `prefix` and the join - the array into a single string with `itemSeparator` separating the - items. Otherwise, first add `prefix`, then recursively process - individual elements. - If the array is empty, it does not add anything to command line. - - - **object**: Add `prefix` only, and recursively add object fields for - which `inputBinding` is specified. - - - **null**: Add nothing. - - """ - - def __init__( - self, - loadContents: Optional[Any] = None, - position: Optional[Any] = None, - prefix: Optional[Any] = None, - separate: Optional[Any] = None, - itemSeparator: Optional[Any] = None, - valueFrom: Optional[Any] = None, - shellQuote: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.loadContents = loadContents - self.position = position - self.prefix = prefix - self.separate = separate - self.itemSeparator = itemSeparator - self.valueFrom = valueFrom - self.shellQuote = shellQuote - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandLineBinding): - return bool( - self.loadContents == other.loadContents - and self.position == other.position - and self.prefix == other.prefix - and self.separate == other.separate - and self.itemSeparator == other.itemSeparator - and self.valueFrom == other.valueFrom - and self.shellQuote == other.shellQuote + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + and self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: return hash( ( + self.doc, + self.name, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, self.loadContents, - self.position, - self.prefix, - self.separate, - self.itemSeparator, - self.valueFrom, - self.shellQuote, + self.loadListing, + self.inputBinding, ) ) @@ -9100,29 +8129,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandLineBinding": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - loadContents = None - if "loadContents" in _doc: + name = None + if "name" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + name = _load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -9130,13 +8159,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9148,28 +8177,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - position = None - if "position" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_inttype_or_ExpressionLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -9177,13 +8215,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9195,28 +8233,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - prefix = None - if "prefix" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - prefix = load_field( - _doc.get("prefix"), + label = _load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("prefix") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `prefix`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -9224,13 +8310,13 @@ def fromDoc( ) ) else: - val = _doc.get("prefix") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `prefix` field is not valid because:", - SourceLine(_doc, "prefix", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9242,28 +8328,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `prefix` field is not valid because:", - SourceLine(_doc, "prefix", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `prefix` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - separate = None - if "separate" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - separate = load_field( - _doc.get("separate"), - union_of_None_type_or_booltype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("separate") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `separate`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -9271,13 +8357,13 @@ def fromDoc( ) ) else: - val = _doc.get("separate") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `separate` field is not valid because:", - SourceLine(_doc, "separate", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9289,28 +8375,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `separate` field is not valid because:", - SourceLine(_doc, "separate", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `separate` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - itemSeparator = None - if "itemSeparator" in _doc: + streamable = None + if "streamable" in _doc: try: - itemSeparator = load_field( - _doc.get("itemSeparator"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("itemSeparator") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `itemSeparator`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -9318,13 +8404,13 @@ def fromDoc( ) ) else: - val = _doc.get("itemSeparator") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `itemSeparator` field is not valid because:", - SourceLine(_doc, "itemSeparator", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9336,28 +8422,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `itemSeparator` field is not valid because:", - SourceLine(_doc, "itemSeparator", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `itemSeparator` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + format = None + if "format" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -9365,13 +8451,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9383,28 +8469,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - shellQuote = None - if "shellQuote" in _doc: + loadContents = None + if "loadContents" in _doc: try: - shellQuote = load_field( - _doc.get("shellQuote"), + loadContents = _load_field( + _doc.get("loadContents"), union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("shellQuote") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `shellQuote`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -9412,13 +8498,13 @@ def fromDoc( ) ) else: - val = _doc.get("shellQuote") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `shellQuote` field is not valid because:", - SourceLine(_doc, "shellQuote", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9430,48 +8516,146 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `shellQuote` field is not valid because:", - SourceLine(_doc, "shellQuote", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `shellQuote` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `loadContents`, `position`, `prefix`, `separate`, `itemSeparator`, `valueFrom`, `shellQuote`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - loadContents=loadContents, - position=position, - prefix=prefix, - separate=separate, - itemSeparator=itemSeparator, - valueFrom=valueFrom, - shellQuote=shellQuote, + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`, `inputBinding`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + doc=doc, + type_=type_, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + format=format, + loadContents=loadContents, + loadListing=loadListing, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -9485,44 +8669,57 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.prefix is not None: - r["prefix"] = save( - self.prefix, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.separate is not None: - r["separate"] = save( - self.separate, top=False, base_url=base_url, relative_uris=relative_uris + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - if self.itemSeparator is not None: - r["itemSeparator"] = save( - self.itemSeparator, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, + if self.format is not None: + u = save_relative_uri(self.format, self.name, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) - if self.shellQuote is not None: - r["shellQuote"] = save( - self.shellQuote, + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, top=False, - base_url=base_url, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, relative_uris=relative_uris, ) @@ -9534,42 +8731,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "loadContents", - "position", - "prefix", - "separate", - "itemSeparator", - "valueFrom", - "shellQuote", - ] - ) - - -class CommandOutputBinding(LoadContents): - """ - Describes how to generate an output parameter based on the files produced - by a CommandLineTool. - - The output parameter value is generated by applying these operations in the - following order: - - - glob - - loadContents - - outputEval - - secondaryFiles - - """ - def __init__( self, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - glob: Optional[Any] = None, - outputEval: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -9579,23 +8754,60 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format self.loadContents = loadContents self.loadListing = loadListing - self.glob = glob - self.outputEval = outputEval + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "doc", + "name", + "type", + "label", + "secondaryFiles", + "streamable", + "format", + "loadContents", + "loadListing", + "inputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandInputRecordSchema(InputRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputBinding): + if isinstance(other, CommandInputRecordSchema): return bool( - self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.glob == other.glob - and self.outputEval == other.outputEval + self.fields == other.fields + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + and self.name == other.name + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.loadContents, self.loadListing, self.glob, self.outputEval)) + return hash( + ( + self.fields, + self.type_, + self.label, + self.doc, + self.name, + self.inputBinding, + ) + ) @classmethod def fromDoc( @@ -9603,29 +8815,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputBinding": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - loadContents = None - if "loadContents" in _doc: + name = None + if "name" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -9633,13 +8845,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9651,28 +8863,36 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + fields = None + if "fields" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("fields") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( str(e), @@ -9680,13 +8900,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("fields") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9698,28 +8918,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `fields` field with value `{val}` " "is not valid because:", ) ) - glob = None - if "glob" in _doc: - try: - glob = load_field( - _doc.get("glob"), - union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Record_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("glob") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `glob`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -9727,13 +8995,13 @@ def fromDoc( ) ) else: - val = _doc.get("glob") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `glob` field is not valid because:", - SourceLine(_doc, "glob", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9745,28 +9013,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `glob` field is not valid because:", - SourceLine(_doc, "glob", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `glob` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - outputEval = None - if "outputEval" in _doc: + doc = None + if "doc" in _doc: try: - outputEval = load_field( - _doc.get("outputEval"), - union_of_None_type_or_ExpressionLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("outputEval") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputEval`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -9774,13 +9042,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputEval") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputEval` field is not valid because:", - SourceLine(_doc, "outputEval", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9792,14 +9060,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputEval` field is not valid because:", - SourceLine(_doc, "outputEval", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `outputEval` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + inputBinding = None + if "inputBinding" in _doc: + try: + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -9807,14 +9122,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `loadContents`, `loadListing`, `glob`, `outputEval`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -9824,13 +9139,16 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - loadContents=loadContents, - loadListing=loadListing, - glob=glob, - outputEval=outputEval, + name=name, + fields=fields, + type_=type_, + label=label, + doc=doc, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -9844,29 +9162,30 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.glob is not None: - r["glob"] = save( - self.glob, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.outputEval is not None: - r["outputEval"] = save( - self.outputEval, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) @@ -9878,30 +9197,16 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["loadContents", "loadListing", "glob", "outputEval"]) - - -class CommandLineBindable(Saveable): - pass - - -class CommandInputRecordField(InputRecordField, CommandLineBindable): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CommandInputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -9911,29 +9216,30 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.fields = fields self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing + self.doc = doc + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) self.inputBinding = inputBinding + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputEnumSchema(InputEnumSchema): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputRecordField): + if isinstance(other, CommandInputEnumSchema): return bool( - self.doc == other.doc - and self.name == other.name + self.name == other.name + and self.symbols == other.symbols and self.type_ == other.type_ and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing + and self.doc == other.doc and self.inputBinding == other.inputBinding ) return False @@ -9941,15 +9247,11 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( ( - self.doc, self.name, + self.symbols, self.type_, self.label, - self.secondaryFiles, - self.streamable, - self.format, - self.loadContents, - self.loadListing, + self.doc, self.inputBinding, ) ) @@ -9960,8 +9262,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -9971,9 +9273,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -10016,68 +9318,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("symbols") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + detailed_message=f"the `symbols` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -10122,7 +9424,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -10166,21 +9468,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -10188,13 +9490,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10206,28 +9508,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -10235,13 +9537,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10253,28 +9555,176 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`, `inputBinding`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + symbols=symbols, + type_=type_, + label=label, + doc=doc, + inputBinding=inputBinding, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, self.name, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols + self.type_ = type_ + self.label = label + self.doc = doc + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputArraySchema(InputArraySchema): + name: str + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CommandInputArraySchema): + return bool( + self.items == other.items + and self.type_ == other.type_ + and self.label == other.label + and self.doc == other.doc + and self.name == other.name + and self.inputBinding == other.inputBinding + ) + return False + + def __hash__(self) -> int: + return hash( + (self.items, self.type_, self.label, self.doc, self.name, self.inputBinding) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, + name = _load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -10282,13 +9732,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10300,28 +9750,132 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: + + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -10329,13 +9883,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10347,28 +9901,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + doc = None + if "doc" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -10376,13 +9930,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10394,17 +9948,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) inputBinding = None if "inputBinding" in _doc: try: - inputBinding = load_field( + inputBinding = _load_field( _doc.get("inputBinding"), union_of_None_type_or_CommandLineBindingLoader, baseuri, @@ -10448,7 +10002,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -10456,14 +10010,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `loadContents`, `loadListing`, `inputBinding`".format( + "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -10473,20 +10027,16 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + items=items, type_=type_, label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - format=format, - loadContents=loadContents, - loadListing=loadListing, + doc=doc, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -10501,12 +10051,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.items is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -10515,36 +10064,9 @@ def save( r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.name, True, None, relative_uris) - r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -10562,37 +10084,16 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "doc", - "name", - "type", - "label", - "secondaryFiles", - "streamable", - "format", - "loadContents", - "loadListing", - "inputBinding", - ] - ) - - -class CommandInputRecordSchema( - InputRecordSchema, CommandInputSchema, CommandLineBindable -): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -10602,34 +10103,47 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.items = items self.type_ = type_ self.label = label self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) self.inputBinding = inputBinding + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name", "inputBinding"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputRecordField(OutputRecordField): + name: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputRecordSchema): + if isinstance(other, CommandOutputRecordField): return bool( - self.fields == other.fields + self.doc == other.doc + and self.name == other.name and self.type_ == other.type_ and self.label == other.label - and self.doc == other.doc - and self.name == other.name - and self.inputBinding == other.inputBinding + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.format == other.format + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: return hash( ( - self.fields, - self.type_, - self.label, self.doc, self.name, - self.inputBinding, + self.type_, + self.label, + self.secondaryFiles, + self.streamable, + self.format, + self.outputBinding, ) ) @@ -10639,8 +10153,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -10650,9 +10164,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -10695,29 +10209,29 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: - try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, + name = "" + _errors__.append(ValidationException("missing name")) + else: + baseuri = name + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -10725,13 +10239,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10743,10 +10257,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) @@ -10754,9 +10268,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Record_nameLoader_2, + typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -10801,7 +10315,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -10845,21 +10359,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -10867,13 +10381,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10885,28 +10399,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: + streamable = None + if "streamable" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -10914,13 +10428,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -10932,14 +10446,108 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + outputBinding = None + if "outputBinding" in _doc: + try: + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputBinding") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputBinding") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -10947,14 +10555,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `outputBinding`".format( k ), SourceLine(_doc, k, str), @@ -10964,16 +10572,18 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - fields=fields, + name=name, + doc=doc, type_=type_, label=label, - doc=doc, - name=name, - inputBinding=inputBinding, + secondaryFiles=secondaryFiles, + streamable=streamable, + format=format, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -10988,11 +10598,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) if self.type_ is not None: r["type"] = save( @@ -11002,13 +10612,26 @@ def save( r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.format is not None: + u = save_relative_uri(self.format, self.name, True, None, relative_uris) + r["format"] = u + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, top=False, base_url=self.name, relative_uris=relative_uris, @@ -11022,22 +10645,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["fields", "type", "label", "doc", "name", "inputBinding"]) - - -class CommandInputEnumSchema(InputEnumSchema, CommandInputSchema, CommandLineBindable): - name: str - def __init__( self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + name: str, + type_: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | str, + doc: None | Sequence[str] | str = None, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + format: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11047,36 +10666,46 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols + self.doc = doc + self.name = name self.type_ = type_ self.label = label - self.doc = doc - self.inputBinding = inputBinding + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.format = format + self.outputBinding = outputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "doc", + "name", + "type", + "label", + "secondaryFiles", + "streamable", + "format", + "outputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputRecordSchema(OutputRecordSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputEnumSchema): + if isinstance(other, CommandOutputRecordSchema): return bool( - self.name == other.name - and self.symbols == other.symbols + self.fields == other.fields and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.inputBinding == other.inputBinding + and self.name == other.name ) return False def __hash__(self) -> int: - return hash( - ( - self.name, - self.symbols, - self.type_, - self.label, - self.doc, - self.inputBinding, - ) - ) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -11084,8 +10713,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputEnumSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -11095,7 +10724,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -11140,69 +10769,67 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) + else: + baseuri = name + fields = None + if "fields" in _doc: + try: + fields = _load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, + baseuri, + loadingOptions, + lc=_doc.get("fields") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `fields`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + val = _doc.get("fields") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + detailed_message=f"the `fields` field with value `{val}` " + "is not valid because:", + ) ) - ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Enum_nameLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -11247,7 +10874,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -11294,7 +10921,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -11338,54 +10965,7 @@ def fromDoc( "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -11393,14 +10973,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`, `inputBinding`".format( + "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( k ), SourceLine(_doc, k, str), @@ -11411,15 +10991,14 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( name=name, - symbols=symbols, + fields=fields, type_=type_, label=label, doc=doc, - inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -11434,11 +11013,12 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=self.name, relative_uris=relative_uris + ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -11451,13 +11031,6 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -11467,24 +11040,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type", "label", "doc", "inputBinding"]) - - -class CommandInputArraySchema( - InputArraySchema, CommandInputSchema, CommandLineBindable -): - name: str - def __init__( self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + type_: Record_name, + fields: None | Sequence[CommandOutputRecordField] = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11494,29 +11058,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items + self.fields = fields self.type_ = type_ self.label = label self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + ["fields", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputEnumSchema(OutputEnumSchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputArraySchema): + if isinstance(other, CommandOutputEnumSchema): return bool( - self.items == other.items + self.name == other.name + and self.symbols == other.symbols and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.name == other.name - and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash( - (self.items, self.type_, self.label, self.doc, self.name, self.inputBinding) - ) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -11524,8 +11093,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -11535,7 +11104,7 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -11580,30 +11149,29 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) + else: + baseuri = name try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, + symbols = _load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("items") + lc=_doc.get("symbols") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `items`": + if str(e) == "missing required field `symbols`": _errors__.append( ValidationException( str(e), @@ -11611,13 +11179,13 @@ def fromDoc( ) ) else: - val = _doc.get("items") + val = _doc.get("symbols") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -11629,10 +11197,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), [e], - detailed_message=f"the `items` field with value `{val}` " + detailed_message=f"the `symbols` field with value `{val}` " "is not valid because:", ) ) @@ -11640,9 +11208,9 @@ def fromDoc( if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Array_nameLoader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -11687,7 +11255,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -11734,7 +11302,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -11778,54 +11346,7 @@ def fromDoc( "is not valid because:", ) ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -11833,14 +11354,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), @@ -11850,16 +11371,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, + name=name, + symbols=symbols, type_=type_, label=label, doc=doc, - name=name, - inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -11874,11 +11394,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.items is not None: - u = save_relative_uri(self.items, self.name, False, 2, relative_uris) - r["items"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -11891,13 +11411,6 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) # top refers to the directory level if top: @@ -11907,24 +11420,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type", "label", "doc", "name", "inputBinding"]) - - -class CommandOutputRecordField(OutputRecordField): - name: str - def __init__( self, - name: Any, - type_: Any, - doc: Optional[Any] = None, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - format: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + symbols: Sequence[str], + type_: Enum_name, + name: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -11934,42 +11438,34 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.symbols = symbols self.type_ = type_ self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.format = format - self.outputBinding = outputBinding + self.doc = doc + + attrs: ClassVar[Collection[str]] = frozenset( + ["name", "symbols", "type", "label", "doc"] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputArraySchema(OutputArraySchema): + name: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputRecordField): + if isinstance(other, CommandOutputArraySchema): return bool( - self.doc == other.doc - and self.name == other.name + self.items == other.items and self.type_ == other.type_ and self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.format == other.format - and self.outputBinding == other.outputBinding + and self.doc == other.doc + and self.name == other.name ) return False def __hash__(self) -> int: - return hash( - ( - self.doc, - self.name, - self.type_, - self.label, - self.secondaryFiles, - self.streamable, - self.format, - self.outputBinding, - ) - ) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -11977,8 +11473,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputRecordField": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -11988,9 +11484,9 @@ def fromDoc( name = None if "name" in _doc: try: - name = load_field( + name = _load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -12033,68 +11529,68 @@ def fromDoc( ) ) - __original_name_is_none = name is None if name is None: if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + name = "_:" + str(_uuid__.uuid4()) + else: + baseuri = name + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + items = _load_field( + _doc.get("items"), + uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) - if str(e) == "missing required field `doc`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("items") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + detailed_message=f"the `items` field with value `{val}` " + "is not valid because:", ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -12139,7 +11635,7 @@ def fromDoc( label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -12183,21 +11679,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -12205,13 +11701,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12223,191 +11719,47 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: - try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], - detailed_message=f"the `outputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `doc`, `name`, `type`, `label`, `secondaryFiles`, `streamable`, `format`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - doc=doc, name=name, + items=items, type_=type_, label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - format=format, - outputBinding=outputBinding, + doc=doc, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -12422,12 +11774,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) + u = save_relative_uri(self.name, self.name, True, None, relative_uris) r["name"] = u - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.items is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.name, relative_uris=relative_uris @@ -12436,29 +11787,9 @@ def save( r["label"] = save( self.label, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.format is not None: - u = save_relative_uri(self.format, self.name, True, None, relative_uris) - r["format"] = u - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -12469,32 +11800,15 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "doc", - "name", - "type", - "label", - "secondaryFiles", - "streamable", - "format", - "outputBinding", - ] - ) - - -class CommandOutputRecordSchema(OutputRecordSchema): - name: str - def __init__( self, - type_: Any, - fields: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + items: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | str, + type_: Array_name, + label: None | str = None, + doc: None | Sequence[str] | str = None, + name: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -12504,25 +11818,59 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.fields = fields + self.items = items self.type_ = type_ self.label = label self.doc = doc self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + attrs: ClassVar[Collection[str]] = frozenset( + ["items", "type", "label", "doc", "name"] + ) + + +@mypyc_attr(native_class=True) +class CommandInputParameter(Saveable): + """ + An input parameter for a CommandLineTool. + + """ + + id: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputRecordSchema): + if isinstance(other, CommandInputParameter): return bool( - self.fields == other.fields - and self.type_ == other.type_ - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.name == other.name + and self.id == other.id + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.default == other.default + and self.type_ == other.type_ + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.fields, self.type_, self.label, self.doc, self.name)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.loadContents, + self.loadListing, + self.default, + self.type_, + self.inputBinding, + ) + ) @classmethod def fromDoc( @@ -12530,29 +11878,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputRecordSchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -12560,13 +11908,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12578,37 +11926,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot + id = docRoot else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - fields = None - if "fields" in _doc: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: try: - fields = load_field( - _doc.get("fields"), - idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("fields") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `fields`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -12616,13 +11964,13 @@ def fromDoc( ) ) else: - val = _doc.get("fields") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12634,76 +11982,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `fields` field is not valid because:", - SourceLine(_doc, "fields", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `fields` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Record_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - label = None - if "label" in _doc: + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -12711,13 +12058,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12729,17 +12076,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -12783,154 +12130,68 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + format = None + if "format" in _doc: + try: + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("format") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `fields`, `type`, `label`, `doc`, `name`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - fields=fields, - type_=type_, - label=label, - doc=doc, - name=name, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.fields is not None: - r["fields"] = save( - self.fields, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["fields", "type", "label", "doc", "name"]) - - -class CommandOutputEnumSchema(OutputEnumSchema): - name: str - - def __init__( - self, - symbols: Any, - type_: Any, - name: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.symbols = symbols - self.type_ = type_ - self.label = label - self.doc = doc - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputEnumSchema): - return bool( - self.name == other.name - and self.symbols == other.symbols - and self.type_ == other.type_ - and self.label == other.label - and self.doc == other.doc - ) - return False - - def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type_, self.label, self.doc)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputEnumSchema": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - name = None - if "name" in _doc: + else: + val = _doc.get("format") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + detailed_message=f"the `format` field with value `{val}` " + "is not valid because:", + ) + ) + loadContents = None + if "loadContents" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -12938,13 +12199,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -12956,77 +12217,114 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " "is not valid because:", ) ) + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("symbols") is None: - raise ValidationException("missing required field `symbols`", None, []) - - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("symbols") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `symbols`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("symbols") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": _errors__.append( ValidationException( - "the `symbols` field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - detailed_message=f"the `symbols` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) + else: + val = _doc.get("default") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + detailed_message=f"the `default` field with value `{val}` " + "is not valid because:", + ) + ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), - typedsl_Enum_nameLoader_2, + typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -13068,68 +12366,21 @@ def fromDoc( "is not valid because:", ) ) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: + inputBinding = None + if "inputBinding" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -13137,13 +12388,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13155,14 +12406,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -13170,14 +12421,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -13187,15 +12438,21 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - symbols=symbols, - type_=type_, + id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, doc=doc, + format=format, + loadContents=loadContents, + loadListing=loadListing, + default=default, + type_=type_, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -13209,76 +12466,161 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.label is not None: r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) if self.doc is not None: r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris + self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "symbols", "type", "label", "doc"]) - - -class CommandOutputArraySchema(OutputArraySchema): - name: str - - def __init__( - self, - items: Any, - type_: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - name: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.items = items - self.type_ = type_ - self.label = label - self.doc = doc - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + id: str, + type_: CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | Sequence[CWLType | CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema | str] | stdin | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + default: CWLObjectType | None = None, + inputBinding: CommandLineBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + self.default = default + self.type_ = type_ + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "loadContents", + "loadListing", + "default", + "type", + "inputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandOutputParameter(Saveable): + """ + An output parameter for a CommandLineTool. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputArraySchema): + if isinstance(other, CommandOutputParameter): return bool( - self.items == other.items - and self.type_ == other.type_ - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.name == other.name + and self.id == other.id + and self.format == other.format + and self.type_ == other.type_ + and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.items, self.type_, self.label, self.doc, self.name)) + return hash( + ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.type_, + self.outputBinding, + ) + ) @classmethod def fromDoc( @@ -13286,29 +12628,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputArraySchema": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + id = None + if "id" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -13316,13 +12658,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13334,122 +12676,26 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - __original_name_is_none = name is None - if name is None: + if id is None: if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("items") is None: - raise ValidationException("missing required field `items`", None, []) - - items = load_field( - _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, - baseuri, - loadingOptions, - lc=_doc.get("items") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `items`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("items") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `items` field is not valid because:", - SourceLine(_doc, "items", str), - [e], - detailed_message=f"the `items` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_Array_nameLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) + id = docRoot else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -13493,21 +12739,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -13515,13 +12761,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13533,196 +12779,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `items`, `type`, `label`, `doc`, `name`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - items=items, - type_=type_, - label=label, - doc=doc, - name=name, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.items is not None: - u = save_relative_uri(self.items, self.name, False, 2, relative_uris) - r["items"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["items", "type", "label", "doc", "name"]) - - -class CommandInputParameter(InputParameter): - """ - An input parameter for a CommandLineTool. - """ - - id: str - - def __init__( - self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - default: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing - self.default = default - self.type_ = type_ - self.inputBinding = inputBinding - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandInputParameter): - return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.default == other.default - and self.type_ == other.type_ - and self.inputBinding == other.inputBinding - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.loadContents, - self.loadListing, - self.default, - self.type_, - self.inputBinding, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandInputParameter": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + streamable = None + if "streamable" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -13730,13 +12808,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13748,37 +12826,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + doc = None + if "doc" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -13786,13 +12855,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13804,28 +12873,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + format = None + if "format" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -13833,13 +12902,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -13851,169 +12920,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - loadContents = None - if "loadContents" in _doc: + outputBinding = None + if "outputBinding" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + outputBinding = _load_field( + _doc.get("outputBinding"), + union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("outputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `outputBinding`": _errors__.append( ValidationException( str(e), @@ -14021,13 +12997,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("outputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14039,242 +13015,50 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `outputBinding` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: - try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, - baseuri, - loadingOptions, - lc=_doc.get("loadListing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loadListing`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("loadListing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], - detailed_message=f"the `loadListing` field with value `{val}` " - "is not valid because:", - ) - ) - default = None - if "default" in _doc: - try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, - baseuri, - loadingOptions, - lc=_doc.get("default") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `default`": _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("default") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [e], - detailed_message=f"the `default` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - inputBinding = None - if "inputBinding" in _doc: - try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputBinding") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputBinding`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputBinding") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], - detailed_message=f"the `inputBinding` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`, `outputBinding`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, label=label, secondaryFiles=secondaryFiles, streamable=streamable, doc=doc, - id=id, format=format, - loadContents=loadContents, - loadListing=loadListing, - default=default, type_=type_, - inputBinding=inputBinding, + outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -14289,7 +13073,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.label is not None: r["label"] = save( @@ -14316,31 +13100,13 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, + if self.outputBinding is not None: + r["outputBinding"] = save( + self.outputBinding, top=False, base_url=self.id, relative_uris=relative_uris, @@ -14354,42 +13120,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "loadContents", - "loadListing", - "default", - "type", - "inputBinding", - ] - ) - - -class CommandOutputParameter(OutputParameter): - """ - An output parameter for a CommandLineTool. - """ - - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - outputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | Sequence[CWLType | CommandOutputArraySchema | CommandOutputEnumSchema | CommandOutputRecordSchema | str] | stderr | stdout | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + outputBinding: CommandOutputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -14403,36 +13145,79 @@ def __init__( self.secondaryFiles = secondaryFiles self.streamable = streamable self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.id = id self.format = format self.type_ = type_ self.outputBinding = outputBinding + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "type", + "outputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class CommandLineTool(Saveable): + """ + This defines the schema of the CWL Command Line Tool Description document. + + """ + + id: str + def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandOutputParameter): + if isinstance(other, CommandLineTool): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable + self.id == other.id + and self.label == other.label and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.type_ == other.type_ - and self.outputBinding == other.outputBinding + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.requirements == other.requirements + and self.hints == other.hints + and self.cwlVersion == other.cwlVersion + and self.intent == other.intent + and self.class_ == other.class_ + and self.baseCommand == other.baseCommand + and self.arguments == other.arguments + and self.stdin == other.stdin + and self.stderr == other.stderr + and self.stdout == other.stdout + and self.successCodes == other.successCodes + and self.temporaryFailCodes == other.temporaryFailCodes + and self.permanentFailCodes == other.permanentFailCodes ) return False def __hash__(self) -> int: return hash( ( + self.id, self.label, - self.secondaryFiles, - self.streamable, self.doc, - self.id, - self.format, - self.type_, - self.outputBinding, + self.inputs, + self.outputs, + self.requirements, + self.hints, + self.cwlVersion, + self.intent, + self.class_, + self.baseCommand, + self.arguments, + self.stdin, + self.stderr, + self.stdout, + self.successCodes, + self.temporaryFailCodes, + self.permanentFailCodes, ) ) @@ -14442,8 +13227,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -14453,9 +13238,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -14498,18 +13283,34 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + id = "_:" + str(_uuid__.uuid4()) + else: + baseuri = id + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_CommandLineTool_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -14553,21 +13354,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -14575,13 +13376,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14593,28 +13394,124 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_CommandInputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + detailed_message=f"the `inputs` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_CommandOutputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + detailed_message=f"the `outputs` field with value `{val}` " + "is not valid because:", + ) + ) + requirements = None + if "requirements" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("requirements") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `requirements`": _errors__.append( ValidationException( str(e), @@ -14622,13 +13519,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("requirements") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14640,28 +13537,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `requirements` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + hints = None + if "hints" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -14669,13 +13566,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14687,28 +13584,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + cwlVersion = None + if "cwlVersion" in _doc: try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("cwlVersion") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( str(e), @@ -14716,13 +13613,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("cwlVersion") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14734,76 +13631,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `cwlVersion` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - outputBinding = None - if "outputBinding" in _doc: + intent = None + if "intent" in _doc: try: - outputBinding = load_field( - _doc.get("outputBinding"), - union_of_None_type_or_CommandOutputBindingLoader, + intent = _load_field( + _doc.get("intent"), + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("outputBinding") + lc=_doc.get("intent") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputBinding`": + if str(e) == "missing required field `intent`": _errors__.append( ValidationException( str(e), @@ -14811,13 +13660,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputBinding") + val = _doc.get("intent") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -14829,259 +13678,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputBinding` field is not valid because:", - SourceLine(_doc, "outputBinding", str), + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), [e], - detailed_message=f"the `outputBinding` field with value `{val}` " + detailed_message=f"the `intent` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`, `outputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - type_=type_, - outputBinding=outputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputBinding is not None: - r["outputBinding"] = save( - self.outputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "type", - "outputBinding", - ] - ) - - -class CommandLineTool(Process): - """ - This defines the schema of the CWL Command Line Tool Description document. - - """ - - id: str - - def __init__( - self, - inputs: Any, - outputs: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - intent: Optional[Any] = None, - baseCommand: Optional[Any] = None, - arguments: Optional[Any] = None, - stdin: Optional[Any] = None, - stderr: Optional[Any] = None, - stdout: Optional[Any] = None, - successCodes: Optional[Any] = None, - temporaryFailCodes: Optional[Any] = None, - permanentFailCodes: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.intent = intent - self.class_ = "CommandLineTool" - self.baseCommand = baseCommand - self.arguments = arguments - self.stdin = stdin - self.stderr = stderr - self.stdout = stdout - self.successCodes = successCodes - self.temporaryFailCodes = temporaryFailCodes - self.permanentFailCodes = permanentFailCodes - - def __eq__(self, other: Any) -> bool: - if isinstance(other, CommandLineTool): - return bool( - self.id == other.id - and self.label == other.label - and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.intent == other.intent - and self.class_ == other.class_ - and self.baseCommand == other.baseCommand - and self.arguments == other.arguments - and self.stdin == other.stdin - and self.stderr == other.stderr - and self.stdout == other.stdout - and self.successCodes == other.successCodes - and self.temporaryFailCodes == other.temporaryFailCodes - and self.permanentFailCodes == other.permanentFailCodes - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.id, - self.label, - self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.intent, - self.class_, - self.baseCommand, - self.arguments, - self.stdin, - self.stderr, - self.stdout, - self.successCodes, - self.temporaryFailCodes, - self.permanentFailCodes, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CommandLineTool": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + baseCommand = None + if "baseCommand" in _doc: try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + baseCommand = _load_field( + _doc.get("baseCommand"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("baseCommand") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `baseCommand`": _errors__.append( ValidationException( str(e), @@ -15089,13 +13707,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("baseCommand") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15107,53 +13725,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `baseCommand` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_CommandLineTool_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - label = None - if "label" in _doc: + arguments = None + if "arguments" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + arguments = _load_field( + _doc.get("arguments"), + union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("arguments") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `arguments`": _errors__.append( ValidationException( str(e), @@ -15161,13 +13754,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("arguments") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15179,28 +13772,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `arguments` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + stdin = None + if "stdin" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + stdin = _load_field( + _doc.get("stdin"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("stdin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `stdin`": _errors__.append( ValidationException( str(e), @@ -15208,13 +13801,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("stdin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15226,124 +13819,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `stdin` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_CommandInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_CommandOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + stderr = None + if "stderr" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, + stderr = _load_field( + _doc.get("stderr"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("stderr") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `stderr`": _errors__.append( ValidationException( str(e), @@ -15351,13 +13848,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("stderr") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15369,28 +13866,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `stderr` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + stdout = None + if "stdout" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, + stdout = _load_field( + _doc.get("stdout"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("stdout") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `stdout`": _errors__.append( ValidationException( str(e), @@ -15398,13 +13895,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("stdout") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15416,28 +13913,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `stdout` field with value `{val}` " "is not valid because:", ) ) - cwlVersion = None - if "cwlVersion" in _doc: + successCodes = None + if "successCodes" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + successCodes = _load_field( + _doc.get("successCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("successCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `successCodes`": _errors__.append( ValidationException( str(e), @@ -15445,13 +13942,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("successCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15463,28 +13960,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `successCodes` field with value `{val}` " "is not valid because:", ) ) - intent = None - if "intent" in _doc: + temporaryFailCodes = None + if "temporaryFailCodes" in _doc: try: - intent = load_field( - _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None_None, + temporaryFailCodes = _load_field( + _doc.get("temporaryFailCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("intent") + lc=_doc.get("temporaryFailCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `intent`": + if str(e) == "missing required field `temporaryFailCodes`": _errors__.append( ValidationException( str(e), @@ -15492,13 +13989,13 @@ def fromDoc( ) ) else: - val = _doc.get("intent") + val = _doc.get("temporaryFailCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15510,28 +14007,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), [e], - detailed_message=f"the `intent` field with value `{val}` " + detailed_message=f"the `temporaryFailCodes` field with value `{val}` " "is not valid because:", ) ) - baseCommand = None - if "baseCommand" in _doc: + permanentFailCodes = None + if "permanentFailCodes" in _doc: try: - baseCommand = load_field( - _doc.get("baseCommand"), - union_of_None_type_or_strtype_or_array_of_strtype, + permanentFailCodes = _load_field( + _doc.get("permanentFailCodes"), + union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, - lc=_doc.get("baseCommand") + lc=_doc.get("permanentFailCodes") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `baseCommand`": + if str(e) == "missing required field `permanentFailCodes`": _errors__.append( ValidationException( str(e), @@ -15539,13 +14036,13 @@ def fromDoc( ) ) else: - val = _doc.get("baseCommand") + val = _doc.get("permanentFailCodes") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `baseCommand` field is not valid because:", - SourceLine(_doc, "baseCommand", str), + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -15557,2052 +14054,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `baseCommand` field is not valid because:", - SourceLine(_doc, "baseCommand", str), + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), [e], - detailed_message=f"the `baseCommand` field with value `{val}` " + detailed_message=f"the `permanentFailCodes` field with value `{val}` " "is not valid because:", ) ) - arguments = None - if "arguments" in _doc: - try: - arguments = load_field( - _doc.get("arguments"), - union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, - baseuri, - loadingOptions, - lc=_doc.get("arguments") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `arguments`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("arguments") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `arguments` field is not valid because:", - SourceLine(_doc, "arguments", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `arguments` field is not valid because:", - SourceLine(_doc, "arguments", str), - [e], - detailed_message=f"the `arguments` field with value `{val}` " - "is not valid because:", - ) - ) - stdin = None - if "stdin" in _doc: - try: - stdin = load_field( - _doc.get("stdin"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stdin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stdin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stdin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stdin` field is not valid because:", - SourceLine(_doc, "stdin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stdin` field is not valid because:", - SourceLine(_doc, "stdin", str), - [e], - detailed_message=f"the `stdin` field with value `{val}` " - "is not valid because:", - ) - ) - stderr = None - if "stderr" in _doc: - try: - stderr = load_field( - _doc.get("stderr"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stderr") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stderr`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stderr") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stderr` field is not valid because:", - SourceLine(_doc, "stderr", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stderr` field is not valid because:", - SourceLine(_doc, "stderr", str), - [e], - detailed_message=f"the `stderr` field with value `{val}` " - "is not valid because:", - ) - ) - stdout = None - if "stdout" in _doc: - try: - stdout = load_field( - _doc.get("stdout"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("stdout") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `stdout`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("stdout") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `stdout` field is not valid because:", - SourceLine(_doc, "stdout", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `stdout` field is not valid because:", - SourceLine(_doc, "stdout", str), - [e], - detailed_message=f"the `stdout` field with value `{val}` " - "is not valid because:", - ) - ) - successCodes = None - if "successCodes" in _doc: - try: - successCodes = load_field( - _doc.get("successCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("successCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `successCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("successCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `successCodes` field is not valid because:", - SourceLine(_doc, "successCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `successCodes` field is not valid because:", - SourceLine(_doc, "successCodes", str), - [e], - detailed_message=f"the `successCodes` field with value `{val}` " - "is not valid because:", - ) - ) - temporaryFailCodes = None - if "temporaryFailCodes" in _doc: - try: - temporaryFailCodes = load_field( - _doc.get("temporaryFailCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("temporaryFailCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `temporaryFailCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("temporaryFailCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `temporaryFailCodes` field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `temporaryFailCodes` field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [e], - detailed_message=f"the `temporaryFailCodes` field with value `{val}` " - "is not valid because:", - ) - ) - permanentFailCodes = None - if "permanentFailCodes" in _doc: - try: - permanentFailCodes = load_field( - _doc.get("permanentFailCodes"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("permanentFailCodes") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `permanentFailCodes`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("permanentFailCodes") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `permanentFailCodes` field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `permanentFailCodes` field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [e], - detailed_message=f"the `permanentFailCodes` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `baseCommand`, `arguments`, `stdin`, `stderr`, `stdout`, `successCodes`, `temporaryFailCodes`, `permanentFailCodes`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - label=label, - doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - intent=intent, - baseCommand=baseCommand, - arguments=arguments, - stdin=stdin, - stderr=stderr, - stdout=stdout, - successCodes=successCodes, - temporaryFailCodes=temporaryFailCodes, - permanentFailCodes=permanentFailCodes, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.intent is not None: - u = save_relative_uri(self.intent, self.id, True, None, relative_uris) - r["intent"] = u - if self.baseCommand is not None: - r["baseCommand"] = save( - self.baseCommand, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.arguments is not None: - r["arguments"] = save( - self.arguments, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stdin is not None: - r["stdin"] = save( - self.stdin, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stderr is not None: - r["stderr"] = save( - self.stderr, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.stdout is not None: - r["stdout"] = save( - self.stdout, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.successCodes is not None: - r["successCodes"] = save( - self.successCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.temporaryFailCodes is not None: - r["temporaryFailCodes"] = save( - self.temporaryFailCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.permanentFailCodes is not None: - r["permanentFailCodes"] = save( - self.permanentFailCodes, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "intent", - "class", - "baseCommand", - "arguments", - "stdin", - "stderr", - "stdout", - "successCodes", - "temporaryFailCodes", - "permanentFailCodes", - ] - ) - - -class DockerRequirement(ProcessRequirement): - """ - Indicates that a workflow component should be run in a - [Docker](https://docker.com) or Docker-compatible (such as - [Singularity](https://www.sylabs.io/) and [udocker](https://github.com/indigo-dc/udocker)) container environment and - specifies how to fetch or build the image. - - If a CommandLineTool lists `DockerRequirement` under - `hints` (or `requirements`), it may (or must) be run in the specified Docker - container. - - The platform must first acquire or install the correct Docker image as - specified by `dockerPull`, `dockerImport`, `dockerLoad` or `dockerFile`. - - The platform must execute the tool in the container using `docker run` with - the appropriate Docker image and tool command line. - - The workflow platform may provide input files and the designated output - directory through the use of volume bind mounts. The platform should rewrite - file paths in the input object to correspond to the Docker bind mounted - locations. That is, the platform should rewrite values in the parameter context - such as `runtime.outdir`, `runtime.tmpdir` and others to be valid paths - within the container. The platform must ensure that `runtime.outdir` and - `runtime.tmpdir` are distinct directories. - - When running a tool contained in Docker, the workflow platform must not - assume anything about the contents of the Docker container, such as the - presence or absence of specific software, except to assume that the - generated command line represents a valid command within the runtime - environment of the container. - - A container image may specify an - [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) - and/or - [CMD](https://docs.docker.com/engine/reference/builder/#cmd). - Command line arguments will be appended after all elements of - ENTRYPOINT, and will override all elements specified using CMD (in - other words, CMD is only used when the CommandLineTool definition - produces an empty command line). - - Use of implicit ENTRYPOINT or CMD are discouraged due to reproducibility - concerns of the implicit hidden execution point (For further discussion, see - [https://doi.org/10.12688/f1000research.15140.1](https://doi.org/10.12688/f1000research.15140.1)). Portable - CommandLineTool wrappers in which use of a container is optional must not rely on ENTRYPOINT or CMD. - CommandLineTools which do rely on ENTRYPOINT or CMD must list `DockerRequirement` in the - `requirements` section. - - ## Interaction with other requirements - - If [EnvVarRequirement](#EnvVarRequirement) is specified alongside a - DockerRequirement, the environment variables must be provided to Docker - using `--env` or `--env-file` and interact with the container's preexisting - environment as defined by Docker. - - """ - - def __init__( - self, - dockerPull: Optional[Any] = None, - dockerLoad: Optional[Any] = None, - dockerFile: Optional[Any] = None, - dockerImport: Optional[Any] = None, - dockerImageId: Optional[Any] = None, - dockerOutputDirectory: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "DockerRequirement" - self.dockerPull = dockerPull - self.dockerLoad = dockerLoad - self.dockerFile = dockerFile - self.dockerImport = dockerImport - self.dockerImageId = dockerImageId - self.dockerOutputDirectory = dockerOutputDirectory - - def __eq__(self, other: Any) -> bool: - if isinstance(other, DockerRequirement): - return bool( - self.class_ == other.class_ - and self.dockerPull == other.dockerPull - and self.dockerLoad == other.dockerLoad - and self.dockerFile == other.dockerFile - and self.dockerImport == other.dockerImport - and self.dockerImageId == other.dockerImageId - and self.dockerOutputDirectory == other.dockerOutputDirectory - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.class_, - self.dockerPull, - self.dockerLoad, - self.dockerFile, - self.dockerImport, - self.dockerImageId, - self.dockerOutputDirectory, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "DockerRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_DockerRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - dockerPull = None - if "dockerPull" in _doc: - try: - dockerPull = load_field( - _doc.get("dockerPull"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerPull") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerPull`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerPull") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerPull` field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerPull` field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [e], - detailed_message=f"the `dockerPull` field with value `{val}` " - "is not valid because:", - ) - ) - dockerLoad = None - if "dockerLoad" in _doc: - try: - dockerLoad = load_field( - _doc.get("dockerLoad"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerLoad") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerLoad`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerLoad") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerLoad` field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerLoad` field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [e], - detailed_message=f"the `dockerLoad` field with value `{val}` " - "is not valid because:", - ) - ) - dockerFile = None - if "dockerFile" in _doc: - try: - dockerFile = load_field( - _doc.get("dockerFile"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerFile") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerFile`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerFile") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerFile` field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerFile` field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [e], - detailed_message=f"the `dockerFile` field with value `{val}` " - "is not valid because:", - ) - ) - dockerImport = None - if "dockerImport" in _doc: - try: - dockerImport = load_field( - _doc.get("dockerImport"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerImport") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerImport`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerImport") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerImport` field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerImport` field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [e], - detailed_message=f"the `dockerImport` field with value `{val}` " - "is not valid because:", - ) - ) - dockerImageId = None - if "dockerImageId" in _doc: - try: - dockerImageId = load_field( - _doc.get("dockerImageId"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerImageId") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerImageId`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerImageId") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerImageId` field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerImageId` field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [e], - detailed_message=f"the `dockerImageId` field with value `{val}` " - "is not valid because:", - ) - ) - dockerOutputDirectory = None - if "dockerOutputDirectory" in _doc: - try: - dockerOutputDirectory = load_field( - _doc.get("dockerOutputDirectory"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("dockerOutputDirectory") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `dockerOutputDirectory`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("dockerOutputDirectory") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `dockerOutputDirectory` field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `dockerOutputDirectory` field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [e], - detailed_message=f"the `dockerOutputDirectory` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `dockerPull`, `dockerLoad`, `dockerFile`, `dockerImport`, `dockerImageId`, `dockerOutputDirectory`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - dockerPull=dockerPull, - dockerLoad=dockerLoad, - dockerFile=dockerFile, - dockerImport=dockerImport, - dockerImageId=dockerImageId, - dockerOutputDirectory=dockerOutputDirectory, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.dockerPull is not None: - r["dockerPull"] = save( - self.dockerPull, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerLoad is not None: - r["dockerLoad"] = save( - self.dockerLoad, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerFile is not None: - r["dockerFile"] = save( - self.dockerFile, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerImport is not None: - r["dockerImport"] = save( - self.dockerImport, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerImageId is not None: - r["dockerImageId"] = save( - self.dockerImageId, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.dockerOutputDirectory is not None: - r["dockerOutputDirectory"] = save( - self.dockerOutputDirectory, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "class", - "dockerPull", - "dockerLoad", - "dockerFile", - "dockerImport", - "dockerImageId", - "dockerOutputDirectory", - ] - ) - - -class SoftwareRequirement(ProcessRequirement): - """ - A list of software packages that should be configured in the environment of - the defined process. - - """ - - def __init__( - self, - packages: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "SoftwareRequirement" - self.packages = packages - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SoftwareRequirement): - return bool(self.class_ == other.class_ and self.packages == other.packages) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.packages)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SoftwareRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_SoftwareRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("packages") is None: - raise ValidationException("missing required field `packages`", None, []) - - packages = load_field( - _doc.get("packages"), - idmap_packages_array_of_SoftwarePackageLoader, - baseuri, - loadingOptions, - lc=_doc.get("packages") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `packages`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("packages") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `packages` field is not valid because:", - SourceLine(_doc, "packages", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `packages` field is not valid because:", - SourceLine(_doc, "packages", str), - [e], - detailed_message=f"the `packages` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `packages`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - packages=packages, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.packages is not None: - r["packages"] = save( - self.packages, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "packages"]) - - -class SoftwarePackage(Saveable): - def __init__( - self, - package: Any, - version: Optional[Any] = None, - specs: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.package = package - self.version = version - self.specs = specs - - def __eq__(self, other: Any) -> bool: - if isinstance(other, SoftwarePackage): - return bool( - self.package == other.package - and self.version == other.version - and self.specs == other.specs - ) - return False - - def __hash__(self) -> int: - return hash((self.package, self.version, self.specs)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SoftwarePackage": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("package") is None: - raise ValidationException("missing required field `package`", None, []) - - package = load_field( - _doc.get("package"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("package") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `package`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("package") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `package` field is not valid because:", - SourceLine(_doc, "package", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `package` field is not valid because:", - SourceLine(_doc, "package", str), - [e], - detailed_message=f"the `package` field with value `{val}` " - "is not valid because:", - ) - ) - version = None - if "version" in _doc: - try: - version = load_field( - _doc.get("version"), - union_of_None_type_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("version") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `version`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("version") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `version` field is not valid because:", - SourceLine(_doc, "version", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `version` field is not valid because:", - SourceLine(_doc, "version", str), - [e], - detailed_message=f"the `version` field with value `{val}` " - "is not valid because:", - ) - ) - specs = None - if "specs" in _doc: - try: - specs = load_field( - _doc.get("specs"), - uri_union_of_None_type_or_array_of_strtype_False_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("specs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `specs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("specs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `specs` field is not valid because:", - SourceLine(_doc, "specs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `specs` field is not valid because:", - SourceLine(_doc, "specs", str), - [e], - detailed_message=f"the `specs` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `package`, `version`, `specs`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - package=package, - version=version, - specs=specs, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.package is not None: - r["package"] = save( - self.package, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.version is not None: - r["version"] = save( - self.version, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.specs is not None: - u = save_relative_uri(self.specs, base_url, False, None, relative_uris) - r["specs"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["package", "version", "specs"]) - - -class Dirent(Saveable): - """ - Define a file or subdirectory that must be staged to a particular - place prior to executing the command line tool. May be the result - of executing an expression, such as building a configuration file - from a template. - - Usually files are staged within the [designated output directory](#Runtime_environment). - However, under certain circumstances, files may be staged at - arbitrary locations, see discussion for `entryname`. - - """ - - def __init__( - self, - entry: Any, - entryname: Optional[Any] = None, - writable: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.entryname = entryname - self.entry = entry - self.writable = writable - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Dirent): - return bool( - self.entryname == other.entryname - and self.entry == other.entry - and self.writable == other.writable - ) - return False - - def __hash__(self) -> int: - return hash((self.entryname, self.entry, self.writable)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Dirent": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - entryname = None - if "entryname" in _doc: - try: - entryname = load_field( - _doc.get("entryname"), - union_of_None_type_or_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("entryname") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `entryname`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("entryname") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `entryname` field is not valid because:", - SourceLine(_doc, "entryname", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `entryname` field is not valid because:", - SourceLine(_doc, "entryname", str), - [e], - detailed_message=f"the `entryname` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("entry") is None: - raise ValidationException("missing required field `entry`", None, []) - - entry = load_field( - _doc.get("entry"), - union_of_strtype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("entry") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `entry`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("entry") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `entry` field is not valid because:", - SourceLine(_doc, "entry", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `entry` field is not valid because:", - SourceLine(_doc, "entry", str), - [e], - detailed_message=f"the `entry` field with value `{val}` " - "is not valid because:", - ) - ) - writable = None - if "writable" in _doc: - try: - writable = load_field( - _doc.get("writable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("writable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `writable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("writable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `writable` field is not valid because:", - SourceLine(_doc, "writable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `writable` field is not valid because:", - SourceLine(_doc, "writable", str), - [e], - detailed_message=f"the `writable` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `entryname`, `entry`, `writable`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - entryname=entryname, - entry=entry, - writable=writable, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.entryname is not None: - r["entryname"] = save( - self.entryname, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.entry is not None: - r["entry"] = save( - self.entry, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.writable is not None: - r["writable"] = save( - self.writable, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["entryname", "entry", "writable"]) - - -class InitialWorkDirRequirement(ProcessRequirement): - """ - Define a list of files and subdirectories that must be staged by the workflow platform prior to executing the command line tool. - Normally files are staged within the designated output directory. However, when running inside containers, files may be staged at arbitrary locations, see discussion for [`Dirent.entryname`](#Dirent). Together with `DockerRequirement.dockerOutputDirectory` it is possible to control the locations of both input and output files when running in containers. - """ - - def __init__( - self, - listing: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "InitialWorkDirRequirement" - self.listing = listing - - def __eq__(self, other: Any) -> bool: - if isinstance(other, InitialWorkDirRequirement): - return bool(self.class_ == other.class_ and self.listing == other.listing) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.listing)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InitialWorkDirRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_InitialWorkDirRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("listing") is None: - raise ValidationException("missing required field `listing`", None, []) - - listing = load_field( - _doc.get("listing"), - union_of_ExpressionLoader_or_array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader, - baseuri, - loadingOptions, - lc=_doc.get("listing") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `listing`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("listing") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `listing` field is not valid because:", - SourceLine(_doc, "listing", str), - [e], - detailed_message=f"the `listing` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `listing`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - listing=listing, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.listing is not None: - r["listing"] = save( - self.listing, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "listing"]) - - -class EnvVarRequirement(ProcessRequirement): - """ - Define a list of environment variables which will be set in the - execution environment of the tool. See `EnvironmentDef` for details. - - """ - - def __init__( - self, - envDef: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "EnvVarRequirement" - self.envDef = envDef - - def __eq__(self, other: Any) -> bool: - if isinstance(other, EnvVarRequirement): - return bool(self.class_ == other.class_ and self.envDef == other.envDef) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.envDef)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "EnvVarRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_EnvVarRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("envDef") is None: - raise ValidationException("missing required field `envDef`", None, []) - - envDef = load_field( - _doc.get("envDef"), - idmap_envDef_array_of_EnvironmentDefLoader, - baseuri, - loadingOptions, - lc=_doc.get("envDef") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `envDef`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("envDef") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `envDef` field is not valid because:", - SourceLine(_doc, "envDef", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `envDef` field is not valid because:", - SourceLine(_doc, "envDef", str), - [e], - detailed_message=f"the `envDef` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -17610,14 +14069,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `envDef`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `baseCommand`, `arguments`, `stdin`, `stderr`, `stdout`, `successCodes`, `temporaryFailCodes`, `permanentFailCodes`".format( k ), SourceLine(_doc, k, str), @@ -17627,10 +14086,27 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - envDef=envDef, + id=id, + label=label, + doc=doc, + inputs=inputs, + outputs=outputs, + requirements=requirements, + hints=hints, + cwlVersion=cwlVersion, + intent=intent, + baseCommand=baseCommand, + arguments=arguments, + stdin=stdin, + stderr=stderr, + stdout=stdout, + successCodes=successCodes, + temporaryFailCodes=temporaryFailCodes, + permanentFailCodes=permanentFailCodes, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -17644,17 +14120,95 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) + u = save_relative_uri(uri, self.id, False, None, relative_uris) r["class"] = u - if self.envDef is not None: - r["envDef"] = save( - self.envDef, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.requirements is not None: + r["requirements"] = save( + self.requirements, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.intent is not None: + u = save_relative_uri(self.intent, self.id, True, None, relative_uris) + r["intent"] = u + if self.baseCommand is not None: + r["baseCommand"] = save( + self.baseCommand, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.arguments is not None: + r["arguments"] = save( + self.arguments, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stdin is not None: + r["stdin"] = save( + self.stdin, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stderr is not None: + r["stderr"] = save( + self.stderr, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.stdout is not None: + r["stdout"] = save( + self.stdout, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.successCodes is not None: + r["successCodes"] = save( + self.successCodes, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.temporaryFailCodes is not None: + r["temporaryFailCodes"] = save( + self.temporaryFailCodes, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.permanentFailCodes is not None: + r["permanentFailCodes"] = save( + self.permanentFailCodes, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) # top refers to the directory level @@ -17665,25 +14219,27 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "envDef"]) - - -class ShellCommandRequirement(ProcessRequirement): - """ - Modify the behavior of CommandLineTool to generate a single string - containing a shell command line. Each item in the `arguments` list must - be joined into a string separated by single spaces and quoted to prevent - interpretation by the shell, unless `CommandLineBinding` for that argument - contains `shellQuote: false`. If `shellQuote: false` is specified, the - argument is joined into the command string without quoting, which allows - the use of shell metacharacters such as `|` for pipes. - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + inputs: Sequence[CommandInputParameter], + outputs: Sequence[CommandOutputParameter], + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + intent: None | Sequence[str] = None, + baseCommand: None | Sequence[str] | str = None, + arguments: None | Sequence[CommandLineBinding | str] = None, + stdin: None | str = None, + stderr: None | str = None, + stdout: None | str = None, + successCodes: None | Sequence[i32] = None, + temporaryFailCodes: None | Sequence[i32] = None, + permanentFailCodes: None | Sequence[i32] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -17693,178 +14249,85 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ShellCommandRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ShellCommandRequirement): - return bool(self.class_ == other.class_) - return False - - def __hash__(self) -> int: - return hash((self.class_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ShellCommandRequirement": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ShellCommandRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.doc = doc + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.cwlVersion = cwlVersion + self.intent = intent + self.class_: Final[str] = "CommandLineTool" + self.baseCommand = baseCommand + self.arguments = arguments + self.stdin = stdin + self.stderr = stderr + self.stdout = stdout + self.successCodes = successCodes + self.temporaryFailCodes = temporaryFailCodes + self.permanentFailCodes = permanentFailCodes - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "inputs", + "outputs", + "requirements", + "hints", + "cwlVersion", + "intent", + "class", + "baseCommand", + "arguments", + "stdin", + "stderr", + "stdout", + "successCodes", + "temporaryFailCodes", + "permanentFailCodes", + ] + ) - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - attrs = frozenset(["class"]) +@mypyc_attr(native_class=True) +class DockerRequirement(Saveable): + """ + Indicates that a workflow component should be run in a `Docker `__ or Docker-compatible (such as `Singularity `__ and `udocker `__) container environment and specifies how to fetch or build the image. + If a CommandLineTool lists ``DockerRequirement`` under ``hints`` (or ``requirements``), it may (or must) be run in the specified Docker container. -class ResourceRequirement(ProcessRequirement): - """ - Specify basic hardware resource requirements. + The platform must first acquire or install the correct Docker image as specified by ``dockerPull``, ``dockerImport``, ``dockerLoad`` or ``dockerFile``. - "min" is the minimum amount of a resource that must be reserved to - schedule a job. If "min" cannot be satisfied, the job should not - be run. + The platform must execute the tool in the container using ``docker run`` with the appropriate Docker image and tool command line. - "max" is the maximum amount of a resource that the job shall be - allocated. If a node has sufficient resources, multiple jobs may - be scheduled on a single node provided each job's "max" resource - requirements are met. If a job attempts to exceed its resource - allocation, an implementation may deny additional resources, which - may result in job failure. + The workflow platform may provide input files and the designated output directory through the use of volume bind mounts. The platform should rewrite file paths in the input object to correspond to the Docker bind mounted locations. That is, the platform should rewrite values in the parameter context such as ``runtime.outdir``, ``runtime.tmpdir`` and others to be valid paths within the container. The platform must ensure that ``runtime.outdir`` and ``runtime.tmpdir`` are distinct directories. - If both "min" and "max" are specified, an implementation may - choose to allocate any amount between "min" and "max", with the - actual allocation provided in the `runtime` object. + When running a tool contained in Docker, the workflow platform must not assume anything about the contents of the Docker container, such as the presence or absence of specific software, except to assume that the generated command line represents a valid command within the runtime environment of the container. - If "min" is specified but "max" is not, then "max" == "min" - If "max" is specified by "min" is not, then "min" == "max". + A container image may specify an `ENTRYPOINT `__ and/or `CMD `__. Command line arguments will be appended after all elements of ENTRYPOINT, and will override all elements specified using CMD (in other words, CMD is only used when the CommandLineTool definition produces an empty command line). - It is an error if max < min. + Use of implicit ENTRYPOINT or CMD are discouraged due to reproducibility concerns of the implicit hidden execution point (For further discussion, see `https://doi.org/10.12688/f1000research.15140.1 `__). Portable CommandLineTool wrappers in which use of a container is optional must not rely on ENTRYPOINT or CMD. CommandLineTools which do rely on ENTRYPOINT or CMD must list ``DockerRequirement`` in the ``requirements`` section. - It is an error if the value of any of these fields is negative. + Interaction with other requirements + ----------------------------------- - If neither "min" nor "max" is specified for a resource, use the default values below. + If `EnvVarRequirement <#EnvVarRequirement>`__ is specified alongside a DockerRequirement, the environment variables must be provided to Docker using ``--env`` or ``--env-file`` and interact with the container's preexisting environment as defined by Docker. """ - def __init__( - self, - coresMin: Optional[Any] = None, - coresMax: Optional[Any] = None, - ramMin: Optional[Any] = None, - ramMax: Optional[Any] = None, - tmpdirMin: Optional[Any] = None, - tmpdirMax: Optional[Any] = None, - outdirMin: Optional[Any] = None, - outdirMax: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "ResourceRequirement" - self.coresMin = coresMin - self.coresMax = coresMax - self.ramMin = ramMin - self.ramMax = ramMax - self.tmpdirMin = tmpdirMin - self.tmpdirMax = tmpdirMax - self.outdirMin = outdirMin - self.outdirMax = outdirMax - def __eq__(self, other: Any) -> bool: - if isinstance(other, ResourceRequirement): + if isinstance(other, DockerRequirement): return bool( self.class_ == other.class_ - and self.coresMin == other.coresMin - and self.coresMax == other.coresMax - and self.ramMin == other.ramMin - and self.ramMax == other.ramMax - and self.tmpdirMin == other.tmpdirMin - and self.tmpdirMax == other.tmpdirMax - and self.outdirMin == other.outdirMin - and self.outdirMax == other.outdirMax + and self.dockerPull == other.dockerPull + and self.dockerLoad == other.dockerLoad + and self.dockerFile == other.dockerFile + and self.dockerImport == other.dockerImport + and self.dockerImageId == other.dockerImageId + and self.dockerOutputDirectory == other.dockerOutputDirectory ) return False @@ -17872,14 +14335,12 @@ def __hash__(self) -> int: return hash( ( self.class_, - self.coresMin, - self.coresMax, - self.ramMin, - self.ramMax, - self.tmpdirMin, - self.tmpdirMax, - self.outdirMin, - self.outdirMax, + self.dockerPull, + self.dockerLoad, + self.dockerFile, + self.dockerImport, + self.dockerImageId, + self.dockerOutputDirectory, ) ) @@ -17889,8 +14350,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ResourceRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -17901,221 +14362,34 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_ResourceRequirement_classLoader_False_True_None_None, + uri_DockerRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e - coresMin = None - if "coresMin" in _doc: - try: - coresMin = load_field( - _doc.get("coresMin"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("coresMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `coresMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("coresMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `coresMin` field is not valid because:", - SourceLine(_doc, "coresMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `coresMin` field is not valid because:", - SourceLine(_doc, "coresMin", str), - [e], - detailed_message=f"the `coresMin` field with value `{val}` " - "is not valid because:", - ) - ) - coresMax = None - if "coresMax" in _doc: - try: - coresMax = load_field( - _doc.get("coresMax"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("coresMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `coresMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("coresMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `coresMax` field is not valid because:", - SourceLine(_doc, "coresMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `coresMax` field is not valid because:", - SourceLine(_doc, "coresMax", str), - [e], - detailed_message=f"the `coresMax` field with value `{val}` " - "is not valid because:", - ) - ) - ramMin = None - if "ramMin" in _doc: - try: - ramMin = load_field( - _doc.get("ramMin"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("ramMin") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `ramMin`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("ramMin") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `ramMin` field is not valid because:", - SourceLine(_doc, "ramMin", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `ramMin` field is not valid because:", - SourceLine(_doc, "ramMin", str), - [e], - detailed_message=f"the `ramMin` field with value `{val}` " - "is not valid because:", - ) - ) - ramMax = None - if "ramMax" in _doc: - try: - ramMax = load_field( - _doc.get("ramMax"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("ramMax") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `ramMax`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("ramMax") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `ramMax` field is not valid because:", - SourceLine(_doc, "ramMax", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `ramMax` field is not valid because:", - SourceLine(_doc, "ramMax", str), - [e], - detailed_message=f"the `ramMax` field with value `{val}` " - "is not valid because:", - ) - ) - tmpdirMin = None - if "tmpdirMin" in _doc: + raise e + dockerPull = None + if "dockerPull" in _doc: try: - tmpdirMin = load_field( - _doc.get("tmpdirMin"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, + dockerPull = _load_field( + _doc.get("dockerPull"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tmpdirMin") + lc=_doc.get("dockerPull") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tmpdirMin`": + if str(e) == "missing required field `dockerPull`": _errors__.append( ValidationException( str(e), @@ -18123,13 +14397,13 @@ def fromDoc( ) ) else: - val = _doc.get("tmpdirMin") + val = _doc.get("dockerPull") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tmpdirMin` field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18141,28 +14415,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tmpdirMin` field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), [e], - detailed_message=f"the `tmpdirMin` field with value `{val}` " + detailed_message=f"the `dockerPull` field with value `{val}` " "is not valid because:", ) ) - tmpdirMax = None - if "tmpdirMax" in _doc: + dockerLoad = None + if "dockerLoad" in _doc: try: - tmpdirMax = load_field( - _doc.get("tmpdirMax"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, + dockerLoad = _load_field( + _doc.get("dockerLoad"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tmpdirMax") + lc=_doc.get("dockerLoad") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tmpdirMax`": + if str(e) == "missing required field `dockerLoad`": _errors__.append( ValidationException( str(e), @@ -18170,13 +14444,13 @@ def fromDoc( ) ) else: - val = _doc.get("tmpdirMax") + val = _doc.get("dockerLoad") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tmpdirMax` field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18188,28 +14462,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tmpdirMax` field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), [e], - detailed_message=f"the `tmpdirMax` field with value `{val}` " + detailed_message=f"the `dockerLoad` field with value `{val}` " "is not valid because:", ) ) - outdirMin = None - if "outdirMin" in _doc: + dockerFile = None + if "dockerFile" in _doc: try: - outdirMin = load_field( - _doc.get("outdirMin"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, + dockerFile = _load_field( + _doc.get("dockerFile"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("outdirMin") + lc=_doc.get("dockerFile") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outdirMin`": + if str(e) == "missing required field `dockerFile`": _errors__.append( ValidationException( str(e), @@ -18217,13 +14491,13 @@ def fromDoc( ) ) else: - val = _doc.get("outdirMin") + val = _doc.get("dockerFile") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outdirMin` field is not valid because:", - SourceLine(_doc, "outdirMin", str), + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18235,28 +14509,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outdirMin` field is not valid because:", - SourceLine(_doc, "outdirMin", str), + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), [e], - detailed_message=f"the `outdirMin` field with value `{val}` " + detailed_message=f"the `dockerFile` field with value `{val}` " "is not valid because:", ) ) - outdirMax = None - if "outdirMax" in _doc: + dockerImport = None + if "dockerImport" in _doc: try: - outdirMax = load_field( - _doc.get("outdirMax"), - union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, + dockerImport = _load_field( + _doc.get("dockerImport"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("outdirMax") + lc=_doc.get("dockerImport") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outdirMax`": + if str(e) == "missing required field `dockerImport`": _errors__.append( ValidationException( str(e), @@ -18264,13 +14538,13 @@ def fromDoc( ) ) else: - val = _doc.get("outdirMax") + val = _doc.get("dockerImport") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outdirMax` field is not valid because:", - SourceLine(_doc, "outdirMax", str), + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18282,453 +14556,108 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outdirMax` field is not valid because:", - SourceLine(_doc, "outdirMax", str), + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), [e], - detailed_message=f"the `outdirMax` field with value `{val}` " + detailed_message=f"the `dockerImport` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `coresMin`, `coresMax`, `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, `outdirMax`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - coresMin=coresMin, - coresMax=coresMax, - ramMin=ramMin, - ramMax=ramMax, - tmpdirMin=tmpdirMin, - tmpdirMax=tmpdirMax, - outdirMin=outdirMin, - outdirMax=outdirMax, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.coresMin is not None: - r["coresMin"] = save( - self.coresMin, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.coresMax is not None: - r["coresMax"] = save( - self.coresMax, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.ramMin is not None: - r["ramMin"] = save( - self.ramMin, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.ramMax is not None: - r["ramMax"] = save( - self.ramMax, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.tmpdirMin is not None: - r["tmpdirMin"] = save( - self.tmpdirMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.tmpdirMax is not None: - r["tmpdirMax"] = save( - self.tmpdirMax, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.outdirMin is not None: - r["outdirMin"] = save( - self.outdirMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.outdirMax is not None: - r["outdirMax"] = save( - self.outdirMax, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "class", - "coresMin", - "coresMax", - "ramMin", - "ramMax", - "tmpdirMin", - "tmpdirMax", - "outdirMin", - "outdirMax", - ] - ) - - -class WorkReuse(ProcessRequirement): - """ - For implementations that support reusing output from past work (on - the assumption that same code and same input produce same - results), control whether to enable or disable the reuse behavior - for a particular tool or step (to accommodate situations where that - assumption is incorrect). A reused step is not executed but - instead returns the same output as the original execution. - - If `WorkReuse` is not specified, correct tools should assume it - is enabled by default. - - """ - - def __init__( - self, - enableReuse: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "WorkReuse" - self.enableReuse = enableReuse - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkReuse): - return bool( - self.class_ == other.class_ and self.enableReuse == other.enableReuse - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.enableReuse)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkReuse": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_WorkReuse_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("enableReuse") is None: - raise ValidationException("missing required field `enableReuse`", None, []) - - enableReuse = load_field( - _doc.get("enableReuse"), - union_of_booltype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("enableReuse") - ) + dockerImageId = None + if "dockerImageId" in _doc: + try: + dockerImageId = _load_field( + _doc.get("dockerImageId"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerImageId") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `enableReuse`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("enableReuse") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `dockerImageId`": _errors__.append( ValidationException( - "the `enableReuse` field is not valid because:", - SourceLine(_doc, "enableReuse", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `enableReuse` field is not valid because:", - SourceLine(_doc, "enableReuse", str), - [e], - detailed_message=f"the `enableReuse` field with value `{val}` " - "is not valid because:", + val = _doc.get("dockerImageId") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `enableReuse`".format( - k - ), - SourceLine(_doc, k, str), + else: + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [e], + detailed_message=f"the `dockerImageId` field with value `{val}` " + "is not valid because:", + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - enableReuse=enableReuse, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.enableReuse is not None: - r["enableReuse"] = save( - self.enableReuse, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class", "enableReuse"]) - - -class NetworkAccess(ProcessRequirement): - """ - Indicate whether a process requires outgoing IPv4/IPv6 network - access. Choice of IPv4 or IPv6 is implementation and site - specific, correct tools must support both. - - If `networkAccess` is false or not specified, tools must not - assume network access, except for localhost (the loopback device). - - If `networkAccess` is true, the tool must be able to make outgoing - connections to network resources. Resources may be on a private - subnet or the public Internet. However, implementations and sites - may apply their own security policies to restrict what is - accessible by the tool. - - Enabling network access does not imply a publicly routable IP - address or the ability to accept inbound connections. - - """ - - def __init__( - self, - networkAccess: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "NetworkAccess" - self.networkAccess = networkAccess - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NetworkAccess): - return bool( - self.class_ == other.class_ - and self.networkAccess == other.networkAccess - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.networkAccess)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NetworkAccess": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_NetworkAccess_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("networkAccess") is None: - raise ValidationException("missing required field `networkAccess`", None, []) - - networkAccess = load_field( - _doc.get("networkAccess"), - union_of_booltype_or_ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("networkAccess") - ) + dockerOutputDirectory = None + if "dockerOutputDirectory" in _doc: + try: + dockerOutputDirectory = _load_field( + _doc.get("dockerOutputDirectory"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("dockerOutputDirectory") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `networkAccess`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("networkAccess") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `dockerOutputDirectory`": _errors__.append( ValidationException( - "the `networkAccess` field is not valid because:", - SourceLine(_doc, "networkAccess", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `networkAccess` field is not valid because:", - SourceLine(_doc, "networkAccess", str), - [e], - detailed_message=f"the `networkAccess` field with value `{val}` " - "is not valid because:", + val = _doc.get("dockerOutputDirectory") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [e], + detailed_message=f"the `dockerOutputDirectory` field with value `{val}` " + "is not valid because:", + ) ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18736,14 +14665,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `networkAccess`".format( + "invalid field `{}`, expected one of: `class`, `dockerPull`, `dockerLoad`, `dockerFile`, `dockerImport`, `dockerImageId`, `dockerOutputDirectory`".format( k ), SourceLine(_doc, k, str), @@ -18753,7 +14682,12 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - networkAccess=networkAccess, + dockerPull=dockerPull, + dockerLoad=dockerLoad, + dockerFile=dockerFile, + dockerImport=dockerImport, + dockerImageId=dockerImageId, + dockerOutputDirectory=dockerOutputDirectory, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -18771,16 +14705,53 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.networkAccess is not None: - r["networkAccess"] = save( - self.networkAccess, + if self.dockerPull is not None: + r["dockerPull"] = save( + self.dockerPull, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerLoad is not None: + r["dockerLoad"] = save( + self.dockerLoad, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerFile is not None: + r["dockerFile"] = save( + self.dockerFile, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerImport is not None: + r["dockerImport"] = save( + self.dockerImport, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerImageId is not None: + r["dockerImageId"] = save( + self.dockerImageId, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.dockerOutputDirectory is not None: + r["dockerOutputDirectory"] = save( + self.dockerOutputDirectory, top=False, base_url=base_url, relative_uris=relative_uris, @@ -18794,49 +14765,16 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "networkAccess"]) - - -class InplaceUpdateRequirement(ProcessRequirement): - """ - - If `inplaceUpdate` is true, then an implementation supporting this - feature may permit tools to directly update files with `writable: - true` in InitialWorkDirRequirement. That is, as an optimization, - files may be destructively modified in place as opposed to copied - and updated. - - An implementation must ensure that only one workflow step may - access a writable file at a time. It is an error if a file which - is writable by one workflow step file is accessed (for reading or - writing) by any other workflow step running independently. - However, a file which has been updated in a previous completed - step may be used as input to multiple steps, provided it is - read-only in every step. - - Workflow steps which modify a file must produce the modified file - as output. Downstream steps which further process the file must - use the output of previous steps, and not refer to a common input - (this is necessary for both ordering and correctness). - - Workflow authors should provide this in the `hints` section. The - intent of this feature is that workflows produce the same results - whether or not InplaceUpdateRequirement is supported by the - implementation, and this feature is primarily available as an - optimization for particular environments. - - Users and implementers should be aware that workflows that - destructively modify inputs may not be repeatable or reproducible. - In particular, enabling this feature implies that WorkReuse should - not be enabled. - - """ - def __init__( self, - inplaceUpdate: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + dockerPull: None | str = None, + dockerLoad: None | str = None, + dockerFile: None | str = None, + dockerImport: None | str = None, + dockerImageId: None | str = None, + dockerOutputDirectory: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -18846,19 +14784,41 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "InplaceUpdateRequirement" - self.inplaceUpdate = inplaceUpdate + self.class_: Final[str] = "DockerRequirement" + self.dockerPull = dockerPull + self.dockerLoad = dockerLoad + self.dockerFile = dockerFile + self.dockerImport = dockerImport + self.dockerImageId = dockerImageId + self.dockerOutputDirectory = dockerOutputDirectory + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "dockerPull", + "dockerLoad", + "dockerFile", + "dockerImport", + "dockerImageId", + "dockerOutputDirectory", + ] + ) + + +@mypyc_attr(native_class=True) +class SoftwareRequirement(Saveable): + """ + A list of software packages that should be configured in the environment of the defined process. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, InplaceUpdateRequirement): - return bool( - self.class_ == other.class_ - and self.inplaceUpdate == other.inplaceUpdate - ) + if isinstance(other, SoftwareRequirement): + return bool(self.class_ == other.class_ and self.packages == other.packages) return False def __hash__(self) -> int: - return hash((self.class_, self.inplaceUpdate)) + return hash((self.class_, self.packages)) @classmethod def fromDoc( @@ -18866,8 +14826,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "InplaceUpdateRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -18878,34 +14838,35 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_InplaceUpdateRequirement_classLoader_False_True_None_None, + uri_SoftwareRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - raise e + raise e try: - if _doc.get("inplaceUpdate") is None: - raise ValidationException("missing required field `inplaceUpdate`", None, []) + if _doc.get("packages") is None: + raise ValidationException("missing required field `packages`", None, []) - inplaceUpdate = load_field( - _doc.get("inplaceUpdate"), - booltype, + packages = _load_field( + _doc.get("packages"), + idmap_packages_array_of_SoftwarePackageLoader, baseuri, loadingOptions, - lc=_doc.get("inplaceUpdate") + lc=_doc.get("packages") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inplaceUpdate`": + if str(e) == "missing required field `packages`": _errors__.append( ValidationException( str(e), @@ -18913,13 +14874,13 @@ def fromDoc( ) ) else: - val = _doc.get("inplaceUpdate") + val = _doc.get("packages") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inplaceUpdate` field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -18931,14 +14892,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inplaceUpdate` field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), [e], - detailed_message=f"the `inplaceUpdate` field with value `{val}` " + detailed_message=f"the `packages` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -18946,14 +14907,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `inplaceUpdate`".format( + "invalid field `{}`, expected one of: `class`, `packages`".format( k ), SourceLine(_doc, k, str), @@ -18963,7 +14924,7 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - inplaceUpdate=inplaceUpdate, + packages=packages, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -18981,19 +14942,18 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.inplaceUpdate is not None: - r["inplaceUpdate"] = save( - self.inplaceUpdate, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.packages is not None: + r["packages"] = save( + self.packages, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -19004,26 +14964,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "inplaceUpdate"]) - - -class ToolTimeLimit(ProcessRequirement): - """ - Set an upper limit on the execution time of a CommandLineTool. - A CommandLineTool whose execution duration exceeds the time - limit may be preemptively terminated and considered failed. - May also be used by batch systems to make scheduling decisions. - The execution duration excludes external operations, such as - staging of files, pulling a docker image etc, and only counts - wall-time for the execution of the command line itself. - - """ - def __init__( self, - timelimit: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + packages: Sequence[SoftwarePackage], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -19033,18 +14978,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ToolTimeLimit" - self.timelimit = timelimit + self.class_: Final[str] = "SoftwareRequirement" + self.packages = packages + attrs: ClassVar[Collection[str]] = frozenset(["class", "packages"]) + + +@mypyc_attr(native_class=True) +class SoftwarePackage(Saveable): def __eq__(self, other: Any) -> bool: - if isinstance(other, ToolTimeLimit): + if isinstance(other, SoftwarePackage): return bool( - self.class_ == other.class_ and self.timelimit == other.timelimit + self.package == other.package + and self.version == other.version + and self.specs == other.specs ) return False def __hash__(self) -> int: - return hash((self.class_, self.timelimit)) + return hash((self.package, self.version, self.specs)) @classmethod def fromDoc( @@ -19052,8 +15004,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ToolTimeLimit": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -19061,37 +15013,21 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ToolTimeLimit_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("timelimit") is None: - raise ValidationException("missing required field `timelimit`", None, []) + if _doc.get("package") is None: + raise ValidationException("missing required field `package`", None, []) - timelimit = load_field( - _doc.get("timelimit"), - union_of_inttype_or_ExpressionLoader, + package = _load_field( + _doc.get("package"), + strtype, baseuri, loadingOptions, - lc=_doc.get("timelimit") + lc=_doc.get("package") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `timelimit`": + if str(e) == "missing required field `package`": _errors__.append( ValidationException( str(e), @@ -19099,32 +15035,126 @@ def fromDoc( ) ) else: - val = _doc.get("timelimit") + val = _doc.get("package") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `timelimit` field is not valid because:", - SourceLine(_doc, "timelimit", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [e], + detailed_message=f"the `package` field with value `{val}` " + "is not valid because:", + ) + ) + version = None + if "version" in _doc: + try: + version = _load_field( + _doc.get("version"), + union_of_None_type_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("version") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `version`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("version") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [e], + detailed_message=f"the `version` field with value `{val}` " + "is not valid because:", + ) + ) + specs = None + if "specs" in _doc: + try: + specs = _load_field( + _doc.get("specs"), + uri_union_of_None_type_or_array_of_strtype_False_False_None_True, + baseuri, + loadingOptions, + lc=_doc.get("specs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `specs`": + _errors__.append( + ValidationException( + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `timelimit` field is not valid because:", - SourceLine(_doc, "timelimit", str), - [e], - detailed_message=f"the `timelimit` field with value `{val}` " - "is not valid because:", + val = _doc.get("specs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} + else: + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [e], + detailed_message=f"the `specs` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -19132,14 +15162,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `timelimit`".format( + "invalid field `{}`, expected one of: `package`, `version`, `specs`".format( k ), SourceLine(_doc, k, str), @@ -19149,7 +15179,9 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - timelimit=timelimit, + package=package, + version=version, + specs=specs, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -19166,21 +15198,17 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.timelimit is not None: - r["timelimit"] = save( - self.timelimit, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.package is not None: + r["package"] = save( + self.package, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.version is not None: + r["version"] = save( + self.version, top=False, base_url=base_url, relative_uris=relative_uris ) + if self.specs is not None: + u = save_relative_uri(self.specs, base_url, False, None, relative_uris) + r["specs"] = u # top refers to the directory level if top: @@ -19190,23 +15218,13 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "timelimit"]) - - -class ExpressionToolOutputParameter(OutputParameter): - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + package: str, + version: None | Sequence[str] = None, + specs: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -19216,39 +15234,33 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.type_ = type_ + self.package = package + self.version = version + self.specs = specs + + attrs: ClassVar[Collection[str]] = frozenset(["package", "version", "specs"]) + + +@mypyc_attr(native_class=True) +class Dirent(Saveable): + """ + Define a file or subdirectory that must be staged to a particular place prior to executing the command line tool. May be the result of executing an expression, such as building a configuration file from a template. + + Usually files are staged within the `designated output directory <#Runtime_environment>`__. However, under certain circumstances, files may be staged at arbitrary locations, see discussion for ``entryname``. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, ExpressionToolOutputParameter): + if isinstance(other, Dirent): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.type_ == other.type_ + self.entryname == other.entryname + and self.entry == other.entry + and self.writable == other.writable ) return False def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.type_, - ) - ) + return hash((self.entryname, self.entry, self.writable)) @classmethod def fromDoc( @@ -19256,29 +15268,29 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ExpressionToolOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: + entryname = None + if "entryname" in _doc: try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, + entryname = _load_field( + _doc.get("entryname"), + union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("entryname") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `entryname`": _errors__.append( ValidationException( str(e), @@ -19286,13 +15298,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("entryname") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19304,131 +15316,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `entryname` field with value `{val}` " "is not valid because:", ) ) + try: + if _doc.get("entry") is None: + raise ValidationException("missing required field `entry`", None, []) - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) + entry = _load_field( + _doc.get("entry"), + union_of_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("entry") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) + if str(e) == "missing required field `entry`": + _errors__.append( + ValidationException( + str(e), + None ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `secondaryFiles`": + else: + val = _doc.get("entry") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - streamable = None - if "streamable" in _doc: + ) + else: + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [e], + detailed_message=f"the `entry` field with value `{val}` " + "is not valid because:", + ) + ) + writable = None + if "writable" in _doc: try: - streamable = load_field( - _doc.get("streamable"), + writable = _load_field( + _doc.get("writable"), union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("writable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `writable`": _errors__.append( ValidationException( str(e), @@ -19436,13 +15393,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("writable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19454,123 +15411,345 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `writable` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `entryname`, `entry`, `writable`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + entryname=entryname, + entry=entry, + writable=writable, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed - if str(e) == "missing required field `doc`": + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.entryname is not None: + r["entryname"] = save( + self.entryname, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.entry is not None: + r["entry"] = save( + self.entry, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.writable is not None: + r["writable"] = save( + self.writable, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + entry: str, + entryname: None | str = None, + writable: None | bool = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.entryname = entryname + self.entry = entry + self.writable = writable + + attrs: ClassVar[Collection[str]] = frozenset(["entryname", "entry", "writable"]) + + +@mypyc_attr(native_class=True) +class InitialWorkDirRequirement(Saveable): + """ + Define a list of files and subdirectories that must be staged by the workflow platform prior to executing the command line tool. Normally files are staged within the designated output directory. However, when running inside containers, files may be staged at arbitrary locations, see discussion for ```Dirent.entryname`` <#Dirent>`__. Together with ``DockerRequirement.dockerOutputDirectory`` it is possible to control the locations of both input and output files when running in containers. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InitialWorkDirRequirement): + return bool(self.class_ == other.class_ and self.listing == other.listing) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.listing)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_InitialWorkDirRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("listing") is None: + raise ValidationException("missing required field `listing`", None, []) + + listing = _load_field( + _doc.get("listing"), + union_of_ExpressionLoader_or_array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("listing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("listing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + detailed_message=f"the `listing` field with value `{val}` " + "is not valid because:", ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `class`, `listing`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + listing=listing, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.listing is not None: + r["listing"] = save( + self.listing, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + listing: Sequence[Directory | Dirent | File | None | Sequence[Directory | File] | str] | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "InitialWorkDirRequirement" + self.listing = listing + + attrs: ClassVar[Collection[str]] = frozenset(["class", "listing"]) + + +@mypyc_attr(native_class=True) +class EnvVarRequirement(Saveable): + """ + Define a list of environment variables which will be set in the execution environment of the tool. See ``EnvironmentDef`` for details. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, EnvVarRequirement): + return bool(self.class_ == other.class_ and self.envDef == other.envDef) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.envDef)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + class_ = _load_field( + _doc.get("class"), + uri_EnvVarRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("envDef") is None: + raise ValidationException("missing required field `envDef`", None, []) + + envDef = _load_field( + _doc.get("envDef"), + idmap_envDef_array_of_EnvironmentDefLoader, + baseuri, + loadingOptions, + lc=_doc.get("envDef") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `envDef`": _errors__.append( ValidationException( str(e), @@ -19578,13 +15757,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("envDef") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -19596,14 +15775,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `envDef` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -19611,14 +15790,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`".format( + "invalid field `{}`, expected one of: `class`, `envDef`".format( k ), SourceLine(_doc, k, str), @@ -19628,17 +15807,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - type_=type_, + envDef=envDef, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -19652,37 +15824,19 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.envDef is not None: + r["envDef"] = save( + self.envDef, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -19693,29 +15847,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - ["label", "secondaryFiles", "streamable", "doc", "id", "format", "type"] - ) - - -class WorkflowInputParameter(InputParameter): - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - default: Optional[Any] = None, - inputBinding: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + envDef: Sequence[EnvironmentDef], + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -19725,51 +15861,26 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing - self.default = default - self.type_ = type_ - self.inputBinding = inputBinding + self.class_: Final[str] = "EnvVarRequirement" + self.envDef = envDef - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowInputParameter): - return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable - and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.default == other.default - and self.type_ == other.type_ - and self.inputBinding == other.inputBinding - ) - return False + attrs: ClassVar[Collection[str]] = frozenset(["class", "envDef"]) - def __hash__(self) -> int: - return hash( - ( - self.label, - self.secondaryFiles, - self.streamable, - self.doc, - self.id, - self.format, - self.loadContents, - self.loadListing, - self.default, - self.type_, - self.inputBinding, - ) - ) + +@mypyc_attr(native_class=True) +class ShellCommandRequirement(Saveable): + """ + Modify the behavior of CommandLineTool to generate a single string containing a shell command line. Each item in the ``arguments`` list must be joined into a string separated by single spaces and quoted to prevent interpretation by the shell, unless ``CommandLineBinding`` for that argument contains ``shellQuote: false``. If ``shellQuote: false`` is specified, the argument is joined into the command string without quoting, which allows the use of shell metacharacters such as ``|`` for pipes. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, ShellCommandRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) @classmethod def fromDoc( @@ -19777,320 +15888,204 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowInputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + class_ = _load_field( + _doc.get("class"), + uri_ShellCommandRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - if str(e) == "missing required field `id`": + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`".format(k), + SourceLine(_doc, k, str), ) + ) - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: - try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("label") - ) + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r - if str(e) == "missing required field `label`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("label") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), - [e], - detailed_message=f"the `label` field with value `{val}` " - "is not valid because:", - ) - ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) + def __init__( + self, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "ShellCommandRequirement" - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + attrs: ClassVar[Collection[str]] = frozenset(["class"]) - if str(e) == "missing required field `secondaryFiles`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) +@mypyc_attr(native_class=True) +class ResourceRequirement(Saveable): + """ + Specify basic hardware resource requirements. - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) + "min" is the minimum amount of a resource that must be reserved to schedule a job. If "min" cannot be satisfied, the job should not be run. - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + "max" is the maximum amount of a resource that the job shall be allocated. If a node has sufficient resources, multiple jobs may be scheduled on a single node provided each job's "max" resource requirements are met. If a job attempts to exceed its resource allocation, an implementation may deny additional resources, which may result in job failure. - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) + If both "min" and "max" are specified, an implementation may choose to allocate any amount between "min" and "max", with the actual allocation provided in the ``runtime`` object. - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + If "min" is specified but "max" is not, then "max" == "min" If "max" is specified by "min" is not, then "min" == "max". - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) - loadContents = None - if "loadContents" in _doc: + It is an error if max < min. + + It is an error if the value of any of these fields is negative. + + If neither "min" nor "max" is specified for a resource, use the default values below. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, ResourceRequirement): + return bool( + self.class_ == other.class_ + and self.coresMin == other.coresMin + and self.coresMax == other.coresMax + and self.ramMin == other.ramMin + and self.ramMax == other.ramMax + and self.tmpdirMin == other.tmpdirMin + and self.tmpdirMax == other.tmpdirMax + and self.outdirMin == other.outdirMin + and self.outdirMax == other.outdirMax + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.class_, + self.coresMin, + self.coresMax, + self.ramMin, + self.ramMax, + self.tmpdirMin, + self.tmpdirMax, + self.outdirMin, + self.outdirMax, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ResourceRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + coresMin = None + if "coresMin" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + coresMin = _load_field( + _doc.get("coresMin"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("coresMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `coresMin`": _errors__.append( ValidationException( str(e), @@ -20098,13 +16093,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("coresMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20116,28 +16111,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `coresMin` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + coresMax = None + if "coresMax" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + coresMax = _load_field( + _doc.get("coresMax"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("coresMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `coresMax`": _errors__.append( ValidationException( str(e), @@ -20145,13 +16140,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("coresMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20163,28 +16158,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `coresMax` field with value `{val}` " "is not valid because:", ) ) - default = None - if "default" in _doc: + ramMin = None + if "ramMin" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, + ramMin = _load_field( + _doc.get("ramMin"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("ramMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `ramMin`": _errors__.append( ValidationException( str(e), @@ -20192,94 +16187,46 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("ramMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), - [e], - detailed_message=f"the `default` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + else: + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [e], + detailed_message=f"the `ramMin` field with value `{val}` " + "is not valid because:", + ) ) - ) - inputBinding = None - if "inputBinding" in _doc: + ramMax = None + if "ramMax" in _doc: try: - inputBinding = load_field( - _doc.get("inputBinding"), - union_of_None_type_or_InputBindingLoader, + ramMax = _load_field( + _doc.get("ramMax"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("inputBinding") + lc=_doc.get("ramMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputBinding`": + if str(e) == "missing required field `ramMax`": _errors__.append( ValidationException( str(e), @@ -20287,13 +16234,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputBinding") + val = _doc.get("ramMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20305,261 +16252,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputBinding` field is not valid because:", - SourceLine(_doc, "inputBinding", str), + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), [e], - detailed_message=f"the `inputBinding` field with value `{val}` " + detailed_message=f"the `ramMax` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - loadContents=loadContents, - loadListing=loadListing, - default=default, - type_=type_, - inputBinding=inputBinding, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputBinding is not None: - r["inputBinding"] = save( - self.inputBinding, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "loadContents", - "loadListing", - "default", - "type", - "inputBinding", - ] - ) - - -class ExpressionTool(Process): - """ - An ExpressionTool is a type of Process object that can be run by itself - or as a Workflow step. It executes a pure Javascript expression that has - access to the same input parameters as a workflow. It is meant to be used - sparingly as a way to isolate complex Javascript expressions that need to - operate on input data and produce some result; perhaps just a - rearrangement of the inputs. No Docker software container is required - or allowed. - - """ - - id: str - - def __init__( - self, - inputs: Any, - outputs: Any, - expression: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - intent: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.intent = intent - self.class_ = "ExpressionTool" - self.expression = expression - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ExpressionTool): - return bool( - self.id == other.id - and self.label == other.label - and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.intent == other.intent - and self.class_ == other.class_ - and self.expression == other.expression - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.id, - self.label, - self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.intent, - self.class_, - self.expression, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ExpressionTool": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + tmpdirMin = None + if "tmpdirMin" in _doc: try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + tmpdirMin = _load_field( + _doc.get("tmpdirMin"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("tmpdirMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `tmpdirMin`": _errors__.append( ValidationException( str(e), @@ -20567,13 +16281,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("tmpdirMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20585,53 +16299,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `tmpdirMin` field with value `{val}` " "is not valid because:", ) ) + tmpdirMax = None + if "tmpdirMax" in _doc: + try: + tmpdirMax = _load_field( + _doc.get("tmpdirMax"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("tmpdirMax") + ) - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_ExpressionTool_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - label = None - if "label" in _doc: + if str(e) == "missing required field `tmpdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("tmpdirMax") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [e], + detailed_message=f"the `tmpdirMax` field with value `{val}` " + "is not valid because:", + ) + ) + outdirMin = None + if "outdirMin" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + outdirMin = _load_field( + _doc.get("outdirMin"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("outdirMin") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `outdirMin`": _errors__.append( ValidationException( str(e), @@ -20639,13 +16375,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("outdirMin") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20657,28 +16393,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `outdirMin` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + outdirMax = None + if "outdirMax" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + outdirMax = _load_field( + _doc.get("outdirMax"), + union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("outdirMax") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `outdirMax`": _errors__.append( ValidationException( str(e), @@ -20686,13 +16422,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("outdirMax") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20704,77 +16440,237 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `outdirMax` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `coresMin`, `coresMax`, `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, `outdirMax`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + coresMin=coresMin, + coresMax=coresMax, + ramMin=ramMin, + ramMax=ramMax, + tmpdirMin=tmpdirMin, + tmpdirMax=tmpdirMax, + outdirMin=outdirMin, + outdirMax=outdirMax, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.coresMin is not None: + r["coresMin"] = save( + self.coresMin, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.coresMax is not None: + r["coresMax"] = save( + self.coresMax, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.ramMin is not None: + r["ramMin"] = save( + self.ramMin, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.ramMax is not None: + r["ramMax"] = save( + self.ramMax, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.tmpdirMin is not None: + r["tmpdirMin"] = save( + self.tmpdirMin, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.tmpdirMax is not None: + r["tmpdirMax"] = save( + self.tmpdirMax, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.outdirMin is not None: + r["outdirMin"] = save( + self.outdirMin, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.outdirMax is not None: + r["outdirMax"] = save( + self.outdirMax, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + coresMin: None | float | i32 | i64 | str = None, + coresMax: None | float | i32 | i64 | str = None, + ramMin: None | float | i32 | i64 | str = None, + ramMax: None | float | i32 | i64 | str = None, + tmpdirMin: None | float | i32 | i64 | str = None, + tmpdirMax: None | float | i32 | i64 | str = None, + outdirMin: None | float | i32 | i64 | str = None, + outdirMax: None | float | i32 | i64 | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "ResourceRequirement" + self.coresMin = coresMin + self.coresMax = coresMax + self.ramMin = ramMin + self.ramMax = ramMax + self.tmpdirMin = tmpdirMin + self.tmpdirMax = tmpdirMax + self.outdirMin = outdirMin + self.outdirMax = outdirMax + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "class", + "coresMin", + "coresMax", + "ramMin", + "ramMax", + "tmpdirMin", + "tmpdirMax", + "outdirMin", + "outdirMax", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkReuse(Saveable): + """ + For implementations that support reusing output from past work (on the assumption that same code and same input produce same results), control whether to enable or disable the reuse behavior for a particular tool or step (to accommodate situations where that assumption is incorrect). A reused step is not executed but instead returns the same output as the original execution. + + If ``WorkReuse`` is not specified, correct tools should assume it is enabled by default. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, WorkReuse): + return bool( + self.class_ == other.class_ and self.enableReuse == other.enableReuse + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.enableReuse)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_WorkflowInputParameterLoader, + class_ = _load_field( + _doc.get("class"), + uri_WorkReuse_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("inputs") + lc=_doc.get("class") ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) + raise e try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) + if _doc.get("enableReuse") is None: + raise ValidationException("missing required field `enableReuse`", None, []) - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_ExpressionToolOutputParameterLoader, + enableReuse = _load_field( + _doc.get("enableReuse"), + union_of_booltype_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("outputs") + lc=_doc.get("enableReuse") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputs`": + if str(e) == "missing required field `enableReuse`": _errors__.append( ValidationException( str(e), @@ -20782,13 +16678,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputs") + val = _doc.get("enableReuse") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -20800,217 +16696,365 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), [e], - detailed_message=f"the `outputs` field with value `{val}` " + detailed_message=f"the `enableReuse` field with value `{val}` " "is not valid because:", ) ) - requirements = None - if "requirements" in _doc: - try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, - baseuri, - loadingOptions, - lc=_doc.get("requirements") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `requirements`": + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("requirements") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], - detailed_message=f"the `requirements` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `enableReuse`".format( + k + ), + SourceLine(_doc, k, str), ) - hints = None - if "hints" in _doc: - try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("hints") - ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + enableReuse=enableReuse, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.enableReuse is not None: + r["enableReuse"] = save( + self.enableReuse, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + enableReuse: bool | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "WorkReuse" + self.enableReuse = enableReuse + + attrs: ClassVar[Collection[str]] = frozenset(["class", "enableReuse"]) + + +@mypyc_attr(native_class=True) +class NetworkAccess(Saveable): + """ + Indicate whether a process requires outgoing IPv4/IPv6 network access. Choice of IPv4 or IPv6 is implementation and site specific, correct tools must support both. + + If ``networkAccess`` is false or not specified, tools must not assume network access, except for localhost (the loopback device). + + If ``networkAccess`` is true, the tool must be able to make outgoing connections to network resources. Resources may be on a private subnet or the public Internet. However, implementations and sites may apply their own security policies to restrict what is accessible by the tool. + + Enabling network access does not imply a publicly routable IP address or the ability to accept inbound connections. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NetworkAccess): + return bool( + self.class_ == other.class_ + and self.networkAccess == other.networkAccess + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.networkAccess)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + class_ = _load_field( + _doc.get("class"), + uri_NetworkAccess_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) - if str(e) == "missing required field `hints`": + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("networkAccess") is None: + raise ValidationException("missing required field `networkAccess`", None, []) + + networkAccess = _load_field( + _doc.get("networkAccess"), + union_of_booltype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("networkAccess") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `networkAccess`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("networkAccess") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("hints") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [e], - detailed_message=f"the `hints` field with value `{val}` " - "is not valid because:", - ) - ) - cwlVersion = None - if "cwlVersion" in _doc: - try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("cwlVersion") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( - str(e), - None + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [e], + detailed_message=f"the `networkAccess` field with value `{val}` " + "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("cwlVersion") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " - "is not valid because:", - ) - ) - intent = None - if "intent" in _doc: - try: - intent = load_field( - _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("intent") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `intent`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `class`, `networkAccess`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("intent") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), - [e], - detailed_message=f"the `intent` field with value `{val}` " - "is not valid because:", - ) - ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + networkAccess=networkAccess, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.networkAccess is not None: + r["networkAccess"] = save( + self.networkAccess, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + networkAccess: bool | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "NetworkAccess" + self.networkAccess = networkAccess + + attrs: ClassVar[Collection[str]] = frozenset(["class", "networkAccess"]) + + +@mypyc_attr(native_class=True) +class InplaceUpdateRequirement(Saveable): + """ + If ``inplaceUpdate`` is true, then an implementation supporting this feature may permit tools to directly update files with ``writable: true`` in InitialWorkDirRequirement. That is, as an optimization, files may be destructively modified in place as opposed to copied and updated. + + An implementation must ensure that only one workflow step may access a writable file at a time. It is an error if a file which is writable by one workflow step file is accessed (for reading or writing) by any other workflow step running independently. However, a file which has been updated in a previous completed step may be used as input to multiple steps, provided it is read-only in every step. + + Workflow steps which modify a file must produce the modified file as output. Downstream steps which further process the file must use the output of previous steps, and not refer to a common input (this is necessary for both ordering and correctness). + + Workflow authors should provide this in the ``hints`` section. The intent of this feature is that workflows produce the same results whether or not InplaceUpdateRequirement is supported by the implementation, and this feature is primarily available as an optimization for particular environments. + + Users and implementers should be aware that workflows that destructively modify inputs may not be repeatable or reproducible. In particular, enabling this feature implies that WorkReuse should not be enabled. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, InplaceUpdateRequirement): + return bool( + self.class_ == other.class_ + and self.inplaceUpdate == other.inplaceUpdate + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.inplaceUpdate)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("expression") is None: - raise ValidationException("missing required field `expression`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - expression = load_field( - _doc.get("expression"), - ExpressionLoader, + class_ = _load_field( + _doc.get("class"), + uri_InplaceUpdateRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("expression") + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("inplaceUpdate") is None: + raise ValidationException("missing required field `inplaceUpdate`", None, []) + + inplaceUpdate = _load_field( + _doc.get("inplaceUpdate"), + booltype, + baseuri, + loadingOptions, + lc=_doc.get("inplaceUpdate") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `expression`": + if str(e) == "missing required field `inplaceUpdate`": _errors__.append( ValidationException( str(e), @@ -21018,13 +17062,13 @@ def fromDoc( ) ) else: - val = _doc.get("expression") + val = _doc.get("inplaceUpdate") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `expression` field is not valid because:", - SourceLine(_doc, "expression", str), + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -21036,14 +17080,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `expression` field is not valid because:", - SourceLine(_doc, "expression", str), + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), [e], - detailed_message=f"the `expression` field with value `{val}` " + detailed_message=f"the `inplaceUpdate` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -21051,14 +17095,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `expression`".format( + "invalid field `{}`, expected one of: `class`, `inplaceUpdate`".format( k ), SourceLine(_doc, k, str), @@ -21068,20 +17112,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - label=label, - doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - intent=intent, - expression=expression, + inplaceUpdate=inplaceUpdate, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -21095,55 +17129,21 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) + u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.intent is not None: - u = save_relative_uri(self.intent, self.id, True, None, relative_uris) - r["intent"] = u - if self.expression is not None: - r["expression"] = save( - self.expression, + if self.inplaceUpdate is not None: + r["inplaceUpdate"] = save( + self.inplaceUpdate, top=False, - base_url=self.id, + base_url=base_url, relative_uris=relative_uris, ) @@ -21155,51 +17155,195 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "intent", - "class", - "expression", - ] - ) + def __init__( + self, + inplaceUpdate: bool, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "InplaceUpdateRequirement" + self.inplaceUpdate = inplaceUpdate + attrs: ClassVar[Collection[str]] = frozenset(["class", "inplaceUpdate"]) -class WorkflowOutputParameter(OutputParameter): - """ - Describe an output parameter of a workflow. The parameter must be - connected to one or more parameters defined in the workflow that - will provide the value of the output parameter. It is legal to - connect a WorkflowInputParameter to a WorkflowOutputParameter. - See [WorkflowStepInput](#WorkflowStepInput) for discussion of - `linkMerge` and `pickValue`. +@mypyc_attr(native_class=True) +class ToolTimeLimit(Saveable): + """ + Set an upper limit on the execution time of a CommandLineTool. A CommandLineTool whose execution duration exceeds the time limit may be preemptively terminated and considered failed. May also be used by batch systems to make scheduling decisions. The execution duration excludes external operations, such as staging of files, pulling a docker image etc, and only counts wall-time for the execution of the command line itself. """ - id: str + def __eq__(self, other: Any) -> bool: + if isinstance(other, ToolTimeLimit): + return bool( + self.class_ == other.class_ and self.timelimit == other.timelimit + ) + return False + + def __hash__(self) -> int: + return hash((self.class_, self.timelimit)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ToolTimeLimit_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + try: + if _doc.get("timelimit") is None: + raise ValidationException("missing required field `timelimit`", None, []) + + timelimit = _load_field( + _doc.get("timelimit"), + union_of_inttype_or_longtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("timelimit") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `timelimit`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("timelimit") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), + [e], + detailed_message=f"the `timelimit` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `class`, `timelimit`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + timelimit=timelimit, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + if self.timelimit is not None: + r["timelimit"] = save( + self.timelimit, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - outputSource: Optional[Any] = None, - linkMerge: Optional[Any] = None, - pickValue: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + timelimit: i32 | i64 | str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -21209,19 +17353,18 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.outputSource = outputSource - self.linkMerge = linkMerge - self.pickValue = pickValue - self.type_ = type_ + self.class_: Final[str] = "ToolTimeLimit" + self.timelimit = timelimit + + attrs: ClassVar[Collection[str]] = frozenset(["class", "timelimit"]) + + +@mypyc_attr(native_class=True) +class ExpressionToolOutputParameter(Saveable): + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowOutputParameter): + if isinstance(other, ExpressionToolOutputParameter): return bool( self.label == other.label and self.secondaryFiles == other.secondaryFiles @@ -21229,9 +17372,6 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.outputSource == other.outputSource - and self.linkMerge == other.linkMerge - and self.pickValue == other.pickValue and self.type_ == other.type_ ) return False @@ -21245,9 +17385,6 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.outputSource, - self.linkMerge, - self.pickValue, self.type_, ) ) @@ -21258,8 +17395,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -21269,7 +17406,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_strtype_True_False_None_None, baseuri, @@ -21314,18 +17451,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: + id = "" _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -21372,7 +17509,7 @@ def fromDoc( secondaryFiles = None if "secondaryFiles" in _doc: try: - secondaryFiles = load_field( + secondaryFiles = _load_field( _doc.get("secondaryFiles"), secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, @@ -21419,7 +17556,7 @@ def fromDoc( streamable = None if "streamable" in _doc: try: - streamable = load_field( + streamable = _load_field( _doc.get("streamable"), union_of_None_type_or_booltype, baseuri, @@ -21466,7 +17603,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -21513,7 +17650,7 @@ def fromDoc( format = None if "format" in _doc: try: - format = load_field( + format = _load_field( _doc.get("format"), uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, @@ -21557,152 +17694,11 @@ def fromDoc( "is not valid because:", ) ) - outputSource = None - if "outputSource" in _doc: - try: - outputSource = load_field( - _doc.get("outputSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, - baseuri, - loadingOptions, - lc=_doc.get("outputSource") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputSource`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputSource") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), - [e], - detailed_message=f"the `outputSource` field with value `{val}` " - "is not valid because:", - ) - ) - linkMerge = None - if "linkMerge" in _doc: - try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, - baseuri, - loadingOptions, - lc=_doc.get("linkMerge") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `linkMerge`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("linkMerge") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], - detailed_message=f"the `linkMerge` field with value `{val}` " - "is not valid because:", - ) - ) - pickValue = None - if "pickValue" in _doc: - try: - pickValue = load_field( - _doc.get("pickValue"), - union_of_None_type_or_PickValueMethodLoader, - baseuri, - loadingOptions, - lc=_doc.get("pickValue") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `pickValue`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("pickValue") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `pickValue` field is not valid because:", - SourceLine(_doc, "pickValue", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `pickValue` field is not valid because:", - SourceLine(_doc, "pickValue", str), - [e], - detailed_message=f"the `pickValue` field with value `{val}` " - "is not valid because:", - ) - ) try: if _doc.get("type") is None: raise ValidationException("missing required field `type`", None, []) - type_ = load_field( + type_ = _load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, @@ -21746,7 +17742,7 @@ def fromDoc( "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -21754,14 +17750,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `outputSource`, `linkMerge`, `pickValue`, `type`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`".format( k ), SourceLine(_doc, k, str), @@ -21771,20 +17767,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, label=label, secondaryFiles=secondaryFiles, streamable=streamable, doc=doc, - id=id, format=format, - outputSource=outputSource, - linkMerge=linkMerge, - pickValue=pickValue, type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -21799,7 +17792,7 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.label is not None: r["label"] = save( @@ -21826,17 +17819,6 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.outputSource is not None: - u = save_relative_uri(self.outputSource, self.id, False, 1, relative_uris) - r["outputSource"] = u - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.pickValue is not None: - r["pickValue"] = save( - self.pickValue, top=False, base_url=self.id, relative_uris=relative_uris - ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.id, relative_uris=relative_uris @@ -21850,154 +17832,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "outputSource", - "linkMerge", - "pickValue", - "type", - ] - ) - - -class Sink(Saveable): - pass - - -class WorkflowStepInput(IdentifierRequired, Sink, LoadContents, Labeled): - """ - The input of a workflow step connects an upstream parameter (from the - workflow inputs, or the outputs of other workflows steps) with the input - parameters of the process specified by the `run` field. Only input parameters - declared by the target process will be passed through at runtime to the process - though additional parameters may be specified (for use within `valueFrom` - expressions for instance) - unconnected or unused parameters do not represent an - error condition. - - # Input object - - A WorkflowStepInput object must contain an `id` field in the form - `#fieldname` or `#prefix/fieldname`. When the `id` field contains a slash - `/` the field name consists of the characters following the final slash - (the prefix portion may contain one or more slashes to indicate scope). - This defines a field of the workflow step input object with the value of - the `source` parameter(s). - - # Merging multiple inbound data links - - To merge multiple inbound data links, - [MultipleInputFeatureRequirement](#MultipleInputFeatureRequirement) must be specified - in the workflow or workflow step requirements. - - If the sink parameter is an array, or named in a [workflow - scatter](#WorkflowStep) operation, there may be multiple inbound - data links listed in the `source` field. The values from the - input links are merged depending on the method specified in the - `linkMerge` field. If both `linkMerge` and `pickValue` are null - or not specified, and there is more than one element in the - `source` array, the default method is "merge_nested". - - If both `linkMerge` and `pickValue` are null or not specified, and - there is only a single element in the `source`, then the input - parameter takes the scalar value from the single input link (it is - *not* wrapped in a single-list). - - * **merge_nested** - - The input must be an array consisting of exactly one entry for each - input link. If "merge_nested" is specified with a single link, the value - from the link must be wrapped in a single-item list. - - * **merge_flattened** - - 1. The source and sink parameters must be compatible types, or the source - type must be compatible with single element from the "items" type of - the destination array parameter. - 2. Source parameters which are arrays are concatenated. - Source parameters which are single element types are appended as - single elements. - - # Picking non-null values among inbound data links - - If present, `pickValue` specifies how to pick non-null values among inbound data links. - - `pickValue` is evaluated - 1. Once all source values from upstream step or parameters are available. - 2. After `linkMerge`. - 3. Before `scatter` or `valueFrom`. - - This is specifically intended to be useful in combination with - [conditional execution](#WorkflowStep), where several upstream - steps may be connected to a single input (`source` is a list), and - skipped steps produce null values. - - Static type checkers should check for type consistency after inferring what the type - will be after `pickValue` is applied, just as they do currently for `linkMerge`. - - * **first_non_null** - - For the first level of a list input, pick the first non-null element. The result is a scalar. - It is an error if there is no non-null element. Examples: - * `[null, x, null, y] -> x` - * `[null, [null], null, y] -> [null]` - * `[null, null, null] -> Runtime Error` - - *Intended use case*: If-else pattern where the - value comes either from a conditional step or from a default or - fallback value. The conditional step(s) should be placed first in - the list. - - * **the_only_non_null** - - For the first level of a list input, pick the single non-null element. The result is a scalar. - It is an error if there is more than one non-null element. Examples: - - * `[null, x, null] -> x` - * `[null, x, null, y] -> Runtime Error` - * `[null, [null], null] -> [null]` - * `[null, null, null] -> Runtime Error` - - *Intended use case*: Switch type patterns where developer considers - more than one active code path as a workflow error - (possibly indicating an error in writing `when` condition expressions). - - * **all_non_null** - - For the first level of a list input, pick all non-null values. - The result is a list, which may be empty. Examples: - - * `[null, x, null] -> [x]` - * `[x, null, y] -> [x, y]` - * `[null, [x], [null]] -> [[x], [null]]` - * `[null, null, null] -> []` - - *Intended use case*: It is valid to have more than one source, but - sources are conditional, so null sources (from skipped steps) - should be filtered out. - - """ - - id: str - def __init__( self, - id: Any, - source: Optional[Any] = None, - linkMerge: Optional[Any] = None, - pickValue: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - label: Optional[Any] = None, - default: Optional[Any] = None, - valueFrom: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -22007,43 +17852,54 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.source = source - self.linkMerge = linkMerge - self.pickValue = pickValue - self.loadContents = loadContents - self.loadListing = loadListing self.label = label - self.default = default - self.valueFrom = valueFrom + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( + ["label", "secondaryFiles", "streamable", "doc", "id", "format", "type"] + ) + + +@mypyc_attr(native_class=True) +class WorkflowInputParameter(Saveable): + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepInput): + if isinstance(other, WorkflowInputParameter): return bool( - self.id == other.id - and self.source == other.source - and self.linkMerge == other.linkMerge - and self.pickValue == other.pickValue + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id + and self.format == other.format and self.loadContents == other.loadContents and self.loadListing == other.loadListing - and self.label == other.label and self.default == other.default - and self.valueFrom == other.valueFrom + and self.type_ == other.type_ + and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: return hash( ( + self.label, + self.secondaryFiles, + self.streamable, + self.doc, self.id, - self.source, - self.linkMerge, - self.pickValue, + self.format, self.loadContents, self.loadListing, - self.label, self.default, - self.valueFrom, + self.type_, + self.inputBinding, ) ) @@ -22053,8 +17909,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStepInput": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -22064,7 +17920,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_strtype_True_False_None_None, baseuri, @@ -22109,29 +17965,29 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: + id = "" _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - source = None - if "source" in _doc: + else: + baseuri = id + label = None + if "label" in _doc: try: - source = load_field( - _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("source") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `source`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -22139,13 +17995,13 @@ def fromDoc( ) ) else: - val = _doc.get("source") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22157,28 +18013,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `source` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - linkMerge = None - if "linkMerge" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("linkMerge") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `linkMerge`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -22186,13 +18042,13 @@ def fromDoc( ) ) else: - val = _doc.get("linkMerge") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22204,28 +18060,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `linkMerge` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - pickValue = None - if "pickValue" in _doc: + streamable = None + if "streamable" in _doc: try: - pickValue = load_field( - _doc.get("pickValue"), - union_of_None_type_or_PickValueMethodLoader, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("pickValue") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `pickValue`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -22233,13 +18089,13 @@ def fromDoc( ) ) else: - val = _doc.get("pickValue") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `pickValue` field is not valid because:", - SourceLine(_doc, "pickValue", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22251,28 +18107,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `pickValue` field is not valid because:", - SourceLine(_doc, "pickValue", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `pickValue` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - loadContents = None - if "loadContents" in _doc: + doc = None + if "doc" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -22280,13 +18136,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22298,28 +18154,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + format = None + if "format" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -22327,13 +18183,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22345,28 +18201,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + loadContents = None + if "loadContents" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("loadContents") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( str(e), @@ -22374,13 +18230,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("loadContents") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22392,17 +18248,64 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `loadContents` field with value `{val}` " + "is not valid because:", + ) + ) + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " "is not valid because:", ) ) default = None if "default" in _doc: try: - default = load_field( + default = _load_field( _doc.get("default"), union_of_None_type_or_CWLObjectTypeLoader, baseuri, @@ -22446,21 +18349,69 @@ def fromDoc( "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + inputBinding = None + if "inputBinding" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + inputBinding = _load_field( + _doc.get("inputBinding"), + union_of_None_type_or_InputBindingLoader, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("inputBinding") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `inputBinding`": _errors__.append( ValidationException( str(e), @@ -22468,13 +18419,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("inputBinding") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -22486,14 +18437,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `inputBinding` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -22501,14 +18452,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `source`, `linkMerge`, `pickValue`, `loadContents`, `loadListing`, `label`, `default`, `valueFrom`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`, `inputBinding`".format( k ), SourceLine(_doc, k, str), @@ -22519,18 +18470,20 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, - source=source, - linkMerge=linkMerge, - pickValue=pickValue, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + format=format, loadContents=loadContents, loadListing=loadListing, - label=label, default=default, - valueFrom=valueFrom, + type_=type_, + inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -22545,44 +18498,61 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u - if self.source is not None: - u = save_relative_uri(self.source, self.id, False, 2, relative_uris) - r["source"] = u - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.pickValue is not None: - r["pickValue"] = save( - self.pickValue, top=False, base_url=self.id, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputBinding is not None: + r["inputBinding"] = save( + self.inputBinding, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) # top refers to the directory level @@ -22593,287 +18563,21 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "source", - "linkMerge", - "pickValue", - "loadContents", - "loadListing", - "label", - "default", - "valueFrom", - ] - ) - - -class WorkflowStepOutput(IdentifierRequired): - """ - Associate an output parameter of the underlying process with a workflow - parameter. The workflow parameter (given in the `id` field) be may be used - as a `source` to connect with input parameters of other workflow steps, or - with an output parameter of the process. - - A unique identifier for this workflow output parameter. This is - the identifier to use in the `source` field of `WorkflowStepInput` - to connect the output value to downstream parameters. - - """ - - id: str - - def __init__( - self, - id: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepOutput): - return bool(self.id == other.id) - return False - - def __hash__(self) -> int: - return hash((self.id)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStepOutput": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`".format(k), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["id"]) - - -class WorkflowStep(IdentifierRequired, Labeled, Documented): - """ - A workflow step is an executable element of a workflow. It specifies the - underlying process implementation (such as `CommandLineTool` or another - `Workflow`) in the `run` field and connects the input and output parameters - of the underlying process to workflow parameters. - - # Scatter/gather - - To use scatter/gather, - [ScatterFeatureRequirement](#ScatterFeatureRequirement) must be specified - in the workflow or workflow step requirements. - - A "scatter" operation specifies that the associated workflow step or - subworkflow should execute separately over a list of input elements. Each - job making up a scatter operation is independent and may be executed - concurrently. - - The `scatter` field specifies one or more input parameters which will be - scattered. An input parameter may be listed more than once. The declared - type of each input parameter implicitly becomes an array of items of the - input parameter type. If a parameter is listed more than once, it becomes - a nested array. As a result, upstream parameters which are connected to - scattered parameters must be arrays. - - All output parameter types are also implicitly wrapped in arrays. Each job - in the scatter results in an entry in the output array. - - If any scattered parameter runtime value is an empty array, all outputs are - set to empty arrays and no work is done for the step, according to - applicable scattering rules. - - If `scatter` declares more than one input parameter, `scatterMethod` - describes how to decompose the input into a discrete set of jobs. - - * **dotproduct** specifies that each of the input arrays are aligned and one - element taken from each array to construct each job. It is an error - if all input arrays are not the same length. - - * **nested_crossproduct** specifies the Cartesian product of the inputs, - producing a job for every combination of the scattered inputs. The - output must be nested arrays for each level of scattering, in the - order that the input arrays are listed in the `scatter` field. - - * **flat_crossproduct** specifies the Cartesian product of the inputs, - producing a job for every combination of the scattered inputs. The - output arrays must be flattened to a single level, but otherwise listed in the - order that the input arrays are listed in the `scatter` field. - - # Conditional execution (Optional) - - Conditional execution makes execution of a step conditional on an - expression. A step that is not executed is "skipped". A skipped - step produces `null` for all output parameters. - - The condition is evaluated after `scatter`, using the input object - of each individual scatter job. This means over a set of scatter - jobs, some may be executed and some may be skipped. When the - results are gathered, skipped steps must be `null` in the output - arrays. - - The `when` field controls conditional execution. This is an - expression that must be evaluated with `inputs` bound to the step - input object (or individual scatter job), and returns a boolean - value. It is an error if this expression returns a value other - than `true` or `false`. - - Conditionals in CWL are an optional feature and are not required - to be implemented by all consumers of CWL documents. An - implementation that does not support conditionals must return a - fatal error when attempting to execute a workflow that uses - conditional constructs the implementation does not support. - - # Subworkflows - - To specify a nested workflow as part of a workflow step, - [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) must be - specified in the workflow or workflow step requirements. - - It is a fatal error if a workflow directly or indirectly invokes itself as - a subworkflow (recursive workflows are not allowed). - - """ - - id: str - def __init__( self, - id: Any, - in_: Any, - out: Any, - run: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - when: Optional[Any] = None, - scatter: Optional[Any] = None, - scatterMethod: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + default: CWLObjectType | None = None, + inputBinding: InputBinding | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -22883,32 +18587,58 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable self.doc = doc - self.in_ = in_ - self.out = out - self.requirements = requirements - self.hints = hints - self.run = run - self.when = when - self.scatter = scatter - self.scatterMethod = scatterMethod + self.id = id + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + self.default = default + self.type_ = type_ + self.inputBinding = inputBinding + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "loadContents", + "loadListing", + "default", + "type", + "inputBinding", + ] + ) + + +@mypyc_attr(native_class=True) +class ExpressionTool(Saveable): + """ + An ExpressionTool is a type of Process object that can be run by itself or as a Workflow step. It executes a pure Javascript expression that has access to the same input parameters as a workflow. It is meant to be used sparingly as a way to isolate complex Javascript expressions that need to operate on input data and produce some result; perhaps just a rearrangement of the inputs. No Docker software container is required or allowed. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStep): + if isinstance(other, ExpressionTool): return bool( self.id == other.id and self.label == other.label and self.doc == other.doc - and self.in_ == other.in_ - and self.out == other.out + and self.inputs == other.inputs + and self.outputs == other.outputs and self.requirements == other.requirements and self.hints == other.hints - and self.run == other.run - and self.when == other.when - and self.scatter == other.scatter - and self.scatterMethod == other.scatterMethod + and self.cwlVersion == other.cwlVersion + and self.intent == other.intent + and self.class_ == other.class_ + and self.expression == other.expression ) return False @@ -22918,14 +18648,14 @@ def __hash__(self) -> int: self.id, self.label, self.doc, - self.in_, - self.out, + self.inputs, + self.outputs, self.requirements, self.hints, - self.run, - self.when, - self.scatter, - self.scatterMethod, + self.cwlVersion, + self.intent, + self.class_, + self.expression, ) ) @@ -22935,8 +18665,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowStep": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -22946,9 +18676,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -22991,18 +18721,34 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + id = "_:" + str(_uuid__.uuid4()) + else: + baseuri = id + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ExpressionTool_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -23049,7 +18795,7 @@ def fromDoc( doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -23094,21 +18840,21 @@ def fromDoc( ) ) try: - if _doc.get("in") is None: - raise ValidationException("missing required field `in`", None, []) + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) - in_ = load_field( - _doc.get("in"), - idmap_in__array_of_WorkflowStepInputLoader, + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, - lc=_doc.get("in") + lc=_doc.get("inputs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `in`": + if str(e) == "missing required field `inputs`": _errors__.append( ValidationException( str(e), @@ -23116,13 +18862,13 @@ def fromDoc( ) ) else: - val = _doc.get("in") + val = _doc.get("inputs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23134,29 +18880,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), [e], - detailed_message=f"the `in` field with value `{val}` " + detailed_message=f"the `inputs` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("out") is None: - raise ValidationException("missing required field `out`", None, []) + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) - out = load_field( - _doc.get("out"), - uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_ExpressionToolOutputParameterLoader, baseuri, loadingOptions, - lc=_doc.get("out") + lc=_doc.get("outputs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `out`": + if str(e) == "missing required field `outputs`": _errors__.append( ValidationException( str(e), @@ -23164,13 +18910,13 @@ def fromDoc( ) ) else: - val = _doc.get("out") + val = _doc.get("outputs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23182,19 +18928,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), [e], - detailed_message=f"the `out` field with value `{val}` " + detailed_message=f"the `outputs` field with value `{val}` " "is not valid because:", ) ) requirements = None if "requirements" in _doc: try: - requirements = load_field( + requirements = _load_field( _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, lc=_doc.get("requirements") @@ -23236,118 +18982,21 @@ def fromDoc( "is not valid because:", ) ) - hints = None - if "hints" in _doc: - try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("hints") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `hints`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("hints") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [e], - detailed_message=f"the `hints` field with value `{val}` " - "is not valid because:", - ) - ) - - subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) - try: - if _doc.get("run") is None: - raise ValidationException("missing required field `run`", None, []) - - run = load_field( - _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_False_False_None_None, - subscope_baseuri, - loadingOptions, - lc=_doc.get("run") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `run`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("run") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [e], - detailed_message=f"the `run` field with value `{val}` " - "is not valid because:", - ) - ) - when = None - if "when" in _doc: + hints = None + if "hints" in _doc: try: - when = load_field( - _doc.get("when"), - union_of_None_type_or_ExpressionLoader, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("when") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `when`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -23355,13 +19004,13 @@ def fromDoc( ) ) else: - val = _doc.get("when") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `when` field is not valid because:", - SourceLine(_doc, "when", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23373,28 +19022,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `when` field is not valid because:", - SourceLine(_doc, "when", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `when` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - scatter = None - if "scatter" in _doc: + cwlVersion = None + if "cwlVersion" in _doc: try: - scatter = load_field( - _doc.get("scatter"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("scatter") + lc=_doc.get("cwlVersion") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `scatter`": + if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( str(e), @@ -23402,13 +19051,13 @@ def fromDoc( ) ) else: - val = _doc.get("scatter") + val = _doc.get("cwlVersion") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `scatter` field is not valid because:", - SourceLine(_doc, "scatter", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23420,28 +19069,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `scatter` field is not valid because:", - SourceLine(_doc, "scatter", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [e], - detailed_message=f"the `scatter` field with value `{val}` " + detailed_message=f"the `cwlVersion` field with value `{val}` " "is not valid because:", ) ) - scatterMethod = None - if "scatterMethod" in _doc: + intent = None + if "intent" in _doc: try: - scatterMethod = load_field( - _doc.get("scatterMethod"), - uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, + intent = _load_field( + _doc.get("intent"), + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("scatterMethod") + lc=_doc.get("intent") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `scatterMethod`": + if str(e) == "missing required field `intent`": _errors__.append( ValidationException( str(e), @@ -23449,13 +19098,13 @@ def fromDoc( ) ) else: - val = _doc.get("scatterMethod") + val = _doc.get("intent") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `scatterMethod` field is not valid because:", - SourceLine(_doc, "scatterMethod", str), + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23467,14 +19116,62 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `scatterMethod` field is not valid because:", - SourceLine(_doc, "scatterMethod", str), + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), [e], - detailed_message=f"the `scatterMethod` field with value `{val}` " + detailed_message=f"the `intent` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + try: + if _doc.get("expression") is None: + raise ValidationException("missing required field `expression`", None, []) + + expression = _load_field( + _doc.get("expression"), + ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("expression") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expression`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("expression") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [e], + detailed_message=f"the `expression` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -23482,14 +19179,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `in`, `out`, `requirements`, `hints`, `run`, `when`, `scatter`, `scatterMethod`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `expression`".format( k ), SourceLine(_doc, k, str), @@ -23502,18 +19199,17 @@ def fromDoc( id=id, label=label, doc=doc, - in_=in_, - out=out, + inputs=inputs, + outputs=outputs, requirements=requirements, hints=hints, - run=run, - when=when, - scatter=scatter, - scatterMethod=scatterMethod, + cwlVersion=cwlVersion, + intent=intent, + expression=expression, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -23528,8 +19224,18 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.id, False, None, relative_uris) + r["class"] = u if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.id, relative_uris=relative_uris @@ -23538,13 +19244,14 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.in_ is not None: - r["in"] = save( - self.in_, top=False, base_url=self.id, relative_uris=relative_uris + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.out is not None: - u = save_relative_uri(self.out, self.id, True, None, relative_uris) - r["out"] = u if self.requirements is not None: r["requirements"] = save( self.requirements, @@ -23556,21 +19263,19 @@ def save( r["hints"] = save( self.hints, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u - if self.when is not None: - r["when"] = save( - self.when, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.scatter is not None: - u = save_relative_uri(self.scatter, self.id, False, 0, relative_uris) - r["scatter"] = u - if self.scatterMethod is not None: - u = save_relative_uri( - self.scatterMethod, self.id, False, None, relative_uris + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.intent is not None: + u = save_relative_uri(self.intent, self.id, True, None, relative_uris) + r["intent"] = u + if self.expression is not None: + r["expression"] = save( + self.expression, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - r["scatterMethod"] = u # top refers to the directory level if top: @@ -23580,95 +19285,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "label", - "doc", - "in", - "out", - "requirements", - "hints", - "run", - "when", - "scatter", - "scatterMethod", - ] - ) - - -class Workflow(Process): - """ - A workflow describes a set of **steps** and the **dependencies** between - those steps. When a step produces output that will be consumed by a - second step, the first step is a dependency of the second step. - - When there is a dependency, the workflow engine must execute the preceding - step and wait for it to successfully produce output before executing the - dependent step. If two steps are defined in the workflow graph that - are not directly or indirectly dependent, these steps are **independent**, - and may execute in any order or execute concurrently. A workflow is - complete when all steps have been executed. - - Dependencies between parameters are expressed using the `source` - field on [workflow step input parameters](#WorkflowStepInput) and - `outputSource` field on [workflow output - parameters](#WorkflowOutputParameter). - - The `source` field on each workflow step input parameter expresses - the data links that contribute to the value of the step input - parameter (the "sink"). A workflow step can only begin execution - when every data link connected to a step has been fulfilled. - - The `outputSource` field on each workflow step input parameter - expresses the data links that contribute to the value of the - workflow output parameter (the "sink"). Workflow execution cannot - complete successfully until every data link connected to an output - parameter has been fulfilled. - - ## Workflow success and failure - - A completed step must result in one of `success`, `temporaryFailure` or - `permanentFailure` states. An implementation may choose to retry a step - execution which resulted in `temporaryFailure`. An implementation may - choose to either continue running other steps of a workflow, or terminate - immediately upon `permanentFailure`. - - * If any step of a workflow execution results in `permanentFailure`, then - the workflow status is `permanentFailure`. - - * If one or more steps result in `temporaryFailure` and all other steps - complete `success` or are not executed, then the workflow status is - `temporaryFailure`. - - * If all workflow steps are executed and complete with `success`, then the - workflow status is `success`. - - # Extensions - - [ScatterFeatureRequirement](#ScatterFeatureRequirement) and - [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) are - available as standard [extensions](#Extensions_and_Metadata) to core - workflow semantics. - - """ - - id: str - def __init__( self, - inputs: Any, - outputs: Any, - steps: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - intent: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + inputs: Sequence[WorkflowInputParameter], + outputs: Sequence[ExpressionToolOutputParameter], + expression: str, + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + intent: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -23687,40 +19317,66 @@ def __init__( self.hints = hints self.cwlVersion = cwlVersion self.intent = intent - self.class_ = "Workflow" - self.steps = steps + self.class_: Final[str] = "ExpressionTool" + self.expression = expression + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "inputs", + "outputs", + "requirements", + "hints", + "cwlVersion", + "intent", + "class", + "expression", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkflowOutputParameter(Saveable): + """ + Describe an output parameter of a workflow. The parameter must be connected to one or more parameters defined in the workflow that will provide the value of the output parameter. It is legal to connect a WorkflowInputParameter to a WorkflowOutputParameter. + + See `WorkflowStepInput <#WorkflowStepInput>`__ for discussion of ``linkMerge`` and ``pickValue``. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, Workflow): + if isinstance(other, WorkflowOutputParameter): return bool( - self.id == other.id - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.intent == other.intent - and self.class_ == other.class_ - and self.steps == other.steps + and self.id == other.id + and self.format == other.format + and self.outputSource == other.outputSource + and self.linkMerge == other.linkMerge + and self.pickValue == other.pickValue + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( ( - self.id, self.label, + self.secondaryFiles, + self.streamable, self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.intent, - self.class_, - self.steps, + self.id, + self.format, + self.outputSource, + self.linkMerge, + self.pickValue, + self.type_, ) ) @@ -23730,8 +19386,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Workflow": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -23741,9 +19397,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -23786,34 +19442,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_Workflow_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -23857,21 +19497,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -23879,13 +19519,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -23897,124 +19537,122 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_WorkflowInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("streamable") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", + val = _doc.get("streamable") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_WorkflowOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: + try: + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - requirements = None - if "requirements" in _doc: + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + format = None + if "format" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -24022,13 +19660,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -24040,28 +19678,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + outputSource = None + if "outputSource" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, + outputSource = _load_field( + _doc.get("outputSource"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("outputSource") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `outputSource`": _errors__.append( ValidationException( str(e), @@ -24069,13 +19707,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("outputSource") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -24087,28 +19725,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `outputSource` field with value `{val}` " "is not valid because:", ) ) - cwlVersion = None - if "cwlVersion" in _doc: + linkMerge = None + if "linkMerge" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + linkMerge = _load_field( + _doc.get("linkMerge"), + union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("linkMerge") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `linkMerge`": _errors__.append( ValidationException( str(e), @@ -24116,13 +19754,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("linkMerge") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -24134,28 +19772,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `linkMerge` field with value `{val}` " "is not valid because:", ) ) - intent = None - if "intent" in _doc: + pickValue = None + if "pickValue" in _doc: try: - intent = load_field( - _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None_None, + pickValue = _load_field( + _doc.get("pickValue"), + union_of_None_type_or_PickValueMethodLoader, baseuri, loadingOptions, - lc=_doc.get("intent") + lc=_doc.get("pickValue") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `intent`": + if str(e) == "missing required field `pickValue`": _errors__.append( ValidationException( str(e), @@ -24163,13 +19801,13 @@ def fromDoc( ) ) else: - val = _doc.get("intent") + val = _doc.get("pickValue") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -24181,29 +19819,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), [e], - detailed_message=f"the `intent` field with value `{val}` " + detailed_message=f"the `pickValue` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("steps") is None: - raise ValidationException("missing required field `steps`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - steps = load_field( - _doc.get("steps"), - idmap_steps_union_of_array_of_WorkflowStepLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("steps") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `steps`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -24211,13 +19849,13 @@ def fromDoc( ) ) else: - val = _doc.get("steps") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `steps` field is not valid because:", - SourceLine(_doc, "steps", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -24229,14 +19867,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `steps` field is not valid because:", - SourceLine(_doc, "steps", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `steps` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -24244,14 +19882,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `steps`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `outputSource`, `linkMerge`, `pickValue`, `type`".format( k ), SourceLine(_doc, k, str), @@ -24263,18 +19901,18 @@ def fromDoc( _constructed = cls( id=id, label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - intent=intent, - steps=steps, + format=format, + outputSource=outputSource, + linkMerge=linkMerge, + pickValue=pickValue, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -24289,52 +19927,47 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.intent is not None: - u = save_relative_uri(self.intent, self.id, True, None, relative_uris) - r["intent"] = u - if self.steps is not None: - r["steps"] = save( - self.steps, top=False, base_url=self.id, relative_uris=relative_uris + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.outputSource is not None: + u = save_relative_uri(self.outputSource, self.id, False, 1, relative_uris) + r["outputSource"] = u + if self.linkMerge is not None: + r["linkMerge"] = save( + self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.pickValue is not None: + r["pickValue"] = save( + self.pickValue, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -24345,34 +19978,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "intent", - "class", - "steps", - ] - ) - - -class SubworkflowFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support nested workflows in - the `run` field of [WorkflowStep](#WorkflowStep). - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + outputSource: None | Sequence[str] | str = None, + linkMerge: LinkMergeMethod | None = None, + pickValue: None | PickValueMethod = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -24382,134 +20001,141 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "SubworkflowFeatureRequirement" + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.outputSource = outputSource + self.linkMerge = linkMerge + self.pickValue = pickValue + self.type_ = type_ - def __eq__(self, other: Any) -> bool: - if isinstance(other, SubworkflowFeatureRequirement): - return bool(self.class_ == other.class_) - return False + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "outputSource", + "linkMerge", + "pickValue", + "type", + ] + ) - def __hash__(self) -> int: - return hash((self.class_)) - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "SubworkflowFeatureRequirement": - _doc = copy.copy(doc) +@mypyc_attr(native_class=True) +class WorkflowStepInput(Saveable): + """ + The input of a workflow step connects an upstream parameter (from the workflow inputs, or the outputs of other workflows steps) with the input parameters of the process specified by the ``run`` field. Only input parameters declared by the target process will be passed through at runtime to the process though additional parameters may be specified (for use within ``valueFrom`` expressions for instance) - unconnected or unused parameters do not represent an error condition. - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + Input object + ============ - class_ = load_field( - _doc.get("class"), - uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + A WorkflowStepInput object must contain an ``id`` field in the form ``#fieldname`` or ``#prefix/fieldname``. When the ``id`` field contains a slash ``/`` the field name consists of the characters following the final slash (the prefix portion may contain one or more slashes to indicate scope). This defines a field of the workflow step input object with the value of the ``source`` parameter(s). - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), - ) - ) + Merging multiple inbound data links + =================================== - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed + To merge multiple inbound data links, `MultipleInputFeatureRequirement <#MultipleInputFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + If the sink parameter is an array, or named in a `workflow scatter <#WorkflowStep>`__ operation, there may be multiple inbound data links listed in the ``source`` field. The values from the input links are merged depending on the method specified in the ``linkMerge`` field. If both ``linkMerge`` and ``pickValue`` are null or not specified, and there is more than one element in the ``source`` array, the default method is "merge_nested". + + If both ``linkMerge`` and ``pickValue`` are null or not specified, and there is only a single element in the ``source``, then the input parameter takes the scalar value from the single input link (it is *not* wrapped in a single-list). + + * **merge_nested** + + The input must be an array consisting of exactly one entry for each input link. If "merge_nested" is specified with a single link, the value from the link must be wrapped in a single-item list. + + * **merge_flattened** + + 1. The source and sink parameters must be compatible types, or the source type must be compatible with single element from the "items" type of the destination array parameter. + 2. Source parameters which are arrays are concatenated. Source parameters which are single element types are appended as single elements. + + Picking non-null values among inbound data links + ================================================ + + If present, ``pickValue`` specifies how to pick non-null values among inbound data links. + + ``pickValue`` is evaluated + + 1. Once all source values from upstream step or parameters are available. + 2. After ``linkMerge``. + 3. Before ``scatter`` or ``valueFrom``. + + This is specifically intended to be useful in combination with `conditional execution <#WorkflowStep>`__, where several upstream steps may be connected to a single input (``source`` is a list), and skipped steps produce null values. + + Static type checkers should check for type consistency after inferring what the type will be after ``pickValue`` is applied, just as they do currently for ``linkMerge``. + + * **first_non_null** + + For the first level of a list input, pick the first non-null element. The result is a scalar. It is an error if there is no non-null element. Examples: + + * ``[null, x, null, y] -> x`` + * ``[null, [null], null, y] -> [null]`` + * ``[null, null, null] -> Runtime Error`` + + *Intended use case*: If-else pattern where the value comes either from a conditional step or from a default or fallback value. The conditional step(s) should be placed first in the list. + + * **the_only_non_null** + + For the first level of a list input, pick the single non-null element. The result is a scalar. It is an error if there is more than one non-null element. Examples: - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} + * ``[null, x, null] -> x`` + * ``[null, x, null, y] -> Runtime Error`` + * ``[null, [null], null] -> [null]`` + * ``[null, null, null] -> Runtime Error`` - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + *Intended use case*: Switch type patterns where developer considers more than one active code path as a workflow error (possibly indicating an error in writing ``when`` condition expressions). - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r + * **all_non_null** - attrs = frozenset(["class"]) + For the first level of a list input, pick all non-null values. The result is a list, which may be empty. Examples: + * ``[null, x, null] -> [x]`` + * ``[x, null, y] -> [x, y]`` + * ``[null, [x], [null]] -> [[x], [null]]`` + * ``[null, null, null] -> []`` -class ScatterFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support the `scatter` and - `scatterMethod` fields of [WorkflowStep](#WorkflowStep). + *Intended use case*: It is valid to have more than one source, but sources are conditional, so null sources (from skipped steps) should be filtered out. """ - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "ScatterFeatureRequirement" + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, ScatterFeatureRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, WorkflowStepInput): + return bool( + self.id == other.id + and self.source == other.source + and self.linkMerge == other.linkMerge + and self.pickValue == other.pickValue + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.label == other.label + and self.default == other.default + and self.valueFrom == other.valueFrom + ) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash( + ( + self.id, + self.source, + self.linkMerge, + self.pickValue, + self.loadContents, + self.loadListing, + self.label, + self.default, + self.valueFrom, + ) + ) @classmethod def fromDoc( @@ -24517,150 +20143,447 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ScatterFeatureRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + source = None + if "source" in _doc: + try: + source = _load_field( + _doc.get("source"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + baseuri, + loadingOptions, + lc=_doc.get("source") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `source`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("source") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [e], + detailed_message=f"the `source` field with value `{val}` " + "is not valid because:", + ) + ) + linkMerge = None + if "linkMerge" in _doc: + try: + linkMerge = _load_field( + _doc.get("linkMerge"), + union_of_None_type_or_LinkMergeMethodLoader, + baseuri, + loadingOptions, + lc=_doc.get("linkMerge") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("linkMerge") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + detailed_message=f"the `linkMerge` field with value `{val}` " + "is not valid because:", + ) + ) + pickValue = None + if "pickValue" in _doc: + try: + pickValue = _load_field( + _doc.get("pickValue"), + union_of_None_type_or_PickValueMethodLoader, + baseuri, + loadingOptions, + lc=_doc.get("pickValue") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `pickValue`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("pickValue") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), + [e], + detailed_message=f"the `pickValue` field with value `{val}` " + "is not valid because:", + ) + ) + loadContents = None + if "loadContents" in _doc: + try: + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("loadContents") + ) - class_ = load_field( - _doc.get("class"), - uri_ScatterFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + if str(e) == "missing required field `loadContents`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("loadContents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + detailed_message=f"the `loadContents` field with value `{val}` " + "is not valid because:", + ) + ) + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["class"]) - - -class MultipleInputFeatureRequirement(ProcessRequirement): - """ - Indicates that the workflow platform must support multiple inbound data links - listed in the `source` field of [WorkflowStepInput](#WorkflowStepInput). - - """ - - def __init__( - self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "MultipleInputFeatureRequirement" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, MultipleInputFeatureRequirement): - return bool(self.class_ == other.class_) - return False + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - def __hash__(self) -> int: - return hash((self.class_)) + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MultipleInputFeatureRequirement": - _doc = copy.copy(doc) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("default") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + detailed_message=f"the `default` field with value `{val}` " + "is not valid because:", + ) + ) + valueFrom = None + if "valueFrom" in _doc: + try: + valueFrom = _load_field( + _doc.get("valueFrom"), + union_of_None_type_or_strtype_or_ExpressionLoader, + baseuri, + loadingOptions, + lc=_doc.get("valueFrom") + ) - class_ = load_field( - _doc.get("class"), - uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("valueFrom") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + detailed_message=f"the `valueFrom` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -24668,14 +20591,16 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), + "invalid field `{}`, expected one of: `id`, `source`, `linkMerge`, `pickValue`, `loadContents`, `loadListing`, `label`, `default`, `valueFrom`".format( + k + ), SourceLine(_doc, k, str), ) ) @@ -24683,9 +20608,19 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, + source=source, + linkMerge=linkMerge, + pickValue=pickValue, + loadContents=loadContents, + loadListing=loadListing, + label=label, + default=default, + valueFrom=valueFrom, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -24699,14 +20634,46 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.source is not None: + u = save_relative_uri(self.source, self.id, False, 2, relative_uris) + r["source"] = u + if self.linkMerge is not None: + r["linkMerge"] = save( + self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.pickValue is not None: + r["pickValue"] = save( + self.pickValue, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.valueFrom is not None: + r["valueFrom"] = save( + self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -24716,20 +20683,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class"]) - - -class StepInputExpressionRequirement(ProcessRequirement): - """ - Indicate that the workflow platform must support the `valueFrom` field - of [WorkflowStepInput](#WorkflowStepInput). - - """ - def __init__( self, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + source: None | Sequence[str] | str = None, + linkMerge: LinkMergeMethod | None = None, + pickValue: None | PickValueMethod = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + label: None | str = None, + default: CWLObjectType | None = None, + valueFrom: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -24739,15 +20705,49 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "StepInputExpressionRequirement" + self.id = id + self.source = source + self.linkMerge = linkMerge + self.pickValue = pickValue + self.loadContents = loadContents + self.loadListing = loadListing + self.label = label + self.default = default + self.valueFrom = valueFrom + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "source", + "linkMerge", + "pickValue", + "loadContents", + "loadListing", + "label", + "default", + "valueFrom", + ] + ) + + +@mypyc_attr(native_class=True) +class WorkflowStepOutput(Saveable): + """ + Associate an output parameter of the underlying process with a workflow parameter. The workflow parameter (given in the ``id`` field) be may be used as a ``source`` to connect with input parameters of other workflow steps, or with an output parameter of the process. + + A unique identifier for this workflow output parameter. This is the identifier to use in the ``source`` field of ``WorkflowStepInput`` to connect the output value to downstream parameters. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, StepInputExpressionRequirement): - return bool(self.class_ == other.class_) + if isinstance(other, WorkflowStepOutput): + return bool(self.id == other.id) return False def __hash__(self) -> int: - return hash((self.class_)) + return hash((self.id)) @classmethod def fromDoc( @@ -24755,31 +20755,71 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "StepInputExpressionRequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) - class_ = load_field( - _doc.get("class"), - uri_StepInputExpressionRequirement_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - extension_fields: dict[str, Any] = {} + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -24787,14 +20827,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`".format(k), + "invalid field `{}`, expected one of: `id`".format(k), SourceLine(_doc, k, str), ) ) @@ -24802,9 +20842,11 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -24818,14 +20860,9 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u # top refers to the directory level if top: @@ -24835,31 +20872,11 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class"]) - - -class OperationInputParameter(InputParameter): - """ - Describe an input parameter of an operation. - - """ - - id: str - def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - loadContents: Optional[Any] = None, - loadListing: Optional[Any] = None, - default: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -24869,46 +20886,90 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.loadContents = loadContents - self.loadListing = loadListing - self.default = default - self.type_ = type_ + self.id = id + + attrs: ClassVar[Collection[str]] = frozenset(["id"]) + + +@mypyc_attr(native_class=True) +class WorkflowStep(schema_salad.metaschema.Documented): + """ + A workflow step is an executable element of a workflow. It specifies the underlying process implementation (such as ``CommandLineTool`` or another ``Workflow``) in the ``run`` field and connects the input and output parameters of the underlying process to workflow parameters. + + Scatter/gather + ============== + + To use scatter/gather, `ScatterFeatureRequirement <#ScatterFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + A "scatter" operation specifies that the associated workflow step or subworkflow should execute separately over a list of input elements. Each job making up a scatter operation is independent and may be executed concurrently. + + The ``scatter`` field specifies one or more input parameters which will be scattered. An input parameter may be listed more than once. The declared type of each input parameter implicitly becomes an array of items of the input parameter type. If a parameter is listed more than once, it becomes a nested array. As a result, upstream parameters which are connected to scattered parameters must be arrays. + + All output parameter types are also implicitly wrapped in arrays. Each job in the scatter results in an entry in the output array. + + If any scattered parameter runtime value is an empty array, all outputs are set to empty arrays and no work is done for the step, according to applicable scattering rules. + + If ``scatter`` declares more than one input parameter, ``scatterMethod`` describes how to decompose the input into a discrete set of jobs. + + * **dotproduct** specifies that each of the input arrays are aligned and one element taken from each array to construct each job. It is an error if all input arrays are not the same length. + + * **nested_crossproduct** specifies the Cartesian product of the inputs, producing a job for every combination of the scattered inputs. The output must be nested arrays for each level of scattering, in the order that the input arrays are listed in the ``scatter`` field. + + * **flat_crossproduct** specifies the Cartesian product of the inputs, producing a job for every combination of the scattered inputs. The output arrays must be flattened to a single level, but otherwise listed in the order that the input arrays are listed in the ``scatter`` field. + + Conditional execution (Optional) + ================================ + + Conditional execution makes execution of a step conditional on an expression. A step that is not executed is "skipped". A skipped step produces ``null`` for all output parameters. + + The condition is evaluated after ``scatter``, using the input object of each individual scatter job. This means over a set of scatter jobs, some may be executed and some may be skipped. When the results are gathered, skipped steps must be ``null`` in the output arrays. + + The ``when`` field controls conditional execution. This is an expression that must be evaluated with ``inputs`` bound to the step input object (or individual scatter job), and returns a boolean value. It is an error if this expression returns a value other than ``true`` or ``false``. + + Conditionals in CWL are an optional feature and are not required to be implemented by all consumers of CWL documents. An implementation that does not support conditionals must return a fatal error when attempting to execute a workflow that uses conditional constructs the implementation does not support. + + Subworkflows + ============ + + To specify a nested workflow as part of a workflow step, `SubworkflowFeatureRequirement <#SubworkflowFeatureRequirement>`__ must be specified in the workflow or workflow step requirements. + + It is a fatal error if a workflow directly or indirectly invokes itself as a subworkflow (recursive workflows are not allowed). + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, OperationInputParameter): + if isinstance(other, WorkflowStep): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable + self.id == other.id + and self.label == other.label and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.loadContents == other.loadContents - and self.loadListing == other.loadListing - and self.default == other.default - and self.type_ == other.type_ + and self.in_ == other.in_ + and self.out == other.out + and self.requirements == other.requirements + and self.hints == other.hints + and self.run == other.run + and self.when == other.when + and self.scatter == other.scatter + and self.scatterMethod == other.scatterMethod ) return False def __hash__(self) -> int: return hash( ( + self.id, self.label, - self.secondaryFiles, - self.streamable, self.doc, - self.id, - self.format, - self.loadContents, - self.loadListing, - self.default, - self.type_, + self.in_, + self.out, + self.requirements, + self.hints, + self.run, + self.when, + self.scatter, + self.scatterMethod, ) ) @@ -24918,8 +20979,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OperationInputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -24929,7 +20990,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_strtype_True_False_None_None, baseuri, @@ -24974,18 +21035,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: + id = "" _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -25029,21 +21090,21 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: + doc = None + if "doc" in _doc: try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("secondaryFiles") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `secondaryFiles`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -25051,13 +21112,13 @@ def fromDoc( ) ) else: - val = _doc.get("secondaryFiles") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25069,28 +21130,124 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - streamable = None - if "streamable" in _doc: + try: + if _doc.get("in") is None: + raise ValidationException("missing required field `in`", None, []) + + in_ = _load_field( + _doc.get("in"), + idmap_in__array_of_WorkflowStepInputLoader, + baseuri, + loadingOptions, + lc=_doc.get("in") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("in") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + detailed_message=f"the `in` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("out") is None: + raise ValidationException("missing required field `out`", None, []) + + out = _load_field( + _doc.get("out"), + uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("out") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `out`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("out") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [e], + detailed_message=f"the `out` field with value `{val}` " + "is not valid because:", + ) + ) + requirements = None + if "requirements" in _doc: try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, - lc=_doc.get("streamable") + lc=_doc.get("requirements") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `streamable`": + if str(e) == "missing required field `requirements`": _errors__.append( ValidationException( str(e), @@ -25098,13 +21255,13 @@ def fromDoc( ) ) else: - val = _doc.get("streamable") + val = _doc.get("requirements") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25116,28 +21273,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [e], - detailed_message=f"the `streamable` field with value `{val}` " + detailed_message=f"the `requirements` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + hints = None + if "hints" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_Any_type, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -25145,13 +21302,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25163,75 +21320,78 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + subscope_baseuri = _expand_url('run', baseuri, loadingOptions, True) + try: + if _doc.get("run") is None: + raise ValidationException("missing required field `run`", None, []) - if str(e) == "missing required field `format`": + run = _load_field( + _doc.get("run"), + uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None_None, + subscope_baseuri, + loadingOptions, + lc=_doc.get("run") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `run`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("run") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [e], + detailed_message=f"the `run` field with value `{val}` " + "is not valid because:", ) - loadContents = None - if "loadContents" in _doc: + ) + when = None + if "when" in _doc: try: - loadContents = load_field( - _doc.get("loadContents"), - union_of_None_type_or_booltype, + when = _load_field( + _doc.get("when"), + union_of_None_type_or_ExpressionLoader, baseuri, loadingOptions, - lc=_doc.get("loadContents") + lc=_doc.get("when") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadContents`": + if str(e) == "missing required field `when`": _errors__.append( ValidationException( str(e), @@ -25239,13 +21399,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadContents") + val = _doc.get("when") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25257,28 +21417,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadContents` field is not valid because:", - SourceLine(_doc, "loadContents", str), + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), [e], - detailed_message=f"the `loadContents` field with value `{val}` " + detailed_message=f"the `when` field with value `{val}` " "is not valid because:", ) ) - loadListing = None - if "loadListing" in _doc: + scatter = None + if "scatter" in _doc: try: - loadListing = load_field( - _doc.get("loadListing"), - union_of_None_type_or_LoadListingEnumLoader, + scatter = _load_field( + _doc.get("scatter"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, baseuri, loadingOptions, - lc=_doc.get("loadListing") + lc=_doc.get("scatter") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loadListing`": + if str(e) == "missing required field `scatter`": _errors__.append( ValidationException( str(e), @@ -25286,13 +21446,13 @@ def fromDoc( ) ) else: - val = _doc.get("loadListing") + val = _doc.get("scatter") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25304,28 +21464,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loadListing` field is not valid because:", - SourceLine(_doc, "loadListing", str), + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), [e], - detailed_message=f"the `loadListing` field with value `{val}` " + detailed_message=f"the `scatter` field with value `{val}` " "is not valid because:", ) ) - default = None - if "default" in _doc: + scatterMethod = None + if "scatterMethod" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_CWLObjectTypeLoader, + scatterMethod = _load_field( + _doc.get("scatterMethod"), + uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("scatterMethod") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `scatterMethod`": _errors__.append( ValidationException( str(e), @@ -25333,13 +21493,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("scatterMethod") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25351,62 +21511,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `scatterMethod` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -25414,14 +21526,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `in`, `out`, `requirements`, `hints`, `run`, `when`, `scatter`, `scatterMethod`".format( k ), SourceLine(_doc, k, str), @@ -25431,20 +21543,21 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( + id=id, label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, doc=doc, - id=id, - format=format, - loadContents=loadContents, - loadListing=loadListing, - default=default, - type_=type_, + in_=in_, + out=out, + requirements=requirements, + hints=hints, + run=run, + when=when, + scatter=scatter, + scatterMethod=scatterMethod, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -25459,99 +21572,73 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) + u = save_relative_uri(self.id, self.id, True, None, relative_uris) r["id"] = u if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) if self.doc is not None: r["doc"] = save( self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.loadContents is not None: - r["loadContents"] = save( - self.loadContents, - top=False, - base_url=self.id, - relative_uris=relative_uris, + if self.in_ is not None: + r["in"] = save( + self.in_, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.loadListing is not None: - r["loadListing"] = save( - self.loadListing, + if self.out is not None: + u = save_relative_uri(self.out, self.id, True, None, relative_uris) + r["out"] = u + if self.requirements is not None: + r["requirements"] = save( + self.requirements, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris ) + if self.run is not None: + u = save_relative_uri(self.run, self.id, False, None, relative_uris) + r["run"] = u + if self.when is not None: + r["when"] = save( + self.when, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.scatter is not None: + u = save_relative_uri(self.scatter, self.id, False, 0, relative_uris) + r["scatter"] = u + if self.scatterMethod is not None: + u = save_relative_uri( + self.scatterMethod, self.id, False, None, relative_uris + ) + r["scatterMethod"] = u - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "secondaryFiles", - "streamable", - "doc", - "id", - "format", - "loadContents", - "loadListing", - "default", - "type", - ] - ) - - -class OperationOutputParameter(OutputParameter): - """ - Describe an output parameter of an operation. - - """ - - id: str + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r def __init__( self, - id: Any, - type_: Any, - label: Optional[Any] = None, - secondaryFiles: Optional[Any] = None, - streamable: Optional[Any] = None, - doc: Optional[Any] = None, - format: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + in_: Sequence[WorkflowStepInput], + out: Sequence[WorkflowStepOutput | str], + run: CommandLineTool | ExpressionTool | Operation | Workflow | str, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any] = None, + when: None | str = None, + scatter: None | Sequence[str] | str = None, + scatterMethod: None | ScatterMethod = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -25561,37 +21648,99 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.id = id self.label = label - self.secondaryFiles = secondaryFiles - self.streamable = streamable self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.format = format - self.type_ = type_ + self.in_ = in_ + self.out = out + self.requirements = requirements + self.hints = hints + self.run = run + self.when = when + self.scatter = scatter + self.scatterMethod = scatterMethod + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "in", + "out", + "requirements", + "hints", + "run", + "when", + "scatter", + "scatterMethod", + ] + ) + + +@mypyc_attr(native_class=True) +class Workflow(Saveable): + """ + A workflow describes a set of **steps** and the **dependencies** between those steps. When a step produces output that will be consumed by a second step, the first step is a dependency of the second step. + + When there is a dependency, the workflow engine must execute the preceding step and wait for it to successfully produce output before executing the dependent step. If two steps are defined in the workflow graph that are not directly or indirectly dependent, these steps are **independent**, and may execute in any order or execute concurrently. A workflow is complete when all steps have been executed. + + Dependencies between parameters are expressed using the ``source`` field on `workflow step input parameters <#WorkflowStepInput>`__ and ``outputSource`` field on `workflow output parameters <#WorkflowOutputParameter>`__. + + The ``source`` field on each workflow step input parameter expresses the data links that contribute to the value of the step input parameter (the "sink"). A workflow step can only begin execution when every data link connected to a step has been fulfilled. + + The ``outputSource`` field on each workflow step input parameter expresses the data links that contribute to the value of the workflow output parameter (the "sink"). Workflow execution cannot complete successfully until every data link connected to an output parameter has been fulfilled. + + Workflow success and failure + ---------------------------- + + A completed step must result in one of ``success``, ``temporaryFailure`` or ``permanentFailure`` states. An implementation may choose to retry a step execution which resulted in ``temporaryFailure``. An implementation may choose to either continue running other steps of a workflow, or terminate immediately upon ``permanentFailure``. + + * If any step of a workflow execution results in ``permanentFailure``, then the workflow status is ``permanentFailure``. + + * If one or more steps result in ``temporaryFailure`` and all other steps complete ``success`` or are not executed, then the workflow status is ``temporaryFailure``. + + * If all workflow steps are executed and complete with ``success``, then the workflow status is ``success``. + + Extensions + ========== + + `ScatterFeatureRequirement <#ScatterFeatureRequirement>`__ and `SubworkflowFeatureRequirement <#SubworkflowFeatureRequirement>`__ are available as standard `extensions <#Extensions_and_Metadata>`__ to core workflow semantics. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, OperationOutputParameter): + if isinstance(other, Workflow): return bool( - self.label == other.label - and self.secondaryFiles == other.secondaryFiles - and self.streamable == other.streamable + self.id == other.id + and self.label == other.label and self.doc == other.doc - and self.id == other.id - and self.format == other.format - and self.type_ == other.type_ + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.requirements == other.requirements + and self.hints == other.hints + and self.cwlVersion == other.cwlVersion + and self.intent == other.intent + and self.class_ == other.class_ + and self.steps == other.steps ) return False def __hash__(self) -> int: return hash( ( + self.id, self.label, - self.secondaryFiles, - self.streamable, self.doc, - self.id, - self.format, - self.type_, + self.inputs, + self.outputs, + self.requirements, + self.hints, + self.cwlVersion, + self.intent, + self.class_, + self.steps, ) ) @@ -25601,8 +21750,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "OperationOutputParameter": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -25612,9 +21761,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -25657,18 +21806,34 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - _errors__.append(ValidationException("missing id")) - if not __original_id_is_none: - baseuri = cast(str, id) + id = "_:" + str(_uuid__.uuid4()) + else: + baseuri = id + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_Workflow_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -25712,104 +21877,10 @@ def fromDoc( "is not valid because:", ) ) - secondaryFiles = None - if "secondaryFiles" in _doc: - try: - secondaryFiles = load_field( - _doc.get("secondaryFiles"), - secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, - baseuri, - loadingOptions, - lc=_doc.get("secondaryFiles") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `secondaryFiles`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secondaryFiles") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `secondaryFiles` field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], - detailed_message=f"the `secondaryFiles` field with value `{val}` " - "is not valid because:", - ) - ) - streamable = None - if "streamable" in _doc: - try: - streamable = load_field( - _doc.get("streamable"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("streamable") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `streamable`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("streamable") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `streamable` field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], - detailed_message=f"the `streamable` field with value `{val}` " - "is not valid because:", - ) - ) doc = None if "doc" in _doc: try: - doc = load_field( + doc = _load_field( _doc.get("doc"), union_of_None_type_or_strtype_or_array_of_strtype, baseuri, @@ -25853,69 +21924,22 @@ def fromDoc( "is not valid because:", ) ) - format = None - if "format" in _doc: - try: - format = load_field( - _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, - baseuri, - loadingOptions, - lc=_doc.get("format") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `format`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("format") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), - [e], - detailed_message=f"the `format` field with value `{val}` " - "is not valid because:", - ) - ) try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("inputs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `inputs`": _errors__.append( ValidationException( str(e), @@ -25923,13 +21947,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("inputs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -25941,216 +21965,123 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `inputs` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") + try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_WorkflowOutputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + else: + val = _doc.get("outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`".format( - k - ), - SourceLine(_doc, k, str), + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + detailed_message=f"the `outputs` field with value `{val}` " + "is not valid because:", ) ) + requirements = None + if "requirements" in _doc: + try: + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, + baseuri, + loadingOptions, + lc=_doc.get("requirements") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - secondaryFiles=secondaryFiles, - streamable=streamable, - doc=doc, - id=id, - format=format, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.secondaryFiles is not None: - r["secondaryFiles"] = save( - self.secondaryFiles, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.streamable is not None: - r["streamable"] = save( - self.streamable, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - u = save_relative_uri(self.format, self.id, True, None, relative_uris) - r["format"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - ["label", "secondaryFiles", "streamable", "doc", "id", "format", "type"] - ) - - -class Operation(Process): - """ - This record describes an abstract operation. It is a potential - step of a workflow that has not yet been bound to a concrete - implementation. It specifies an input and output signature, but - does not provide enough information to be executed. An - implementation (or other tooling) may provide a means of binding - an Operation to a concrete process (such as Workflow, - CommandLineTool, or ExpressionTool) with a compatible signature. - - """ - - id: str - - def __init__( - self, - inputs: Any, - outputs: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - intent: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.intent = intent - self.class_ = "Operation" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Operation): - return bool( - self.id == other.id - and self.label == other.label - and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.intent == other.intent - and self.class_ == other.class_ - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.id, - self.label, - self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.intent, - self.class_, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Operation": - _doc = copy.copy(doc) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("requirements") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + detailed_message=f"the `requirements` field with value `{val}` " + "is not valid because:", + ) + ) + hints = None + if "hints" in _doc: try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -26158,13 +22089,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -26176,53 +22107,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_Operation_classLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - label = None - if "label" in _doc: + cwlVersion = None + if "cwlVersion" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("cwlVersion") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( str(e), @@ -26230,13 +22136,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("cwlVersion") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -26248,28 +22154,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `cwlVersion` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + intent = None + if "intent" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + intent = _load_field( + _doc.get("intent"), + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("intent") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `intent`": _errors__.append( ValidationException( str(e), @@ -26277,13 +22183,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("intent") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -26295,29 +22201,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `intent` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) + if _doc.get("steps") is None: + raise ValidationException("missing required field `steps`", None, []) - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_OperationInputParameterLoader, + steps = _load_field( + _doc.get("steps"), + idmap_steps_union_of_array_of_WorkflowStepLoader, baseuri, loadingOptions, - lc=_doc.get("inputs") + lc=_doc.get("steps") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `inputs`": + if str(e) == "missing required field `steps`": _errors__.append( ValidationException( str(e), @@ -26325,13 +22231,13 @@ def fromDoc( ) ) else: - val = _doc.get("inputs") + val = _doc.get("steps") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -26343,250 +22249,345 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), [e], - detailed_message=f"the `inputs` field with value `{val}` " + detailed_message=f"the `steps` field with value `{val}` " "is not valid because:", ) ) + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `steps`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + id=id, + label=label, + doc=doc, + inputs=inputs, + outputs=outputs, + requirements=requirements, + hints=hints, + cwlVersion=cwlVersion, + intent=intent, + steps=steps, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[id] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.id, False, None, relative_uris) + r["class"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.requirements is not None: + r["requirements"] = save( + self.requirements, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.intent is not None: + u = save_relative_uri(self.intent, self.id, True, None, relative_uris) + r["intent"] = u + if self.steps is not None: + r["steps"] = save( + self.steps, top=False, base_url=self.id, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + inputs: Sequence[WorkflowInputParameter], + outputs: Sequence[WorkflowOutputParameter], + steps: Sequence[WorkflowStep], + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + intent: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.doc = doc + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.cwlVersion = cwlVersion + self.intent = intent + self.class_: Final[str] = "Workflow" + self.steps = steps + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "inputs", + "outputs", + "requirements", + "hints", + "cwlVersion", + "intent", + "class", + "steps", + ] + ) + + +@mypyc_attr(native_class=True) +class SubworkflowFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support nested workflows in the ``run`` field of `WorkflowStep <#WorkflowStep>`__. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, SubworkflowFeatureRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_OperationOutputParameterLoader, + class_ = _load_field( + _doc.get("class"), + uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("outputs") + lc=_doc.get("class") ) + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + raise e + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + ValidationException("mapping with implicit null key") ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", + "invalid field `{}`, expected one of: `class`".format(k), + SourceLine(_doc, k, str), ) ) - requirements = None - if "requirements" in _doc: - try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, - baseuri, - loadingOptions, - lc=_doc.get("requirements") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed - if str(e) == "missing required field `requirements`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("requirements") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], - detailed_message=f"the `requirements` field with value `{val}` " - "is not valid because:", - ) - ) - hints = None - if "hints" in _doc: - try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("hints") - ) + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u - if str(e) == "missing required field `hints`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("hints") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), - [e], - detailed_message=f"the `hints` field with value `{val}` " - "is not valid because:", - ) - ) - cwlVersion = None - if "cwlVersion" in _doc: - try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("cwlVersion") - ) + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + def __init__( + self, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "SubworkflowFeatureRequirement" - if str(e) == "missing required field `cwlVersion`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("cwlVersion") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " - "is not valid because:", - ) - ) - intent = None - if "intent" in _doc: - try: - intent = load_field( - _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("intent") - ) + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class ScatterFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support the ``scatter`` and ``scatterMethod`` fields of `WorkflowStep <#WorkflowStep>`__. + + """ - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + def __eq__(self, other: Any) -> bool: + if isinstance(other, ScatterFeatureRequirement): + return bool(self.class_ == other.class_) + return False - if str(e) == "missing required field `intent`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("intent") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), - [e], - detailed_message=f"the `intent` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} + def __hash__(self) -> int: + return hash((self.class_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_ScatterFeatureRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -26594,16 +22595,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -26611,19 +22610,9 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - label=label, - doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - intent=intent, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -26637,50 +22626,16 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) + u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.intent is not None: - u = save_relative_uri(self.intent, self.id, True, None, relative_uris) - r["intent"] = u # top refers to the directory level if top: @@ -26690,28 +22645,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "intent", - "class", - ] - ) - - -class Secrets(ProcessRequirement): def __init__( self, - secrets: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -26721,16 +22658,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "Secrets" - self.secrets = secrets + self.class_: Final[str] = "ScatterFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class MultipleInputFeatureRequirement(Saveable): + """ + Indicates that the workflow platform must support multiple inbound data links listed in the ``source`` field of `WorkflowStepInput <#WorkflowStepInput>`__. + + """ def __eq__(self, other: Any) -> bool: - if isinstance(other, Secrets): - return bool(self.class_ == other.class_ and self.secrets == other.secrets) + if isinstance(other, MultipleInputFeatureRequirement): + return bool(self.class_ == other.class_) return False def __hash__(self) -> int: - return hash((self.class_, self.secrets)) + return hash((self.class_)) @classmethod def fromDoc( @@ -26738,8 +22684,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Secrets": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -26750,67 +22696,142 @@ def fromDoc( if _doc.get("class") is None: raise ValidationException("missing required field `class`", None, []) - class_ = load_field( + class_ = _load_field( _doc.get("class"), - uri_strtype_False_True_None_None, + uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None, baseuri, loadingOptions, lc=_doc.get("class") ) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("secrets") is None: - raise ValidationException("missing required field `secrets`", None, []) - - secrets = load_field( - _doc.get("secrets"), - uri_array_of_strtype_False_False_0_None, - baseuri, - loadingOptions, - lc=_doc.get("secrets") - ) - + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `secrets`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("secrets") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + raise e + extension_fields: MutableMapping[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - "the `secrets` field is not valid because:", - SourceLine(_doc, "secrets", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = _expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "the `secrets` field is not valid because:", - SourceLine(_doc, "secrets", str), - [e], - detailed_message=f"the `secrets` field with value `{val}` " - "is not valid because:", + "invalid field `{}`, expected one of: `class`".format(k), + SourceLine(_doc, k, str), ) ) - extension_fields: dict[str, Any] = {} + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.class_ is not None: + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, base_url, False, None, relative_uris) + r["class"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + def __init__( + self, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.class_: Final[str] = "MultipleInputFeatureRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class StepInputExpressionRequirement(Saveable): + """ + Indicate that the workflow platform must support the ``valueFrom`` field of `WorkflowStepInput <#WorkflowStepInput>`__. + + """ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, StepInputExpressionRequirement): + return bool(self.class_ == other.class_) + return False + + def __hash__(self) -> int: + return hash((self.class_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: str | None = None + ) -> Self: + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_StepInputExpressionRequirement_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -26818,16 +22839,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `secrets`".format( - k - ), + "invalid field `{}`, expected one of: `class`".format(k), SourceLine(_doc, k, str), ) ) @@ -26835,7 +22854,6 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - secrets=secrets, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -26853,16 +22871,15 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ u = save_relative_uri(uri, base_url, False, None, relative_uris) r["class"] = u - if self.secrets is not None: - u = save_relative_uri(self.secrets, base_url, False, 0, relative_uris) - r["secrets"] = u # top refers to the directory level if top: @@ -26872,26 +22889,10 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "secrets"]) - - -class ProcessGenerator(Process): - id: str - def __init__( self, - inputs: Any, - outputs: Any, - run: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - requirements: Optional[Any] = None, - hints: Optional[Any] = None, - cwlVersion: Optional[Any] = None, - intent: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -26901,49 +22902,49 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.inputs = inputs - self.outputs = outputs - self.requirements = requirements - self.hints = hints - self.cwlVersion = cwlVersion - self.intent = intent - self.class_ = "ProcessGenerator" - self.run = run + self.class_: Final[str] = "StepInputExpressionRequirement" + + attrs: ClassVar[Collection[str]] = frozenset(["class"]) + + +@mypyc_attr(native_class=True) +class OperationInputParameter(Saveable): + """ + Describe an input parameter of an operation. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, ProcessGenerator): + if isinstance(other, OperationInputParameter): return bool( - self.id == other.id - and self.label == other.label + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable and self.doc == other.doc - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.requirements == other.requirements - and self.hints == other.hints - and self.cwlVersion == other.cwlVersion - and self.intent == other.intent - and self.class_ == other.class_ - and self.run == other.run + and self.id == other.id + and self.format == other.format + and self.loadContents == other.loadContents + and self.loadListing == other.loadListing + and self.default == other.default + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( ( - self.id, self.label, + self.secondaryFiles, + self.streamable, self.doc, - self.inputs, - self.outputs, - self.requirements, - self.hints, - self.cwlVersion, - self.intent, - self.class_, - self.run, + self.id, + self.format, + self.loadContents, + self.loadListing, + self.default, + self.type_, ) ) @@ -26953,8 +22954,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ProcessGenerator": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -26964,9 +22965,9 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("id") @@ -27009,34 +23010,18 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id label = None if "label" in _doc: try: - label = load_field( + label = _load_field( _doc.get("label"), union_of_None_type_or_strtype, baseuri, @@ -27080,164 +23065,21 @@ def fromDoc( "is not valid because:", ) ) - doc = None - if "doc" in _doc: - try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("doc") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `doc`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("doc") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), - [e], - detailed_message=f"the `doc` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("inputs") is None: - raise ValidationException("missing required field `inputs`", None, []) - - inputs = load_field( - _doc.get("inputs"), - idmap_inputs_array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputs") is None: - raise ValidationException("missing required field `outputs`", None, []) - - outputs = load_field( - _doc.get("outputs"), - idmap_outputs_array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputs`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], - detailed_message=f"the `outputs` field with value `{val}` " - "is not valid because:", - ) - ) - requirements = None - if "requirements" in _doc: + secondaryFiles = None + if "secondaryFiles" in _doc: try: - requirements = load_field( - _doc.get("requirements"), - idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, - lc=_doc.get("requirements") + lc=_doc.get("secondaryFiles") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `requirements`": + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( str(e), @@ -27245,13 +23087,13 @@ def fromDoc( ) ) else: - val = _doc.get("requirements") + val = _doc.get("secondaryFiles") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27263,28 +23105,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `requirements` field is not valid because:", - SourceLine(_doc, "requirements", str), + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), [e], - detailed_message=f"the `requirements` field with value `{val}` " + detailed_message=f"the `secondaryFiles` field with value `{val}` " "is not valid because:", ) ) - hints = None - if "hints" in _doc: + streamable = None + if "streamable" in _doc: try: - hints = load_field( - _doc.get("hints"), - idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("hints") + lc=_doc.get("streamable") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hints`": + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( str(e), @@ -27292,13 +23134,13 @@ def fromDoc( ) ) else: - val = _doc.get("hints") + val = _doc.get("streamable") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27310,28 +23152,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hints` field is not valid because:", - SourceLine(_doc, "hints", str), + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), [e], - detailed_message=f"the `hints` field with value `{val}` " + detailed_message=f"the `streamable` field with value `{val}` " "is not valid because:", ) ) - cwlVersion = None - if "cwlVersion" in _doc: + doc = None + if "doc" in _doc: try: - cwlVersion = load_field( - _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("cwlVersion") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cwlVersion`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -27339,13 +23181,13 @@ def fromDoc( ) ) else: - val = _doc.get("cwlVersion") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27357,28 +23199,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cwlVersion` field is not valid because:", - SourceLine(_doc, "cwlVersion", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `cwlVersion` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - intent = None - if "intent" in _doc: + format = None + if "format" in _doc: try: - intent = load_field( - _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None_None, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("intent") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `intent`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -27386,13 +23228,13 @@ def fromDoc( ) ) else: - val = _doc.get("intent") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27404,267 +23246,170 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `intent` field is not valid because:", - SourceLine(_doc, "intent", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `intent` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) + loadContents = None + if "loadContents" in _doc: + try: + loadContents = _load_field( + _doc.get("loadContents"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("loadContents") + ) - subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) - try: - if _doc.get("run") is None: - raise ValidationException("missing required field `run`", None, []) - - run = load_field( - _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_False_False_None_None, - subscope_baseuri, - loadingOptions, - lc=_doc.get("run") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `run`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("run") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: + if str(e) == "missing required field `loadContents`": _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), - [e], - detailed_message=f"the `run` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`, `run`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - label=label, - doc=doc, - inputs=inputs, - outputs=outputs, - requirements=requirements, - hints=hints, - cwlVersion=cwlVersion, - intent=intent, - run=run, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.id, False, None, relative_uris) - r["class"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.requirements is not None: - r["requirements"] = save( - self.requirements, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hints is not None: - r["hints"] = save( - self.hints, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.cwlVersion is not None: - u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) - r["cwlVersion"] = u - if self.intent is not None: - u = save_relative_uri(self.intent, self.id, True, None, relative_uris) - r["intent"] = u - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "label", - "doc", - "inputs", - "outputs", - "requirements", - "hints", - "cwlVersion", - "intent", - "class", - "run", - ] - ) - - -class MPIRequirement(ProcessRequirement): - """ - Indicates that a process requires an MPI runtime. - - """ - - def __init__( - self, - processes: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "MPIRequirement" - self.processes = processes - - def __eq__(self, other: Any) -> bool: - if isinstance(other, MPIRequirement): - return bool( - self.class_ == other.class_ and self.processes == other.processes - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.processes)) + val = _doc.get("loadContents") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + detailed_message=f"the `loadContents` field with value `{val}` " + "is not valid because:", + ) + ) + loadListing = None + if "loadListing" in _doc: + try: + loadListing = _load_field( + _doc.get("loadListing"), + union_of_None_type_or_LoadListingEnumLoader, + baseuri, + loadingOptions, + lc=_doc.get("loadListing") + ) - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "MPIRequirement": - _doc = copy.copy(doc) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("loadListing") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + detailed_message=f"the `loadListing` field with value `{val}` " + "is not valid because:", + ) + ) + default = None + if "default" in _doc: + try: + default = _load_field( + _doc.get("default"), + union_of_None_type_or_CWLObjectTypeLoader, + baseuri, + loadingOptions, + lc=_doc.get("default") + ) - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("default") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + detailed_message=f"the `default` field with value `{val}` " + "is not valid because:", + ) + ) try: - if _doc.get("processes") is None: - raise ValidationException("missing required field `processes`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - processes = load_field( - _doc.get("processes"), - union_of_inttype_or_ExpressionLoader, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("processes") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `processes`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -27672,13 +23417,13 @@ def fromDoc( ) ) else: - val = _doc.get("processes") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `processes` field is not valid because:", - SourceLine(_doc, "processes", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27690,14 +23435,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `processes` field is not valid because:", - SourceLine(_doc, "processes", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `processes` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -27705,14 +23450,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `processes`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `loadContents`, `loadListing`, `default`, `type`".format( k ), SourceLine(_doc, k, str), @@ -27722,10 +23467,20 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - processes=processes, + id=id, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + format=format, + loadContents=loadContents, + loadListing=loadListing, + default=default, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -27739,21 +23494,56 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.processes is not None: - r["processes"] = save( - self.processes, + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, top=False, - base_url=base_url, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.streamable is not None: + r["streamable"] = save( + self.streamable, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.loadContents is not None: + r["loadContents"] = save( + self.loadContents, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.loadListing is not None: + r["loadListing"] = save( + self.loadListing, + top=False, + base_url=self.id, relative_uris=relative_uris, ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -27763,23 +23553,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "processes"]) - - -class CUDARequirement(ProcessRequirement): - """ - Require support for NVIDA CUDA (GPU hardware acceleration). - - """ - def __init__( self, - cudaComputeCapability: Any, - cudaVersionMin: Any, - cudaDeviceCountMax: Optional[Any] = None, - cudaDeviceCountMin: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | Sequence[str] | str = None, + loadContents: None | bool = None, + loadListing: LoadListingEnum | None = None, + default: CWLObjectType | None = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -27789,31 +23576,65 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "CUDARequirement" - self.cudaComputeCapability = cudaComputeCapability - self.cudaDeviceCountMax = cudaDeviceCountMax - self.cudaDeviceCountMin = cudaDeviceCountMin - self.cudaVersionMin = cudaVersionMin + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.loadContents = loadContents + self.loadListing = loadListing + self.default = default + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( + [ + "label", + "secondaryFiles", + "streamable", + "doc", + "id", + "format", + "loadContents", + "loadListing", + "default", + "type", + ] + ) + + +@mypyc_attr(native_class=True) +class OperationOutputParameter(Saveable): + """ + Describe an output parameter of an operation. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, CUDARequirement): + if isinstance(other, OperationOutputParameter): return bool( - self.class_ == other.class_ - and self.cudaComputeCapability == other.cudaComputeCapability - and self.cudaDeviceCountMax == other.cudaDeviceCountMax - and self.cudaDeviceCountMin == other.cudaDeviceCountMin - and self.cudaVersionMin == other.cudaVersionMin + self.label == other.label + and self.secondaryFiles == other.secondaryFiles + and self.streamable == other.streamable + and self.doc == other.doc + and self.id == other.id + and self.format == other.format + and self.type_ == other.type_ ) return False def __hash__(self) -> int: return hash( ( - self.class_, - self.cudaComputeCapability, - self.cudaDeviceCountMax, - self.cudaDeviceCountMin, - self.cudaVersionMin, + self.label, + self.secondaryFiles, + self.streamable, + self.doc, + self.id, + self.format, + self.type_, ) ) @@ -27823,93 +23644,226 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "CUDARequirement": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) + id = None + if "id" in _doc: + try: + id = _load_field( + _doc.get("id"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("cudaComputeCapability") is None: - raise ValidationException("missing required field `cudaComputeCapability`", None, []) + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) - cudaComputeCapability = load_field( - _doc.get("cudaComputeCapability"), - union_of_strtype_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("cudaComputeCapability") - ) + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "" + _errors__.append(ValidationException("missing id")) + else: + baseuri = id + label = None + if "label" in _doc: + try: + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cudaComputeCapability`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + secondaryFiles = None + if "secondaryFiles" in _doc: + try: + secondaryFiles = _load_field( + _doc.get("secondaryFiles"), + secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + baseuri, + loadingOptions, + lc=_doc.get("secondaryFiles") ) - else: - val = _doc.get("cudaComputeCapability") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": _errors__.append( ValidationException( - "the `cudaComputeCapability` field is not valid because:", - SourceLine(_doc, "cudaComputeCapability", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("secondaryFiles") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + detailed_message=f"the `secondaryFiles` field with value `{val}` " + "is not valid because:", + ) + ) + streamable = None + if "streamable" in _doc: + try: + streamable = _load_field( + _doc.get("streamable"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("streamable") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": _errors__.append( ValidationException( - "the `cudaComputeCapability` field is not valid because:", - SourceLine(_doc, "cudaComputeCapability", str), - [e], - detailed_message=f"the `cudaComputeCapability` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - cudaDeviceCountMax = None - if "cudaDeviceCountMax" in _doc: + else: + val = _doc.get("streamable") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + detailed_message=f"the `streamable` field with value `{val}` " + "is not valid because:", + ) + ) + doc = None + if "doc" in _doc: try: - cudaDeviceCountMax = load_field( - _doc.get("cudaDeviceCountMax"), - union_of_None_type_or_inttype_or_ExpressionLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("cudaDeviceCountMax") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cudaDeviceCountMax`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -27917,13 +23871,13 @@ def fromDoc( ) ) else: - val = _doc.get("cudaDeviceCountMax") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cudaDeviceCountMax` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMax", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27935,28 +23889,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cudaDeviceCountMax` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMax", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `cudaDeviceCountMax` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - cudaDeviceCountMin = None - if "cudaDeviceCountMin" in _doc: + format = None + if "format" in _doc: try: - cudaDeviceCountMin = load_field( - _doc.get("cudaDeviceCountMin"), - union_of_None_type_or_inttype_or_ExpressionLoader, + format = _load_field( + _doc.get("format"), + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, - lc=_doc.get("cudaDeviceCountMin") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cudaDeviceCountMin`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -27964,13 +23918,13 @@ def fromDoc( ) ) else: - val = _doc.get("cudaDeviceCountMin") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cudaDeviceCountMin` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMin", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -27982,29 +23936,29 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cudaDeviceCountMin` field is not valid because:", - SourceLine(_doc, "cudaDeviceCountMin", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `cudaDeviceCountMin` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) try: - if _doc.get("cudaVersionMin") is None: - raise ValidationException("missing required field `cudaVersionMin`", None, []) + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - cudaVersionMin = load_field( - _doc.get("cudaVersionMin"), - strtype, + type_ = _load_field( + _doc.get("type"), + typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("cudaVersionMin") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `cudaVersionMin`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -28012,13 +23966,13 @@ def fromDoc( ) ) else: - val = _doc.get("cudaVersionMin") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `cudaVersionMin` field is not valid because:", - SourceLine(_doc, "cudaVersionMin", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -28030,14 +23984,14 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `cudaVersionMin` field is not valid because:", - SourceLine(_doc, "cudaVersionMin", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `cudaVersionMin` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -28045,14 +23999,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `cudaComputeCapability`, `cudaDeviceCountMax`, `cudaDeviceCountMin`, `cudaVersionMin`".format( + "invalid field `{}`, expected one of: `label`, `secondaryFiles`, `streamable`, `doc`, `id`, `format`, `type`".format( k ), SourceLine(_doc, k, str), @@ -28062,13 +24016,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - cudaComputeCapability=cudaComputeCapability, - cudaDeviceCountMax=cudaDeviceCountMax, - cudaDeviceCountMin=cudaDeviceCountMin, - cudaVersionMin=cudaVersionMin, + id=id, + label=label, + secondaryFiles=secondaryFiles, + streamable=streamable, + doc=doc, + format=format, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -28082,41 +24040,37 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.cudaComputeCapability is not None: - r["cudaComputeCapability"] = save( - self.cudaComputeCapability, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.cudaDeviceCountMax is not None: - r["cudaDeviceCountMax"] = save( - self.cudaDeviceCountMax, + if self.secondaryFiles is not None: + r["secondaryFiles"] = save( + self.secondaryFiles, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) - if self.cudaDeviceCountMin is not None: - r["cudaDeviceCountMin"] = save( - self.cudaDeviceCountMin, + if self.streamable is not None: + r["streamable"] = save( + self.streamable, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) - if self.cudaVersionMin is not None: - r["cudaVersionMin"] = save( - self.cudaVersionMin, - top=False, - base_url=base_url, - relative_uris=relative_uris, + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.format is not None: + u = save_relative_uri(self.format, self.id, True, None, relative_uris) + r["format"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -28127,30 +24081,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "class", - "cudaComputeCapability", - "cudaDeviceCountMax", - "cudaDeviceCountMin", - "cudaVersionMin", - ] - ) - - -class LoopInput(Saveable): - id: str - def __init__( self, - default: Optional[Any] = None, - id: Optional[Any] = None, - linkMerge: Optional[Any] = None, - loopSource: Optional[Any] = None, - pickValue: Optional[Any] = None, - valueFrom: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + id: str, + type_: CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | Sequence[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] | str, + label: None | str = None, + secondaryFiles: None | SecondaryFileSchema | Sequence[SecondaryFileSchema] = None, + streamable: None | bool = None, + doc: None | Sequence[str] | str = None, + format: None | str = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -28160,34 +24101,57 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.default = default - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.linkMerge = linkMerge - self.loopSource = loopSource - self.pickValue = pickValue - self.valueFrom = valueFrom + self.label = label + self.secondaryFiles = secondaryFiles + self.streamable = streamable + self.doc = doc + self.id = id + self.format = format + self.type_ = type_ + + attrs: ClassVar[Collection[str]] = frozenset( + ["label", "secondaryFiles", "streamable", "doc", "id", "format", "type"] + ) + + +@mypyc_attr(native_class=True) +class Operation(Saveable): + """ + This record describes an abstract operation. It is a potential step of a workflow that has not yet been bound to a concrete implementation. It specifies an input and output signature, but does not provide enough information to be executed. An implementation (or other tooling) may provide a means of binding an Operation to a concrete process (such as Workflow, CommandLineTool, or ExpressionTool) with a compatible signature. + + """ + + id: str def __eq__(self, other: Any) -> bool: - if isinstance(other, LoopInput): + if isinstance(other, Operation): return bool( - self.default == other.default - and self.id == other.id - and self.linkMerge == other.linkMerge - and self.loopSource == other.loopSource - and self.pickValue == other.pickValue - and self.valueFrom == other.valueFrom + self.id == other.id + and self.label == other.label + and self.doc == other.doc + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.requirements == other.requirements + and self.hints == other.hints + and self.cwlVersion == other.cwlVersion + and self.intent == other.intent + and self.class_ == other.class_ ) return False def __hash__(self) -> int: return hash( ( - self.default, self.id, - self.linkMerge, - self.loopSource, - self.pickValue, - self.valueFrom, + self.label, + self.doc, + self.inputs, + self.outputs, + self.requirements, + self.hints, + self.cwlVersion, + self.intent, + self.class_, ) ) @@ -28197,8 +24161,8 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "LoopInput": + docRoot: str | None = None + ) -> Self: _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -28208,7 +24172,7 @@ def fromDoc( id = None if "id" in _doc: try: - id = load_field( + id = _load_field( _doc.get("id"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, @@ -28253,29 +24217,45 @@ def fromDoc( ) ) - __original_id_is_none = id is None if id is None: if docRoot is not None: id = docRoot else: id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - default = None - if "default" in _doc: + else: + baseuri = id + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = _load_field( + _doc.get("class"), + uri_Operation_classLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + vocab = _vocab | loadingOptions.vocab + if class_ not in (cls.__name__, vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + label = None + if "label" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_Any_type, + label = _load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -28283,13 +24263,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -28301,28 +24281,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - linkMerge = None - if "linkMerge" in _doc: + doc = None + if "doc" in _doc: try: - linkMerge = load_field( - _doc.get("linkMerge"), - union_of_None_type_or_LinkMergeMethodLoader, + doc = _load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("linkMerge") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `linkMerge`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -28330,13 +24310,13 @@ def fromDoc( ) ) else: - val = _doc.get("linkMerge") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -28348,28 +24328,124 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `linkMerge` field is not valid because:", - SourceLine(_doc, "linkMerge", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `linkMerge` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - loopSource = None - if "loopSource" in _doc: + try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + + inputs = _load_field( + _doc.get("inputs"), + idmap_inputs_array_of_OperationInputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + detailed_message=f"the `inputs` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + + outputs = _load_field( + _doc.get("outputs"), + idmap_outputs_array_of_OperationOutputParameterLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + detailed_message=f"the `outputs` field with value `{val}` " + "is not valid because:", + ) + ) + requirements = None + if "requirements" in _doc: try: - loopSource = load_field( - _doc.get("loopSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, + requirements = _load_field( + _doc.get("requirements"), + idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, - lc=_doc.get("loopSource") + lc=_doc.get("requirements") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `loopSource`": + if str(e) == "missing required field `requirements`": _errors__.append( ValidationException( str(e), @@ -28377,13 +24453,13 @@ def fromDoc( ) ) else: - val = _doc.get("loopSource") + val = _doc.get("requirements") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `loopSource` field is not valid because:", - SourceLine(_doc, "loopSource", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -28395,28 +24471,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `loopSource` field is not valid because:", - SourceLine(_doc, "loopSource", str), + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), [e], - detailed_message=f"the `loopSource` field with value `{val}` " + detailed_message=f"the `requirements` field with value `{val}` " "is not valid because:", ) ) - pickValue = None - if "pickValue" in _doc: + hints = None + if "hints" in _doc: try: - pickValue = load_field( - _doc.get("pickValue"), - union_of_None_type_or_PickValueMethodLoader, + hints = _load_field( + _doc.get("hints"), + idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("pickValue") + lc=_doc.get("hints") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `pickValue`": + if str(e) == "missing required field `hints`": _errors__.append( ValidationException( str(e), @@ -28424,13 +24500,13 @@ def fromDoc( ) ) else: - val = _doc.get("pickValue") + val = _doc.get("hints") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `pickValue` field is not valid because:", - SourceLine(_doc, "pickValue", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -28442,28 +24518,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `pickValue` field is not valid because:", - SourceLine(_doc, "pickValue", str), + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), [e], - detailed_message=f"the `pickValue` field with value `{val}` " + detailed_message=f"the `hints` field with value `{val}` " "is not valid because:", ) ) - valueFrom = None - if "valueFrom" in _doc: + cwlVersion = None + if "cwlVersion" in _doc: try: - valueFrom = load_field( - _doc.get("valueFrom"), - union_of_None_type_or_strtype_or_ExpressionLoader, + cwlVersion = _load_field( + _doc.get("cwlVersion"), + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, - lc=_doc.get("valueFrom") + lc=_doc.get("cwlVersion") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `valueFrom`": + if str(e) == "missing required field `cwlVersion`": _errors__.append( ValidationException( str(e), @@ -28471,13 +24547,13 @@ def fromDoc( ) ) else: - val = _doc.get("valueFrom") + val = _doc.get("cwlVersion") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -28489,323 +24565,61 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `valueFrom` field is not valid because:", - SourceLine(_doc, "valueFrom", str), + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), [e], - detailed_message=f"the `valueFrom` field with value `{val}` " + detailed_message=f"the `cwlVersion` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `default`, `id`, `linkMerge`, `loopSource`, `pickValue`, `valueFrom`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - default=default, - id=id, - linkMerge=linkMerge, - loopSource=loopSource, - pickValue=pickValue, - valueFrom=valueFrom, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.linkMerge is not None: - r["linkMerge"] = save( - self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.loopSource is not None: - u = save_relative_uri(self.loopSource, self.id, False, 1, relative_uris) - r["loopSource"] = u - if self.pickValue is not None: - r["pickValue"] = save( - self.pickValue, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.valueFrom is not None: - r["valueFrom"] = save( - self.valueFrom, top=False, base_url=self.id, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - ["default", "id", "linkMerge", "loopSource", "pickValue", "valueFrom"] - ) - - -class Loop(ProcessRequirement): - """ - Prototype to enable workflow-level looping of a step. - - Valid only under `requirements` of a https://www.commonwl.org/v1.2/Workflow.html#WorkflowStep. - Unlike other CWL requirements, Loop requirement is not propagated to inner steps. - - `loopWhen` is an expansion of the CWL v1.2 `when` construct which controls - conditional execution. - - Using `loopWhen` and `when` for the same step will produce an error. - - `loopWhen` is not compatible with `scatter` at this time and combining the - two in the same step will produce an error. - - """ - - def __init__( - self, - loop: Any, - loopWhen: Any, - outputMethod: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.class_ = "Loop" - self.loop = loop - self.loopWhen = loopWhen - self.outputMethod = outputMethod - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Loop): - return bool( - self.class_ == other.class_ - and self.loop == other.loop - and self.loopWhen == other.loopWhen - and self.outputMethod == other.outputMethod - ) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.loop, self.loopWhen, self.outputMethod)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Loop": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("loop") is None: - raise ValidationException("missing required field `loop`", None, []) - - loop = load_field( - _doc.get("loop"), - idmap_loop_array_of_LoopInputLoader, - baseuri, - loadingOptions, - lc=_doc.get("loop") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loop`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("loop") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loop` field is not valid because:", - SourceLine(_doc, "loop", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loop` field is not valid because:", - SourceLine(_doc, "loop", str), - [e], - detailed_message=f"the `loop` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("loopWhen") is None: - raise ValidationException("missing required field `loopWhen`", None, []) - - loopWhen = load_field( - _doc.get("loopWhen"), - ExpressionLoader, - baseuri, - loadingOptions, - lc=_doc.get("loopWhen") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `loopWhen`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("loopWhen") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `loopWhen` field is not valid because:", - SourceLine(_doc, "loopWhen", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `loopWhen` field is not valid because:", - SourceLine(_doc, "loopWhen", str), - [e], - detailed_message=f"the `loopWhen` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("outputMethod") is None: - raise ValidationException("missing required field `outputMethod`", None, []) - - outputMethod = load_field( - _doc.get("outputMethod"), - LoopOutputModesLoader, - baseuri, - loadingOptions, - lc=_doc.get("outputMethod") - ) + intent = None + if "intent" in _doc: + try: + intent = _load_field( + _doc.get("intent"), + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("intent") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputMethod`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputMethod") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `intent`": _errors__.append( ValidationException( - "the `outputMethod` field is not valid because:", - SourceLine(_doc, "outputMethod", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: - _errors__.append( - ValidationException( - "the `outputMethod` field is not valid because:", - SourceLine(_doc, "outputMethod", str), - [e], - detailed_message=f"the `outputMethod` field with value `{val}` " - "is not valid because:", + val = _doc.get("intent") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - extension_fields: dict[str, Any] = {} + else: + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [e], + detailed_message=f"the `intent` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: MutableMapping[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: if not k: @@ -28813,14 +24627,14 @@ def fromDoc( ValidationException("mapping with implicit null key") ) elif ":" in k: - ex = expand_url( + ex = _expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) extension_fields[ex] = _doc[k] else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `class`, `loop`, `loopWhen`, `outputMethod`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `inputs`, `outputs`, `requirements`, `hints`, `cwlVersion`, `intent`, `class`".format( k ), SourceLine(_doc, k, str), @@ -28830,12 +24644,19 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - loop=loop, - loopWhen=loopWhen, - outputMethod=outputMethod, + id=id, + label=label, + doc=doc, + inputs=inputs, + outputs=outputs, + requirements=requirements, + hints=hints, + cwlVersion=cwlVersion, + intent=intent, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[id] = (_constructed, loadingOptions) return _constructed def save( @@ -28849,29 +24670,52 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, self.id, True, None, relative_uris) + r["id"] = u if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + vocab = _vocab | self.loadingOptions.vocab + rvocab = _rvocab | self.loadingOptions.rvocab + uri = vocab[self.class_] + if p := rvocab.get(uri[: -len(self.class_)]): uri = f"{p}:{self.class_}" else: uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) + u = save_relative_uri(uri, self.id, False, None, relative_uris) r["class"] = u - if self.loop is not None: - r["loop"] = save( - self.loop, top=False, base_url=base_url, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.loopWhen is not None: - r["loopWhen"] = save( - self.loopWhen, top=False, base_url=base_url, relative_uris=relative_uris + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.outputMethod is not None: - r["outputMethod"] = save( - self.outputMethod, + if self.requirements is not None: + r["requirements"] = save( + self.requirements, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) + if self.hints is not None: + r["hints"] = save( + self.hints, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.cwlVersion is not None: + u = save_relative_uri(self.cwlVersion, self.id, False, None, relative_uris) + r["cwlVersion"] = u + if self.intent is not None: + u = save_relative_uri(self.intent, self.id, True, None, relative_uris) + r["intent"] = u # top refers to the directory level if top: @@ -28881,15 +24725,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["class", "loop", "loopWhen", "outputMethod"]) - - -class ShmSize(ProcessRequirement): def __init__( self, - shmSize: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, + inputs: Sequence[OperationInputParameter], + outputs: Sequence[OperationOutputParameter], + id: None | str = None, + label: None | str = None, + doc: None | Sequence[str] | str = None, + requirements: None | Sequence[DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + hints: None | Sequence[Any | DockerRequirement | EnvVarRequirement | InitialWorkDirRequirement | InlineJavascriptRequirement | InplaceUpdateRequirement | LoadListingRequirement | MultipleInputFeatureRequirement | NetworkAccess | ResourceRequirement | ScatterFeatureRequirement | SchemaDefRequirement | ShellCommandRequirement | SoftwareRequirement | StepInputExpressionRequirement | SubworkflowFeatureRequirement | ToolTimeLimit | WorkReuse] = None, + cwlVersion: CWLVersion | None = None, + intent: None | Sequence[str] = None, + extension_fields: MutableMapping[str, Any] | None = None, + loadingOptions: LoadingOptions | None = None, ) -> None: if extension_fields: self.extension_fields = extension_fields @@ -28899,165 +24747,36 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.class_ = "ShmSize" - self.shmSize = shmSize - - def __eq__(self, other: Any) -> bool: - if isinstance(other, ShmSize): - return bool(self.class_ == other.class_ and self.shmSize == other.shmSize) - return False - - def __hash__(self) -> int: - return hash((self.class_, self.shmSize)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "ShmSize": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_strtype_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - try: - if _doc.get("shmSize") is None: - raise ValidationException("missing required field `shmSize`", None, []) - - shmSize = load_field( - _doc.get("shmSize"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("shmSize") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `shmSize`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("shmSize") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `shmSize` field is not valid because:", - SourceLine(_doc, "shmSize", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `shmSize` field is not valid because:", - SourceLine(_doc, "shmSize", str), - [e], - detailed_message=f"the `shmSize` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `class`, `shmSize`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - shmSize=shmSize, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, base_url, False, None, relative_uris) - r["class"] = u - if self.shmSize is not None: - r["shmSize"] = save( - self.shmSize, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.doc = doc + self.inputs = inputs + self.outputs = outputs + self.requirements = requirements + self.hints = hints + self.cwlVersion = cwlVersion + self.intent = intent + self.class_: Final[str] = "Operation" - attrs = frozenset(["class", "shmSize"]) + attrs: ClassVar[Collection[str]] = frozenset( + [ + "id", + "label", + "doc", + "inputs", + "outputs", + "requirements", + "hints", + "cwlVersion", + "intent", + "class", + ] + ) -_vocab = { +_vocab.update({ "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", - "CUDARequirement": "http://commonwl.org/cwltool#CUDARequirement", "CWLArraySchema": "https://w3id.org/cwl/cwl#CWLArraySchema", "CWLInputFile": "https://w3id.org/cwl/cwl#CWLInputFile", "CWLObjectType": "https://w3id.org/cwl/cwl#CWLObjectType", @@ -29112,9 +24831,6 @@ def save( "LoadContents": "https://w3id.org/cwl/cwl#LoadContents", "LoadListingEnum": "https://w3id.org/cwl/cwl#LoadListingEnum", "LoadListingRequirement": "https://w3id.org/cwl/cwl#LoadListingRequirement", - "Loop": "http://commonwl.org/cwltool#Loop", - "LoopInput": "http://commonwl.org/cwltool#LoopInput", - "MPIRequirement": "http://commonwl.org/cwltool#MPIRequirement", "MapSchema": "https://w3id.org/cwl/salad#MapSchema", "MultipleInputFeatureRequirement": "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement", "NetworkAccess": "https://w3id.org/cwl/cwl#NetworkAccess", @@ -29132,7 +24848,6 @@ def save( "PickValueMethod": "https://w3id.org/cwl/cwl#PickValueMethod", "PrimitiveType": "https://w3id.org/cwl/salad#PrimitiveType", "Process": "https://w3id.org/cwl/cwl#Process", - "ProcessGenerator": "http://commonwl.org/cwltool#ProcessGenerator", "ProcessRequirement": "https://w3id.org/cwl/cwl#ProcessRequirement", "RecordField": "https://w3id.org/cwl/salad#RecordField", "RecordSchema": "https://w3id.org/cwl/salad#RecordSchema", @@ -29141,9 +24856,7 @@ def save( "ScatterMethod": "https://w3id.org/cwl/cwl#ScatterMethod", "SchemaDefRequirement": "https://w3id.org/cwl/cwl#SchemaDefRequirement", "SecondaryFileSchema": "https://w3id.org/cwl/cwl#SecondaryFileSchema", - "Secrets": "http://commonwl.org/cwltool#Secrets", "ShellCommandRequirement": "https://w3id.org/cwl/cwl#ShellCommandRequirement", - "ShmSize": "http://commonwl.org/cwltool#ShmSize", "Sink": "https://w3id.org/cwl/cwl#Sink", "SoftwarePackage": "https://w3id.org/cwl/cwl#SoftwarePackage", "SoftwareRequirement": "https://w3id.org/cwl/cwl#SoftwareRequirement", @@ -29158,29 +24871,17 @@ def save( "WorkflowStep": "https://w3id.org/cwl/cwl#WorkflowStep", "WorkflowStepInput": "https://w3id.org/cwl/cwl#WorkflowStepInput", "WorkflowStepOutput": "https://w3id.org/cwl/cwl#WorkflowStepOutput", - "all": "http://commonwl.org/cwltool#Loop/outputMethod/LoopOutputModes/all", "all_non_null": "https://w3id.org/cwl/cwl#PickValueMethod/all_non_null", "array": "https://w3id.org/cwl/salad#array", "boolean": "http://www.w3.org/2001/XMLSchema#boolean", "deep_listing": "https://w3id.org/cwl/cwl#LoadListingEnum/deep_listing", "dotproduct": "https://w3id.org/cwl/cwl#ScatterMethod/dotproduct", "double": "http://www.w3.org/2001/XMLSchema#double", - "draft-2": "https://w3id.org/cwl/cwl#draft-2", - "draft-3": "https://w3id.org/cwl/cwl#draft-3", - "draft-3.dev1": "https://w3id.org/cwl/cwl#draft-3.dev1", - "draft-3.dev2": "https://w3id.org/cwl/cwl#draft-3.dev2", - "draft-3.dev3": "https://w3id.org/cwl/cwl#draft-3.dev3", - "draft-3.dev4": "https://w3id.org/cwl/cwl#draft-3.dev4", - "draft-3.dev5": "https://w3id.org/cwl/cwl#draft-3.dev5", - "draft-4.dev1": "https://w3id.org/cwl/cwl#draft-4.dev1", - "draft-4.dev2": "https://w3id.org/cwl/cwl#draft-4.dev2", - "draft-4.dev3": "https://w3id.org/cwl/cwl#draft-4.dev3", "enum": "https://w3id.org/cwl/salad#enum", "first_non_null": "https://w3id.org/cwl/cwl#PickValueMethod/first_non_null", "flat_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/flat_crossproduct", "float": "http://www.w3.org/2001/XMLSchema#float", "int": "http://www.w3.org/2001/XMLSchema#int", - "last": "http://commonwl.org/cwltool#Loop/outputMethod/LoopOutputModes/last", "long": "http://www.w3.org/2001/XMLSchema#long", "map": "https://w3id.org/cwl/salad#map", "merge_flattened": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened", @@ -29196,21 +24897,11 @@ def save( "string": "http://www.w3.org/2001/XMLSchema#string", "the_only_non_null": "https://w3id.org/cwl/cwl#PickValueMethod/the_only_non_null", "union": "https://w3id.org/cwl/salad#union", - "v1.0": "https://w3id.org/cwl/cwl#v1.0", - "v1.0.dev4": "https://w3id.org/cwl/cwl#v1.0.dev4", - "v1.1": "https://w3id.org/cwl/cwl#v1.1", - "v1.1.0-dev1": "https://w3id.org/cwl/cwl#v1.1.0-dev1", "v1.2": "https://w3id.org/cwl/cwl#v1.2", - "v1.2.0-dev1": "https://w3id.org/cwl/cwl#v1.2.0-dev1", - "v1.2.0-dev2": "https://w3id.org/cwl/cwl#v1.2.0-dev2", - "v1.2.0-dev3": "https://w3id.org/cwl/cwl#v1.2.0-dev3", - "v1.2.0-dev4": "https://w3id.org/cwl/cwl#v1.2.0-dev4", - "v1.2.0-dev5": "https://w3id.org/cwl/cwl#v1.2.0-dev5", -} -_rvocab = { +}) +_rvocab.update({ "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", - "http://commonwl.org/cwltool#CUDARequirement": "CUDARequirement", "https://w3id.org/cwl/cwl#CWLArraySchema": "CWLArraySchema", "https://w3id.org/cwl/cwl#CWLInputFile": "CWLInputFile", "https://w3id.org/cwl/cwl#CWLObjectType": "CWLObjectType", @@ -29265,9 +24956,6 @@ def save( "https://w3id.org/cwl/cwl#LoadContents": "LoadContents", "https://w3id.org/cwl/cwl#LoadListingEnum": "LoadListingEnum", "https://w3id.org/cwl/cwl#LoadListingRequirement": "LoadListingRequirement", - "http://commonwl.org/cwltool#Loop": "Loop", - "http://commonwl.org/cwltool#LoopInput": "LoopInput", - "http://commonwl.org/cwltool#MPIRequirement": "MPIRequirement", "https://w3id.org/cwl/salad#MapSchema": "MapSchema", "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement": "MultipleInputFeatureRequirement", "https://w3id.org/cwl/cwl#NetworkAccess": "NetworkAccess", @@ -29285,7 +24973,6 @@ def save( "https://w3id.org/cwl/cwl#PickValueMethod": "PickValueMethod", "https://w3id.org/cwl/salad#PrimitiveType": "PrimitiveType", "https://w3id.org/cwl/cwl#Process": "Process", - "http://commonwl.org/cwltool#ProcessGenerator": "ProcessGenerator", "https://w3id.org/cwl/cwl#ProcessRequirement": "ProcessRequirement", "https://w3id.org/cwl/salad#RecordField": "RecordField", "https://w3id.org/cwl/salad#RecordSchema": "RecordSchema", @@ -29294,9 +24981,7 @@ def save( "https://w3id.org/cwl/cwl#ScatterMethod": "ScatterMethod", "https://w3id.org/cwl/cwl#SchemaDefRequirement": "SchemaDefRequirement", "https://w3id.org/cwl/cwl#SecondaryFileSchema": "SecondaryFileSchema", - "http://commonwl.org/cwltool#Secrets": "Secrets", "https://w3id.org/cwl/cwl#ShellCommandRequirement": "ShellCommandRequirement", - "http://commonwl.org/cwltool#ShmSize": "ShmSize", "https://w3id.org/cwl/cwl#Sink": "Sink", "https://w3id.org/cwl/cwl#SoftwarePackage": "SoftwarePackage", "https://w3id.org/cwl/cwl#SoftwareRequirement": "SoftwareRequirement", @@ -29311,29 +24996,17 @@ def save( "https://w3id.org/cwl/cwl#WorkflowStep": "WorkflowStep", "https://w3id.org/cwl/cwl#WorkflowStepInput": "WorkflowStepInput", "https://w3id.org/cwl/cwl#WorkflowStepOutput": "WorkflowStepOutput", - "http://commonwl.org/cwltool#Loop/outputMethod/LoopOutputModes/all": "all", "https://w3id.org/cwl/cwl#PickValueMethod/all_non_null": "all_non_null", "https://w3id.org/cwl/salad#array": "array", "http://www.w3.org/2001/XMLSchema#boolean": "boolean", "https://w3id.org/cwl/cwl#LoadListingEnum/deep_listing": "deep_listing", "https://w3id.org/cwl/cwl#ScatterMethod/dotproduct": "dotproduct", "http://www.w3.org/2001/XMLSchema#double": "double", - "https://w3id.org/cwl/cwl#draft-2": "draft-2", - "https://w3id.org/cwl/cwl#draft-3": "draft-3", - "https://w3id.org/cwl/cwl#draft-3.dev1": "draft-3.dev1", - "https://w3id.org/cwl/cwl#draft-3.dev2": "draft-3.dev2", - "https://w3id.org/cwl/cwl#draft-3.dev3": "draft-3.dev3", - "https://w3id.org/cwl/cwl#draft-3.dev4": "draft-3.dev4", - "https://w3id.org/cwl/cwl#draft-3.dev5": "draft-3.dev5", - "https://w3id.org/cwl/cwl#draft-4.dev1": "draft-4.dev1", - "https://w3id.org/cwl/cwl#draft-4.dev2": "draft-4.dev2", - "https://w3id.org/cwl/cwl#draft-4.dev3": "draft-4.dev3", "https://w3id.org/cwl/salad#enum": "enum", "https://w3id.org/cwl/cwl#PickValueMethod/first_non_null": "first_non_null", "https://w3id.org/cwl/cwl#ScatterMethod/flat_crossproduct": "flat_crossproduct", "http://www.w3.org/2001/XMLSchema#float": "float", "http://www.w3.org/2001/XMLSchema#int": "int", - "http://commonwl.org/cwltool#Loop/outputMethod/LoopOutputModes/last": "last", "http://www.w3.org/2001/XMLSchema#long": "long", "https://w3id.org/cwl/salad#map": "map", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened": "merge_flattened", @@ -29349,25 +25022,20 @@ def save( "http://www.w3.org/2001/XMLSchema#string": "string", "https://w3id.org/cwl/cwl#PickValueMethod/the_only_non_null": "the_only_non_null", "https://w3id.org/cwl/salad#union": "union", - "https://w3id.org/cwl/cwl#v1.0": "v1.0", - "https://w3id.org/cwl/cwl#v1.0.dev4": "v1.0.dev4", - "https://w3id.org/cwl/cwl#v1.1": "v1.1", - "https://w3id.org/cwl/cwl#v1.1.0-dev1": "v1.1.0-dev1", "https://w3id.org/cwl/cwl#v1.2": "v1.2", - "https://w3id.org/cwl/cwl#v1.2.0-dev1": "v1.2.0-dev1", - "https://w3id.org/cwl/cwl#v1.2.0-dev2": "v1.2.0-dev2", - "https://w3id.org/cwl/cwl#v1.2.0-dev3": "v1.2.0-dev3", - "https://w3id.org/cwl/cwl#v1.2.0-dev4": "v1.2.0-dev4", - "https://w3id.org/cwl/cwl#v1.2.0-dev5": "v1.2.0-dev5", -} - -strtype = _PrimitiveLoader(str) -inttype = _PrimitiveLoader(int) -floattype = _PrimitiveLoader(float) -booltype = _PrimitiveLoader(bool) -None_type = _PrimitiveLoader(type(None)) -Any_type = _AnyLoader() -PrimitiveTypeLoader = _EnumLoader( +}) + +strtype: Final[_Loader[str]] = _PrimitiveLoader(str) +inttype: Final[_Loader[i32]] = _PrimitiveLoader(i32) +longtype: Final[_Loader[i64]] = _PrimitiveLoader(i64) +floattype: Final[_Loader[float]] = _PrimitiveLoader(float) +booltype: Final[_Loader[bool]] = _PrimitiveLoader(bool) +None_type: Final[_Loader[None]] = _PrimitiveLoader(type(None)) +Any_type: Final[_Loader[Any]] = _AnyLoader() +PrimitiveType: TypeAlias = Literal[ + "null", "boolean", "int", "long", "float", "double", "string" +] +PrimitiveTypeLoader: Final[_Loader[PrimitiveType]] = _EnumLoader( ( "null", "boolean", @@ -29382,28 +25050,49 @@ def save( """ Names of salad data types (based on Avro schema declarations). -Refer to the [Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for -detailed information. +Refer to the `Avro schema declaration documentation `__ for detailed information. null: no value + boolean: a binary value + int: 32-bit signed integer + long: 64-bit signed integer + float: single precision (32-bit) IEEE 754 floating-point number + double: double precision (64-bit) IEEE 754 floating-point number + string: Unicode character sequence """ -AnyLoader = _EnumLoader(("Any",), "Any") +Any_: TypeAlias = Literal["Any"] +Any_Loader: Final[_Loader[Any_]] = _EnumLoader(("Any",), "Any_") """ The **Any** type validates for any non-null value. """ -RecordFieldLoader = _RecordLoader(RecordField, None, None) -RecordSchemaLoader = _RecordLoader(RecordSchema, None, None) -EnumSchemaLoader = _RecordLoader(EnumSchema, None, None) -ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) -MapSchemaLoader = _RecordLoader(MapSchema, None, None) -UnionSchemaLoader = _RecordLoader(UnionSchema, None, None) -CWLTypeLoader = _EnumLoader( +RecordFieldLoader: Final[_Loader[schema_salad.metaschema.RecordField]] = _RecordLoader( + schema_salad.metaschema.RecordField, None, None +) +RecordSchemaLoader: Final[_Loader[schema_salad.metaschema.RecordSchema]] = ( + _RecordLoader(schema_salad.metaschema.RecordSchema, None, None) +) +EnumSchemaLoader: Final[_Loader[schema_salad.metaschema.EnumSchema]] = _RecordLoader( + schema_salad.metaschema.EnumSchema, None, None +) +ArraySchemaLoader: Final[_Loader[schema_salad.metaschema.ArraySchema]] = _RecordLoader( + schema_salad.metaschema.ArraySchema, None, None +) +MapSchemaLoader: Final[_Loader[schema_salad.metaschema.MapSchema]] = _RecordLoader( + schema_salad.metaschema.MapSchema, None, None +) +UnionSchemaLoader: Final[_Loader[schema_salad.metaschema.UnionSchema]] = _RecordLoader( + schema_salad.metaschema.UnionSchema, None, None +) +CWLType: TypeAlias = Literal[ + "null", "boolean", "int", "long", "float", "double", "string", "File", "Directory" +] +CWLTypeLoader: Final[_Loader[CWLType]] = _EnumLoader( ( "null", "boolean", @@ -29419,58 +25108,107 @@ def save( ) """ Extends primitive types with the concept of a file and directory as a builtin type. + File: A File object + Directory: A Directory object """ -CWLArraySchemaLoader = _RecordLoader(CWLArraySchema, None, None) -CWLRecordFieldLoader = _RecordLoader(CWLRecordField, None, None) -CWLRecordSchemaLoader = _RecordLoader(CWLRecordSchema, None, None) -FileLoader = _RecordLoader(File, None, None) -DirectoryLoader = _RecordLoader(Directory, None, None) -CWLObjectTypeLoader = _UnionLoader((), "CWLObjectTypeLoader") -union_of_None_type_or_CWLObjectTypeLoader = _UnionLoader( - ( - None_type, - CWLObjectTypeLoader, +CWLArraySchemaLoader: Final[_Loader[CWLArraySchema]] = _RecordLoader( + CWLArraySchema, None, None +) +CWLRecordFieldLoader: Final[_Loader[CWLRecordField]] = _RecordLoader( + CWLRecordField, None, None +) +CWLRecordSchemaLoader: Final[_Loader[CWLRecordSchema]] = _RecordLoader( + CWLRecordSchema, None, None +) +FileLoader: Final[_Loader[File]] = _RecordLoader(File, None, None) +DirectoryLoader: Final[_Loader[Directory]] = _RecordLoader(Directory, None, None) +CWLObjectTypeLoader: Final[_UnionLoader[Any]] = _UnionLoader((), "CWLObjectTypeLoader") +union_of_None_type_or_CWLObjectTypeLoader: Final[_Loader[CWLObjectType | None]] = ( + _UnionLoader( + ( + None_type, + CWLObjectTypeLoader, + ) ) ) -array_of_union_of_None_type_or_CWLObjectTypeLoader = _ArrayLoader( - union_of_None_type_or_CWLObjectTypeLoader +array_of_union_of_None_type_or_CWLObjectTypeLoader: Final[ + _Loader[Sequence[CWLObjectType | None]] +] = _ArrayLoader(union_of_None_type_or_CWLObjectTypeLoader) +map_of_union_of_None_type_or_CWLObjectTypeLoader: Final[ + _Loader[Mapping[str, CWLObjectType | None]] +] = _MapLoader(union_of_None_type_or_CWLObjectTypeLoader, "None", None, None) +InlineJavascriptRequirementLoader: Final[_Loader[InlineJavascriptRequirement]] = ( + _RecordLoader(InlineJavascriptRequirement, None, None) +) +SchemaDefRequirementLoader: Final[_Loader[SchemaDefRequirement]] = _RecordLoader( + SchemaDefRequirement, None, None +) +LoadListingRequirementLoader: Final[_Loader[LoadListingRequirement]] = _RecordLoader( + LoadListingRequirement, None, None +) +DockerRequirementLoader: Final[_Loader[DockerRequirement]] = _RecordLoader( + DockerRequirement, None, None +) +SoftwareRequirementLoader: Final[_Loader[SoftwareRequirement]] = _RecordLoader( + SoftwareRequirement, None, None +) +InitialWorkDirRequirementLoader: Final[_Loader[InitialWorkDirRequirement]] = ( + _RecordLoader(InitialWorkDirRequirement, None, None) +) +EnvVarRequirementLoader: Final[_Loader[EnvVarRequirement]] = _RecordLoader( + EnvVarRequirement, None, None +) +ShellCommandRequirementLoader: Final[_Loader[ShellCommandRequirement]] = _RecordLoader( + ShellCommandRequirement, None, None +) +ResourceRequirementLoader: Final[_Loader[ResourceRequirement]] = _RecordLoader( + ResourceRequirement, None, None ) -map_of_union_of_None_type_or_CWLObjectTypeLoader = _MapLoader( - union_of_None_type_or_CWLObjectTypeLoader, "None", None, None +WorkReuseLoader: Final[_Loader[WorkReuse]] = _RecordLoader(WorkReuse, None, None) +NetworkAccessLoader: Final[_Loader[NetworkAccess]] = _RecordLoader( + NetworkAccess, None, None ) -InlineJavascriptRequirementLoader = _RecordLoader( - InlineJavascriptRequirement, None, None +InplaceUpdateRequirementLoader: Final[_Loader[InplaceUpdateRequirement]] = ( + _RecordLoader(InplaceUpdateRequirement, None, None) ) -SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement, None, None) -LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement, None, None) -DockerRequirementLoader = _RecordLoader(DockerRequirement, None, None) -SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement, None, None) -InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement, None, None) -EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement, None, None) -ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement, None, None) -ResourceRequirementLoader = _RecordLoader(ResourceRequirement, None, None) -WorkReuseLoader = _RecordLoader(WorkReuse, None, None) -NetworkAccessLoader = _RecordLoader(NetworkAccess, None, None) -InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement, None, None) -ToolTimeLimitLoader = _RecordLoader(ToolTimeLimit, None, None) -SubworkflowFeatureRequirementLoader = _RecordLoader( - SubworkflowFeatureRequirement, None, None +ToolTimeLimitLoader: Final[_Loader[ToolTimeLimit]] = _RecordLoader( + ToolTimeLimit, None, None ) -ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement, None, None) -MultipleInputFeatureRequirementLoader = _RecordLoader( - MultipleInputFeatureRequirement, None, None +SubworkflowFeatureRequirementLoader: Final[_Loader[SubworkflowFeatureRequirement]] = ( + _RecordLoader(SubworkflowFeatureRequirement, None, None) ) -StepInputExpressionRequirementLoader = _RecordLoader( - StepInputExpressionRequirement, None, None +ScatterFeatureRequirementLoader: Final[_Loader[ScatterFeatureRequirement]] = ( + _RecordLoader(ScatterFeatureRequirement, None, None) ) -SecretsLoader = _RecordLoader(Secrets, None, None) -MPIRequirementLoader = _RecordLoader(MPIRequirement, None, None) -CUDARequirementLoader = _RecordLoader(CUDARequirement, None, None) -LoopLoader = _RecordLoader(Loop, None, None) -ShmSizeLoader = _RecordLoader(ShmSize, None, None) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader = _UnionLoader( +MultipleInputFeatureRequirementLoader: Final[ + _Loader[MultipleInputFeatureRequirement] +] = _RecordLoader(MultipleInputFeatureRequirement, None, None) +StepInputExpressionRequirementLoader: Final[_Loader[StepInputExpressionRequirement]] = ( + _RecordLoader(StepInputExpressionRequirement, None, None) +) +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] +] = _UnionLoader( ( InlineJavascriptRequirementLoader, SchemaDefRequirementLoader, @@ -29489,59 +25227,132 @@ def save( ScatterFeatureRequirementLoader, MultipleInputFeatureRequirementLoader, StepInputExpressionRequirementLoader, - SecretsLoader, - MPIRequirementLoader, - CUDARequirementLoader, - LoopLoader, - ShmSizeLoader, ) ) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader: Final[ + _Loader[ + CWLObjectType + | None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, CWLObjectTypeLoader, ) ) -map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader = _MapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader, +map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader: Final[ + _Loader[ + Mapping[ + str, + CWLObjectType + | None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ], + ] + ] +] = _MapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader, "CWLInputFile", "@list", True, ) -CWLInputFileLoader = map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_CWLObjectTypeLoader -CWLVersionLoader = _EnumLoader( - ( - "draft-2", - "draft-3.dev1", - "draft-3.dev2", - "draft-3.dev3", - "draft-3.dev4", - "draft-3.dev5", - "draft-3", - "draft-4.dev1", - "draft-4.dev2", - "draft-4.dev3", - "v1.0.dev4", - "v1.0", - "v1.1.0-dev1", - "v1.1", - "v1.2.0-dev1", - "v1.2.0-dev2", - "v1.2.0-dev3", - "v1.2.0-dev4", - "v1.2.0-dev5", - "v1.2", - ), - "CWLVersion", -) +CWLInputFileLoader: Final[ + _Loader[ + Mapping[ + str, + CWLObjectType + | None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ], + ] + ] +] = map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader +CWLVersion: TypeAlias = Literal["v1.2"] +CWLVersionLoader: Final[_Loader[CWLVersion]] = _EnumLoader(("v1.2",), "CWLVersion") """ -Version symbols for published CWL document versions. +Current version symbol for CWL documents. """ -LoadListingEnumLoader = _EnumLoader( +LoadListingEnum: TypeAlias = Literal["no_listing", "shallow_listing", "deep_listing"] +LoadListingEnumLoader: Final[_Loader[LoadListingEnum]] = _EnumLoader( ( "no_listing", "shallow_listing", @@ -29550,160 +25361,235 @@ def save( "LoadListingEnum", ) """ -Specify the desired behavior for loading the `listing` field of -a Directory object for use by expressions. +Specify the desired behavior for loading the ``listing`` field of a Directory object for use by expressions. no_listing: Do not load the directory listing. + shallow_listing: Only load the top level listing, do not recurse into subdirectories. + deep_listing: Load the directory listing and recursively load all subdirectories as well. """ -ExpressionLoader = _ExpressionLoader(str) -InputBindingLoader = _RecordLoader(InputBinding, None, None) -InputRecordFieldLoader = _RecordLoader(InputRecordField, None, None) -InputRecordSchemaLoader = _RecordLoader(InputRecordSchema, None, None) -InputEnumSchemaLoader = _RecordLoader(InputEnumSchema, None, None) -InputArraySchemaLoader = _RecordLoader(InputArraySchema, None, None) -OutputRecordFieldLoader = _RecordLoader(OutputRecordField, None, None) -OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema, None, None) -OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema, None, None) -OutputArraySchemaLoader = _RecordLoader(OutputArraySchema, None, None) -SecondaryFileSchemaLoader = _RecordLoader(SecondaryFileSchema, None, None) -EnvironmentDefLoader = _RecordLoader(EnvironmentDef, None, None) -CommandLineBindingLoader = _RecordLoader(CommandLineBinding, None, None) -CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding, None, None) -CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField, None, None) -CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema, None, None) -CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema, None, None) -CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema, None, None) -CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField, None, None) -CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema, None, None) -CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema, None, None) -CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema, None, None) -CommandInputParameterLoader = _RecordLoader(CommandInputParameter, None, None) -CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter, None, None) -stdinLoader = _EnumLoader(("stdin",), "stdin") +Expression: TypeAlias = Literal["ExpressionPlaceholder"] +ExpressionLoader: Final[_Loader[str]] = _ExpressionLoader(str) +InputBindingLoader: Final[_Loader[InputBinding]] = _RecordLoader( + InputBinding, None, None +) +InputRecordFieldLoader: Final[_Loader[InputRecordField]] = _RecordLoader( + InputRecordField, None, None +) +InputRecordSchemaLoader: Final[_Loader[InputRecordSchema]] = _RecordLoader( + InputRecordSchema, None, None +) +InputEnumSchemaLoader: Final[_Loader[InputEnumSchema]] = _RecordLoader( + InputEnumSchema, None, None +) +InputArraySchemaLoader: Final[_Loader[InputArraySchema]] = _RecordLoader( + InputArraySchema, None, None +) +OutputRecordFieldLoader: Final[_Loader[OutputRecordField]] = _RecordLoader( + OutputRecordField, None, None +) +OutputRecordSchemaLoader: Final[_Loader[OutputRecordSchema]] = _RecordLoader( + OutputRecordSchema, None, None +) +OutputEnumSchemaLoader: Final[_Loader[OutputEnumSchema]] = _RecordLoader( + OutputEnumSchema, None, None +) +OutputArraySchemaLoader: Final[_Loader[OutputArraySchema]] = _RecordLoader( + OutputArraySchema, None, None +) +SecondaryFileSchemaLoader: Final[_Loader[SecondaryFileSchema]] = _RecordLoader( + SecondaryFileSchema, None, None +) +EnvironmentDefLoader: Final[_Loader[EnvironmentDef]] = _RecordLoader( + EnvironmentDef, None, None +) +CommandLineBindingLoader: Final[_Loader[CommandLineBinding]] = _RecordLoader( + CommandLineBinding, None, None +) +CommandOutputBindingLoader: Final[_Loader[CommandOutputBinding]] = _RecordLoader( + CommandOutputBinding, None, None +) +CommandInputRecordFieldLoader: Final[_Loader[CommandInputRecordField]] = _RecordLoader( + CommandInputRecordField, None, None +) +CommandInputRecordSchemaLoader: Final[_Loader[CommandInputRecordSchema]] = ( + _RecordLoader(CommandInputRecordSchema, None, None) +) +CommandInputEnumSchemaLoader: Final[_Loader[CommandInputEnumSchema]] = _RecordLoader( + CommandInputEnumSchema, None, None +) +CommandInputArraySchemaLoader: Final[_Loader[CommandInputArraySchema]] = _RecordLoader( + CommandInputArraySchema, None, None +) +CommandOutputRecordFieldLoader: Final[_Loader[CommandOutputRecordField]] = ( + _RecordLoader(CommandOutputRecordField, None, None) +) +CommandOutputRecordSchemaLoader: Final[_Loader[CommandOutputRecordSchema]] = ( + _RecordLoader(CommandOutputRecordSchema, None, None) +) +CommandOutputEnumSchemaLoader: Final[_Loader[CommandOutputEnumSchema]] = _RecordLoader( + CommandOutputEnumSchema, None, None +) +CommandOutputArraySchemaLoader: Final[_Loader[CommandOutputArraySchema]] = ( + _RecordLoader(CommandOutputArraySchema, None, None) +) +CommandInputParameterLoader: Final[_Loader[CommandInputParameter]] = _RecordLoader( + CommandInputParameter, None, None +) +CommandOutputParameterLoader: Final[_Loader[CommandOutputParameter]] = _RecordLoader( + CommandOutputParameter, None, None +) +stdin: TypeAlias = Literal["stdin"] +stdinLoader: Final[_Loader[stdin]] = _EnumLoader(("stdin",), "stdin") """ -Only valid as a `type` for a `CommandLineTool` input with no -`inputBinding` set. `stdin` must not be specified at the `CommandLineTool` -level. +Only valid as a ``type`` for a ``CommandLineTool`` input with no ``inputBinding`` set. ``stdin`` must not be specified at the ``CommandLineTool`` level. The following -``` -inputs: - an_input_name: - type: stdin -``` + +:: + + inputs: + an_input_name: + type: stdin + + is equivalent to -``` -inputs: - an_input_name: - type: File - streamable: true - -stdin: $(inputs.an_input_name.path) -``` + +:: + + inputs: + an_input_name: + type: File + streamable: true + + stdin: $(inputs.an_input_name.path) """ -stdoutLoader = _EnumLoader(("stdout",), "stdout") +stdout: TypeAlias = Literal["stdout"] +stdoutLoader: Final[_Loader[stdout]] = _EnumLoader(("stdout",), "stdout") """ -Only valid as a `type` for a `CommandLineTool` output with no -`outputBinding` set. +Only valid as a ``type`` for a ``CommandLineTool`` output with no ``outputBinding`` set. The following -``` -outputs: - an_output_name: - type: stdout -stdout: a_stdout_file -``` +:: + + outputs: + an_output_name: + type: stdout + + stdout: a_stdout_file + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: a_stdout_file - -stdout: a_stdout_file -``` - -If there is no `stdout` name provided, a random filename will be created. -For example, the following -``` -outputs: - an_output_name: - type: stdout -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: a_stdout_file + + stdout: a_stdout_file + + +If there is no ``stdout`` name provided, a random filename will be created. For example, the following + +:: + + outputs: + an_output_name: + type: stdout + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: random_stdout_filenameABCDEFG - -stdout: random_stdout_filenameABCDEFG -``` - -If the `CommandLineTool` contains logically chained commands -(e.g. `echo a && echo b`) `stdout` must include the output of -every command. + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: random_stdout_filenameABCDEFG + + stdout: random_stdout_filenameABCDEFG + + +If the ``CommandLineTool`` contains logically chained commands (e.g. ``echo a && echo b``) ``stdout`` must include the output of every command. """ -stderrLoader = _EnumLoader(("stderr",), "stderr") +stderr: TypeAlias = Literal["stderr"] +stderrLoader: Final[_Loader[stderr]] = _EnumLoader(("stderr",), "stderr") """ -Only valid as a `type` for a `CommandLineTool` output with no -`outputBinding` set. +Only valid as a ``type`` for a ``CommandLineTool`` output with no ``outputBinding`` set. The following -``` -outputs: - an_output_name: - type: stderr -stderr: a_stderr_file -``` +:: + + outputs: + an_output_name: + type: stderr + + stderr: a_stderr_file + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: a_stderr_file - -stderr: a_stderr_file -``` - -If there is no `stderr` name provided, a random filename will be created. -For example, the following -``` -outputs: - an_output_name: - type: stderr -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: a_stderr_file + + stderr: a_stderr_file + + +If there is no ``stderr`` name provided, a random filename will be created. For example, the following + +:: + + outputs: + an_output_name: + type: stderr + + is equivalent to -``` -outputs: - an_output_name: - type: File - streamable: true - outputBinding: - glob: random_stderr_filenameABCDEFG - -stderr: random_stderr_filenameABCDEFG -``` + +:: + + outputs: + an_output_name: + type: File + streamable: true + outputBinding: + glob: random_stderr_filenameABCDEFG + + stderr: random_stderr_filenameABCDEFG """ -CommandLineToolLoader = _RecordLoader(CommandLineTool, None, None) -SoftwarePackageLoader = _RecordLoader(SoftwarePackage, None, None) -DirentLoader = _RecordLoader(Dirent, None, None) -ExpressionToolOutputParameterLoader = _RecordLoader( - ExpressionToolOutputParameter, None, None +CommandLineToolLoader: Final[_Loader[CommandLineTool]] = _RecordLoader( + CommandLineTool, None, None +) +SoftwarePackageLoader: Final[_Loader[SoftwarePackage]] = _RecordLoader( + SoftwarePackage, None, None +) +DirentLoader: Final[_Loader[Dirent]] = _RecordLoader(Dirent, None, None) +ExpressionToolOutputParameterLoader: Final[_Loader[ExpressionToolOutputParameter]] = ( + _RecordLoader(ExpressionToolOutputParameter, None, None) ) -WorkflowInputParameterLoader = _RecordLoader(WorkflowInputParameter, None, None) -ExpressionToolLoader = _RecordLoader(ExpressionTool, None, None) -LinkMergeMethodLoader = _EnumLoader( +WorkflowInputParameterLoader: Final[_Loader[WorkflowInputParameter]] = _RecordLoader( + WorkflowInputParameter, None, None +) +ExpressionToolLoader: Final[_Loader[ExpressionTool]] = _RecordLoader( + ExpressionTool, None, None +) +LinkMergeMethod: TypeAlias = Literal["merge_nested", "merge_flattened"] +LinkMergeMethodLoader: Final[_Loader[LinkMergeMethod]] = _EnumLoader( ( "merge_nested", "merge_flattened", @@ -29711,9 +25597,12 @@ def save( "LinkMergeMethod", ) """ -The input link merge method, described in [WorkflowStepInput](#WorkflowStepInput). +The input link merge method, described in `WorkflowStepInput <#WorkflowStepInput>`__. """ -PickValueMethodLoader = _EnumLoader( +PickValueMethod: TypeAlias = Literal[ + "first_non_null", "the_only_non_null", "all_non_null" +] +PickValueMethodLoader: Final[_Loader[PickValueMethod]] = _EnumLoader( ( "first_non_null", "the_only_non_null", @@ -29722,12 +25611,21 @@ def save( "PickValueMethod", ) """ -Picking non-null values among inbound data links, described in [WorkflowStepInput](#WorkflowStepInput). +Picking non-null values among inbound data links, described in `WorkflowStepInput <#WorkflowStepInput>`__. """ -WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter, None, None) -WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput, None, None) -WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput, None, None) -ScatterMethodLoader = _EnumLoader( +WorkflowOutputParameterLoader: Final[_Loader[WorkflowOutputParameter]] = _RecordLoader( + WorkflowOutputParameter, None, None +) +WorkflowStepInputLoader: Final[_Loader[WorkflowStepInput]] = _RecordLoader( + WorkflowStepInput, None, None +) +WorkflowStepOutputLoader: Final[_Loader[WorkflowStepOutput]] = _RecordLoader( + WorkflowStepOutput, None, None +) +ScatterMethod: TypeAlias = Literal[ + "dotproduct", "nested_crossproduct", "flat_crossproduct" +] +ScatterMethodLoader: Final[_Loader[ScatterMethod]] = _EnumLoader( ( "dotproduct", "nested_crossproduct", @@ -29736,25 +25634,43 @@ def save( "ScatterMethod", ) """ -The scatter method, as described in [workflow step scatter](#WorkflowStep). +The scatter method, as described in `workflow step scatter <#WorkflowStep>`__. """ -WorkflowStepLoader = _RecordLoader(WorkflowStep, None, None) -WorkflowLoader = _RecordLoader(Workflow, None, None) -OperationInputParameterLoader = _RecordLoader(OperationInputParameter, None, None) -OperationOutputParameterLoader = _RecordLoader(OperationOutputParameter, None, None) -OperationLoader = _RecordLoader(Operation, None, None) -ProcessGeneratorLoader = _RecordLoader(ProcessGenerator, None, None) -LoopInputLoader = _RecordLoader(LoopInput, None, None) -array_of_strtype = _ArrayLoader(strtype) -union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( +WorkflowStepLoader: Final[_Loader[WorkflowStep]] = _RecordLoader( + WorkflowStep, None, None +) +WorkflowLoader: Final[_Loader[Workflow]] = _RecordLoader(Workflow, None, None) +OperationInputParameterLoader: Final[_Loader[OperationInputParameter]] = _RecordLoader( + OperationInputParameter, None, None +) +OperationOutputParameterLoader: Final[_Loader[OperationOutputParameter]] = ( + _RecordLoader(OperationOutputParameter, None, None) +) +OperationLoader: Final[_Loader[Operation]] = _RecordLoader(Operation, None, None) +array_of_strtype: Final[_Loader[Sequence[str]]] = _ArrayLoader(strtype) +union_of_None_type_or_strtype_or_array_of_strtype: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, array_of_strtype, ) ) -uri_strtype_True_False_None_None = _URILoader(strtype, True, False, None, None) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( +uri_strtype_True_False_None_None: Final[_Loader[str]] = _URILoader( + strtype, True, False, None, None +) +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, @@ -29765,10 +25681,41 @@ def save( strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + ] +] = _ArrayLoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, @@ -29780,51 +25727,116 @@ def save( array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, ) ) -typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _TypeDSLLoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, 2, "v1.1", ) -array_of_RecordFieldLoader = _ArrayLoader(RecordFieldLoader) -union_of_None_type_or_array_of_RecordFieldLoader = _UnionLoader( +array_of_RecordFieldLoader: Final[ + _Loader[Sequence[schema_salad.metaschema.RecordField]] +] = _ArrayLoader(RecordFieldLoader) +union_of_None_type_or_array_of_RecordFieldLoader: Final[ + _Loader[None | Sequence[schema_salad.metaschema.RecordField]] +] = _UnionLoader( ( None_type, array_of_RecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_RecordFieldLoader, "name", "type" +idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader: Final[ + _Loader[None | Sequence[schema_salad.metaschema.RecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_RecordFieldLoader, "name", "type") +Record_name: TypeAlias = Literal["record"] +Record_nameLoader: Final[_Loader[Record_name]] = _EnumLoader(("record",), "Record_name") +typedsl_Record_nameLoader_2: Final[_Loader[Record_name]] = _TypeDSLLoader( + Record_nameLoader, 2, "v1.1" ) -Record_nameLoader = _EnumLoader(("record",), "Record_name") -typedsl_Record_nameLoader_2 = _TypeDSLLoader(Record_nameLoader, 2, "v1.1") -union_of_None_type_or_strtype = _UnionLoader( +union_of_None_type_or_strtype: Final[_Loader[None | str]] = _UnionLoader( ( None_type, strtype, ) ) -uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( - union_of_None_type_or_strtype, True, False, None, None +uri_union_of_None_type_or_strtype_True_False_None_None: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, True, False, None, None) ) -uri_array_of_strtype_True_False_None_None = _URILoader( +uri_array_of_strtype_True_False_None_None: Final[_Loader[Sequence[str]]] = _URILoader( array_of_strtype, True, False, None, None ) -Enum_nameLoader = _EnumLoader(("enum",), "Enum_name") -typedsl_Enum_nameLoader_2 = _TypeDSLLoader(Enum_nameLoader, 2, "v1.1") -uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None = _URILoader( +Enum_name: TypeAlias = Literal["enum"] +Enum_nameLoader: Final[_Loader[Enum_name]] = _EnumLoader(("enum",), "Enum_name") +typedsl_Enum_nameLoader_2: Final[_Loader[Enum_name]] = _TypeDSLLoader( + Enum_nameLoader, 2, "v1.1" +) +uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + PrimitiveType + | Sequence[ + PrimitiveType + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] + | schema_salad.metaschema.ArraySchema + | schema_salad.metaschema.EnumSchema + | schema_salad.metaschema.MapSchema + | schema_salad.metaschema.RecordSchema + | schema_salad.metaschema.UnionSchema + | str + ] +] = _URILoader( union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, False, True, 2, None, ) -Array_nameLoader = _EnumLoader(("array",), "Array_name") -typedsl_Array_nameLoader_2 = _TypeDSLLoader(Array_nameLoader, 2, "v1.1") -Map_nameLoader = _EnumLoader(("map",), "Map_name") -typedsl_Map_nameLoader_2 = _TypeDSLLoader(Map_nameLoader, 2, "v1.1") -Union_nameLoader = _EnumLoader(("union",), "Union_name") -typedsl_Union_nameLoader_2 = _TypeDSLLoader(Union_nameLoader, 2, "v1.1") -union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( +Array_name: TypeAlias = Literal["array"] +Array_nameLoader: Final[_Loader[Array_name]] = _EnumLoader(("array",), "Array_name") +typedsl_Array_nameLoader_2: Final[_Loader[Array_name]] = _TypeDSLLoader( + Array_nameLoader, 2, "v1.1" +) +Map_name: TypeAlias = Literal["map"] +Map_nameLoader: Final[_Loader[Map_name]] = _EnumLoader(("map",), "Map_name") +typedsl_Map_nameLoader_2: Final[_Loader[Map_name]] = _TypeDSLLoader( + Map_nameLoader, 2, "v1.1" +) +Union_name: TypeAlias = Literal["union"] +Union_nameLoader: Final[_Loader[Union_name]] = _EnumLoader(("union",), "Union_name") +typedsl_Union_nameLoader_2: Final[_Loader[Union_name]] = _TypeDSLLoader( + Union_nameLoader, 2, "v1.1" +) +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, CWLRecordSchemaLoader, @@ -29833,10 +25845,35 @@ def save( strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + ] +] = _ArrayLoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _UnionLoader( ( PrimitiveTypeLoader, CWLRecordSchemaLoader, @@ -29846,57 +25883,99 @@ def save( array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, ) ) -uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _URILoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, False, True, 2, None, ) -typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | Sequence[ + CWLArraySchema + | CWLRecordSchema + | PrimitiveType + | schema_salad.metaschema.EnumSchema + | str + ] + | schema_salad.metaschema.EnumSchema + | str + ] +] = _TypeDSLLoader( union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CWLRecordFieldLoader = _ArrayLoader(CWLRecordFieldLoader) -union_of_None_type_or_array_of_CWLRecordFieldLoader = _UnionLoader( +array_of_CWLRecordFieldLoader: Final[_Loader[Sequence[CWLRecordField]]] = _ArrayLoader( + CWLRecordFieldLoader +) +union_of_None_type_or_array_of_CWLRecordFieldLoader: Final[ + _Loader[None | Sequence[CWLRecordField]] +] = _UnionLoader( ( None_type, array_of_CWLRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type" -) -File_classLoader = _EnumLoader(("File",), "File_class") -uri_File_classLoader_False_True_None_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader: Final[ + _Loader[None | Sequence[CWLRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type") +File_class: TypeAlias = Literal["File"] +File_classLoader: Final[_Loader[File_class]] = _EnumLoader(("File",), "File_class") +uri_File_classLoader_False_True_None_None: Final[_Loader[File_class]] = _URILoader( File_classLoader, False, True, None, None ) -uri_union_of_None_type_or_strtype_False_False_None_None = _URILoader( - union_of_None_type_or_strtype, False, False, None, None +uri_union_of_None_type_or_strtype_False_False_None_None: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, False, False, None, None) ) -union_of_None_type_or_inttype = _UnionLoader( - ( - None_type, - inttype, +union_of_None_type_or_inttype_or_longtype: Final[_Loader[None | i32 | i64]] = ( + _UnionLoader( + ( + None_type, + inttype, + longtype, + ) ) ) -union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +union_of_FileLoader_or_DirectoryLoader: Final[_Loader[Directory | File]] = _UnionLoader( ( FileLoader, DirectoryLoader, ) ) -array_of_union_of_FileLoader_or_DirectoryLoader = _ArrayLoader( - union_of_FileLoader_or_DirectoryLoader -) -union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[Sequence[Directory | File]] +] = _ArrayLoader(union_of_FileLoader_or_DirectoryLoader) +union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[None | Sequence[Directory | File]] +] = _UnionLoader( ( None_type, array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[None | Sequence[Directory | File]] +] = _UnionLoader( ( _SecondaryDSLLoader( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader @@ -29904,34 +25983,45 @@ def save( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -uri_union_of_None_type_or_strtype_True_False_None_True = _URILoader( - union_of_None_type_or_strtype, True, False, None, True +uri_union_of_None_type_or_strtype_True_False_None_True: Final[_Loader[None | str]] = ( + _URILoader(union_of_None_type_or_strtype, True, False, None, True) ) -Directory_classLoader = _EnumLoader(("Directory",), "Directory_class") -uri_Directory_classLoader_False_True_None_None = _URILoader( - Directory_classLoader, False, True, None, None +Directory_class: TypeAlias = Literal["Directory"] +Directory_classLoader: Final[_Loader[Directory_class]] = _EnumLoader( + ("Directory",), "Directory_class" ) -union_of_None_type_or_booltype = _UnionLoader( +uri_Directory_classLoader_False_True_None_None: Final[_Loader[Directory_class]] = ( + _URILoader(Directory_classLoader, False, True, None, None) +) +union_of_None_type_or_booltype: Final[_Loader[None | bool]] = _UnionLoader( ( None_type, booltype, ) ) -union_of_None_type_or_LoadListingEnumLoader = _UnionLoader( - ( - None_type, - LoadListingEnumLoader, +union_of_None_type_or_LoadListingEnumLoader: Final[_Loader[LoadListingEnum | None]] = ( + _UnionLoader( + ( + None_type, + LoadListingEnumLoader, + ) ) ) -array_of_SecondaryFileSchemaLoader = _ArrayLoader(SecondaryFileSchemaLoader) -union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _UnionLoader( +array_of_SecondaryFileSchemaLoader: Final[_Loader[Sequence[SecondaryFileSchema]]] = ( + _ArrayLoader(SecondaryFileSchemaLoader) +) +union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader: ( + Final[_Loader[None | SecondaryFileSchema | Sequence[SecondaryFileSchema]]] +) = _UnionLoader( ( None_type, SecondaryFileSchemaLoader, array_of_SecondaryFileSchemaLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _UnionLoader( +secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader: Final[ + _Loader[None | SecondaryFileSchema | Sequence[SecondaryFileSchema]] +] = _UnionLoader( ( _SecondaryDSLLoader( union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader @@ -29939,7 +26029,9 @@ def save( union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, ) ) -union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -29947,24 +26039,32 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( +uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader( union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader, True, False, None, True, ) -union_of_None_type_or_strtype_or_ExpressionLoader = _UnionLoader( - ( - None_type, - strtype, - ExpressionLoader, +union_of_None_type_or_strtype_or_ExpressionLoader: Final[_Loader[None | str]] = ( + _UnionLoader( + ( + None_type, + strtype, + ExpressionLoader, + ) ) ) -uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( +uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True: Final[ + _Loader[None | str] +] = _URILoader( union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None, True ) -union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] +] = _UnionLoader( ( CWLTypeLoader, InputRecordSchemaLoader, @@ -29973,10 +26073,25 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, InputRecordSchemaLoader, @@ -29986,29 +26101,57 @@ def save( array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_InputRecordFieldLoader = _ArrayLoader(InputRecordFieldLoader) -union_of_None_type_or_array_of_InputRecordFieldLoader = _UnionLoader( +array_of_InputRecordFieldLoader: Final[_Loader[Sequence[InputRecordField]]] = ( + _ArrayLoader(InputRecordFieldLoader) +) +union_of_None_type_or_array_of_InputRecordFieldLoader: Final[ + _Loader[None | Sequence[InputRecordField]] +] = _UnionLoader( ( None_type, array_of_InputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type" -) -uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader: Final[ + _Loader[None | Sequence[InputRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type") +uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | InputArraySchema + | InputEnumSchema + | InputRecordSchema + | Sequence[ + CWLType | InputArraySchema | InputEnumSchema | InputRecordSchema | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str] +] = _UnionLoader( ( CWLTypeLoader, OutputRecordSchemaLoader, @@ -30017,10 +26160,27 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, OutputRecordSchemaLoader, @@ -30030,44 +26190,91 @@ def save( array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_OutputRecordFieldLoader = _ArrayLoader(OutputRecordFieldLoader) -union_of_None_type_or_array_of_OutputRecordFieldLoader = _UnionLoader( +array_of_OutputRecordFieldLoader: Final[_Loader[Sequence[OutputRecordField]]] = ( + _ArrayLoader(OutputRecordFieldLoader) +) +union_of_None_type_or_array_of_OutputRecordFieldLoader: Final[ + _Loader[None | Sequence[OutputRecordField]] +] = _UnionLoader( ( None_type, array_of_OutputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader = _IdMapLoader( - union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type" -) -uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader: Final[ + _Loader[None | Sequence[OutputRecordField]] +] = _IdMapLoader(union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type") +uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | OutputArraySchema + | OutputEnumSchema + | OutputRecordSchema + | Sequence[ + CWLType | OutputArraySchema | OutputEnumSchema | OutputRecordSchema | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader = _UnionLoader( +union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader: Final[ + _Loader[CommandInputParameter | OperationInputParameter | WorkflowInputParameter] +] = _UnionLoader( ( CommandInputParameterLoader, WorkflowInputParameterLoader, OperationInputParameterLoader, ) ) -array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader = _ArrayLoader( +array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader: Final[ + _Loader[ + Sequence[ + CommandInputParameter | OperationInputParameter | WorkflowInputParameter + ] + ] +] = _ArrayLoader( union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader ) -idmap_inputs_array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader = _IdMapLoader( +idmap_inputs_array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader: Final[ + _Loader[ + Sequence[ + CommandInputParameter | OperationInputParameter | WorkflowInputParameter + ] + ] +] = _IdMapLoader( array_of_union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader, "id", "type", ) -union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader = _UnionLoader( +union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader: Final[ + _Loader[ + CommandOutputParameter + | ExpressionToolOutputParameter + | OperationOutputParameter + | WorkflowOutputParameter + ] +] = _UnionLoader( ( CommandOutputParameterLoader, ExpressionToolOutputParameterLoader, @@ -30075,26 +26282,111 @@ def save( OperationOutputParameterLoader, ) ) -array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader = _ArrayLoader( +array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader: Final[ + _Loader[ + Sequence[ + CommandOutputParameter + | ExpressionToolOutputParameter + | OperationOutputParameter + | WorkflowOutputParameter + ] + ] +] = _ArrayLoader( union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader ) -idmap_outputs_array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader = _IdMapLoader( +idmap_outputs_array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader: Final[ + _Loader[ + Sequence[ + CommandOutputParameter + | ExpressionToolOutputParameter + | OperationOutputParameter + | WorkflowOutputParameter + ] + ] +] = _IdMapLoader( array_of_union_of_CommandOutputParameterLoader_or_ExpressionToolOutputParameterLoader_or_WorkflowOutputParameterLoader_or_OperationOutputParameterLoader, "id", "type", ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, ) ) -idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader = _IdMapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader, +idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader: Final[ + _Loader[ + None + | Sequence[ + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _IdMapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, "class", "None", ) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type = _UnionLoader( +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] +] = _UnionLoader( ( InlineJavascriptRequirementLoader, SchemaDefRequirementLoader, @@ -30113,95 +26405,182 @@ def save( ScatterFeatureRequirementLoader, MultipleInputFeatureRequirementLoader, StepInputExpressionRequirementLoader, - SecretsLoader, - MPIRequirementLoader, - CUDARequirementLoader, - LoopLoader, - ShmSizeLoader, Any_type, ) ) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type ) -union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type = _UnionLoader( +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + None + | Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _UnionLoader( ( None_type, - array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, ) ) -idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type = _IdMapLoader( - union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_SecretsLoader_or_MPIRequirementLoader_or_CUDARequirementLoader_or_LoopLoader_or_ShmSizeLoader_or_Any_type, +idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type: Final[ + _Loader[ + None + | Sequence[ + Any + | DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse + ] + ] +] = _IdMapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, "class", "None", ) -union_of_None_type_or_CWLVersionLoader = _UnionLoader( - ( - None_type, - CWLVersionLoader, +union_of_None_type_or_CWLVersionLoader: Final[_Loader[CWLVersion | None]] = ( + _UnionLoader( + ( + None_type, + CWLVersionLoader, + ) ) ) -uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None = _URILoader( - union_of_None_type_or_CWLVersionLoader, False, True, None, None -) -union_of_None_type_or_array_of_strtype = _UnionLoader( - ( - None_type, - array_of_strtype, +uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None: Final[ + _Loader[CWLVersion | None] +] = _URILoader(union_of_None_type_or_CWLVersionLoader, False, True, None, None) +union_of_None_type_or_array_of_strtype: Final[_Loader[None | Sequence[str]]] = ( + _UnionLoader( + ( + None_type, + array_of_strtype, + ) ) ) -uri_union_of_None_type_or_array_of_strtype_True_False_None_None = _URILoader( - union_of_None_type_or_array_of_strtype, True, False, None, None -) -InlineJavascriptRequirement_classLoader = _EnumLoader( - ("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class" -) -uri_InlineJavascriptRequirement_classLoader_False_True_None_None = _URILoader( - InlineJavascriptRequirement_classLoader, False, True, None, None +uri_union_of_None_type_or_array_of_strtype_True_False_None_None: Final[ + _Loader[None | Sequence[str]] +] = _URILoader(union_of_None_type_or_array_of_strtype, True, False, None, None) +InlineJavascriptRequirement_class: TypeAlias = Literal["InlineJavascriptRequirement"] +InlineJavascriptRequirement_classLoader: Final[ + _Loader[InlineJavascriptRequirement_class] +] = _EnumLoader(("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class") +uri_InlineJavascriptRequirement_classLoader_False_True_None_None: Final[ + _Loader[InlineJavascriptRequirement_class] +] = _URILoader(InlineJavascriptRequirement_classLoader, False, True, None, None) +SchemaDefRequirement_class: TypeAlias = Literal["SchemaDefRequirement"] +SchemaDefRequirement_classLoader: Final[_Loader[SchemaDefRequirement_class]] = ( + _EnumLoader(("SchemaDefRequirement",), "SchemaDefRequirement_class") ) -SchemaDefRequirement_classLoader = _EnumLoader( - ("SchemaDefRequirement",), "SchemaDefRequirement_class" -) -uri_SchemaDefRequirement_classLoader_False_True_None_None = _URILoader( - SchemaDefRequirement_classLoader, False, True, None, None -) -union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader = _UnionLoader( +uri_SchemaDefRequirement_classLoader_False_True_None_None: Final[ + _Loader[SchemaDefRequirement_class] +] = _URILoader(SchemaDefRequirement_classLoader, False, True, None, None) +union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader: Final[ + _Loader[CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema] +] = _UnionLoader( ( CommandInputRecordSchemaLoader, CommandInputEnumSchemaLoader, CommandInputArraySchemaLoader, ) ) -array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader = _ArrayLoader( +array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader: Final[ + _Loader[ + Sequence[ + CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema + ] + ] +] = _ArrayLoader( union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader ) -union_of_strtype_or_ExpressionLoader = _UnionLoader( +union_of_strtype_or_ExpressionLoader: Final[_Loader[str]] = _UnionLoader( ( strtype, ExpressionLoader, ) ) -union_of_None_type_or_booltype_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_booltype_or_ExpressionLoader: Final[ + _Loader[None | bool | str] +] = _UnionLoader( ( None_type, booltype, ExpressionLoader, ) ) -LoadListingRequirement_classLoader = _EnumLoader( - ("LoadListingRequirement",), "LoadListingRequirement_class" -) -uri_LoadListingRequirement_classLoader_False_True_None_None = _URILoader( - LoadListingRequirement_classLoader, False, True, None, None +LoadListingRequirement_class: TypeAlias = Literal["LoadListingRequirement"] +LoadListingRequirement_classLoader: Final[_Loader[LoadListingRequirement_class]] = ( + _EnumLoader(("LoadListingRequirement",), "LoadListingRequirement_class") ) -union_of_None_type_or_inttype_or_ExpressionLoader = _UnionLoader( - ( - None_type, - inttype, - ExpressionLoader, +uri_LoadListingRequirement_classLoader_False_True_None_None: Final[ + _Loader[LoadListingRequirement_class] +] = _URILoader(LoadListingRequirement_classLoader, False, True, None, None) +union_of_None_type_or_inttype_or_ExpressionLoader: Final[_Loader[None | i32 | str]] = ( + _UnionLoader( + ( + None_type, + inttype, + ExpressionLoader, + ) ) ) -union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype = _UnionLoader( +union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype: Final[ + _Loader[None | Sequence[str] | str] +] = _UnionLoader( ( None_type, strtype, @@ -30209,19 +26588,29 @@ def save( array_of_strtype, ) ) -union_of_None_type_or_ExpressionLoader = _UnionLoader( +union_of_None_type_or_ExpressionLoader: Final[_Loader[None | str]] = _UnionLoader( ( None_type, ExpressionLoader, ) ) -union_of_None_type_or_CommandLineBindingLoader = _UnionLoader( +union_of_None_type_or_CommandLineBindingLoader: Final[ + _Loader[CommandLineBinding | None] +] = _UnionLoader( ( None_type, CommandLineBindingLoader, ) ) -union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandInputRecordSchemaLoader, @@ -30230,10 +26619,35 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandInputRecordSchemaLoader, @@ -30243,31 +26657,73 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, 2, "v1.1", ) -array_of_CommandInputRecordFieldLoader = _ArrayLoader(CommandInputRecordFieldLoader) -union_of_None_type_or_array_of_CommandInputRecordFieldLoader = _UnionLoader( +array_of_CommandInputRecordFieldLoader: Final[ + _Loader[Sequence[CommandInputRecordField]] +] = _ArrayLoader(CommandInputRecordFieldLoader) +union_of_None_type_or_array_of_CommandInputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandInputRecordField]] +] = _UnionLoader( ( None_type, array_of_CommandInputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader = ( - _IdMapLoader( - union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" - ) +idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandInputRecordField]] +] = _IdMapLoader( + union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandOutputRecordSchemaLoader, @@ -30276,10 +26732,35 @@ def save( strtype, ) ) -array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _ArrayLoader( +array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + ] +] = _ArrayLoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype ) -union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _UnionLoader( ( CWLTypeLoader, CommandOutputRecordSchemaLoader, @@ -30289,37 +26770,89 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_None_type_or_CommandOutputBindingLoader = _UnionLoader( +union_of_None_type_or_CommandOutputBindingLoader: Final[ + _Loader[CommandOutputBinding | None] +] = _UnionLoader( ( None_type, CommandOutputBindingLoader, ) ) -array_of_CommandOutputRecordFieldLoader = _ArrayLoader(CommandOutputRecordFieldLoader) -union_of_None_type_or_array_of_CommandOutputRecordFieldLoader = _UnionLoader( +array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[Sequence[CommandOutputRecordField]] +] = _ArrayLoader(CommandOutputRecordFieldLoader) +union_of_None_type_or_array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandOutputRecordField]] +] = _UnionLoader( ( None_type, array_of_CommandOutputRecordFieldLoader, ) ) -idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader = ( - _IdMapLoader( - union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" - ) +idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader: Final[ + _Loader[None | Sequence[CommandOutputRecordField]] +] = _IdMapLoader( + union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | str + ] +] = _URILoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, False, True, 2, None, ) -union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | stdin + | str + ] +] = _UnionLoader( ( CWLTypeLoader, stdinLoader, @@ -30330,12 +26863,45 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | Sequence[ + CWLType + | CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordSchema + | str + ] + | stdin + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, 2, "v1.1", ) -union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( +union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | stderr + | stdout + | str + ] +] = _UnionLoader( ( CWLTypeLoader, stdoutLoader, @@ -30347,72 +26913,109 @@ def save( array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, ) ) -typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( +typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2: Final[ + _Loader[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | Sequence[ + CWLType + | CommandOutputArraySchema + | CommandOutputEnumSchema + | CommandOutputRecordSchema + | str + ] + | stderr + | stdout + | str + ] +] = _TypeDSLLoader( union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, 2, "v1.1", ) -CommandLineTool_classLoader = _EnumLoader(("CommandLineTool",), "CommandLineTool_class") -uri_CommandLineTool_classLoader_False_True_None_None = _URILoader( - CommandLineTool_classLoader, False, True, None, None -) -array_of_CommandInputParameterLoader = _ArrayLoader(CommandInputParameterLoader) -idmap_inputs_array_of_CommandInputParameterLoader = _IdMapLoader( - array_of_CommandInputParameterLoader, "id", "type" +CommandLineTool_class: TypeAlias = Literal["CommandLineTool"] +CommandLineTool_classLoader: Final[_Loader[CommandLineTool_class]] = _EnumLoader( + ("CommandLineTool",), "CommandLineTool_class" ) -array_of_CommandOutputParameterLoader = _ArrayLoader(CommandOutputParameterLoader) -idmap_outputs_array_of_CommandOutputParameterLoader = _IdMapLoader( - array_of_CommandOutputParameterLoader, "id", "type" -) -union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = _UnionLoader( +uri_CommandLineTool_classLoader_False_True_None_None: Final[ + _Loader[CommandLineTool_class] +] = _URILoader(CommandLineTool_classLoader, False, True, None, None) +array_of_CommandInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter]] +] = _ArrayLoader(CommandInputParameterLoader) +idmap_inputs_array_of_CommandInputParameterLoader: Final[ + _Loader[Sequence[CommandInputParameter]] +] = _IdMapLoader(array_of_CommandInputParameterLoader, "id", "type") +array_of_CommandOutputParameterLoader: Final[ + _Loader[Sequence[CommandOutputParameter]] +] = _ArrayLoader(CommandOutputParameterLoader) +idmap_outputs_array_of_CommandOutputParameterLoader: Final[ + _Loader[Sequence[CommandOutputParameter]] +] = _IdMapLoader(array_of_CommandOutputParameterLoader, "id", "type") +union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[CommandLineBinding | str] +] = _UnionLoader( ( strtype, ExpressionLoader, CommandLineBindingLoader, ) ) -array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = ( - _ArrayLoader(union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader) -) -union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader = _UnionLoader( +array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[Sequence[CommandLineBinding | str]] +] = _ArrayLoader(union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader) +union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader: Final[ + _Loader[None | Sequence[CommandLineBinding | str]] +] = _UnionLoader( ( None_type, array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, ) ) -array_of_inttype = _ArrayLoader(inttype) -union_of_None_type_or_array_of_inttype = _UnionLoader( - ( - None_type, - array_of_inttype, +array_of_inttype: Final[_Loader[Sequence[i32]]] = _ArrayLoader(inttype) +union_of_None_type_or_array_of_inttype: Final[_Loader[None | Sequence[i32]]] = ( + _UnionLoader( + ( + None_type, + array_of_inttype, + ) ) ) -DockerRequirement_classLoader = _EnumLoader( +DockerRequirement_class: TypeAlias = Literal["DockerRequirement"] +DockerRequirement_classLoader: Final[_Loader[DockerRequirement_class]] = _EnumLoader( ("DockerRequirement",), "DockerRequirement_class" ) -uri_DockerRequirement_classLoader_False_True_None_None = _URILoader( - DockerRequirement_classLoader, False, True, None, None -) -SoftwareRequirement_classLoader = _EnumLoader( - ("SoftwareRequirement",), "SoftwareRequirement_class" -) -uri_SoftwareRequirement_classLoader_False_True_None_None = _URILoader( - SoftwareRequirement_classLoader, False, True, None, None -) -array_of_SoftwarePackageLoader = _ArrayLoader(SoftwarePackageLoader) -idmap_packages_array_of_SoftwarePackageLoader = _IdMapLoader( - array_of_SoftwarePackageLoader, "package", "specs" +uri_DockerRequirement_classLoader_False_True_None_None: Final[ + _Loader[DockerRequirement_class] +] = _URILoader(DockerRequirement_classLoader, False, True, None, None) +SoftwareRequirement_class: TypeAlias = Literal["SoftwareRequirement"] +SoftwareRequirement_classLoader: Final[_Loader[SoftwareRequirement_class]] = ( + _EnumLoader(("SoftwareRequirement",), "SoftwareRequirement_class") ) -uri_union_of_None_type_or_array_of_strtype_False_False_None_True = _URILoader( - union_of_None_type_or_array_of_strtype, False, False, None, True +uri_SoftwareRequirement_classLoader_False_True_None_None: Final[ + _Loader[SoftwareRequirement_class] +] = _URILoader(SoftwareRequirement_classLoader, False, True, None, None) +array_of_SoftwarePackageLoader: Final[_Loader[Sequence[SoftwarePackage]]] = ( + _ArrayLoader(SoftwarePackageLoader) ) -InitialWorkDirRequirement_classLoader = _EnumLoader( - ("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class" -) -uri_InitialWorkDirRequirement_classLoader_False_True_None_None = _URILoader( - InitialWorkDirRequirement_classLoader, False, True, None, None -) -union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +idmap_packages_array_of_SoftwarePackageLoader: Final[ + _Loader[Sequence[SoftwarePackage]] +] = _IdMapLoader(array_of_SoftwarePackageLoader, "package", "specs") +uri_union_of_None_type_or_array_of_strtype_False_False_None_True: Final[ + _Loader[None | Sequence[str]] +] = _URILoader(union_of_None_type_or_array_of_strtype, False, False, None, True) +InitialWorkDirRequirement_class: TypeAlias = Literal["InitialWorkDirRequirement"] +InitialWorkDirRequirement_classLoader: Final[ + _Loader[InitialWorkDirRequirement_class] +] = _EnumLoader(("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class") +uri_InitialWorkDirRequirement_classLoader_False_True_None_None: Final[ + _Loader[InitialWorkDirRequirement_class] +] = _URILoader(InitialWorkDirRequirement_classLoader, False, True, None, None) +union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[Directory | Dirent | File | None | Sequence[Directory | File] | str] +] = _UnionLoader( ( None_type, DirentLoader, @@ -30422,271 +27025,340 @@ def save( array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader = _ArrayLoader( +array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[ + Sequence[Directory | Dirent | File | None | Sequence[Directory | File] | str] + ] +] = _ArrayLoader( union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader ) -union_of_ExpressionLoader_or_array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( +union_of_ExpressionLoader_or_array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader: Final[ + _Loader[ + Sequence[Directory | Dirent | File | None | Sequence[Directory | File] | str] + | str + ] +] = _UnionLoader( ( ExpressionLoader, array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -EnvVarRequirement_classLoader = _EnumLoader( +EnvVarRequirement_class: TypeAlias = Literal["EnvVarRequirement"] +EnvVarRequirement_classLoader: Final[_Loader[EnvVarRequirement_class]] = _EnumLoader( ("EnvVarRequirement",), "EnvVarRequirement_class" ) -uri_EnvVarRequirement_classLoader_False_True_None_None = _URILoader( - EnvVarRequirement_classLoader, False, True, None, None -) -array_of_EnvironmentDefLoader = _ArrayLoader(EnvironmentDefLoader) -idmap_envDef_array_of_EnvironmentDefLoader = _IdMapLoader( - array_of_EnvironmentDefLoader, "envName", "envValue" -) -ShellCommandRequirement_classLoader = _EnumLoader( - ("ShellCommandRequirement",), "ShellCommandRequirement_class" +uri_EnvVarRequirement_classLoader_False_True_None_None: Final[ + _Loader[EnvVarRequirement_class] +] = _URILoader(EnvVarRequirement_classLoader, False, True, None, None) +array_of_EnvironmentDefLoader: Final[_Loader[Sequence[EnvironmentDef]]] = _ArrayLoader( + EnvironmentDefLoader ) -uri_ShellCommandRequirement_classLoader_False_True_None_None = _URILoader( - ShellCommandRequirement_classLoader, False, True, None, None +idmap_envDef_array_of_EnvironmentDefLoader: Final[_Loader[Sequence[EnvironmentDef]]] = ( + _IdMapLoader(array_of_EnvironmentDefLoader, "envName", "envValue") ) -ResourceRequirement_classLoader = _EnumLoader( - ("ResourceRequirement",), "ResourceRequirement_class" +ShellCommandRequirement_class: TypeAlias = Literal["ShellCommandRequirement"] +ShellCommandRequirement_classLoader: Final[_Loader[ShellCommandRequirement_class]] = ( + _EnumLoader(("ShellCommandRequirement",), "ShellCommandRequirement_class") ) -uri_ResourceRequirement_classLoader_False_True_None_None = _URILoader( - ResourceRequirement_classLoader, False, True, None, None +uri_ShellCommandRequirement_classLoader_False_True_None_None: Final[ + _Loader[ShellCommandRequirement_class] +] = _URILoader(ShellCommandRequirement_classLoader, False, True, None, None) +ResourceRequirement_class: TypeAlias = Literal["ResourceRequirement"] +ResourceRequirement_classLoader: Final[_Loader[ResourceRequirement_class]] = ( + _EnumLoader(("ResourceRequirement",), "ResourceRequirement_class") ) -union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader = _UnionLoader( +uri_ResourceRequirement_classLoader_False_True_None_None: Final[ + _Loader[ResourceRequirement_class] +] = _URILoader(ResourceRequirement_classLoader, False, True, None, None) +union_of_None_type_or_inttype_or_longtype_or_floattype_or_ExpressionLoader: Final[ + _Loader[None | float | i32 | i64 | str] +] = _UnionLoader( ( None_type, inttype, + longtype, floattype, ExpressionLoader, ) ) -WorkReuse_classLoader = _EnumLoader(("WorkReuse",), "WorkReuse_class") -uri_WorkReuse_classLoader_False_True_None_None = _URILoader( - WorkReuse_classLoader, False, True, None, None +WorkReuse_class: TypeAlias = Literal["WorkReuse"] +WorkReuse_classLoader: Final[_Loader[WorkReuse_class]] = _EnumLoader( + ("WorkReuse",), "WorkReuse_class" ) -union_of_booltype_or_ExpressionLoader = _UnionLoader( +uri_WorkReuse_classLoader_False_True_None_None: Final[_Loader[WorkReuse_class]] = ( + _URILoader(WorkReuse_classLoader, False, True, None, None) +) +union_of_booltype_or_ExpressionLoader: Final[_Loader[bool | str]] = _UnionLoader( ( booltype, ExpressionLoader, ) ) -NetworkAccess_classLoader = _EnumLoader(("NetworkAccess",), "NetworkAccess_class") -uri_NetworkAccess_classLoader_False_True_None_None = _URILoader( - NetworkAccess_classLoader, False, True, None, None -) -InplaceUpdateRequirement_classLoader = _EnumLoader( - ("InplaceUpdateRequirement",), "InplaceUpdateRequirement_class" +NetworkAccess_class: TypeAlias = Literal["NetworkAccess"] +NetworkAccess_classLoader: Final[_Loader[NetworkAccess_class]] = _EnumLoader( + ("NetworkAccess",), "NetworkAccess_class" ) -uri_InplaceUpdateRequirement_classLoader_False_True_None_None = _URILoader( - InplaceUpdateRequirement_classLoader, False, True, None, None +uri_NetworkAccess_classLoader_False_True_None_None: Final[ + _Loader[NetworkAccess_class] +] = _URILoader(NetworkAccess_classLoader, False, True, None, None) +InplaceUpdateRequirement_class: TypeAlias = Literal["InplaceUpdateRequirement"] +InplaceUpdateRequirement_classLoader: Final[_Loader[InplaceUpdateRequirement_class]] = ( + _EnumLoader(("InplaceUpdateRequirement",), "InplaceUpdateRequirement_class") ) -ToolTimeLimit_classLoader = _EnumLoader(("ToolTimeLimit",), "ToolTimeLimit_class") -uri_ToolTimeLimit_classLoader_False_True_None_None = _URILoader( - ToolTimeLimit_classLoader, False, True, None, None +uri_InplaceUpdateRequirement_classLoader_False_True_None_None: Final[ + _Loader[InplaceUpdateRequirement_class] +] = _URILoader(InplaceUpdateRequirement_classLoader, False, True, None, None) +ToolTimeLimit_class: TypeAlias = Literal["ToolTimeLimit"] +ToolTimeLimit_classLoader: Final[_Loader[ToolTimeLimit_class]] = _EnumLoader( + ("ToolTimeLimit",), "ToolTimeLimit_class" ) -union_of_inttype_or_ExpressionLoader = _UnionLoader( - ( - inttype, - ExpressionLoader, +uri_ToolTimeLimit_classLoader_False_True_None_None: Final[ + _Loader[ToolTimeLimit_class] +] = _URILoader(ToolTimeLimit_classLoader, False, True, None, None) +union_of_inttype_or_longtype_or_ExpressionLoader: Final[_Loader[i32 | i64 | str]] = ( + _UnionLoader( + ( + inttype, + longtype, + ExpressionLoader, + ) ) ) -union_of_None_type_or_InputBindingLoader = _UnionLoader( - ( - None_type, - InputBindingLoader, +union_of_None_type_or_InputBindingLoader: Final[_Loader[InputBinding | None]] = ( + _UnionLoader( + ( + None_type, + InputBindingLoader, + ) ) ) -ExpressionTool_classLoader = _EnumLoader(("ExpressionTool",), "ExpressionTool_class") -uri_ExpressionTool_classLoader_False_True_None_None = _URILoader( - ExpressionTool_classLoader, False, True, None, None -) -array_of_WorkflowInputParameterLoader = _ArrayLoader(WorkflowInputParameterLoader) -idmap_inputs_array_of_WorkflowInputParameterLoader = _IdMapLoader( - array_of_WorkflowInputParameterLoader, "id", "type" -) -array_of_ExpressionToolOutputParameterLoader = _ArrayLoader( - ExpressionToolOutputParameterLoader -) -idmap_outputs_array_of_ExpressionToolOutputParameterLoader = _IdMapLoader( - array_of_ExpressionToolOutputParameterLoader, "id", "type" +ExpressionTool_class: TypeAlias = Literal["ExpressionTool"] +ExpressionTool_classLoader: Final[_Loader[ExpressionTool_class]] = _EnumLoader( + ("ExpressionTool",), "ExpressionTool_class" ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None -) -union_of_None_type_or_LinkMergeMethodLoader = _UnionLoader( - ( - None_type, - LinkMergeMethodLoader, +uri_ExpressionTool_classLoader_False_True_None_None: Final[ + _Loader[ExpressionTool_class] +] = _URILoader(ExpressionTool_classLoader, False, True, None, None) +array_of_WorkflowInputParameterLoader: Final[ + _Loader[Sequence[WorkflowInputParameter]] +] = _ArrayLoader(WorkflowInputParameterLoader) +idmap_inputs_array_of_WorkflowInputParameterLoader: Final[ + _Loader[Sequence[WorkflowInputParameter]] +] = _IdMapLoader(array_of_WorkflowInputParameterLoader, "id", "type") +array_of_ExpressionToolOutputParameterLoader: Final[ + _Loader[Sequence[ExpressionToolOutputParameter]] +] = _ArrayLoader(ExpressionToolOutputParameterLoader) +idmap_outputs_array_of_ExpressionToolOutputParameterLoader: Final[ + _Loader[Sequence[ExpressionToolOutputParameter]] +] = _IdMapLoader(array_of_ExpressionToolOutputParameterLoader, "id", "type") +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None) +union_of_None_type_or_LinkMergeMethodLoader: Final[_Loader[LinkMergeMethod | None]] = ( + _UnionLoader( + ( + None_type, + LinkMergeMethodLoader, + ) ) ) -union_of_None_type_or_PickValueMethodLoader = _UnionLoader( - ( - None_type, - PickValueMethodLoader, +union_of_None_type_or_PickValueMethodLoader: Final[_Loader[None | PickValueMethod]] = ( + _UnionLoader( + ( + None_type, + PickValueMethodLoader, + ) ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None -) -array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader) -idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader( - array_of_WorkflowStepInputLoader, "id", "source" +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None) +array_of_WorkflowStepInputLoader: Final[_Loader[Sequence[WorkflowStepInput]]] = ( + _ArrayLoader(WorkflowStepInputLoader) ) -union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( +idmap_in__array_of_WorkflowStepInputLoader: Final[ + _Loader[Sequence[WorkflowStepInput]] +] = _IdMapLoader(array_of_WorkflowStepInputLoader, "id", "source") +union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[WorkflowStepOutput | str] +] = _UnionLoader( ( strtype, WorkflowStepOutputLoader, ) ) -array_of_union_of_strtype_or_WorkflowStepOutputLoader = _ArrayLoader( - union_of_strtype_or_WorkflowStepOutputLoader -) -union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( - (array_of_union_of_strtype_or_WorkflowStepOutputLoader,) -) -uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None = _URILoader( +array_of_union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _ArrayLoader(union_of_strtype_or_WorkflowStepOutputLoader) +union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _UnionLoader((array_of_union_of_strtype_or_WorkflowStepOutputLoader,)) +uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None: Final[ + _Loader[Sequence[WorkflowStepOutput | str]] +] = _URILoader( union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, True, False, None, None, ) -array_of_Any_type = _ArrayLoader(Any_type) -union_of_None_type_or_array_of_Any_type = _UnionLoader( - ( - None_type, - array_of_Any_type, +array_of_Any_type: Final[_Loader[Sequence[Any]]] = _ArrayLoader(Any_type) +union_of_None_type_or_array_of_Any_type: Final[_Loader[None | Sequence[Any]]] = ( + _UnionLoader( + ( + None_type, + array_of_Any_type, + ) ) ) -idmap_hints_union_of_None_type_or_array_of_Any_type = _IdMapLoader( - union_of_None_type_or_array_of_Any_type, "class", "None" -) -union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader = _UnionLoader( +idmap_hints_union_of_None_type_or_array_of_Any_type: Final[ + _Loader[None | Sequence[Any]] +] = _IdMapLoader(union_of_None_type_or_array_of_Any_type, "class", "None") +union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader: Final[ + _Loader[CommandLineTool | ExpressionTool | Operation | Workflow | str] +] = _UnionLoader( ( strtype, CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, OperationLoader, - ProcessGeneratorLoader, ) ) -uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_False_False_None_None = _URILoader( - union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader, +uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None_None: Final[ + _Loader[CommandLineTool | ExpressionTool | Operation | Workflow | str] +] = _URILoader( + union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, False, False, None, None, ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None -) -union_of_None_type_or_ScatterMethodLoader = _UnionLoader( - ( - None_type, - ScatterMethodLoader, +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None: Final[ + _Loader[None | Sequence[str] | str] +] = _URILoader(union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None) +union_of_None_type_or_ScatterMethodLoader: Final[_Loader[None | ScatterMethod]] = ( + _UnionLoader( + ( + None_type, + ScatterMethodLoader, + ) ) ) -uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None = _URILoader( - union_of_None_type_or_ScatterMethodLoader, False, True, None, None +uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None: Final[ + _Loader[None | ScatterMethod] +] = _URILoader(union_of_None_type_or_ScatterMethodLoader, False, True, None, None) +Workflow_class: TypeAlias = Literal["Workflow"] +Workflow_classLoader: Final[_Loader[Workflow_class]] = _EnumLoader( + ("Workflow",), "Workflow_class" ) -Workflow_classLoader = _EnumLoader(("Workflow",), "Workflow_class") -uri_Workflow_classLoader_False_True_None_None = _URILoader( - Workflow_classLoader, False, True, None, None +uri_Workflow_classLoader_False_True_None_None: Final[_Loader[Workflow_class]] = ( + _URILoader(Workflow_classLoader, False, True, None, None) ) -array_of_WorkflowOutputParameterLoader = _ArrayLoader(WorkflowOutputParameterLoader) -idmap_outputs_array_of_WorkflowOutputParameterLoader = _IdMapLoader( - array_of_WorkflowOutputParameterLoader, "id", "type" +array_of_WorkflowOutputParameterLoader: Final[ + _Loader[Sequence[WorkflowOutputParameter]] +] = _ArrayLoader(WorkflowOutputParameterLoader) +idmap_outputs_array_of_WorkflowOutputParameterLoader: Final[ + _Loader[Sequence[WorkflowOutputParameter]] +] = _IdMapLoader(array_of_WorkflowOutputParameterLoader, "id", "type") +array_of_WorkflowStepLoader: Final[_Loader[Sequence[WorkflowStep]]] = _ArrayLoader( + WorkflowStepLoader ) -array_of_WorkflowStepLoader = _ArrayLoader(WorkflowStepLoader) -union_of_array_of_WorkflowStepLoader = _UnionLoader((array_of_WorkflowStepLoader,)) -idmap_steps_union_of_array_of_WorkflowStepLoader = _IdMapLoader( - union_of_array_of_WorkflowStepLoader, "id", "None" +union_of_array_of_WorkflowStepLoader: Final[_Loader[Sequence[WorkflowStep]]] = ( + _UnionLoader((array_of_WorkflowStepLoader,)) ) -SubworkflowFeatureRequirement_classLoader = _EnumLoader( +idmap_steps_union_of_array_of_WorkflowStepLoader: Final[ + _Loader[Sequence[WorkflowStep]] +] = _IdMapLoader(union_of_array_of_WorkflowStepLoader, "id", "None") +SubworkflowFeatureRequirement_class: TypeAlias = Literal[ + "SubworkflowFeatureRequirement" +] +SubworkflowFeatureRequirement_classLoader: Final[ + _Loader[SubworkflowFeatureRequirement_class] +] = _EnumLoader( ("SubworkflowFeatureRequirement",), "SubworkflowFeatureRequirement_class" ) -uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None = _URILoader( - SubworkflowFeatureRequirement_classLoader, False, True, None, None -) -ScatterFeatureRequirement_classLoader = _EnumLoader( - ("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class" -) -uri_ScatterFeatureRequirement_classLoader_False_True_None_None = _URILoader( - ScatterFeatureRequirement_classLoader, False, True, None, None -) -MultipleInputFeatureRequirement_classLoader = _EnumLoader( +uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[SubworkflowFeatureRequirement_class] +] = _URILoader(SubworkflowFeatureRequirement_classLoader, False, True, None, None) +ScatterFeatureRequirement_class: TypeAlias = Literal["ScatterFeatureRequirement"] +ScatterFeatureRequirement_classLoader: Final[ + _Loader[ScatterFeatureRequirement_class] +] = _EnumLoader(("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class") +uri_ScatterFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[ScatterFeatureRequirement_class] +] = _URILoader(ScatterFeatureRequirement_classLoader, False, True, None, None) +MultipleInputFeatureRequirement_class: TypeAlias = Literal[ + "MultipleInputFeatureRequirement" +] +MultipleInputFeatureRequirement_classLoader: Final[ + _Loader[MultipleInputFeatureRequirement_class] +] = _EnumLoader( ("MultipleInputFeatureRequirement",), "MultipleInputFeatureRequirement_class" ) -uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None = _URILoader( - MultipleInputFeatureRequirement_classLoader, False, True, None, None -) -StepInputExpressionRequirement_classLoader = _EnumLoader( +uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None: Final[ + _Loader[MultipleInputFeatureRequirement_class] +] = _URILoader(MultipleInputFeatureRequirement_classLoader, False, True, None, None) +StepInputExpressionRequirement_class: TypeAlias = Literal[ + "StepInputExpressionRequirement" +] +StepInputExpressionRequirement_classLoader: Final[ + _Loader[StepInputExpressionRequirement_class] +] = _EnumLoader( ("StepInputExpressionRequirement",), "StepInputExpressionRequirement_class" ) -uri_StepInputExpressionRequirement_classLoader_False_True_None_None = _URILoader( - StepInputExpressionRequirement_classLoader, False, True, None, None -) -Operation_classLoader = _EnumLoader(("Operation",), "Operation_class") -uri_Operation_classLoader_False_True_None_None = _URILoader( - Operation_classLoader, False, True, None, None -) -array_of_OperationInputParameterLoader = _ArrayLoader(OperationInputParameterLoader) -idmap_inputs_array_of_OperationInputParameterLoader = _IdMapLoader( - array_of_OperationInputParameterLoader, "id", "type" -) -array_of_OperationOutputParameterLoader = _ArrayLoader(OperationOutputParameterLoader) -idmap_outputs_array_of_OperationOutputParameterLoader = _IdMapLoader( - array_of_OperationOutputParameterLoader, "id", "type" -) -uri_strtype_False_True_None_None = _URILoader(strtype, False, True, None, None) -uri_array_of_strtype_False_False_0_None = _URILoader( - array_of_strtype, False, False, 0, None -) -union_of_strtype_or_array_of_strtype = _UnionLoader( - ( - strtype, - array_of_strtype, - ) -) -union_of_None_type_or_Any_type = _UnionLoader( - ( - None_type, - Any_type, - ) +uri_StepInputExpressionRequirement_classLoader_False_True_None_None: Final[ + _Loader[StepInputExpressionRequirement_class] +] = _URILoader(StepInputExpressionRequirement_classLoader, False, True, None, None) +Operation_class: TypeAlias = Literal["Operation"] +Operation_classLoader: Final[_Loader[Operation_class]] = _EnumLoader( + ("Operation",), "Operation_class" ) -array_of_LoopInputLoader = _ArrayLoader(LoopInputLoader) -idmap_loop_array_of_LoopInputLoader = _IdMapLoader( - array_of_LoopInputLoader, "id", "loopSource" +uri_Operation_classLoader_False_True_None_None: Final[_Loader[Operation_class]] = ( + _URILoader(Operation_classLoader, False, True, None, None) ) -LoopOutputModesLoader = _EnumLoader( - ( - "last", - "all", - ), - "LoopOutputModes", -) -union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader = _UnionLoader( +array_of_OperationInputParameterLoader: Final[ + _Loader[Sequence[OperationInputParameter]] +] = _ArrayLoader(OperationInputParameterLoader) +idmap_inputs_array_of_OperationInputParameterLoader: Final[ + _Loader[Sequence[OperationInputParameter]] +] = _IdMapLoader(array_of_OperationInputParameterLoader, "id", "type") +array_of_OperationOutputParameterLoader: Final[ + _Loader[Sequence[OperationOutputParameter]] +] = _ArrayLoader(OperationOutputParameterLoader) +idmap_outputs_array_of_OperationOutputParameterLoader: Final[ + _Loader[Sequence[OperationOutputParameter]] +] = _IdMapLoader(array_of_OperationOutputParameterLoader, "id", "type") +union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader: Final[ + _Loader[CommandLineTool | ExpressionTool | Operation | Workflow] +] = _UnionLoader( ( CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, OperationLoader, - ProcessGeneratorLoader, ) ) -array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader = _ArrayLoader( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader +array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader: Final[ + _Loader[Sequence[CommandLineTool | ExpressionTool | Operation | Workflow]] +] = _ArrayLoader( + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader ) -union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader = _UnionLoader( +union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader: Final[ + _Loader[ + CommandLineTool + | ExpressionTool + | Operation + | Sequence[CommandLineTool | ExpressionTool | Operation | Workflow] + | Workflow + ] +] = _UnionLoader( ( CommandLineToolLoader, ExpressionToolLoader, WorkflowLoader, OperationLoader, - ProcessGeneratorLoader, - array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader, + array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, ) ) @@ -30702,19 +27374,77 @@ def save( map_of_union_of_None_type_or_CWLObjectTypeLoader, ) ) +CWLObjectType: TypeAlias = ( + "Directory | File | Mapping[str, CWLObjectType | None] | Sequence[CWLObjectType | None] | bool | float | i32 | str" +) + +Sink: TypeAlias = WorkflowStepInput +InputSchema: TypeAlias = InputArraySchema | InputEnumSchema | InputRecordSchema +OutputSchema: TypeAlias = OutputArraySchema | OutputEnumSchema | OutputRecordSchema +InputParameter: TypeAlias = ( + CommandInputParameter | OperationInputParameter | WorkflowInputParameter +) +OutputParameter: TypeAlias = ( + CommandOutputParameter + | ExpressionToolOutputParameter + | OperationOutputParameter + | WorkflowOutputParameter +) +ProcessRequirement: TypeAlias = ( + DockerRequirement + | EnvVarRequirement + | InitialWorkDirRequirement + | InlineJavascriptRequirement + | InplaceUpdateRequirement + | LoadListingRequirement + | MultipleInputFeatureRequirement + | NetworkAccess + | ResourceRequirement + | ScatterFeatureRequirement + | SchemaDefRequirement + | ShellCommandRequirement + | SoftwareRequirement + | StepInputExpressionRequirement + | SubworkflowFeatureRequirement + | ToolTimeLimit + | WorkReuse +) +Process: TypeAlias = CommandLineTool | ExpressionTool | Operation | Workflow +CommandInputSchema: TypeAlias = ( + CommandInputArraySchema | CommandInputEnumSchema | CommandInputRecordSchema +) +CommandLineBindable: TypeAlias = ( + CommandInputArraySchema + | CommandInputEnumSchema + | CommandInputRecordField + | CommandInputRecordSchema +) +IOSchema: TypeAlias = InputSchema | OutputSchema +LoadContents: TypeAlias = ( + CommandOutputBinding | InputParameter | InputRecordField | WorkflowStepInput +) +InputFormat: TypeAlias = InputParameter | InputRecordField +OutputFormat: TypeAlias = OutputParameter | OutputRecordField +Parameter: TypeAlias = InputParameter | OutputParameter +IdentifierRequired: TypeAlias = ( + Parameter | WorkflowStep | WorkflowStepInput | WorkflowStepOutput +) +FieldBase: TypeAlias = InputRecordField | OutputRecordField | Parameter +Identified: TypeAlias = IdentifierRequired | Process +Labeled: TypeAlias = FieldBase | IOSchema | Process | WorkflowStep | WorkflowStepInput def load_document( doc: Any, - baseuri: Optional[str] = None, - loadingOptions: Optional[LoadingOptions] = None, + baseuri: str | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: if baseuri is None: baseuri = file_uri(os.getcwd()) + "/" if loadingOptions is None: loadingOptions = LoadingOptions() result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, doc, baseuri, loadingOptions, @@ -30724,16 +27454,16 @@ def load_document( def load_document_with_metadata( doc: Any, - baseuri: Optional[str] = None, - loadingOptions: Optional[LoadingOptions] = None, - addl_metadata_fields: Optional[MutableSequence[str]] = None, + baseuri: str | None = None, + loadingOptions: LoadingOptions | None = None, + addl_metadata_fields: MutableSequence[str] | None = None, ) -> Any: if baseuri is None: baseuri = file_uri(os.getcwd()) + "/" if loadingOptions is None: loadingOptions = LoadingOptions(fileuri=baseuri) return _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, doc, baseuri, loadingOptions, @@ -30744,7 +27474,7 @@ def load_document_with_metadata( def load_document_by_string( string: Any, uri: str, - loadingOptions: Optional[LoadingOptions] = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: yaml = yaml_no_ts() result = yaml.load(string) @@ -30754,7 +27484,7 @@ def load_document_by_string( loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, result, uri, loadingOptions, @@ -30765,7 +27495,7 @@ def load_document_by_string( def load_document_by_yaml( yaml: Any, uri: str, - loadingOptions: Optional[LoadingOptions] = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """ Shortcut to load via a YAML object. @@ -30777,7 +27507,7 @@ def load_document_by_yaml( loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _document_load( - union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_ProcessGeneratorLoader, + union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_or_array_of_union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, yaml, uri, loadingOptions, diff --git a/src/cwl_utils/parser/cwl_v1_2_utils.py b/src/cwl_utils/parser/cwl_v1_2_utils.py index c0e5bf50..54949008 100644 --- a/src/cwl_utils/parser/cwl_v1_2_utils.py +++ b/src/cwl_utils/parser/cwl_v1_2_utils.py @@ -2,20 +2,23 @@ import hashlib import logging from collections import namedtuple -from collections.abc import MutableMapping, MutableSequence +from collections.abc import Mapping, MutableMapping, MutableSequence, Sequence from io import StringIO from pathlib import Path -from typing import IO, Any, cast +from typing import IO, Any, TypeAlias, TypeVar, cast from urllib.parse import urldefrag from schema_salad.exceptions import ValidationException -from schema_salad.sourceline import SourceLine, add_lc_filename +from schema_salad.metaschema import ArraySchema, EnumSchema, RecordSchema +from schema_salad.runtime import LoadingOptions, shortname, file_uri, save +from schema_salad.sourceline import add_lc_filename, SourceLine from schema_salad.utils import aslist, json_dumps, yaml_no_ts import cwl_utils.parser import cwl_utils.parser.cwl_v1_2 as cwl import cwl_utils.parser.utils from cwl_utils.errors import WorkflowException +from cwl_utils.types import is_sequence from cwl_utils.utils import yaml_dumps CONTENT_LIMIT: int = 64 * 1024 @@ -24,50 +27,98 @@ SrcSink = namedtuple("SrcSink", ["src", "sink", "linkMerge", "message"]) - -def _compare_records( - src: cwl.RecordSchema, sink: cwl.RecordSchema, strict: bool = False -) -> bool: - """ - Compare two records, ensuring they have compatible fields. - - This handles normalizing record names, which will be relative to workflow - step, so that they can be compared. - """ - srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})} - sinkfields = { - cwl.shortname(field.name): field.type_ for field in (sink.fields or {}) - } - for key in sinkfields.keys(): - if ( - not can_assign_src_to_sink( - srcfields.get(key, "null"), sinkfields.get(key, "null"), strict +BasicInputTypeSchemas: TypeAlias = cwl.InputSchema | str | cwl.CWLType +InputTypeSchemas: TypeAlias = ( + BasicInputTypeSchemas | cwl.stdin | Sequence[BasicInputTypeSchemas] +) +BasicCommandInputTypeSchemas: TypeAlias = ( + cwl.CommandInputArraySchema + | cwl.CommandInputEnumSchema + | cwl.CommandInputRecordSchema + | str + | cwl.CWLType +) +CommandInputTypeSchemas: TypeAlias = ( + BasicCommandInputTypeSchemas | cwl.stdin | Sequence[BasicCommandInputTypeSchemas] +) +BasicOutputTypeSchemas: TypeAlias = cwl.OutputSchema | str | cwl.CWLType +OutputTypeSchemas: TypeAlias = ( + BasicOutputTypeSchemas | cwl.stderr | cwl.stdout | Sequence[BasicOutputTypeSchemas] +) +BasicCommandOutputTypeSchemas: TypeAlias = ( + cwl.CommandOutputArraySchema + | cwl.CommandOutputEnumSchema + | cwl.CommandOutputRecordSchema + | str + | cwl.CWLType +) +CommandOutputTypeSchemas: TypeAlias = ( + BasicCommandOutputTypeSchemas + | cwl.stderr + | cwl.stdout + | Sequence[BasicCommandOutputTypeSchemas] +) +AnyTypeSchema = TypeVar( + "AnyTypeSchema", bound=InputTypeSchemas | CommandOutputTypeSchemas +) + + +def _in_output_type_schema_to_output_type_schema( + schema_type: BasicInputTypeSchemas | BasicOutputTypeSchemas, + loading_options: LoadingOptions, +) -> BasicOutputTypeSchemas: + match schema_type: + case ArraySchema(): + return cwl.OutputArraySchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, ) - and sinkfields.get(key) is not None - ): - _logger.info( - "Record comparison failure for %s and %s\n" - "Did not match fields for %s: %s and %s", - cast(cwl.InputRecordSchema | cwl.CommandOutputRecordSchema, src).name, - cast(cwl.InputRecordSchema | cwl.CommandOutputRecordSchema, sink).name, - key, - srcfields.get(key), - sinkfields.get(key), + case EnumSchema(): + return cwl.OutputEnumSchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, + ) + case RecordSchema(): + return cwl.OutputRecordSchema.fromDoc( + schema_type.save(), + loading_options.baseuri, + loading_options, + ) + case str(): + return schema_type + raise WorkflowException(f"Unexpected output type: {schema_type}.") + + +def in_output_type_schema_to_output_type_schema( + schema_type: ( + BasicInputTypeSchemas + | BasicOutputTypeSchemas + | Sequence[BasicInputTypeSchemas | BasicOutputTypeSchemas] + ), + loading_options: LoadingOptions, +) -> OutputTypeSchemas: + if is_sequence(schema_type): + return [ + _in_output_type_schema_to_output_type_schema( + schema_type_item, loading_options ) - return False - return True + for schema_type_item in schema_type + ] + return _in_output_type_schema_to_output_type_schema(schema_type, loading_options) def _compare_type(type1: Any, type2: Any) -> bool: match (type1, type1): - case cwl.ArraySchema() as t1, cwl.ArraySchema() as t2: + case ArraySchema() as t1, ArraySchema() as t2: return _compare_type(t1.items, t2.items) - case cwl.RecordSchema(), cwl.RecordSchema(): + case RecordSchema(), RecordSchema(): fields1 = { - cwl.shortname(field.name): field.type_ for field in (type1.fields or {}) + shortname(field.name): field.type_ for field in (type1.fields or {}) } fields2 = { - cwl.shortname(field.name): field.type_ for field in (type2.fields or {}) + shortname(field.name): field.type_ for field in (type2.fields or {}) } if fields1.keys() != fields2.keys(): return False @@ -82,18 +133,8 @@ def _compare_type(type1: Any, type2: Any) -> bool: return bool(type1 == type2) -def _is_all_output_method_loop_step( - param_to_step: dict[str, cwl.WorkflowStep], parm_id: str -) -> bool: - if (source_step := param_to_step.get(parm_id)) is not None: - for requirement in source_step.requirements or []: - if isinstance(requirement, cwl.Loop) and requirement.outputMethod == "all": - return True - return False - - def _is_conditional_step( - param_to_step: dict[str, cwl.WorkflowStep], parm_id: str + param_to_step: Mapping[str, cwl.WorkflowStep], parm_id: str ) -> bool: if (source_step := param_to_step.get(parm_id)) is not None: if source_step.when is not None: @@ -104,9 +145,9 @@ def _is_conditional_step( def _inputfile_load( doc: str | MutableMapping[str, Any] | MutableSequence[Any], baseuri: str, - loadingOptions: cwl.LoadingOptions, + loadingOptions: LoadingOptions, addl_metadata_fields: MutableSequence[str] | None = None, -) -> tuple[Any, cwl.LoadingOptions]: +) -> tuple[Any, LoadingOptions]: loader = cwl.CWLInputFileLoader match doc: case str(): @@ -120,9 +161,7 @@ def _inputfile_load( yaml = yaml_no_ts() result = yaml.load(textIO) add_lc_filename(result, doc_url) - loadingOptions = cwl.LoadingOptions( - copyfrom=loadingOptions, fileuri=doc_url - ) + loadingOptions = LoadingOptions(copyfrom=loadingOptions, fileuri=doc_url) _inputfile_load( result, doc_url, @@ -136,7 +175,7 @@ def _inputfile_load( if mf in doc: addl_metadata[mf] = doc[mf] - loadingOptions = cwl.LoadingOptions( + loadingOptions = LoadingOptions( copyfrom=loadingOptions, baseuri=baseuri, addl_metadata=addl_metadata, @@ -163,46 +202,16 @@ def _inputfile_load( ) -def can_assign_src_to_sink(src: Any, sink: Any, strict: bool = False) -> bool: - """ - Check for identical type specifications, ignoring extra keys like inputBinding. - - src: admissible source types - sink: admissible sink types - - In non-strict comparison, at least one source type must match one sink type, - except for 'null'. - In strict comparison, all source types must match at least one sink type. - """ - if "Any" in (src, sink): - return True - if isinstance(src, cwl.ArraySchema) and isinstance(sink, cwl.ArraySchema): - return can_assign_src_to_sink(src.items, sink.items, strict) - if isinstance(src, cwl.RecordSchema) and isinstance(sink, cwl.RecordSchema): - return _compare_records(src, sink, strict) - if isinstance(src, MutableSequence): - if strict: - for this_src in src: - if not can_assign_src_to_sink(this_src, sink): - return False - return True - for this_src in src: - if this_src != "null" and can_assign_src_to_sink(this_src, sink): - return True - return False - if isinstance(sink, MutableSequence): - for this_sink in sink: - if can_assign_src_to_sink(src, this_sink): - return True - return False - return bool(src == sink) - - def check_all_types( - src_dict: dict[str, Any], - sinks: MutableSequence[cwl.WorkflowStepInput | cwl.WorkflowOutputParameter], - param_to_step: dict[str, cwl.WorkflowStep], - type_dict: dict[str, Any], + src_dict: Mapping[str, cwl.WorkflowInputParameter | cwl.WorkflowStepOutput], + sinks: Sequence[cwl.WorkflowStepInput | cwl.WorkflowOutputParameter], + param_to_step: Mapping[str, cwl.WorkflowStep], + type_dict: MutableMapping[ + str, + cwl_utils.parser.utils.InputTypeSchemas + | cwl_utils.parser.utils.OutputTypeSchemas + | None, + ], ) -> dict[str, list[SrcSink]]: """Given a list of sinks, check if their types match with the types of their sources.""" validation: dict[str, list[SrcSink]] = {"warning": [], "exception": []} @@ -219,9 +228,9 @@ def check_all_types( sourceName = "source" sourceField = sink.source case _: - continue + raise WorkflowException(f"Invalid sink type {sink.__class__.__name__}") if sourceField is not None: - if isinstance(sourceField, MutableSequence) and len(sourceField) > 1: + if is_sequence(sourceField) and len(sourceField) > 1: linkMerge: str | None = sink.linkMerge or ( "merge_nested" if len(sourceField) > 1 else None ) @@ -246,20 +255,15 @@ def check_all_types( src_dict[parm_id], sink, linkMerge, - message="Source is from conditional step, but pickValue is not used", + message="Source is from conditional step and may produce `null`", ) ) type_dict[src_dict[parm_id].id] = src_typ - if _is_all_output_method_loop_step(param_to_step, parm_id): - src_typ = type_dict[src_dict[parm_id].id] - type_dict[src_dict[parm_id].id] = cwl.ArraySchema( - items=src_typ, type_="array" - ) else: - if isinstance(sourceField, MutableSequence): - parm_id = cast(str, sourceField[0]) + if is_sequence(sourceField): + parm_id = sourceField[0] else: - parm_id = cast(str, sourceField) + parm_id = sourceField if parm_id not in src_dict: raise SourceLine(sink, sourceName, ValidationException).makeError( f"{sourceName} not found: {parm_id}" @@ -276,34 +280,20 @@ def check_all_types( ) ) if _is_conditional_step(param_to_step, parm_id): - src_typ = aslist(type_dict[src_dict[parm_id].id]) - snk_typ = type_dict[sink.id] - if "null" not in src_typ: - src_typ = ["null"] + cast(list[Any], src_typ) - if ( - not isinstance(snk_typ, MutableSequence) - or "null" not in snk_typ - ): - validation["warning"].append( - SrcSink( - src_dict[parm_id], - sink, - linkMerge, - message="Source is from conditional step and may produce `null`", - ) + validation["warning"].append( + SrcSink( + src_dict[parm_id], + sink, + linkMerge, + message="Source is from conditional step, but pickValue is not used", ) - type_dict[src_dict[parm_id].id] = src_typ - if _is_all_output_method_loop_step(param_to_step, parm_id): - src_typ = type_dict[src_dict[parm_id].id] - type_dict[src_dict[parm_id].id] = cwl.ArraySchema( - items=src_typ, type_="array" ) for src in srcs_of_sink: - check_result = check_types( - type_dict[cast(str, src.id)], + check_result = cwl_utils.parser.utils.check_types( + type_dict[src.id], sink_type, linkMerge, - getattr(sink, "valueFrom", None), + sink.valueFrom if isinstance(sink, cwl.WorkflowStepInput) else None, ) if check_result in ("warning", "exception"): validation[check_result].append( @@ -312,39 +302,6 @@ def check_all_types( return validation -def check_types( - srctype: Any, - sinktype: Any, - linkMerge: str | None, - valueFrom: str | None = None, -) -> str: - """ - Check if the source and sink types are correct. - - Acceptable types are "pass", "warning", or "exception". - """ - if valueFrom is not None: - return "pass" - match linkMerge: - case None: - if can_assign_src_to_sink(srctype, sinktype, strict=True): - return "pass" - if can_assign_src_to_sink(srctype, sinktype, strict=False): - return "warning" - return "exception" - case "merge_nested": - return check_types( - cwl.ArraySchema(items=srctype, type_="array"), - sinktype, - None, - None, - ) - case "merge_flattened": - return check_types(merge_flatten_type(srctype), sinktype, None, None) - case _: - raise ValidationException(f"Invalid value {linkMerge} for linkMerge field.") - - def content_limit_respected_read_bytes(f: IO[bytes]) -> bytes: """ Read file content up to 64 kB as a byte array. @@ -405,8 +362,7 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: ) else: clt.stdin = ( - "$(inputs.%s.path)" - % cast(str, inp.id).rpartition("#")[2].split("/")[-1] + "$(inputs.%s.path)" % inp.id.rpartition("#")[2].split("/")[-1] ) inp.type_ = "File" @@ -414,13 +370,13 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: def load_inputfile( doc: Any, baseuri: str | None = None, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.2 input file from a serialized YAML string or a YAML object.""" if baseuri is None: - baseuri = cwl.file_uri(str(Path.cwd())) + "/" + baseuri = file_uri(str(Path.cwd())) + "/" if loadingOptions is None: - loadingOptions = cwl.LoadingOptions() + loadingOptions = LoadingOptions() result, metadata = _inputfile_load( doc, @@ -433,14 +389,14 @@ def load_inputfile( def load_inputfile_by_string( string: Any, uri: str, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.2 input file from a serialized YAML string.""" result = yaml_no_ts().load(string) add_lc_filename(result, uri) if loadingOptions is None: - loadingOptions = cwl.LoadingOptions(fileuri=uri) + loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _inputfile_load( result, @@ -453,13 +409,13 @@ def load_inputfile_by_string( def load_inputfile_by_yaml( yaml: Any, uri: str, - loadingOptions: cwl.LoadingOptions | None = None, + loadingOptions: LoadingOptions | None = None, ) -> Any: """Load a CWL v1.2 input file from a YAML object.""" add_lc_filename(yaml, uri) if loadingOptions is None: - loadingOptions = cwl.LoadingOptions(fileuri=uri) + loadingOptions = LoadingOptions(fileuri=uri) result, metadata = _inputfile_load( yaml, @@ -469,98 +425,124 @@ def load_inputfile_by_yaml( return result -def merge_flatten_type(src: Any) -> Any: - """Return the merge flattened type of the source type.""" - if isinstance(src, MutableSequence): - return [merge_flatten_type(t) for t in src] - if isinstance(src, cwl.ArraySchema): - return src - return cwl.ArraySchema(type_="array", items=src) +def to_input_array(type_: InputTypeSchemas) -> cwl.InputArraySchema: + return cwl.InputArraySchema(type_="array", items=type_) + + +def to_output_array(type_: OutputTypeSchemas) -> cwl.OutputArraySchema: + return cwl.OutputArraySchema(type_="array", items=type_) def type_for_step_input( step: cwl.WorkflowStep, in_: cwl.WorkflowStepInput, -) -> Any: +) -> cwl_utils.parser.utils.InputTypeSchemas | None: """Determine the type for the given step input.""" if in_.valueFrom is not None: return "Any" step_run = cwl_utils.parser.utils.load_step(step) cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - if step_run and step_run.inputs: - for step_input in step_run.inputs: - if cast(str, step_input.id).split("#")[-1] == in_.id.split("#")[-1]: - input_type = step_input.type_ - if step.scatter is not None and in_.id in aslist(step.scatter): - input_type = cwl.ArraySchema(items=input_type, type_="array") - return input_type + for step_input in step_run.inputs: + if step_input.id.split("#")[-1] == in_.id.split("#")[-1]: + input_type = step_input.type_ + if ( + input_type is not None + and step.scatter is not None + and in_.id in aslist(step.scatter) + ): + input_type = cwl_utils.parser.utils.to_input_array( + input_type, step_run.cwlVersion or "v1.2" + ) + return input_type return "Any" def type_for_step_output( step: cwl.WorkflowStep, sourcename: str, -) -> Any: +) -> cwl_utils.parser.utils.OutputTypeSchemas | None: """Determine the type for the given step output.""" step_run = cwl_utils.parser.utils.load_step(step) cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - if step_run and step_run.outputs: - for output in step_run.outputs: - if ( - output.id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - output_type = output.type_ - if step.scatter is not None: - if step.scatterMethod == "nested_crossproduct": - for _ in range(len(aslist(step.scatter))): - output_type = cwl.ArraySchema( - items=output_type, type_="array" - ) - else: - output_type = cwl.ArraySchema(items=output_type, type_="array") - return output_type + for output in step_run.outputs: + if ( + output.id.split("#")[-1].split("/")[-1] + == sourcename.split("#")[-1].split("/")[-1] + ): + output_type = output.type_ + if output_type is not None and step.scatter is not None: + if step.scatterMethod == "nested_crossproduct": + for _ in range(len(aslist(step.scatter))): + output_type = cwl_utils.parser.utils.to_output_array( + output_type, step_run.cwlVersion or "v1.2" + ) + else: + output_type = cwl_utils.parser.utils.to_output_array( + output_type, step_run.cwlVersion or "v1.2" + ) + return output_type raise ValidationException( "param {} not found in {}.".format( sourcename, - yaml_dumps(cwl.save(step)), + yaml_dumps(save(step)), ) ) def type_for_source( - process: cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool, - sourcenames: str | list[str], + process: cwl.Process, + sourcenames: str | Sequence[str], parent: cwl.Workflow | None = None, linkMerge: str | None = None, pickValue: str | None = None, -) -> Any: +) -> ( + MutableSequence[InputTypeSchemas | OutputTypeSchemas] + | InputTypeSchemas + | OutputTypeSchemas +): """Determine the type for the given sourcenames.""" scatter_context: list[tuple[int, str] | None] = [] - params = param_for_source_id(process, sourcenames, parent, scatter_context) + params = cwl_utils.parser.utils.param_for_source_id( + process, sourcenames, parent, scatter_context + ) if not isinstance(params, MutableSequence): - new_type = params.type_ + new_type: InputTypeSchemas | OutputTypeSchemas = params.type_ if scatter_context[0] is not None: if scatter_context[0][1] == "nested_crossproduct": for _ in range(scatter_context[0][0]): - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) else: - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type_="array") + new_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + new_type, process.loadingOptions + ), + type_="array", + ) elif linkMerge == "merge_flattened": - new_type = merge_flatten_type(new_type) + new_type = cwl_utils.parser.utils.merge_flatten_type(new_type) if pickValue is not None: - if isinstance(new_type, cwl.ArraySchema): + if isinstance(new_type, ArraySchema): if pickValue in ("first_non_null", "the_only_non_null"): - new_type = new_type.items + return new_type.items return new_type - new_type = [] + new_types: MutableSequence[InputTypeSchemas | OutputTypeSchemas] = [] for p, sc in zip(params, scatter_context): - if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type): + if isinstance(p, str) and not any(_compare_type(t, p) for t in new_types): cur_type = p elif hasattr(p, "type_") and not any( - _compare_type(t, p.type_) for t in new_type + _compare_type(t, p.type_) for t in new_types ): cur_type = p.type_ else: @@ -569,116 +551,42 @@ def type_for_source( if sc is not None: if sc[1] == "nested_crossproduct": for _ in range(sc[0]): - cur_type = cwl.ArraySchema(items=cur_type, type_="array") + cur_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + cur_type, process.loadingOptions + ), + type_="array", + ) else: - cur_type = cwl.ArraySchema(items=cur_type, type_="array") - new_type.append(cur_type) - if len(new_type) == 1: - new_type = new_type[0] + cur_type = cwl.OutputArraySchema( + items=in_output_type_schema_to_output_type_schema( + cur_type, process.loadingOptions + ), + type_="array", + ) + new_types.append(cur_type) + if len(new_types) == 1: + final_type: ( + MutableSequence[InputTypeSchemas | OutputTypeSchemas] + | InputTypeSchemas + | OutputTypeSchemas + ) = new_types[0] + else: + final_type = new_types if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type_="array") + final_type = cwl.OutputArraySchema( + items=final_type, + type_="array", + ) elif linkMerge == "merge_flattened": - new_type = merge_flatten_type(new_type) + final_type = cwl_utils.parser.utils.merge_flatten_type(final_type) elif isinstance(sourcenames, list) and len(sourcenames) > 1: - new_type = cwl.ArraySchema(items=new_type, type_="array") + final_type = cwl.OutputArraySchema( + items=final_type, + type_="array", + ) if pickValue is not None: - if isinstance(new_type, cwl.ArraySchema): + if isinstance(final_type, ArraySchema): if pickValue in ("first_non_null", "the_only_non_null"): - new_type = new_type.items - return new_type - - -def param_for_source_id( - process: cwl.CommandLineTool | cwl.Workflow | cwl.ExpressionTool, - sourcenames: str | list[str], - parent: cwl.Workflow | None = None, - scatter_context: list[tuple[int, str] | None] | None = None, -) -> ( - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter - | MutableSequence[ - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter - ] -): - """Find the process input parameter that matches one of the given sourcenames.""" - if isinstance(sourcenames, str): - sourcenames = [sourcenames] - params: MutableSequence[ - cwl.CommandInputParameter - | cwl.CommandOutputParameter - | cwl.WorkflowInputParameter - ] = [] - for sourcename in sourcenames: - if not isinstance(process, cwl.Workflow): - for param in process.inputs: - if param.id.split("#")[-1] == sourcename.split("#")[-1]: - params.append(param) - if scatter_context is not None: - scatter_context.append(None) - targets = [process] - if parent: - targets.append(parent) - for target in targets: - if isinstance(target, cwl.Workflow): - for inp in target.inputs: - if inp.id.split("#")[-1] == sourcename.split("#")[-1]: - params.append(inp) - if scatter_context is not None: - scatter_context.append(None) - for step in target.steps: - if ( - "/".join(sourcename.split("#")[-1].split("/")[:-1]) - == step.id.split("#")[-1] - and step.out - ): - step_run = cwl_utils.parser.utils.load_step(step) - cwl_utils.parser.utils.convert_stdstreams_to_files(step_run) - for outp in step.out: - outp_id = outp if isinstance(outp, str) else outp.id - if ( - outp_id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - if step_run and step_run.outputs: - for output in step_run.outputs: - if ( - output.id.split("#")[-1].split("/")[-1] - == sourcename.split("#")[-1].split("/")[-1] - ): - params.append(output) - if scatter_context is not None: - if scatter_context is not None: - if isinstance(step.scatter, str): - scatter_context.append( - ( - 1, - step.scatterMethod - or "dotproduct", - ) - ) - elif isinstance( - step.scatter, MutableSequence - ): - scatter_context.append( - ( - len(step.scatter), - step.scatterMethod - or "dotproduct", - ) - ) - else: - scatter_context.append(None) - if len(params) == 1: - return params[0] - elif len(params) > 1: - return params - raise WorkflowException( - "param {} not found in {}\n{}.".format( - sourcename, - yaml_dumps(cwl.save(process)), - (f" or\n {yaml_dumps(cwl.save(parent))}" if parent is not None else ""), - ) - ) + return final_type.items + return final_type diff --git a/src/cwl_utils/parser/utils.py b/src/cwl_utils/parser/utils.py index 967beb12..30993c3d 100644 --- a/src/cwl_utils/parser/utils.py +++ b/src/cwl_utils/parser/utils.py @@ -2,21 +2,26 @@ import copy import logging -from collections.abc import MutableSequence +from collections.abc import Mapping +from collections.abc import MutableMapping, MutableSequence, Sequence from pathlib import Path -from types import ModuleType -from typing import Any, Optional, cast +from typing import ( + Any, + Final, + cast, + Literal, + TypeAlias, + overload, +) from urllib.parse import unquote_plus, urlparse from schema_salad.exceptions import ValidationException +from schema_salad.metaschema import ArraySchema +from schema_salad.runtime import file_uri, shortname, save, LoadingOptions from schema_salad.sourceline import SourceLine, strip_dup_lineno -from schema_salad.utils import json_dumps, yaml_no_ts - -import cwl_utils -import cwl_utils.parser +from schema_salad.utils import yaml_no_ts from . import ( - LoadingOptions, Process, Workflow, WorkflowStep, @@ -27,11 +32,179 @@ cwl_v1_1_utils, cwl_v1_2, cwl_v1_2_utils, + load_document_by_uri, + OutputArraySchema, + InputArraySchema, + OutputParameter, + InputParameter, + InputRecordSchema, + CommandOutputRecordSchema, + OutputRecordSchema, + InputRecordField, + OutputRecordField, ) +from ..errors import WorkflowException +from ..types import is_sequence +from ..utils import yaml_dumps _logger = logging.getLogger("cwl_utils") +BasicInputTypeSchemas: TypeAlias = ( + cwl_v1_0_utils.BasicInputTypeSchemas + | cwl_v1_1_utils.BasicInputTypeSchemas + | cwl_v1_2_utils.BasicInputTypeSchemas +) + + +InputTypeSchemas: TypeAlias = ( + cwl_v1_0_utils.InputTypeSchemas + | cwl_v1_1_utils.InputTypeSchemas + | cwl_v1_2_utils.InputTypeSchemas +) + + +BasicOutputTypeSchemas: TypeAlias = ( + cwl_v1_0_utils.BasicOutputTypeSchemas + | cwl_v1_1_utils.BasicOutputTypeSchemas + | cwl_v1_2_utils.BasicOutputTypeSchemas +) + + +OutputTypeSchemas: TypeAlias = ( + cwl_v1_0_utils.OutputTypeSchemas + | cwl_v1_1_utils.OutputTypeSchemas + | cwl_v1_2_utils.OutputTypeSchemas +) + + +SrcSink: TypeAlias = ( + cwl_v1_0_utils.SrcSink | cwl_v1_1_utils.SrcSink | cwl_v1_2_utils.SrcSink +) + + +def _compare_records( + src: InputRecordSchema | OutputRecordSchema, + sink: InputRecordSchema | OutputRecordSchema, + strict: bool = False, +) -> bool: + """ + Compare two records, ensuring they have compatible fields. + + This handles normalizing record names, which will be relative to workflow + step, so that they can be compared. + """ + srcfields = { + shortname(field.name): cast( + InputTypeSchemas | OutputTypeSchemas | None, field.type_ + ) + for field in cast( + Sequence[InputRecordField | OutputRecordField], src.fields or [] + ) + } + sinkfields = { + shortname(field.name): cast( + InputTypeSchemas | OutputTypeSchemas | None, field.type_ + ) + for field in cast( + Sequence[InputRecordField | OutputRecordField], sink.fields or [] + ) + } + for key in sinkfields.keys(): + if ( + not can_assign_src_to_sink( + srcfields.get(key, "null"), sinkfields.get(key, "null"), strict + ) + and sinkfields.get(key) is not None + ): + _logger.info( + "Record comparison failure for %s and %s\n" + "Did not match fields for %s: %s and %s", + cast(InputRecordSchema | CommandOutputRecordSchema, src).name, + cast(InputRecordSchema | CommandOutputRecordSchema, sink).name, + key, + srcfields.get(key), + sinkfields.get(key), + ) + return False + return True + + +def can_assign_src_to_sink( + src: InputTypeSchemas | OutputTypeSchemas | None, + sink: InputTypeSchemas | OutputTypeSchemas | None, + strict: bool = False, +) -> bool: + """ + Check for identical type specifications, ignoring extra keys like inputBinding. + + src: admissible source types + sink: admissible sink types + + In non-strict comparison, at least one source type must match one sink type, + except for 'null'. + In strict comparison, all source types must match at least one sink type. + """ + if "Any" in (src, sink): + return True + if isinstance(src, InputArraySchema | OutputArraySchema) and isinstance( + sink, InputArraySchema | OutputArraySchema + ): + return can_assign_src_to_sink( + cast(InputTypeSchemas | OutputTypeSchemas | None, src.items), + cast(InputTypeSchemas | OutputTypeSchemas | None, sink.items), + strict, + ) + if isinstance(src, InputRecordSchema | OutputRecordSchema) and isinstance( + sink, InputRecordSchema | OutputRecordSchema + ): + return _compare_records(src, sink, strict) + if isinstance(src, MutableSequence): + if strict: + for this_src in src: + if not can_assign_src_to_sink(this_src, sink): + return False + return True + for this_src in src: + if this_src != "null" and can_assign_src_to_sink(this_src, sink): + return True + return False + if isinstance(sink, MutableSequence): + for this_sink in sink: + if can_assign_src_to_sink(src, this_sink): + return True + return False + return bool(src == sink) + + +def check_types( + srctype: InputTypeSchemas | OutputTypeSchemas | None, + sinktype: InputTypeSchemas | OutputTypeSchemas | None, + linkMerge: str | None, + valueFrom: str | None = None, +) -> str: + """ + Check if the source and sink types are correct. + + Acceptable types are "pass", "warning", or "exception". + """ + if valueFrom is not None: + return "pass" + if linkMerge is None: + if can_assign_src_to_sink(srctype, sinktype, strict=True): + return "pass" + if can_assign_src_to_sink(srctype, sinktype, strict=False): + return "warning" + return "exception" + if linkMerge == "merge_nested": + return check_types( + ArraySchema(items=srctype, type_="array"), sinktype, None, None + ) + if linkMerge == "merge_flattened": + return check_types(merge_flatten_type(srctype), sinktype, None, None) + raise ValidationException(f"Invalid value {linkMerge} for linkMerge field.") + + def convert_stdstreams_to_files(process: Process) -> None: """Convert stdin, stdout and stderr type shortcuts to files.""" match process: @@ -64,17 +237,7 @@ def load_inputfile_by_uri( baseuri: str = real_path if loadingOptions is None: - match version: - case "v1.0": - loadingOptions = cwl_v1_0.LoadingOptions(fileuri=baseuri) - case "v1.1": - loadingOptions = cwl_v1_1.LoadingOptions(fileuri=baseuri) - case "v1.2": - loadingOptions = cwl_v1_2.LoadingOptions(fileuri=baseuri) - case _: - raise ValidationException( - f"Version error. Did not recognise {version} as a CWL version" - ) + loadingOptions = LoadingOptions(fileuri=baseuri) doc = loadingOptions.fetcher.fetch_text(real_path) return load_inputfile_by_string(version, doc, baseuri, loadingOptions) @@ -88,7 +251,7 @@ def load_inputfile( ) -> Any: """Load a CWL input file from a serialized YAML string or a YAML object.""" if baseuri is None: - baseuri = cwl_v1_0.file_uri(str(Path.cwd())) + "/" + baseuri = file_uri(str(Path.cwd())) + "/" if isinstance(doc, str): return load_inputfile_by_string(version, doc, baseuri, loadingOptions) return load_inputfile_by_yaml(version, doc, baseuri, loadingOptions) @@ -114,17 +277,11 @@ def load_inputfile_by_yaml( """Load a CWL input file from a YAML object.""" match version: case "v1.0": - return cwl_v1_0_utils.load_inputfile_by_yaml( - yaml, uri, cast(Optional[cwl_v1_0.LoadingOptions], loadingOptions) - ) + return cwl_v1_0_utils.load_inputfile_by_yaml(yaml, uri, loadingOptions) case "v1.1": - return cwl_v1_1_utils.load_inputfile_by_yaml( - yaml, uri, cast(Optional[cwl_v1_1.LoadingOptions], loadingOptions) - ) + return cwl_v1_1_utils.load_inputfile_by_yaml(yaml, uri, loadingOptions) case "v1.2": - return cwl_v1_2_utils.load_inputfile_by_yaml( - yaml, uri, cast(Optional[cwl_v1_2.LoadingOptions], loadingOptions) - ) + return cwl_v1_2_utils.load_inputfile_by_yaml(yaml, uri, loadingOptions) case None: raise ValidationException("could not get the cwlVersion") case _: @@ -134,10 +291,10 @@ def load_inputfile_by_yaml( def load_step( - step: cwl_utils.parser.WorkflowStep, + step: WorkflowStep, ) -> Process: if isinstance(step.run, str): - step_run = cwl_utils.parser.load_document_by_uri( + step_run = load_document_by_uri( path=step.loadingOptions.fetcher.urljoin( base_url=cast(str, step.loadingOptions.fileuri), url=step.run, @@ -145,24 +302,114 @@ def load_step( loadingOptions=step.loadingOptions, ) return cast(Process, step_run) - return cast(Process, copy.deepcopy(step.run)) + return copy.deepcopy(step.run) + + +def merge_flatten_type(src: Any) -> Any: + """Return the merge flattened type of the source type.""" + if isinstance(src, MutableSequence): + return [merge_flatten_type(t) for t in src] + if isinstance(src, ArraySchema): + return src + return ArraySchema(type_="array", items=src) -def static_checker(workflow: cwl_utils.parser.Workflow) -> None: +def param_for_source_id( + process: Process, + sourcenames: str | Sequence[str], + parent: Workflow | None = None, + scatter_context: list[tuple[int, str] | None] | None = None, +) -> ( + InputParameter | OutputParameter | MutableSequence[InputParameter | OutputParameter] +): + """Find the process input parameter that matches one of the given sourcenames.""" + if isinstance(sourcenames, str): + sourcenames = [sourcenames] + params: MutableSequence[InputParameter | OutputParameter] = [] + for sourcename in sourcenames: + if not isinstance(process, Workflow): + for param in process.inputs: + if param.id.split("#")[-1] == sourcename.split("#")[-1]: + params.append(param) + if scatter_context is not None: + scatter_context.append(None) + targets = [process] + if parent: + targets.append(parent) + for target in targets: + if isinstance(target, Workflow): + for inp in target.inputs: + if inp.id.split("#")[-1] == sourcename.split("#")[-1]: + params.append(inp) + if scatter_context is not None: + scatter_context.append(None) + for step in target.steps: + if ( + "/".join(sourcename.split("#")[-1].split("/")[:-1]) + == step.id.split("#")[-1] + and step.out + ): + step_run = load_step(step) + convert_stdstreams_to_files(step_run) + for outp in step.out: + outp_id = outp if isinstance(outp, str) else outp.id + if ( + outp_id.split("#")[-1].split("/")[-1] + == sourcename.split("#")[-1].split("/")[-1] + ): + if step_run and step_run.outputs: + for output in step_run.outputs: + if ( + output.id.split("#")[-1].split("/")[-1] + == sourcename.split("#")[-1].split("/")[-1] + ): + params.append(output) + if scatter_context is not None: + match step.scatter: + case str(): + scatter_context.append( + ( + 1, + step.scatterMethod + or "dotproduct", + ) + ) + case Sequence(): + scatter_context.append( + ( + len(step.scatter), + step.scatterMethod + or "dotproduct", + ) + ) + case _: + scatter_context.append(None) + if len(params) == 1: + return params[0] + elif len(params) > 1: + return params + raise WorkflowException( + "param {} not found in {}\n{}.".format( + sourcename, + yaml_dumps(save(process)), + (f" or\n {yaml_dumps(save(parent))}" if parent is not None else ""), + ) + ) + + +def static_checker(workflow: Workflow) -> None: """Check if all source and sink types of a workflow are compatible before run time.""" - step_inputs = [] + step_inputs: Final[MutableSequence[WorkflowStepInput]] = [] step_outputs = [] - type_dict = {} - param_to_step = {} + type_dict: dict[str, InputTypeSchemas | OutputTypeSchemas | None] = {} + param_to_step: Final[MutableMapping[str, WorkflowStep]] = {} for step in workflow.steps: if step.in_ is not None: step_inputs.extend(step.in_) param_to_step.update({s.id: step for s in step.in_}) type_dict.update( { - cast(str, s.id): type_for_step_input( - step, s, cast(str, workflow.cwlVersion) - ) + s.id: type_for_step_input(step, s, cast(str, workflow.cwlVersion)) for s in step.in_ } ) @@ -204,33 +451,73 @@ def static_checker(workflow: cwl_utils.parser.Workflow) -> None: **{param.id: param.type_ for param in workflow.outputs}, } - parser: ModuleType - step_inputs_val: dict[str, Any] - workflow_outputs_val: dict[str, Any] + step_inputs_val: Mapping[str, Sequence[SrcSink]] + workflow_outputs_val: Mapping[str, Sequence[SrcSink]] match workflow.cwlVersion: case "v1.0": - parser = cwl_v1_0 step_inputs_val = cwl_v1_0_utils.check_all_types( - src_dict, step_inputs, type_dict + cast( + Mapping[str, cwl_v1_0.InputParameter | cwl_v1_0.WorkflowStepOutput], + src_dict, + ), + cast(MutableSequence[cwl_v1_0.WorkflowStepInput], step_inputs), + type_dict, ) workflow_outputs_val = cwl_v1_0_utils.check_all_types( - src_dict, workflow.outputs, type_dict + cast( + Mapping[str, cwl_v1_0.InputParameter | cwl_v1_0.WorkflowStepOutput], + src_dict, + ), + workflow.outputs, + type_dict, ) case "v1.1": - parser = cwl_v1_1 step_inputs_val = cwl_v1_1_utils.check_all_types( - src_dict, step_inputs, type_dict + cast( + Mapping[ + str, + cwl_v1_1.WorkflowInputParameter | cwl_v1_1.WorkflowStepOutput, + ], + src_dict, + ), + cast(MutableSequence[cwl_v1_1.WorkflowStepInput], step_inputs), + type_dict, ) workflow_outputs_val = cwl_v1_1_utils.check_all_types( - src_dict, workflow.outputs, type_dict + cast( + Mapping[ + str, + cwl_v1_1.WorkflowInputParameter | cwl_v1_1.WorkflowStepOutput, + ], + src_dict, + ), + workflow.outputs, + type_dict, ) case "v1.2": - parser = cwl_v1_2 step_inputs_val = cwl_v1_2_utils.check_all_types( - src_dict, step_inputs, param_to_step, type_dict + cast( + Mapping[ + str, + cwl_v1_2.WorkflowInputParameter | cwl_v1_2.WorkflowStepOutput, + ], + src_dict, + ), + cast(MutableSequence[cwl_v1_2.WorkflowStepInput], step_inputs), + cast(MutableMapping[str, cwl_v1_2.WorkflowStep], param_to_step), + type_dict, ) workflow_outputs_val = cwl_v1_2_utils.check_all_types( - src_dict, workflow.outputs, param_to_step, type_dict + cast( + Mapping[ + str, + cwl_v1_2.WorkflowInputParameter | cwl_v1_2.WorkflowStepOutput, + ], + src_dict, + ), + workflow.outputs, + cast(MutableMapping[str, cwl_v1_2.WorkflowStep], param_to_step), + type_dict, ) case _ as cwlVersion: raise Exception(f"Unsupported CWL version {cwlVersion}") @@ -244,20 +531,21 @@ def static_checker(workflow: cwl_utils.parser.Workflow) -> None: src = warning.src sink = warning.sink linkMerge = warning.linkMerge + msg = ( SourceLine(src, "type").makeError( "Source '%s' of type %s may be incompatible" % ( - parser.shortname(src.id), - json_dumps(parser.save(type_dict[src.id])), + shortname(src.id), + save(type_dict[src.id]), ) ) + "\n" + SourceLine(sink, "type").makeError( " with sink '%s' of type %s" % ( - parser.shortname(sink.id), - json_dumps(parser.save(type_dict[sink.id])), + shortname(sink.id), + save(type_dict[sink.id]), ) ) ) @@ -281,14 +569,17 @@ def static_checker(workflow: cwl_utils.parser.Workflow) -> None: msg = ( SourceLine(src, "type").makeError( "Source '%s' of type %s is incompatible" - % (parser.shortname(src.id), json_dumps(parser.save(type_dict[src.id]))) + % ( + shortname(src.id), + save(type_dict[src.id]), + ) ) + "\n" + SourceLine(sink, "type").makeError( " with sink '%s' of type %s" % ( - parser.shortname(sink.id), - json_dumps(parser.save(type_dict[sink.id])), + shortname(sink.id), + save(type_dict[sink.id]), ) ) ) @@ -302,19 +593,17 @@ def static_checker(workflow: cwl_utils.parser.Workflow) -> None: exception_msgs.append(msg) for sink in step_inputs: + sink_type = type_dict[sink.id] if ( - "null" != type_dict[sink.id] - and not ( - isinstance(type_dict[sink.id], MutableSequence) - and "null" in type_dict[sink.id] - ) + "null" != sink_type + and not (is_sequence(sink_type) and "null" in sink_type) and getattr(sink, "source", None) is None and getattr(sink, "default", None) is None and getattr(sink, "valueFrom", None) is None ): msg = SourceLine(sink).makeError( "Required parameter '%s' does not have source, default, or valueFrom expression" - % parser.shortname(sink.id) + % shortname(sink.id), ) exception_msgs.append(msg) @@ -327,6 +616,78 @@ def static_checker(workflow: cwl_utils.parser.Workflow) -> None: raise ValidationException(all_exception_msg) +@overload +def to_input_array( + type_: InputTypeSchemas, cwlVersion: Literal["v1.0"] +) -> cwl_v1_0.InputArraySchema: ... + + +@overload +def to_input_array( + type_: InputTypeSchemas, cwlVersion: Literal["v1.1"] +) -> cwl_v1_1.InputArraySchema: ... + + +@overload +def to_input_array( + type_: InputTypeSchemas, cwlVersion: Literal["v1.2"] +) -> cwl_v1_2.InputArraySchema: ... + + +def to_input_array( + type_: InputTypeSchemas, cwlVersion: Literal["v1.0", "v1.1", "v1.2"] +) -> InputArraySchema: + match cwlVersion: + case "v1.0": + return cwl_v1_0_utils.to_input_array( + cast(cwl_v1_0_utils.InputTypeSchemas, type_) + ) + case "v1.1": + return cwl_v1_1_utils.to_input_array( + cast(cwl_v1_1_utils.InputTypeSchemas, type_) + ) + case "v1.2": + return cwl_v1_2_utils.to_input_array( + cast(cwl_v1_2_utils.InputTypeSchemas, type_) + ) + + +@overload +def to_output_array( + type_: OutputTypeSchemas, cwlVersion: Literal["v1.0"] +) -> cwl_v1_0.OutputArraySchema: ... + + +@overload +def to_output_array( + type_: OutputTypeSchemas, cwlVersion: Literal["v1.1"] +) -> cwl_v1_1.OutputArraySchema: ... + + +@overload +def to_output_array( + type_: OutputTypeSchemas, cwlVersion: Literal["v1.2"] +) -> cwl_v1_2.OutputArraySchema: ... + + +def to_output_array( + type_: OutputTypeSchemas, cwlVersion: Literal["v1.0", "v1.1", "v1.2"] +) -> OutputArraySchema: + match cwlVersion: + case "v1.0": + return cwl_v1_0_utils.to_output_array( + cast(cwl_v1_0_utils.OutputTypeSchemas, type_) + ) + case "v1.1": + return cwl_v1_1_utils.to_output_array( + cast(cwl_v1_1_utils.OutputTypeSchemas, type_) + ) + case "v1.2": + return cwl_v1_2_utils.to_output_array( + cast(cwl_v1_2_utils.OutputTypeSchemas, type_) + ) + + def type_for_source( process: Process, sourcenames: str | list[str], @@ -338,36 +699,21 @@ def type_for_source( match process.cwlVersion: case "v1.0": return cwl_v1_0_utils.type_for_source( - cast( - cwl_v1_0.CommandLineTool - | cwl_v1_0.Workflow - | cwl_v1_0.ExpressionTool, - process, - ), + process, sourcenames, cast(cwl_v1_0.Workflow | None, parent), linkMerge, ) case "v1.1": return cwl_v1_1_utils.type_for_source( - cast( - cwl_v1_1.CommandLineTool - | cwl_v1_1.Workflow - | cwl_v1_1.ExpressionTool, - process, - ), + process, sourcenames, cast(cwl_v1_1.Workflow | None, parent), linkMerge, ) case "v1.2": return cwl_v1_2_utils.type_for_source( - cast( - cwl_v1_2.CommandLineTool - | cwl_v1_2.Workflow - | cwl_v1_2.ExpressionTool, - process, - ), + process, sourcenames, cast(cwl_v1_2.Workflow | None, parent), linkMerge, @@ -383,7 +729,7 @@ def type_for_source( def type_for_step_input( step: WorkflowStep, in_: WorkflowStepInput, cwlVersion: str -) -> Any: +) -> InputTypeSchemas | None: """Determine the type for the given step output.""" match cwlVersion: case "v1.0": @@ -398,9 +744,13 @@ def type_for_step_input( return cwl_v1_2_utils.type_for_step_input( cast(cwl_v1_2.WorkflowStep, step), cast(cwl_v1_2.WorkflowStepInput, in_) ) + case _: + raise Exception(f"Unsupported CWL version {cwlVersion}") -def type_for_step_output(step: WorkflowStep, sourcename: str, cwlVersion: str) -> Any: +def type_for_step_output( + step: WorkflowStep, sourcename: str, cwlVersion: str +) -> OutputTypeSchemas | None: """Determine the type for the given step output.""" match cwlVersion: case "v1.0": @@ -415,87 +765,5 @@ def type_for_step_output(step: WorkflowStep, sourcename: str, cwlVersion: str) - return cwl_v1_2_utils.type_for_step_output( cast(cwl_v1_2.WorkflowStep, step), sourcename ) - - -def param_for_source_id( - process: ( - cwl_utils.parser.CommandLineTool - | cwl_utils.parser.Workflow - | cwl_utils.parser.ExpressionTool - ), - sourcenames: str | list[str], - parent: cwl_utils.parser.Workflow | None = None, - scatter_context: list[tuple[int, str] | None] | None = None, -) -> ( - ( - MutableSequence[ - cwl_utils.parser.cwl_v1_0.InputParameter - | cwl_utils.parser.cwl_v1_0.CommandOutputParameter - ] - | cwl_utils.parser.cwl_v1_0.InputParameter - | cwl_utils.parser.cwl_v1_0.CommandOutputParameter - ) - | ( - MutableSequence[ - cwl_utils.parser.cwl_v1_1.CommandInputParameter - | cwl_utils.parser.cwl_v1_1.CommandOutputParameter - | cwl_utils.parser.cwl_v1_1.WorkflowInputParameter - ] - | cwl_utils.parser.cwl_v1_1.CommandInputParameter - | cwl_utils.parser.cwl_v1_1.CommandOutputParameter - | cwl_utils.parser.cwl_v1_1.WorkflowInputParameter - ) - | ( - MutableSequence[ - cwl_utils.parser.cwl_v1_2.CommandInputParameter - | cwl_utils.parser.cwl_v1_2.CommandOutputParameter - | cwl_utils.parser.cwl_v1_2.WorkflowInputParameter - ] - | cwl_utils.parser.cwl_v1_2.CommandInputParameter - | cwl_utils.parser.cwl_v1_2.CommandOutputParameter - | cwl_utils.parser.cwl_v1_2.WorkflowInputParameter - ) -): - match process.cwlVersion: - case "v1.0": - return cwl_utils.parser.cwl_v1_0_utils.param_for_source_id( - cast( - cwl_utils.parser.cwl_v1_0.CommandLineTool - | cwl_utils.parser.cwl_v1_0.Workflow - | cwl_utils.parser.cwl_v1_0.ExpressionTool, - process, - ), - sourcenames, - cast(cwl_utils.parser.cwl_v1_0.Workflow, parent), - scatter_context, - ) - case "v1.1": - return cwl_utils.parser.cwl_v1_1_utils.param_for_source_id( - cast( - cwl_utils.parser.cwl_v1_1.CommandLineTool - | cwl_utils.parser.cwl_v1_1.Workflow - | cwl_utils.parser.cwl_v1_1.ExpressionTool, - process, - ), - sourcenames, - cast(cwl_utils.parser.cwl_v1_1.Workflow, parent), - scatter_context, - ) - case "v1.2": - return cwl_utils.parser.cwl_v1_2_utils.param_for_source_id( - cast( - cwl_utils.parser.cwl_v1_2.CommandLineTool - | cwl_utils.parser.cwl_v1_2.Workflow - | cwl_utils.parser.cwl_v1_2.ExpressionTool, - process, - ), - sourcenames, - cast(cwl_utils.parser.cwl_v1_2.Workflow, parent), - scatter_context, - ) - case None: - raise ValidationException("could not get the cwlVersion") case _: - raise ValidationException( - f"Version error. Did not recognise {process.cwlVersion} as a CWL version" - ) + raise Exception(f"Unsupported CWL version {cwlVersion}") diff --git a/src/cwl_utils/testdata/extensions/all-output-loop_v1_2.cwl b/src/cwl_utils/testdata/extensions/all-output-loop_v1_2.cwl deleted file mode 100755 index 096be519..00000000 --- a/src/cwl_utils/testdata/extensions/all-output-loop_v1_2.cwl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.2 -class: Workflow -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - InlineJavascriptRequirement: {} -inputs: - i1: int -outputs: - o1: - type: int[] - outputSource: subworkflow/o1 -steps: - subworkflow: - run: - class: ExpressionTool - inputs: - i1: int - outputs: - o1: int - expression: > - ${return {'o1': inputs.i1 + 1};} - in: - i1: i1 - out: [o1] - requirements: - cwltool:Loop: - loopWhen: $(inputs.i1 < 10) - loop: - i1: o1 - outputMethod: all diff --git a/src/cwl_utils/testdata/extensions/cuda-requirement_v1_0.cwl b/src/cwl_utils/testdata/extensions/cuda-requirement_v1_0.cwl deleted file mode 100755 index 21985e6c..00000000 --- a/src/cwl_utils/testdata/extensions/cuda-requirement_v1_0.cwl +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.0 -class: CommandLineTool -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:CUDARequirement: - cudaVersionMin: "1.0" - cudaComputeCapability: "1.0" - cudaDeviceCountMin: $(inputs.gpus) -inputs: - gpus: - type: int - default: 1 -outputs: [] -baseCommand: "nvidia-smi" \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/cuda-requirement_v1_1.cwl b/src/cwl_utils/testdata/extensions/cuda-requirement_v1_1.cwl deleted file mode 100755 index 9c24f0fe..00000000 --- a/src/cwl_utils/testdata/extensions/cuda-requirement_v1_1.cwl +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.1 -class: CommandLineTool -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:CUDARequirement: - cudaVersionMin: "1.0" - cudaComputeCapability: "1.0" - cudaDeviceCountMin: $(inputs.gpus) -inputs: - gpus: - type: int - default: 1 -outputs: [] -baseCommand: "nvidia-smi" \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/cuda-requirement_v1_2.cwl b/src/cwl_utils/testdata/extensions/cuda-requirement_v1_2.cwl deleted file mode 100755 index 4f1ecbd8..00000000 --- a/src/cwl_utils/testdata/extensions/cuda-requirement_v1_2.cwl +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.2 -class: CommandLineTool -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:CUDARequirement: - cudaVersionMin: "1.0" - cudaComputeCapability: "1.0" - cudaDeviceCountMin: $(inputs.gpus) -inputs: - gpus: - type: int - default: 1 -outputs: [] -baseCommand: "nvidia-smi" \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/inplace-update-requirement_v1_0.cwl b/src/cwl_utils/testdata/extensions/inplace-update-requirement_v1_0.cwl deleted file mode 100755 index 14f72054..00000000 --- a/src/cwl_utils/testdata/extensions/inplace-update-requirement_v1_0.cwl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:InplaceUpdateRequirement: - inplaceUpdate: true -inputs: - r: File - script: - type: File - default: - class: File - location: updateval.py -outputs: - out: - type: File - outputBinding: - glob: $(inputs.r.basename) -arguments: [python, $(inputs.script), $(inputs.r.basename)] \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/load-listing-requirement_v1_0.cwl b/src/cwl_utils/testdata/extensions/load-listing-requirement_v1_0.cwl deleted file mode 100755 index 36d67fb4..00000000 --- a/src/cwl_utils/testdata/extensions/load-listing-requirement_v1_0.cwl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: http://commonwl.org/cwltool# -requirements: - cwltool:LoadListingRequirement: - loadListing: shallow_listing -inputs: - d: Directory -outputs: [] -arguments: - [echo, "$(inputs.d.listing[0].listing[0])"] diff --git a/src/cwl_utils/testdata/extensions/mpi-requirement_v1_0.cwl b/src/cwl_utils/testdata/extensions/mpi-requirement_v1_0.cwl deleted file mode 100755 index 72dc680b..00000000 --- a/src/cwl_utils/testdata/extensions/mpi-requirement_v1_0.cwl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" - -baseCommand: env -requirements: - cwltool:MPIRequirement: - processes: 1 -inputs: {} -outputs: - environment: - type: stdout \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/mpi-requirement_v1_1.cwl b/src/cwl_utils/testdata/extensions/mpi-requirement_v1_1.cwl deleted file mode 100755 index a4ad0fe1..00000000 --- a/src/cwl_utils/testdata/extensions/mpi-requirement_v1_1.cwl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.1 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -baseCommand: env -requirements: - cwltool:MPIRequirement: - processes: 1 -inputs: {} -outputs: - environment: - type: stdout \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/mpi-requirement_v1_2.cwl b/src/cwl_utils/testdata/extensions/mpi-requirement_v1_2.cwl deleted file mode 100755 index 5790f414..00000000 --- a/src/cwl_utils/testdata/extensions/mpi-requirement_v1_2.cwl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.2 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -baseCommand: env -requirements: - cwltool:MPIRequirement: - processes: 1 -inputs: {} -outputs: - environment: - type: stdout \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/network-access_v1_0.cwl b/src/cwl_utils/testdata/extensions/network-access_v1_0.cwl deleted file mode 100755 index 4152a116..00000000 --- a/src/cwl_utils/testdata/extensions/network-access_v1_0.cwl +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:NetworkAccess: - networkAccess: true -inputs: [] -outputs: [] -baseCommand: python -arguments: - - "-c" - - valueFrom: | - import urllib.request - assert(urllib.request.urlopen("http://commonwl.org").code == 200) \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/process-generator_v1_0.cwl b/src/cwl_utils/testdata/extensions/process-generator_v1_0.cwl deleted file mode 100755 index 01df6367..00000000 --- a/src/cwl_utils/testdata/extensions/process-generator_v1_0.cwl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -class: cwltool:ProcessGenerator -inputs: - script: string - dir: Directory -outputs: {} -run: - class: CommandLineTool - inputs: - script: string - dir: Directory - outputs: - runProcess: - type: File - outputBinding: - glob: main.cwl - requirements: - InlineJavascriptRequirement: {} - LoadListingRequirement: - loadListing: shallow_listing - InitialWorkDirRequirement: - listing: | - ${ - var v = inputs.dir.listing; - v.push({entryname: "inp.py", entry: inputs.script}); - return v; - } - arguments: [python3, inp.py] - stdout: main.cwl \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/process-generator_v1_1.cwl b/src/cwl_utils/testdata/extensions/process-generator_v1_1.cwl deleted file mode 100755 index b4ccc99c..00000000 --- a/src/cwl_utils/testdata/extensions/process-generator_v1_1.cwl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.1 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -class: cwltool:ProcessGenerator -inputs: - script: string - dir: Directory -outputs: {} -run: - class: CommandLineTool - inputs: - script: string - dir: Directory - outputs: - runProcess: - type: File - outputBinding: - glob: main.cwl - requirements: - InlineJavascriptRequirement: {} - LoadListingRequirement: - loadListing: shallow_listing - InitialWorkDirRequirement: - listing: | - ${ - var v = inputs.dir.listing; - v.push({entryname: "inp.py", entry: inputs.script}); - return v; - } - arguments: [python3, inp.py] - stdout: main.cwl \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/process-generator_v1_2.cwl b/src/cwl_utils/testdata/extensions/process-generator_v1_2.cwl deleted file mode 100755 index 62960a2f..00000000 --- a/src/cwl_utils/testdata/extensions/process-generator_v1_2.cwl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.2 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -class: cwltool:ProcessGenerator -inputs: - script: string - dir: Directory -outputs: {} -run: - class: CommandLineTool - inputs: - script: string - dir: Directory - outputs: - runProcess: - type: File - outputBinding: - glob: main.cwl - requirements: - InlineJavascriptRequirement: {} - LoadListingRequirement: - loadListing: shallow_listing - InitialWorkDirRequirement: - listing: | - ${ - var v = inputs.dir.listing; - v.push({entryname: "inp.py", entry: inputs.script}); - return v; - } - arguments: [python3, inp.py] - stdout: main.cwl \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/secrets_v1_0.cwl b/src/cwl_utils/testdata/extensions/secrets_v1_0.cwl deleted file mode 100755 index 63446512..00000000 --- a/src/cwl_utils/testdata/extensions/secrets_v1_0.cwl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.0 -class: CommandLineTool -$namespaces: - cwltool: http://commonwl.org/cwltool# -requirements: - cwltool:Secrets: - secrets: [pw] -inputs: - pw: string -outputs: - out: stdout -arguments: [cat, example.conf] diff --git a/src/cwl_utils/testdata/extensions/secrets_v1_1.cwl b/src/cwl_utils/testdata/extensions/secrets_v1_1.cwl deleted file mode 100755 index 09d476f6..00000000 --- a/src/cwl_utils/testdata/extensions/secrets_v1_1.cwl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.1 -class: CommandLineTool -$namespaces: - cwltool: http://commonwl.org/cwltool# -requirements: - cwltool:Secrets: - secrets: [pw] -inputs: - pw: string -outputs: - out: stdout -arguments: [cat, example.conf] diff --git a/src/cwl_utils/testdata/extensions/secrets_v1_2.cwl b/src/cwl_utils/testdata/extensions/secrets_v1_2.cwl deleted file mode 100755 index 02d7dff6..00000000 --- a/src/cwl_utils/testdata/extensions/secrets_v1_2.cwl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.2 -class: CommandLineTool -$namespaces: - cwltool: http://commonwl.org/cwltool# -requirements: - cwltool:Secrets: - secrets: [pw] -inputs: - pw: string -outputs: - out: stdout -arguments: [cat, example.conf] diff --git a/src/cwl_utils/testdata/extensions/shm-size_v1_0.cwl b/src/cwl_utils/testdata/extensions/shm-size_v1_0.cwl deleted file mode 100755 index 01f90a44..00000000 --- a/src/cwl_utils/testdata/extensions/shm-size_v1_0.cwl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:ShmSize: - shmSize: 128m -inputs: [] -outputs: - output: - type: stdout -baseCommand: echo -stdout: shm-size.txt -arguments: [ $(runtime) ] diff --git a/src/cwl_utils/testdata/extensions/shm-size_v1_1.cwl b/src/cwl_utils/testdata/extensions/shm-size_v1_1.cwl deleted file mode 100755 index 3bff20df..00000000 --- a/src/cwl_utils/testdata/extensions/shm-size_v1_1.cwl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.1 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:ShmSize: - shmSize: 128m -inputs: [] -outputs: - output: - type: stdout -baseCommand: echo -stdout: shm-size.txt -arguments: [ $(runtime) ] diff --git a/src/cwl_utils/testdata/extensions/shm-size_v1_2.cwl b/src/cwl_utils/testdata/extensions/shm-size_v1_2.cwl deleted file mode 100755 index b6491432..00000000 --- a/src/cwl_utils/testdata/extensions/shm-size_v1_2.cwl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.2 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:ShmSize: - shmSize: 128m -inputs: [] -outputs: - output: - type: stdout -baseCommand: echo -stdout: shm-size.txt -arguments: [ $(runtime) ] diff --git a/src/cwl_utils/testdata/extensions/single-var-loop_v1_2.cwl b/src/cwl_utils/testdata/extensions/single-var-loop_v1_2.cwl deleted file mode 100755 index c5f76563..00000000 --- a/src/cwl_utils/testdata/extensions/single-var-loop_v1_2.cwl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env cwl-runner -cwlVersion: v1.2 -class: Workflow -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - InlineJavascriptRequirement: {} -inputs: - i1: int -outputs: - o1: - type: int - outputSource: subworkflow/o1 -steps: - subworkflow: - run: - class: ExpressionTool - inputs: - i1: int - outputs: - o1: int - expression: > - ${return {'o1': inputs.i1 + 1};} - in: - i1: i1 - out: [o1] - requirements: - cwltool:Loop: - loopWhen: $(inputs.i1 < 10) - loop: - i1: o1 - outputMethod: last diff --git a/src/cwl_utils/testdata/extensions/time-limit_v1_0.cwl b/src/cwl_utils/testdata/extensions/time-limit_v1_0.cwl deleted file mode 100755 index 7106a934..00000000 --- a/src/cwl_utils/testdata/extensions/time-limit_v1_0.cwl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -inputs: - sleep_time: - type: int - default: 3 - inputBinding: {} -outputs: [] -requirements: - cwltool:TimeLimit: - timelimit: 20 -baseCommand: sleep \ No newline at end of file diff --git a/src/cwl_utils/testdata/extensions/work-reuse_v1_0.cwl b/src/cwl_utils/testdata/extensions/work-reuse_v1_0.cwl deleted file mode 100755 index 7278cb2b..00000000 --- a/src/cwl_utils/testdata/extensions/work-reuse_v1_0.cwl +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env cwl-runner -class: CommandLineTool -cwlVersion: v1.0 -$namespaces: - cwltool: "http://commonwl.org/cwltool#" -requirements: - cwltool:WorkReuse: - enableReuse: false -inputs: [] -outputs: - page: stdout -stdout: time.txt -baseCommand: python -arguments: - - "-c" - - valueFrom: | - import time - print(time.time()) diff --git a/src/cwl_utils/tests/test_extensions.py b/src/cwl_utils/tests/test_extensions.py deleted file mode 100644 index fa9044dd..00000000 --- a/src/cwl_utils/tests/test_extensions.py +++ /dev/null @@ -1,197 +0,0 @@ -from cwl_utils.parser import cwl_v1_0, cwl_v1_1, cwl_v1_2, load_document_by_uri - -from .util import get_path - - -def test_cuda_requirement_v1_0() -> None: - """Test that CUDARequirement objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/cuda-requirement_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.CUDARequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:CUDARequirement" - - -def test_cuda_requirement_v1_1() -> None: - """Test that CUDARequirement objects are correctly loaded for CWL v1.1.""" - uri = get_path("testdata/extensions/cuda-requirement_v1_1.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.CUDARequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:CUDARequirement" - - -def test_cuda_requirement_v1_2() -> None: - """Test that CUDARequirement objects are correctly loaded for CWL v1.2.""" - uri = get_path("testdata/extensions/cuda-requirement_v1_2.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.CUDARequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:CUDARequirement" - - -def test_load_listing_requirement_v1_0() -> None: - """Test that LoadListingRequirement objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/load-listing-requirement_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.LoadListingRequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:LoadListingRequirement" - - -def test_loop_v1_2() -> None: - """Test that Loop and LoopInput objects are correctly loaded for CWL v1.2.""" - uri = get_path("testdata/extensions/single-var-loop_v1_2.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - cwl_step = next(iter(cwl_obj.steps)) - loop_req = next(iter(cwl_step.requirements)) - assert isinstance(loop_req, cwl_v1_2.Loop) - assert isinstance(next(iter(loop_req.loop)), cwl_v1_2.LoopInput) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["steps"][0]["requirements"][0]["class"] == "cwltool:Loop" - - -def test_inplace_update_requirement_v1_0() -> None: - """Test that InplaceUpdateRequirement objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/inplace-update-requirement_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance( - next(iter(cwl_obj.requirements)), cwl_v1_0.InplaceUpdateRequirement - ) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:InplaceUpdateRequirement" - - -def test_mpi_requirement_v1_0() -> None: - """Test that MPIRequirement objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/mpi-requirement_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.MPIRequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:MPIRequirement" - - -def test_mpi_requirement_v1_1() -> None: - """Test that MPIRequirement objects are correctly loaded for CWL v1.1.""" - uri = get_path("testdata/extensions/mpi-requirement_v1_1.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.MPIRequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:MPIRequirement" - - -def test_mpi_requirement_v1_2() -> None: - """Test that MPIRequirement objects are correctly loaded for CWL v1.2.""" - uri = get_path("testdata/extensions/mpi-requirement_v1_2.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.MPIRequirement) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:MPIRequirement" - - -def test_network_access_v1_0() -> None: - """Test that NetworkAccess objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/network-access_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.NetworkAccess) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:NetworkAccess" - - -def test_process_generator_v1_0() -> None: - """Test that ProcessGenerator objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/process-generator_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(cwl_obj, cwl_v1_0.ProcessGenerator) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["class"] == "cwltool:ProcessGenerator" - - -def test_process_generator_v1_1() -> None: - """Test that ProcessGenerator objects are correctly loaded for CWL v1.1.""" - uri = get_path("testdata/extensions/process-generator_v1_1.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(cwl_obj, cwl_v1_1.ProcessGenerator) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["class"] == "cwltool:ProcessGenerator" - - -def test_process_generator_v1_2() -> None: - """Test that ProcessGenerator objects are correctly loaded for CWL v1.2.""" - uri = get_path("testdata/extensions/process-generator_v1_2.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(cwl_obj, cwl_v1_2.ProcessGenerator) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["class"] == "cwltool:ProcessGenerator" - - -def test_secrets_v1_0() -> None: - """Test that Secrets objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/secrets_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.Secrets) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:Secrets" - - -def test_secrets_v1_1() -> None: - """Test that Secrets objects are correctly loaded for CWL v1.1.""" - uri = get_path("testdata/extensions/secrets_v1_1.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.Secrets) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:Secrets" - - -def test_secrets_v1_2() -> None: - """Test that Secrets objects are correctly loaded for CWL v1.2.""" - uri = get_path("testdata/extensions/secrets_v1_2.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.Secrets) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:Secrets" - - -def test_shm_size_v1_0() -> None: - """Test that ShmSize objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/shm-size_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.ShmSize) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:ShmSize" - - -def test_shm_size_v1_1() -> None: - """Test that ShmSize objects are correctly loaded for CWL v1.1.""" - uri = get_path("testdata/extensions/shm-size_v1_1.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.ShmSize) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:ShmSize" - - -def test_shm_size_v1_2() -> None: - """Test that ShmSize objects are correctly loaded for CWL v1.2.""" - uri = get_path("testdata/extensions/shm-size_v1_2.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.ShmSize) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:ShmSize" - - -def test_time_limit_v1_0() -> None: - """Test that TimeLimit objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/time-limit_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.TimeLimit) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:TimeLimit" - - -def test_work_reuse_v1_0() -> None: - """Test that WorkReuse objects are correctly loaded for CWL v1.0.""" - uri = get_path("testdata/extensions/work-reuse_v1_0.cwl").as_uri() - cwl_obj = load_document_by_uri(uri) - assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.WorkReuse) - cwl_dict = cwl_obj.save(top=True) - assert cwl_dict["requirements"][0]["class"] == "cwltool:WorkReuse" diff --git a/src/cwl_utils/tests/test_parser.py b/src/cwl_utils/tests/test_parser.py index fc33596a..31cfc80f 100644 --- a/src/cwl_utils/tests/test_parser.py +++ b/src/cwl_utils/tests/test_parser.py @@ -3,11 +3,11 @@ from pytest import raises from ruamel.yaml.main import YAML +from schema_salad.schema import shortname import cwl_utils.parser.latest as latest from cwl_utils.errors import GraphTargetMissingException from cwl_utils.parser import ( - cwl_v1_2, cwl_version, load_document, load_document_by_uri, @@ -86,12 +86,12 @@ def test_latest_parser() -> None: def test_shortname() -> None: - assert cwl_v1_2.shortname("http://example.com/foo") == "foo" - assert cwl_v1_2.shortname("http://example.com/#bar") == "bar" - assert cwl_v1_2.shortname("http://example.com/foo/bar") == "bar" - assert cwl_v1_2.shortname("http://example.com/foo#bar") == "bar" - assert cwl_v1_2.shortname("http://example.com/#foo/bar") == "bar" - assert cwl_v1_2.shortname("http://example.com/foo#bar/baz") == "baz" + assert shortname("http://example.com/foo") == "foo" + assert shortname("http://example.com/#bar") == "bar" + assert shortname("http://example.com/foo/bar") == "bar" + assert shortname("http://example.com/foo#bar") == "bar" + assert shortname("http://example.com/#foo/bar") == "bar" + assert shortname("http://example.com/foo#bar/baz") == "baz" def test_get_id_from_graph() -> None: diff --git a/src/cwl_utils/tests/test_parser_utils.py b/src/cwl_utils/tests/test_parser_utils.py index d977ec75..81d5ff5a 100644 --- a/src/cwl_utils/tests/test_parser_utils.py +++ b/src/cwl_utils/tests/test_parser_utils.py @@ -8,6 +8,7 @@ from typing import cast import pytest +import schema_salad.metaschema from pytest import LogCaptureFixture, raises from schema_salad.exceptions import ValidationException @@ -20,7 +21,6 @@ import cwl_utils.parser.utils from cwl_utils.errors import WorkflowException from cwl_utils.parser import load_document_by_uri - from .util import get_path @@ -128,8 +128,6 @@ def test_static_checker_success(cwlVersion: str) -> None: "testdata/cond-wf-004.1.cwl", "testdata/cond-wf-005.1.cwl", "testdata/cond-single-source-wf-005.1.cwl", - "testdata/extensions/all-output-loop_v1_2.cwl", - "testdata/extensions/single-var-loop_v1_2.cwl", "testdata/wf2.cwl", ] ) @@ -199,6 +197,7 @@ def test_v1_0_stdout_to_file() -> None: ) cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(clt) assert clt.stdout is not None + assert clt.outputs[0].outputBinding is not None assert clt.stdout == clt.outputs[0].outputBinding.glob @@ -231,6 +230,7 @@ def test_v1_0_stdout_to_file_preserve_original() -> None: ) cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(clt) assert clt.stdout == "original.txt" + assert clt.outputs[0].outputBinding is not None assert clt.stdout == clt.outputs[0].outputBinding.glob @@ -244,6 +244,7 @@ def test_v1_0_stderr_to_file() -> None: ) cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(clt) assert clt.stderr is not None + assert clt.outputs[0].outputBinding is not None assert clt.stderr == clt.outputs[0].outputBinding.glob @@ -276,6 +277,7 @@ def test_v1_0_stderr_to_file_preserve_original() -> None: ) cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(clt) assert clt.stderr == "original.txt" + assert clt.outputs[0].outputBinding is not None assert clt.stderr == clt.outputs[0].outputBinding.glob @@ -337,9 +339,9 @@ def test_v1_0_type_output_source_record() -> None: process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.RecordSchema) + assert isinstance(source_type, schema_salad.metaschema.RecordSchema) fields = cast( - MutableSequence[cwl_utils.parser.cwl_v1_0.RecordField], source_type.fields + MutableSequence[schema_salad.metaschema.RecordField], source_type.fields ) assert len(fields) == 2 assert fields[0].type_ == "File" @@ -354,7 +356,7 @@ def test_v1_0_type_for_output_source_with_single_scatter_step() -> None: process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -366,8 +368,8 @@ def test_v1_0_type_for_output_source_with_nested_crossproduct_scatter_step() -> process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "string" @@ -378,7 +380,7 @@ def test_v1_0_type_for_output_source_with_flat_crossproduct_scatter_step() -> No source_type = cwl_utils.parser.utils.type_for_source( process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -391,8 +393,8 @@ def test_v1_0_type_for_source_with_multiple_entries_merge_nested() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "File" @@ -405,7 +407,7 @@ def test_v1_0_type_for_source_with_multiple_entries_merge_flattened() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "File" @@ -418,8 +420,8 @@ def test_v1_0_type_for_source_with_single_entry_merge_nested() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "File" @@ -432,7 +434,7 @@ def test_v1_0_type_for_source_with_single_entry_merge_flattened() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_0.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "File" @@ -505,6 +507,7 @@ def test_v1_1_stdout_to_file() -> None: ) cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(clt) assert clt.stdout is not None + assert clt.outputs[0].outputBinding is not None assert clt.stdout == clt.outputs[0].outputBinding.glob @@ -537,6 +540,7 @@ def test_v1_1_stdout_to_file_preserve_original() -> None: ) cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(clt) assert clt.stdout == "original.txt" + assert clt.outputs[0].outputBinding is not None assert clt.stdout == clt.outputs[0].outputBinding.glob @@ -550,6 +554,7 @@ def test_v1_1_stderr_to_file() -> None: ) cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(clt) assert clt.stderr is not None + assert clt.outputs[0].outputBinding is not None assert clt.stderr == clt.outputs[0].outputBinding.glob @@ -582,6 +587,7 @@ def test_v1_1_stderr_to_file_preserve_original() -> None: ) cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(clt) assert clt.stderr == "original.txt" + assert clt.outputs[0].outputBinding is not None assert clt.stderr == clt.outputs[0].outputBinding.glob @@ -686,9 +692,9 @@ def test_v1_1_type_output_source_record() -> None: process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.RecordSchema) + assert isinstance(source_type, schema_salad.metaschema.RecordSchema) fields = cast( - MutableSequence[cwl_utils.parser.cwl_v1_1.RecordField], source_type.fields + MutableSequence[schema_salad.metaschema.RecordField], source_type.fields ) assert len(fields) == 2 assert fields[0].type_ == "File" @@ -703,7 +709,7 @@ def test_v1_1_type_for_output_source_with_single_scatter_step() -> None: process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -715,8 +721,8 @@ def test_v1_1_type_for_output_source_with_nested_crossproduct_scatter_step() -> process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "string" @@ -728,7 +734,7 @@ def test_v1_1_type_for_output_source_with_flat_crossproduct_scatter_step() -> No process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -741,8 +747,8 @@ def test_v1_1_type_for_source_with_multiple_entries_merge_nested() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "File" @@ -755,7 +761,7 @@ def test_v1_1_type_for_source_with_multiple_entries_merge_flattened() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "File" @@ -768,8 +774,8 @@ def test_v1_1_type_for_source_with_single_entry_merge_nested() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "File" @@ -782,7 +788,7 @@ def test_v1_1_type_for_source_with_single_entry_merge_flattened() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_1.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "File" @@ -855,6 +861,7 @@ def test_v1_2_stdout_to_file() -> None: ) cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(clt) assert clt.stdout is not None + assert clt.outputs[0].outputBinding is not None assert clt.stdout == clt.outputs[0].outputBinding.glob @@ -887,6 +894,7 @@ def test_v1_2_stdout_to_file_preserve_original() -> None: ) cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(clt) assert clt.stdout == "original.txt" + assert clt.outputs[0].outputBinding is not None assert clt.stdout == clt.outputs[0].outputBinding.glob @@ -900,6 +908,7 @@ def test_v1_2_stderr_to_file() -> None: ) cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(clt) assert clt.stderr is not None + assert clt.outputs[0].outputBinding is not None assert clt.stderr == clt.outputs[0].outputBinding.glob @@ -932,6 +941,7 @@ def test_v1_2_stderr_to_file_preserve_original() -> None: ) cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(clt) assert clt.stderr == "original.txt" + assert clt.outputs[0].outputBinding is not None assert clt.stderr == clt.outputs[0].outputBinding.glob @@ -1036,9 +1046,9 @@ def test_v1_2_type_output_source_record() -> None: process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.RecordSchema) + assert isinstance(source_type, schema_salad.metaschema.RecordSchema) fields = cast( - MutableSequence[cwl_utils.parser.cwl_v1_2.RecordField], source_type.fields + MutableSequence[schema_salad.metaschema.RecordField], source_type.fields ) assert len(fields) == 2 assert fields[0].type_ == "File" @@ -1053,7 +1063,7 @@ def test_v1_2_type_for_output_source_with_single_scatter_step() -> None: process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -1065,8 +1075,8 @@ def test_v1_2_type_for_output_source_with_nested_crossproduct_scatter_step() -> process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "string" @@ -1078,7 +1088,7 @@ def test_v1_2_type_for_output_source_with_flat_crossproduct_scatter_step() -> No process=cwl_obj, sourcenames=cwl_obj.outputs[0].outputSource, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -1091,8 +1101,8 @@ def test_v1_2_type_for_source_with_multiple_entries_merge_nested() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "File" @@ -1105,7 +1115,7 @@ def test_v1_2_type_for_source_with_multiple_entries_merge_flattened() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "File" @@ -1118,8 +1128,8 @@ def test_v1_2_type_for_source_with_single_entry_merge_nested() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) - assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) + assert isinstance(source_type.items, schema_salad.metaschema.ArraySchema) assert source_type.items.items == "File" @@ -1132,7 +1142,7 @@ def test_v1_2_type_for_source_with_single_entry_merge_flattened() -> None: sourcenames=cwl_obj.steps[0].in_[0].source, linkMerge=cwl_obj.steps[0].in_[0].linkMerge, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "File" @@ -1169,7 +1179,7 @@ def test_v1_2_type_for_source_with_multiple_entries_all_non_null() -> None: sourcenames=cwl_obj.outputs[0].outputSource, pickValue=cwl_obj.outputs[0].pickValue, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" @@ -1206,5 +1216,5 @@ def test_v1_2_type_for_source_with_single_entry_all_non_null() -> None: sourcenames=cwl_obj.outputs[0].outputSource, pickValue=cwl_obj.outputs[0].pickValue, ) - assert isinstance(source_type, cwl_utils.parser.cwl_v1_2.ArraySchema) + assert isinstance(source_type, schema_salad.metaschema.ArraySchema) assert source_type.items == "string" diff --git a/src/cwl_utils/tests/test_subscope.py b/src/cwl_utils/tests/test_subscope.py index d50bf958..48a68c98 100644 --- a/src/cwl_utils/tests/test_subscope.py +++ b/src/cwl_utils/tests/test_subscope.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 """Test that scoping of identifiers in Workflow.steps[].run is correct.""" -from cwl_utils.parser import Workflow, load_document_by_uri +from cwl_utils.parser import Process, Workflow, load_document_by_uri from .util import get_path @@ -10,6 +10,7 @@ def test_workflow_step_process_scope_v1_0() -> None: """CWL v1.0 IDs under Workflow.steps[].run should not be scoped in the "run" scope.""" uri = get_path("testdata/workflow_input_format_expr.cwl").as_uri() cwl_obj: Workflow = load_document_by_uri(uri) + assert isinstance(cwl_obj.steps[0].run, Process) assert cwl_obj.steps[0].run.inputs[0].id.endswith("#format_extract/target") @@ -17,6 +18,7 @@ def test_workflow_step_process_scope_v1_1() -> None: """CWL v1.1 IDs under Workflow.steps[].run should be scoped in the "run" scope.""" uri = get_path("testdata/workflow_input_format_expr_v1_1.cwl").as_uri() cwl_obj: Workflow = load_document_by_uri(uri) + assert isinstance(cwl_obj.steps[0].run, Process) assert cwl_obj.steps[0].run.inputs[0].id.endswith("#format_extract/run/target") @@ -24,4 +26,5 @@ def test_workflow_step_process_scope_v1_2() -> None: """CWL v1.2 IDs under Workflow.steps[].run should be scoped in the "run" scope.""" uri = get_path("testdata/workflow_input_format_expr_v1_2.cwl").as_uri() cwl_obj: Workflow = load_document_by_uri(uri) + assert isinstance(cwl_obj.steps[0].run, Process) assert cwl_obj.steps[0].run.inputs[0].id.endswith("#format_extract/run/target") diff --git a/src/cwl_utils/types.py b/src/cwl_utils/types.py index 6b7b0d83..03f601c5 100644 --- a/src/cwl_utils/types.py +++ b/src/cwl_utils/types.py @@ -3,7 +3,7 @@ """Shared Python type definitions for commons JSON like CWL objects.""" import sys -from collections.abc import Mapping, MutableMapping, MutableSequence +from collections.abc import Mapping, MutableMapping, MutableSequence, Sequence from typing import Any, Literal, TypeAlias, TypedDict, TypeGuard if sys.version_info >= (3, 13): @@ -161,3 +161,7 @@ def is_file_or_directory( value: Any, ) -> TypeIs[CWLFileType | CWLDirectoryType]: return isinstance(value, Mapping) and value.get("class") in ("File", "Directory") + + +def is_sequence(thing: object) -> TypeIs[Sequence[Any]]: + return isinstance(thing, Sequence) and not isinstance(thing, str) diff --git a/src/cwl_utils/utils.py b/src/cwl_utils/utils.py index bfae73dd..926bb9c2 100644 --- a/src/cwl_utils/utils.py +++ b/src/cwl_utils/utils.py @@ -7,11 +7,11 @@ import urllib.error import urllib.parse import urllib.request -from collections.abc import MutableMapping, MutableSequence +from collections.abc import MutableMapping, MutableSequence, Sequence from copy import deepcopy from importlib.resources import files from io import StringIO -from typing import Any +from typing import Any, cast from urllib.parse import urlparse from ruamel.yaml.main import YAML @@ -415,11 +415,15 @@ def sanitise_schema_field( case {"type": {"type": "enum", **rest}}: schema_field_item["type"] = InputEnumSchemaV1_2( type_="enum", - symbols=rest.get("symbols", ""), + symbols=cast(Sequence[str], rest.get("symbols", [])), ) case {"type": {"type": "array", **rest}}: schema_field_item["type"] = InputArraySchemaV1_2( - type_="array", items=rest.get("items", "") + type_="array", + items=cast( + str | cwl_v1_2.InputSchema | Sequence[str | cwl_v1_2.InputSchema], + rest.get("items", ""), + ), ) case {"type": {"$import": _}}: pass # Leave import as is