Skip to content

Define way to access the output directory in a tool definition #62

Closed

Description

@porterjamesj

To make it easier for tool definitions to conform to the spec's requirement that:

Output files produced by tool execution must be written to the designated output directory.

My suggestion for an implementation is to make the output directory accessible via the job object, so that a JsonPointer expression can pull it out, e.g.:

arguments:
  - position: 1
    prefix: '--log-dir'
    valueFrom:
      engine: JsonPointer
      script: 'job/output_dir'

I'm happy to take a stab at this if you want.

Activity

  1. added this to the Draft 2 milestone on Jun 23, 2015
  2. tetron commented on Jun 24, 2015

    @tetron
    Member

    Comitted, you can now use

          engine: JsonPointer
          script: 'outdir'
    

    or

          engine: JsonPointer
          script: 'tmpdir'
    

    to get the designated output or temporary directories respectively.

    Please review and reopen if you have any issues.

  3. vardaofthevalier commented on Oct 23, 2015

    @vardaofthevalier

    Is there currently any way to specify relative paths to "outdir" for writing an output file? The tool definition that I'm working on produces a large number of files in a single directory (specified as a command line option for the tool), so for the tool's output field I'm trying to simply create a file for the stdout of the process on a path relative to "outdir".

    Here's how I'm coding the output section:

    outputs:
      - id: "#output"
        type: File
        outputBinding:
          glob:
            engine: "#node_engine"
            script: $outdir + '/logs/snapr-index.out'
    

    And here's the error that I get back when I run the tool using "cwl-runner --outdir /cwl-data/workflows/snapr snapr-index.cwl snapr-index.json":

    /usr/local/bin/cwlNodeEngine.js:40
        process.stdout.write(JSON.stringify(require("vm").runInNewContext(fn, {}))
                                                          ^
    ReferenceError: $outdir is not defined
        at evalmachine.<anonymous>:4:20
        at evalmachine.<anonymous>:4:56
        at Socket.<anonymous> (/usr/local/bin/cwlNodeEngine.js:40:55)
        at Socket.emit (events.js:117:20)
        at _stream_readable.js:929:16
        at process._tickCallback (node.js:419:13)
    Error while running job: Expression engine returned non-zero exit code on evaluation of
    {
        "script": "$outdir + '/logs/snapr-index.out'", 
        "job": {
            "fasta_sequence": {
                "path": "/tmp/job745995793_inputs/sequence.fa", 
                "class": "File"
            }, 
            "id": "file:///home/abby/bioinformatics-pipelines/cwl-examples/snapr/snapr-index/snapr-index.json", 
            "genome_index_dir": "/tmp/job_output/genome-index"
        }, 
        "context": null, 
        "engineConfig": [], 
        "tmpdir": "/tmp/job_tmp", 
        "outdir": "/tmp/job_output"
    }
    [job 47949072] completed permanentFail
    Final process status is permanentFail
    Workflow error:
      Process status is ['permanentFail']
    
    

    "#node_engine" is the id that I gave to the ExpressionEngineRequirement at the top of the CWL file snapr-index.cwl, which refers to the commonworkflowlanguage/nodejs-engine docker process.

    I'm sure there's probably a simple explanation for why this isn't working the way I'm expecting it to, but any help or advice you could share would be much appreciated.

  4. added a commit that references this issue on Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions