Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for subscope and __eq__ support #167

Merged
merged 3 commits into from
Sep 13, 2022
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
1 change: 0 additions & 1 deletion cwl_utils/expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
TYPE_CHECKING,
Any,
Callable,
Dict,
List,
MutableMapping,
MutableSequence,
Expand Down
8 changes: 1 addition & 7 deletions cwl_utils/parser/cwl_v1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11069,7 +11069,7 @@ def fromDoc(
try:
default = load_field(
_doc.get("default"),
union_of_None_type_or_Any_type,
union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type,
baseuri,
loadingOptions,
)
Expand Down Expand Up @@ -13448,12 +13448,6 @@ def save(
uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2 = _URILoader(
union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2
)
union_of_None_type_or_Any_type = _UnionLoader(
(
None_type,
Any_type,
)
)
array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader)
idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader(
array_of_WorkflowStepInputLoader, "id", "source"
Expand Down
12 changes: 4 additions & 8 deletions cwl_utils/parser/cwl_v1_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12982,7 +12982,7 @@ def fromDoc(
try:
default = load_field(
_doc.get("default"),
union_of_None_type_or_Any_type,
union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type,
baseuri,
loadingOptions,
)
Expand Down Expand Up @@ -13520,11 +13520,13 @@ def fromDoc(
)
else:
hints = None

subscope_baseuri = expand_url('run', baseuri, loadingOptions, True)
try:
run = load_field(
_doc.get("run"),
uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None,
baseuri,
subscope_baseuri,
loadingOptions,
)
except ValidationException as e:
Expand Down Expand Up @@ -15515,12 +15517,6 @@ def save(
uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2 = _URILoader(
union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2
)
union_of_None_type_or_Any_type = _UnionLoader(
(
None_type,
Any_type,
)
)
array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader)
idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader(
array_of_WorkflowStepInputLoader, "id", "source"
Expand Down
12 changes: 4 additions & 8 deletions cwl_utils/parser/cwl_v1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13191,7 +13191,7 @@ def fromDoc(
try:
default = load_field(
_doc.get("default"),
union_of_None_type_or_Any_type,
union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type,
baseuri,
loadingOptions,
)
Expand Down Expand Up @@ -13763,11 +13763,13 @@ def fromDoc(
)
else:
hints = None

subscope_baseuri = expand_url('run', baseuri, loadingOptions, True)
try:
run = load_field(
_doc.get("run"),
uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None,
baseuri,
subscope_baseuri,
loadingOptions,
)
except ValidationException as e:
Expand Down Expand Up @@ -16995,12 +16997,6 @@ def save(
uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2 = _URILoader(
union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2
)
union_of_None_type_or_Any_type = _UnionLoader(
(
None_type,
Any_type,
)
)
array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader)
idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader(
array_of_WorkflowStepInputLoader, "id", "source"
Expand Down
37 changes: 37 additions & 0 deletions tests/test_subscope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0
"""Test that scoping of identifiers in Workflow.steps[].run is correct."""

from pathlib import Path

from cwl_utils.parser import Workflow, load_document_by_uri

HERE = Path(__file__).resolve().parent


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 = Path(HERE / "../testdata/workflow_input_format_expr.cwl").resolve().as_uri()
cwl_obj: Workflow = load_document_by_uri(uri)
assert cwl_obj.steps[0].run.inputs[0].id.endswith("#format_extract/target")


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 = (
Path(HERE / "../testdata/workflow_input_format_expr_v1_1.cwl")
.resolve()
.as_uri()
)
cwl_obj: Workflow = load_document_by_uri(uri)
assert cwl_obj.steps[0].run.inputs[0].id.endswith("#format_extract/run/target")


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 = (
Path(HERE / "../testdata/workflow_input_format_expr_v1_2.cwl")
.resolve()
.as_uri()
)
cwl_obj: Workflow = load_document_by_uri(uri)
assert cwl_obj.steps[0].run.inputs[0].id.endswith("#format_extract/run/target")