Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 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
19 changes: 19 additions & 0 deletions cwltool/extensions-v1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,22 @@ $graph:
The number of MPI processes to start. If you give a string,
this will be evaluated as a CWL Expression and it must
evaluate to an integer.

- name: StepName
type: record
inVocab: false
extends: cwl:ProcessRequirement
doc: |
Provide a string or expression for naming the runtime workflow step in logs or user interface.
fields:
- name: class
type: string
doc: "Always 'StepName'"
jsonldPredicate:
"_id": "@type"
"_type": "@vocab"
- name: stepname
type: [string, cwl:Expression]
doc: |
A string or expression returning a string with the preferred name for the step.
If it is an expression, it is evaluated after the input object has been completely determined.
2 changes: 2 additions & 0 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,14 @@ def setup_schema(
use_custom_schema("v1.2.0-dev1", "http://commonwl.org/cwltool", ext11)
use_custom_schema("v1.2.0-dev2", "http://commonwl.org/cwltool", ext11)
use_custom_schema("v1.2.0-dev3", "http://commonwl.org/cwltool", ext11)
use_custom_schema("v1.2", "http://commonwl.org/cwltool", ext11)
else:
use_standard_schema("v1.0")
use_standard_schema("v1.1")
use_standard_schema("v1.2.0-dev1")
use_standard_schema("v1.2.0-dev2")
use_standard_schema("v1.2.0-dev3")
use_standard_schema("v1.2")


class ProvLogFormatter(logging.Formatter):
Expand Down
1 change: 1 addition & 0 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def filter(self, record: logging.LogRecord) -> bool:
"http://commonwl.org/cwltool#NetworkAccess",
"http://commonwl.org/cwltool#LoadListingRequirement",
"http://commonwl.org/cwltool#InplaceUpdateRequirement",
"http://commonwl.org/cwltool#StepName",
]

cwl_files = (
Expand Down
8 changes: 7 additions & 1 deletion cwltool/workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ def job(
) -> JobsGeneratorType:
runtimeContext = runtimeContext.copy()
runtimeContext.part_of = self.name
runtimeContext.name = shortname(self.id)

stepnameReq, is_required = self.step.get_requirement("http://commonwl.org/cwltool#StepName")
if is_required is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to use stepnameReq is not None instead

vfinputs = {shortname(k): v for k, v in joborder.items()}
runtimeContext.name = expression.do_eval(stepnameReq["stepname"], vfinputs, self.step.requirements, None, None, {})
else:
runtimeContext.name = shortname(self.id)

_logger.info("[%s] start", self.name)

Expand Down
9 changes: 9 additions & 0 deletions tests/echo_no_output.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env cwl-runner
cwlVersion: v1.1
class: CommandLineTool
inputs:
text:
type: string
inputBinding: {}
outputs: []
baseCommand: echo
26 changes: 26 additions & 0 deletions tests/scatter-echo-wf.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env cwl-runner
$namespaces:
cwltool: "http://commonwl.org/cwltool#"
cwlVersion: v1.1
class: Workflow
requirements:
ScatterFeatureRequirement: {}
InlineJavascriptRequirement: {}
StepInputExpressionRequirement: {}

inputs:
texts:
type: string[]

outputs: []

steps:
echo:
run: echo_no_output.cwl
scatter: text
hints:
cwltool:StepName:
stepname: $("test_" + inputs.text.split('.')[0])
in:
text: texts
out: []
1 change: 1 addition & 0 deletions tests/scatter-echo-wf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
texts: ["a.vcf", "b.vcf", "c.vcf"]
15 changes: 15 additions & 0 deletions tests/test_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,18 @@ def test_warn_large_inputs() -> None:
)
finally:
cwltool.process.FILE_COUNT_WARNING = was


def test_stepname() -> None:
stream = StringIO()

main(
["--enable-ext",
get_data("tests/scatter-echo-wf.cwl"), get_data("tests/scatter-echo-wf.yml")],
stderr=stream,
)

assert (
"test_a" in stream.getvalue() and "test_b" in stream.getvalue()
and "test_c" in stream.getvalue()
)