Skip to content

Codegen changes to support cwltool --fast-parse #156

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

Merged
merged 5 commits into from
Sep 7, 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
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,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/main/v1.0/CommonWorkflowLanguage.yml --codegen-parser-info "org.w3id.cwl.v1_0"``
``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml --codegen-parser-info "org.w3id.cwl.v1_0" > 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/main/CommonWorkflowLanguage.yml --codegen-parser-info "org.w3id.cwl.v1_1"``
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml --codegen-parser-info "org.w3id.cwl.v1_1" > 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/1.2.1_proposed/CommonWorkflowLanguage.yml --codegen-parser-info "org.w3id.cwl.v1_2"``
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/1.2.1_proposed/CommonWorkflowLanguage.yml --codegen-parser-info "org.w3id.cwl.v1_2" > cwl_utils/parser/cwl_v1_2.py``

Release
~~~~~~~
Expand Down
5 changes: 4 additions & 1 deletion cwl_utils/cite_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def extract_software_reqs(
yield req
if process.hints:
for req in process.hints:
if req["class"] == "SoftwareRequirement":
if isinstance(req, cwl.ProcessRequirement):
if isinstance(req, cwl.SoftwareRequirement):
yield req
elif req["class"] == "SoftwareRequirement":
yield cwl.load_field(
req,
cwl.SoftwareRequirementLoader,
Expand Down
9 changes: 2 additions & 7 deletions cwl_utils/cwl_v1_2_expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,14 +702,9 @@ def process_workflow_inputs_and_outputs(
target_type.name = None
target = cwl.WorkflowInputParameter(id=None, type=target_type)
if not isinstance(param2.outputSource, list):
sources: Union[List[str], str] = "/".join(
param2.outputSource.split("#")[-1].split("/")[1:]
)
sources: Union[List[str], str] = param2.outputSource.split("#")[-1]
else:
sources = [
"/".join(s.split("#")[-1].split("/")[1:])
for s in param2.outputSource
]
sources = [s.split("#")[-1] for s in param2.outputSource]
source_type_items = utils.type_for_source(workflow, sources)
if "null" not in source_type_items:
if isinstance(source_type_items, list):
Expand Down
5 changes: 4 additions & 1 deletion cwl_utils/docker_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def extract_docker_reqs(process: ProcessType) -> Iterator[cwl.DockerRequirement]
yield req
if process.hints:
for req in process.hints:
if req["class"] == "DockerRequirement":
if isinstance(req, cwl.ProcessRequirement):
if isinstance(req, cwl.DockerRequirement):
yield req
elif req["class"] == "DockerRequirement":
yield cwl.load_field(
req,
cwl.DockerRequirementLoader,
Expand Down
7 changes: 5 additions & 2 deletions cwl_utils/expression_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Callable,
Dict,
List,
MutableMapping,
MutableSequence,
Optional,
Tuple,
Expand Down Expand Up @@ -43,15 +44,17 @@
)
from cwl_utils.parser import cwl_v1_0, cwl_v1_1, cwl_v1_2

save_type = Union[Dict[str, str], List[Union[Dict[str, str], List[Any], None]], None]
save_type = Optional[
Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]
]


class saveCWL(Protocol):
"""Shortcut type for CWL v1.x parse.save()."""

def __call__(
self,
val: Optional[Union[Any, MutableSequence[Any]]],
val: Any,
top: bool = True,
base_url: str = "",
relative_uris: bool = True,
Expand Down
10 changes: 5 additions & 5 deletions cwl_utils/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
LoadingOptions = Union[
cwl_v1_0.LoadingOptions, cwl_v1_1.LoadingOptions, cwl_v1_2.LoadingOptions
]
Savable = Union[cwl_v1_0.Savable, cwl_v1_1.Savable, cwl_v1_2.Savable]
Saveable = Union[cwl_v1_0.Saveable, cwl_v1_1.Saveable, cwl_v1_2.Saveable]
Workflow = Union[cwl_v1_0.Workflow, cwl_v1_1.Workflow, cwl_v1_2.Workflow]
WorkflowTypes = (cwl_v1_0.Workflow, cwl_v1_1.Workflow, cwl_v1_2.Workflow)
WorkflowStep = Union[
Expand Down Expand Up @@ -157,16 +157,16 @@ def load_document_by_yaml(


def save(
val: Optional[Union[Savable, MutableSequence[Savable]]],
val: Optional[Union[Saveable, MutableSequence[Saveable]]],
top: bool = True,
base_url: str = "",
relative_uris: bool = True,
) -> Any:
"""Convert a given CWL object into a built-in typed object."""
if (
isinstance(val, cwl_v1_0.Savable)
or isinstance(val, cwl_v1_1.Savable)
or isinstance(val, cwl_v1_2.Savable)
isinstance(val, cwl_v1_0.Saveable)
or isinstance(val, cwl_v1_1.Saveable)
or isinstance(val, cwl_v1_2.Saveable)
):
return val.save(top=top, base_url=base_url, relative_uris=relative_uris)
if isinstance(val, MutableSequence):
Expand Down
Loading