Creating a temporary directory at runtime

Which of these methods is preferred to create a temporary directory to use in _JAVA_OPTS during a workflow?

Option 1 - Create in a separate step and pass to tool:

cwlVersion: v1.0

class: CommandLineTool

requirements:
  - class: InlineJavascriptRequirement
  - class: InitialWorkDirRequirement
    listing:
      - entryname: empty_dir
        entry: "$({class: 'Directory', listing: []})"
        writable: true

arguments: [touch, empty_dir/placeholder]

inputs: []

outputs:
  empty_dir:
    type: Directory
    outputBinding:
      glob: empty_dir

Option 2 - Create with expression inside of tool itself:

cwlVersion: v1.0

class: CommandLineTool

arguments:
- java
- -Xmx50g
- -Djava.io.tmpdir=$(runtime.tmpdir)
- -jar
- abra.jar

requirements:
  InlineJavascriptRequirement: {}

inputs:

  working_directory:
    type: Directory?
    inputBinding:
      prefix: --tmpdir
      valueFrom: $(runtime.tmpdir)

Option 3 (slight tweak on option 2):

cwlVersion: v1.0

class: CommandLineTool

arguments:
- java
- -Xmx50g
- -Djava.io.tmpdir=$(runtime.tmpdir)
- -jar
- abra.jar
- prefix: --tmpdir
  valueFrom: $(runtime.tmpdir)
  

inputs: []

(The InlineJavascriptRequirement isn’t required, those are just plain CWL Parameter References.)

Portability bonus: use the classname of the main entrypoint for abra.jar on the command line instead of -jar abra.jar combined with updating your container/environement to put the jar in the CLASSPATH

1 Like