Skip to content

Commit

Permalink
ArraySchema -> CWLArraySchema and RecordSchema -> CWLRecordSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
GlassOfWhiskey committed Oct 7, 2023
1 parent 0815bbb commit 578dfc7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 43 deletions.
6 changes: 4 additions & 2 deletions cwl_utils/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@
cwl_v1_2.SoftwareRequirement,
)
"""Type union for a CWL v1.x SoftwareRequirement object."""
ArraySchema = Union[cwl_v1_0.ArraySchema, cwl_v1_1.ArraySchema, cwl_v1_2.ArraySchema]
ArraySchema = Union[
cwl_v1_0.CWLArraySchema, cwl_v1_1.CWLArraySchema, cwl_v1_2.CWLArraySchema
]
"""Type Union for a CWL v1.x ArraySchema object."""
EnumSchema = Union[cwl_v1_0.EnumSchema, cwl_v1_1.EnumSchema, cwl_v1_2.EnumSchema]
"""Type Union for a CWL v1.x EnumSchema object."""
RecordSchema = Union[
cwl_v1_0.RecordSchema, cwl_v1_1.RecordSchema, cwl_v1_2.RecordSchema
cwl_v1_0.CWLRecordSchema, cwl_v1_1.CWLRecordSchema, cwl_v1_2.CWLRecordSchema
]
"""Type Union for a CWL v1.x RecordSchema object."""
File = Union[cwl_v1_0.File, cwl_v1_1.File, cwl_v1_2.File]
Expand Down
2 changes: 1 addition & 1 deletion cwl_utils/parser/cwl_v1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def load_field(
fieldtype: "_Loader",
baseuri: str,
loadingOptions: LoadingOptions,
lc: Optional[List[Any]],
lc: Optional[List[Any]] = None,
) -> Any:
"""Load field."""
if isinstance(val, MutableMapping):
Expand Down
2 changes: 1 addition & 1 deletion cwl_utils/parser/cwl_v1_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def load_field(
fieldtype: "_Loader",
baseuri: str,
loadingOptions: LoadingOptions,
lc: Optional[List[Any]],
lc: Optional[List[Any]] = None,
) -> Any:
"""Load field."""
if isinstance(val, MutableMapping):
Expand Down
2 changes: 1 addition & 1 deletion cwl_utils/parser/cwl_v1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def load_field(
fieldtype: "_Loader",
baseuri: str,
loadingOptions: LoadingOptions,
lc: Optional[List[Any]],
lc: Optional[List[Any]] = None,
) -> Any:
"""Load field."""
if isinstance(val, MutableMapping):
Expand Down
76 changes: 38 additions & 38 deletions tests/test_parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,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, cwl_utils.parser.cwl_v1_0.CWLRecordSchema)
fields = cast(
MutableSequence[cwl_utils.parser.cwl_v1_0.RecordField], source_type.fields
MutableSequence[cwl_utils.parser.cwl_v1_0.CWLRecordField], source_type.fields
)
assert len(fields) == 2
assert fields[0].type_ == "File"
Expand All @@ -332,7 +332,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items == "string"


Expand All @@ -344,8 +344,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items.items == "string"


Expand All @@ -356,7 +356,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items == "string"


Expand All @@ -369,8 +369,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items.items == "File"


Expand All @@ -383,7 +383,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items == "File"


Expand All @@ -400,8 +400,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items.items == "File"


Expand All @@ -418,7 +418,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, cwl_utils.parser.cwl_v1_0.CWLArraySchema)
assert source_type.items == "File"


Expand Down Expand Up @@ -676,9 +676,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, cwl_utils.parser.cwl_v1_1.CWLRecordSchema)
fields = cast(
MutableSequence[cwl_utils.parser.cwl_v1_1.RecordField], source_type.fields
MutableSequence[cwl_utils.parser.cwl_v1_1.CWLRecordField], source_type.fields
)
assert len(fields) == 2
assert fields[0].type_ == "File"
Expand All @@ -693,7 +693,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items == "string"


Expand All @@ -705,8 +705,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items.items == "string"


Expand All @@ -718,7 +718,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items == "string"


Expand All @@ -731,8 +731,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items.items == "File"


Expand All @@ -745,7 +745,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items == "File"


Expand All @@ -762,8 +762,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items.items == "File"


Expand All @@ -780,7 +780,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, cwl_utils.parser.cwl_v1_1.CWLArraySchema)
assert source_type.items == "File"


Expand Down Expand Up @@ -1038,9 +1038,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, cwl_utils.parser.cwl_v1_2.CWLRecordSchema)
fields = cast(
MutableSequence[cwl_utils.parser.cwl_v1_2.RecordField], source_type.fields
MutableSequence[cwl_utils.parser.cwl_v1_2.CWLRecordField], source_type.fields
)
assert len(fields) == 2
assert fields[0].type_ == "File"
Expand All @@ -1055,7 +1055,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items == "string"


Expand All @@ -1067,8 +1067,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items.items == "string"


Expand All @@ -1080,7 +1080,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items == "string"


Expand All @@ -1093,8 +1093,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items.items == "File"


Expand All @@ -1107,7 +1107,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items == "File"


Expand All @@ -1124,8 +1124,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert isinstance(source_type.items, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items.items == "File"


Expand All @@ -1142,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items == "File"


Expand Down Expand Up @@ -1179,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items == "string"


Expand Down Expand Up @@ -1216,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, cwl_utils.parser.cwl_v1_2.CWLArraySchema)
assert source_type.items == "string"

0 comments on commit 578dfc7

Please sign in to comment.