cwltool icon indicating copy to clipboard operation
cwltool copied to clipboard

Can't redirect stdin

Open serverhorror opened this issue 9 years ago • 2 comments

Hi,

It seems impossible to redirect stdin so that a tool would read this. Am I using it wrong?

$ cwl-runner --debug tr.cwl params.yml
/home/marcherm/cwlSamples/bin/cwl-runner 1.0.20160919152321
[job tr.cwl] initializing from file:///home/marcherm/cwlSamples/tr.cwl
[job tr.cwl] {
    "message": "I am cleartext\nV nz pyrnegrkg\n"
}
[job tr.cwl] path mappings is {}
[job tr.cwl] command line bindings is [
    {
        "position": [
            -1000000,
            0
        ],
        "datum": "tr"
    },
    {
        "position": [
            0,
            0
        ],
        "datum": "[A-Za-z]"
    },
    {
        "position": [
            0,
            1
        ],
        "datum": "[N-ZA-Mn-za-m]"
    }
]
[job tr.cwl] /tmp/tmpcri0kw$ tr \
    [A-Za-z] \
    [N-ZA-Mn-za-m] < infile.tr
[job tr.cwl] initial work dir {
    "_:6f8a753d-6dde-4a4a-9c56-870b062cfa5f": [
        "_:6f8a753d-6dde-4a4a-9c56-870b062cfa5f",
        "/tmp/tmpcri0kw",
        "Directory"
    ],
    "_:dbdb06cc-41fa-41bb-a725-a4c75065d0ca": [
        "I am cleartext\nV nz pyrnegrkg\n",
        "/tmp/tmpcri0kw/infile.tr",
        "CreateFile"
    ]
}
Exception while running job
Traceback (most recent call last):
  File "/home/marcherm/cwlSamples/lib/python2.7/site-packages/cwltool/job.py", line 190, in run
    stdin = open(self.pathmapper.reversemap(self.stdin)[1], "rb")
TypeError: 'NoneType' object has no attribute '__getitem__'
[job tr.cwl] completed permanentFail
[job tr.cwl] {}
Final process status is permanentFail
[job tr.cwl] Removing input staging directory /tmp/tmpI9MKrF
[job tr.cwl] Removing temporary directory /tmp/tmpczQTwN
Workflow error, try again with --debug for more information:
  Process status is ['permanentFail']
Traceback (most recent call last):
  File "/home/marcherm/cwlSamples/lib/python2.7/site-packages/cwltool/main.py", line 672, in main
    **vars(args))
  File "/home/marcherm/cwlSamples/lib/python2.7/site-packages/cwltool/main.py", line 228, in single_job_executor
    raise WorkflowException(u"Process status is %s" % (final_status))
WorkflowException: Process status is ['permanentFail']
# tr.cwl
class: CommandLineTool
cwlVersion: v1.0
baseCommand: "tr"
arguments: ["[A-Za-z]", "[N-ZA-Mn-za-m]"]
#arguments: ["[A-Za-z]", "[N-ZA-Mn-za-m]", "infile.tr"]
#baseCommand: ["cat"]
#arguments: ["infile.tr"]

requirements:
  InitialWorkDirRequirement:
    listing:
      - entryname: infile.tr
        entry: $(inputs.message)

stdin: infile.tr
inputs:
  message:
    type: string
outputs: []
#outputs:
#  result:
#    type: stdout
# params.yml
message: |
  I am cleartext
  V nz pyrnegrkg

serverhorror avatar Sep 20 '16 13:09 serverhorror

Hi @serverhorror this looks like a bug in the interaction between InitialWorkDirRequirement and stdin redirection. The code is assuming an input parameter, not a file created on the fly with InitialWorkDirRequirement.

tetron avatar Sep 22 '16 13:09 tetron

This might be at least partially solved. When I try to run a very similar example (generating a keywords.txt file from an input string), using a command that has a Docker requirement, I get "keywords.txt missing from pathmapper". Apparently, keywords.txt is generated just fine, and a bind mount is created for Docker. However, it is then simply used as < keyword.txt to pipe it into stdin. Is that correct?

To be specific, this is my cwl file:

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
baseCommand: mtzutils
hints:
  DockerRequirement:
    dockerPull: pegi3s/ccp4
requirements:
  InitialWorkDirRequirement:
    listing:
      - entryname: keywords.txt
        entry: $(inputs.keywords)
inputs:
  input_mtz:
    type: File
    inputBinding:
      position: 0
      prefix: hklin
  output_mtz:
    type: string
    inputBinding:
      position: 1
      prefix: hklout
  keywords:
    type: string
stdin: keywords.txt
      

outputs:
  output_mtz:
    type: File
    outputBinding:
      glob: $(inputs.output_mtz)

pmiddend avatar Jun 03 '21 15:06 pmiddend