Creating Files at Runtime
Overview
Teaching: 10 min
Exercises: 0 minQuestions
How do I create required input files from input parameters at runtime?
Objectives
Learn how to create files on the fly during runtime.
Sometimes you need to create a file on the fly from input parameters,
such as tools which expect to read their input configuration from a file
rather than the command line parameters. To do this, use
InitialWorkDirRequirement
.
createfile.cwl
#!/usr/bin/env cwl-runner
class: CommandLineTool
cwlVersion: v1.0
baseCommand: ["cat", "example.conf"]
requirements:
InitialWorkDirRequirement:
listing:
- entryname: example.conf
entry: |
CONFIGVAR=$(inputs.message)
inputs:
message: string
outputs: []
echo-job.yml
message: Hello world!
Now invoke cwl-runner
with the tool wrapper and the input object on the
command line:
$ cwltool createfile.cwl echo-job.yml
[job 140528604979344] /home/example$ cat example.conf
CONFIGVAR=Hello world!
Final process status is success
{}
Key Points
Use
InitialWorkDirRequirement
to specify input files that need to be created during tool runtime.