2.5. 追加の引数とパラメータ#
ツールには、入力パラメータに正確に対応しない追加のコマンドラインオプションが必要な場合があります。
この例では、Javaコンパイラを使用して、javaソースファイルをclassファイルにコンパイルするようにラップします。 デフォルトでは、"javac "はjavaファイルと同じディレクトリにclassファイルを作成します。 しかし、CWLの入力ファイル(およびそのディレクトリ)は読み取り専用である場合があるので、代わりに指定された出力ディレクトリにclassファイルを書き込むように「javac」に指示する必要があります。
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: CommandLineTool
label: Example trivial wrapper for Java 9 compiler
hints:
DockerRequirement:
dockerPull: openjdk:9.0.1-11-slim
baseCommand: javac
arguments: ["-d", $(runtime.outdir)]
inputs:
src:
type: File
inputBinding:
position: 1
outputs:
classfile:
type: File
outputBinding:
glob: "*.class"
src:
class: File
path: Hello.java
次に、CommandLineToolで使用するサンプルJavaファイルを作成します。
$ echo "public class Hello {}" > Hello.java
そして、コマンドラインでツール定義と入力オブジェクトを渡してcwltool
を起動します:
$ cwltool arguments.cwl arguments-job.yml
INFO /home/docs/checkouts/readthedocs.org/user_builds/common-workflow-language-user-guide-ja/envs/latest/bin/cwltool 3.1.20240508115724
INFO Resolved 'arguments.cwl' to 'file:///home/docs/checkouts/readthedocs.org/user_builds/common-workflow-language-user-guide-ja/checkouts/latest/src/_includes/cwl/additional-arguments-and-parameters/arguments.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
ここでは、arguments
フィールドを使用して、特定の入力パラメータに結びつかない追加の引数をコマンドラインに追加しています。
arguments: ["-d", $(runtime.outdir)]
この例では、runtimeパラメータを参照しています。 runtimeパラメータは、ツールが実際に実行されたときのハードウェアまたはソフトウェア環境に関する情報を提供します。 $(runtime.outdir)
パラメータは、指定された出力ディレクトリへのパスです。 その他、$(runtime.tmpdir)
,$(runtime.ram)
,$(runtime.cores)
,$(runtime.outdirSize)
,$(runtime.tmpdirSize)
などがあります。 詳細はCWL仕様書のRuntime Environmentの項を参照してください。