Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions cwl_utils/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -243,8 +245,6 @@
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
Expand All @@ -259,8 +259,24 @@
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(

Check warning on line 277 in cwl_utils/parser/__init__.py

View check run for this annotation

Codecov / codecov/patch

cwl_utils/parser/__init__.py#L277

Added line #L277 was not covered by tests
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)
Expand Down
2 changes: 1 addition & 1 deletion testdata/remote-cwl/tool1.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/remote-cwl/tool2.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/remote-cwl/wf1.cwl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/wf2.cwl
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion testdata/workflows/wf5.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading