Skip to content

Shorten id of WorkflowStepInput via graph_split.py #54

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions cwl_utils/graph_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,35 @@
)

document[key][:] = [rewrite_id(entry) for entry in value]
elif key == "in":

def rewrite_step_input(
entry: MutableMapping[Any, Any]
) -> MutableMapping[Any, Any]:
if "id" in entry:
if entry["id"].startswith(this_id):
entry["id"] = cast(str, entry["id"])[len(this_id) + 1 :]
if "source" in entry:
if isinstance(entry["source"], Text):
if entry["source"].startswith("#" + doc_id):
entry["source"] = entry["source"][len(doc_id) + 2 :]
elif isinstance(entry["source"], list):
new_sources = list()
for source in entry["source"]:
if source.startswith("#" + doc_id):
new_sources.append(source[len(doc_id) + 2 :])
else:
new_sources.append(source)

Check warning on line 154 in cwl_utils/graph_split.py

View check run for this annotation

Codecov / codecov/patch

cwl_utils/graph_split.py#L154

Added line #L154 was not covered by tests
entry["source"] = new_sources
return entry

if isinstance(value, list):
document[key][:] = [
rewrite_step_input(entry) for entry in value
]
elif isinstance(value, MutableMapping):
for in_key in value:
value[in_key] = rewrite_step_input(value[in_key])

Check warning on line 164 in cwl_utils/graph_split.py

View check run for this annotation

Codecov / codecov/patch

cwl_utils/graph_split.py#L162-L164

Added lines #L162 - L164 were not covered by tests
elif key in ("source", "scatter", "items", "format"):
if (
isinstance(value, Text)
Expand Down