common-workflow-language / common-workflow-language/cwl-utils

'save' function truncate input source name if it contains step name

Open
#402 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
43
Forks
28
Avg merge
4h 7m
Merged PRs (30d)
4

Description

I remarked that if a Workflow input source name contains exactly the step name, then if I apply the [save](https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/__init__.py#L410) function on this workflow, the input source is truncated.

Here is an example:
```
cwlVersion: v1.2
class: Workflow
label: "Main Workflow"
doc: >
Test.

inputs:
first_input:
type: string
default: "step_1.log"
second_step_input:
type: string
default: "step_2.log"

outputs:
log:
type: File[]
outputSource:
- second_step/log

steps:
first_step:
run: first_step.cwl
in:
input_1: first_input
out: [log]

second_step:
run: second_step.cwl
in:
input_2: second_step_input
out: [log]
```

Then if you load and save the workflow:
```
from cwl_utils.parser import save, load_document
from cwl_utils.pack import pack

from pathlib import Path

cwl_path = Path("test_workflow.cwl")
cwl_obj = load_document(pack(str(cwl_path)))

saved_cwl = save(cwl_obj)
print(saved_cwl)
```

It gives you:
```
[...] {'id': 'second_step', 'in': [{'id': 'input_2', 'source': '_input'}] [...]
```

The input source is no more `second_step_input` but `_input`.

Do you have any idea if this behavior is expected?

Contributor guide

Open the contributing guide

Research direction

Start in cwl_utils/parser/__init__.py at the save function linked in the issue, then reproduce the case with test_workflow.cwl using pack and load_document. Compare the original second_step_input source with the serialized output; done means saving preserves that input source instead of truncating it, with a regression check for the shown workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.