diff --git a/cwl_utils/parser/__init__.py b/cwl_utils/parser/__init__.py index e493091..13e62a0 100644 --- a/cwl_utils/parser/__init__.py +++ b/cwl_utils/parser/__init__.py @@ -28,6 +28,8 @@ cwl_v1_2.InputRecordField, ] """Type union for a CWL v1.x InputRecordSchema object.""" +InputSchema = Union[cwl_v1_0.InputSchema, cwl_v1_1.InputSchema, cwl_v1_2.InputSchema] +"""Type union for a CWL v1.x InputSchema object.""" OutputParameter = Union[ cwl_v1_0.OutputParameter, cwl_v1_1.OutputParameter, cwl_v1_2.OutputParameter ] @@ -243,8 +245,6 @@ def load_document_by_uri( load_all: bool = False, ) -> Any: """Load a CWL object from a URI or a path.""" - base_uri = "" - real_uri = "" if isinstance(path, str): uri = urlparse(path) id_ = uri.fragment or None @@ -259,8 +259,24 @@ 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 - if loadingOptions is None: + if isinstance(loadingOptions, cwl_v1_0.LoadingOptions): + loadingOptions = cwl_v1_0.LoadingOptions( + fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions + ) + elif isinstance(loadingOptions, cwl_v1_1.LoadingOptions): + loadingOptions = cwl_v1_1.LoadingOptions( + fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions + ) + elif isinstance(loadingOptions, cwl_v1_2.LoadingOptions): + loadingOptions = cwl_v1_2.LoadingOptions( + fileuri=real_uri, baseuri=base_uri, copyfrom=loadingOptions + ) + elif loadingOptions is None: loadingOptions = cwl_v1_2.LoadingOptions(fileuri=real_uri, baseuri=base_uri) + else: + raise ValidationException( + f"Unsupported loadingOptions type: {type(loadingOptions)}" + ) doc = loadingOptions.fetcher.fetch_text(real_uri) return load_document_by_string(doc, real_uri, loadingOptions, id_, load_all) diff --git a/testdata/remote-cwl/tool1.cwl b/testdata/remote-cwl/tool1.cwl index 64453b4..8296e6e 100755 --- a/testdata/remote-cwl/tool1.cwl +++ b/testdata/remote-cwl/tool1.cwl @@ -2,7 +2,7 @@ # We have this tool to test both local and remote packing class: CommandLineTool -cwlVersion: v1.0 +cwlVersion: v1.2 inputs: in1: type: string diff --git a/testdata/remote-cwl/tool2.cwl b/testdata/remote-cwl/tool2.cwl index b2c7c3e..dd364c2 100755 --- a/testdata/remote-cwl/tool2.cwl +++ b/testdata/remote-cwl/tool2.cwl @@ -2,7 +2,7 @@ # We have this tool to test both local and remote packing class: CommandLineTool -cwlVersion: v1.0 +cwlVersion: v1.2 inputs: in1: type: ../types/testtypes.yml#my_boolean_array diff --git a/testdata/remote-cwl/wf1.cwl b/testdata/remote-cwl/wf1.cwl index bd08a51..cff12f8 100755 --- a/testdata/remote-cwl/wf1.cwl +++ b/testdata/remote-cwl/wf1.cwl @@ -1,6 +1,6 @@ #!/usr/bin/env cwl-runner class: Workflow -cwlVersion: v1.0 +cwlVersion: v1.2 inputs: - id: in1 type: ../types/testtypes.yml#my_boolean_array diff --git a/testdata/wf2.cwl b/testdata/wf2.cwl index 1ef89e9..daccbf8 100755 --- a/testdata/wf2.cwl +++ b/testdata/wf2.cwl @@ -1,6 +1,6 @@ #!/usr/bin/env cwl-runner class: Workflow -cwlVersion: v1.0 +cwlVersion: v1.2 inputs: in1: types/testtypes.yml#my_boolean_array in2: diff --git a/testdata/workflows/wf5.cwl b/testdata/workflows/wf5.cwl index 382e68d..c7ff3cb 100755 --- a/testdata/workflows/wf5.cwl +++ b/testdata/workflows/wf5.cwl @@ -2,7 +2,7 @@ # Checks symbolic links on github class: Workflow -cwlVersion: v1.0 +cwlVersion: v1.2 inputs: in1: type: ../types/recursive.yml#file_with_sample_meta diff --git a/tests/test_parser_utils.py b/tests/test_parser_utils.py index 8c16b00..75efdda 100644 --- a/tests/test_parser_utils.py +++ b/tests/test_parser_utils.py @@ -105,6 +105,7 @@ def test_static_checker_success(cwlVersion: str) -> None: "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", ] ) for test_file in test_files: