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

WIP fix #1330 #1566

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
35 changes: 35 additions & 0 deletions cwltool/command_line_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ def job(
) -> Generator[ExpressionJob, None, None]:
builder = self._init_job(job_order, runtimeContext)

paramskey = []
paramskeys = []

if self.tool["inputs"] is not None:
for inp in self.tool["inputs"]:
for k, v in inp.items():
if k == "id":
paramskey.append(v)
paramskeys.append(shortname(v))
if builder.job is not None:
newbj = {}
for k, v in dict(builder.job).items():
if k in paramskey:
newbj[k] = v
elif k in paramskeys:
newbj[k] = v
builder.job = newbj

job = ExpressionJob(
builder,
self.tool["expression"],
Expand Down Expand Up @@ -989,6 +1007,23 @@ def update_status_output_callback(

builder = self._init_job(job_order, runtimeContext)

paramskey = []
paramskeys = []

if self.tool["inputs"] is not None:
for inp in self.tool["inputs"]:
for k, v in inp.items():
if k == "id":
paramskey.append(v)
paramskeys.append(shortname(v))
if builder.job is not None:
newbj = {}
for k, v in dict(builder.job).items():
if k in paramskey:
newbj[k] = v
elif k in paramskeys:
newbj[k] = v
builder.job = newbj
reffiles = copy.deepcopy(builder.files)

j = self.make_job_runner(runtimeContext)(
Expand Down
11 changes: 11 additions & 0 deletions cwltool/schemas/v1.1/conformance_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,17 @@
doc: Test an anonymous enum inside an array inside a record, SchemaDefRequirement
tags: [command_line_tool, schema_def]


- job: tests/empty.json
tool: tests/fail-unconnected-expressiontool.cwl
label: wf_step_access_undeclared_param_expressiontool
id: 198
doc: >-
Test that parameters that don't appear in the `run` process
inputs are not present in the input object used to run the expressiontool.
should_fail: true
tags: [ required, workflow ]

Comment on lines +2601 to +2611
Copy link
Member

Choose a reason for hiding this comment

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

The CI doesn't run this copy of the tests, it makes a new checkout from GitHub

wget "https://github.com/common-workflow-language/${repo}/archive/${spec_branch}.tar.gz"

Copy link
Contributor Author

@manabuishii manabuishii Apr 6, 2022

Choose a reason for hiding this comment

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

@mr-c Thanks

I will create a PullRequest about this test case (tests/fail-unconnected-expressiontool.cwl),

Repo:
https://github.com/common-workflow-language/cwl-v1.2
Branch:
1.2.1_proposed

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, you can also keep it in this PR, just move the test scripts to the the test directory and add an entry to test_examples.py

Copy link
Member

Choose a reason for hiding this comment

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

Can you move this file to the tests directory, or a sub-directory?

# New tests for v1.1

- job: tests/wc-job.json
Expand Down
8 changes: 7 additions & 1 deletion cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,13 @@ def job(
field = shortname(inp["id"])
if not inp.get("not_connected"):
step_input[field] = job_order[inp["id"]]

for inp in dict(job_order).keys():
field = shortname(inp)
step_input[field] = job_order[inp]
# if not isinstance(inp, str):
# if hasattr(inp, "get"):
# if not inp.get("not_connected"):
# step_input[field] = job_order[field]
try:
yield from self.embedded_tool.job(
step_input,
Expand Down
24 changes: 24 additions & 0 deletions cwltool/workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ def object_from_state(
incomplete: bool = False,
) -> Optional[CWLObjectType]:
inputobj = {} # type: CWLObjectType
if state is not None:
for s in state.keys():
ss = state[s]
if ss is not None:
if isinstance(ss, WorkflowStateItem):
inputobj[s] = ss.value
for inp in params:
iid = original_id = cast(str, inp["id"])
if frag_only:
Expand Down Expand Up @@ -551,6 +557,24 @@ def do_output_callback(self, final_output_callback: OutputCallbackType) -> None:
_logger.debug("[%s] outputs %s", self.name, json_dumps(wo, indent=4))

self.did_callback = True
paramskey = []
paramskeys = []

if self.tool["outputs"] is not None:
for inp in self.tool["outputs"]:
for k, v in inp.items():
if k == "id":
paramskey.append(v)
paramskeys.append(shortname(v))

if wo is not None:
newwo = {}
for k, v in dict(wo).items():
if k in paramskey:
newwo[k] = v
elif k in paramskeys:
newwo[k] = v
wo = newwo

final_output_callback(wo, self.processStatus)

Expand Down
20 changes: 20 additions & 0 deletions tests/fail-unconnected-expressiontool.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class: Workflow
cwlVersion: v1.1
inputs:
inp1:
type: string
default: hello inp1
inp2:
type: string
default: hello inp2
outputs:
out:
type: string
outputSource: step1/out
steps:
step1:
in:
in: inp1
in2: inp2
out: [out]
run: fail-unspecified-input-expressiontool.cwl
18 changes: 18 additions & 0 deletions tests/fail-unspecified-input-expressiontool.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cwlVersion: v1.0
class: ExpressionTool

requirements:
InlineJavascriptRequirement: {}

inputs:
in:
type: string

outputs:
out:
type: string

expression: |
${
return {"out": inputs.in +" "+inputs.in2};
}