2.15. Staging Input Files#

Normally, input files are located in a read-only directory separate from the output directory. This causes problems if the underlying tool expects to write its output files alongside the input file in the same directory. You use InitialWorkDirRequirement to stage input files into the output directory. In this example, we use a JavaScript expression to extract the base name of the input file from its leading directory path.

linkfile.cwl#
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: CommandLineTool
hints:
  DockerRequirement:
    dockerPull: openjdk:9.0.1-11-slim
baseCommand: javac

requirements:
  InitialWorkDirRequirement:
    listing:
      - $(inputs.src)

inputs:
  src:
    type: File
    inputBinding:
      position: 1
      valueFrom: $(self.basename)

outputs:
  classfile:
    type: File
    outputBinding:
      glob: "*.class"
arguments-job.yml#
src:
  class: File
  path: Hello.java

Now invoke cwltool with the tool description and the input object on the command line:

$ cwltool linkfile.cwl arguments-job.yml
INFO /home/docs/checkouts/readthedocs.org/user_builds/common-workflow-language-user-guide-pt-br/envs/latest/bin/cwltool 3.1.20240508115724
INFO Resolved 'linkfile.cwl' to 'file:///home/docs/checkouts/readthedocs.org/user_builds/common-workflow-language-user-guide-pt-br/checkouts/latest/src/_includes/cwl/staging-input-files/linkfile.cwl'
ERROR Workflow error, try again with --debug for more information:
Docker is not available for this tool, try --no-container to disable Docker, or install a user space Docker replacement like uDocker with --user-space-docker-cmd.: docker executable is not available