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

Shorten id of WorkflowStepInput via graph_split.py #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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 @@ -130,6 +130,35 @@ def rewrite_id(entry: Any) -> Union[MutableMapping[Any, Any], str]:
)

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)
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])
elif key in ("source", "scatter", "items", "format"):
if (
isinstance(value, Text)
Expand Down