Adding your own script to a step
Overview
Teaching: 0 min
Exercises: 0 minQuestions
How to include and run a script in a step at runtime?
Which requirements need to be specified?
How to capture output of a script?
Objectives
Include and run a script in a step at runtime
Capture output of a script
By the end of this episode, learners should be able to include and run their own script in a step at runtime
Exercise 1:
Which
Requirmentfrom the following options is used to create a script at runtime?A. InlineJavascriptRequirement B. InitialWorkDirRequirement C. ResourceRequirement D. DockerRequirementSolution
B. InitialWorkDirRequirement
Exercise 2:
Using the template below, add the missing instructions so that a script named
script.shwith the specified contents is created at runtime.InitialWorkDirRequirement: listing: - ------: script.sh ------: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: stringSolution:
InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string
Exercise 3:
Since we are using
echoin the script (as shown below) - what is the appropriatetypein theoutputssection of following code block to capture standard output?class: CommandLineTool cwlVersion: v1.1 requirements: DockerRequirement: dockerPull: 'debian:stable' InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string stdout: "message.txt" outputs: message: type: ----Your options are: A. File B. Directory C. stdout D. string
Solution:
C. stdout
Exercise 4:
Fix the
baseCommandin following code snippet to execute the script we have created in previous exercises.baseCommand: []Solution:
baseCommand: [ sh, script.sh ]
Exercise 5:
CHALLENGE question. Extend the
outputssection of the following CWLtool definition to capture the script we have created along with tools’ standard output.This will help you inspect the generated script and is useful in more complex situations to troubleshoot related issues.
class: CommandLineTool cwlVersion: v1.1 requirements: DockerRequirement: dockerPull: 'debian:stable' InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string stdout: "message.txt" baseCommand: ["sh", "script.sh"] outputs: message: type: stdoutSolution:
class: CommandLineTool cwlVersion: v1.1 requirements: DockerRequirement: dockerPull: 'debian:stable' InitialWorkDirRequirement: listing: - entryname: script.sh entry: | echo "*Documenting input*" && \ echo "Input received: $(inputs.message)" && \ echo "Exit" inputs: message: type: string stdout: "message.txt" baseCommand: ["sh", "script.sh"] outputs: message: type: stdout script: type: File outputBinding: glob: "script.sh"
Key Points
First key point. Brief Answer to questions. (FIXME)