1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CWL User Guide 8: Additional Arguments and Parameters をやってみた

Last updated at Posted at 2017-12-07

CWL User Guide 8: Additional Arguments and Parameters

Common Workflow Language User Guide: Additional Arguments and Parameters

今回は実行環境の情報が提供されるパラメータruntimeや、argumentsに関する説明があります。

Javaのソースコードをコンパイルしますが、コンパイルには、dockerコンテナを使うので、Javaをインストールする必要はありません。

この回にでてくる主なキーワード

  • arguments
  • runtime

CWLファイル、arguments.cwl

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
label: Example trivial wrapper for Java 7 compiler
hints:
  DockerRequirement:
    dockerPull: java:7-jdk
baseCommand: javac
arguments: ["-d", $(runtime.outdir)]
inputs:
  src:
    type: File
    inputBinding:
      position: 1
outputs:
  classfile:
    type: File
    outputBinding:
      glob: "*.class"

パラメータファイル arguments-job.yml

src:
  class: File
  path: Hello.java

必要なファイル

簡単な Java のソースコードがかかれたファイルを作成する

echo "public class Hello {}" > Hello.java

実行

実行前確認

Hello.class が存在していないことを確認する
Hello.class が存在すれば、それを削除しておく。

$ rm Hello.class
$ ls Hello.class
ls: cannot access 'Hello.class': No such file or directory

実行方法

cwltool arguments.cwl arguments-job.yml

実行結果

$ cwltool arguments.cwl arguments-job.yml
/usr/local/bin/cwltool 1.0.20171107133715
Resolved 'arguments.cwl' to 'file:///home/vagrant/cwl_user_guide_work/08-arguments/arguments.cwl'
['docker', 'pull', 'java:7-jdk']
7-jdk: Pulling from library/java
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
60170fec2151: Pull complete
66b144b1d5b0: Pull complete
6263baad4f89: Pull complete
Digest: sha256:c0b61b62639124aa838dc755c5a9d57c072f762b71b170281927399a14db4652
Status: Downloaded newer image for java:7-jdk
[job arguments.cwl] /tmp/tmpxVil6_$ docker \
    run \
    -i \
    --volume=/tmp/tmpxVil6_:/var/spool/cwl:rw \
    --volume=/tmp/tmpigrxzv:/tmp:rw \
    --volume=/home/vagrant/cwl_user_guide_work/08-arguments/Hello.java:/var/lib/cwl/stgd0a948ea-31f9-411e-bc4c-82440ed28793/Hello.java:ro \
    --workdir=/var/spool/cwl \
    --read-only=true \
    --user=1000:1000 \
    --rm \
    --env=TMPDIR=/tmp \
    --env=HOME=/var/spool/cwl \
    java:7-jdk \
    javac \
    -d \
    /var/spool/cwl \
    /var/lib/cwl/stgd0a948ea-31f9-411e-bc4c-82440ed28793/Hello.java
[job arguments.cwl] completed success
{
    "classfile": {
        "checksum": "sha1$e68df795c0686e9aa1a1195536bd900f5f417b18",
        "basename": "Hello.class",
        "location": "file:///home/vagrant/cwl_user_guide_work/08-arguments/Hello.class",
        "path": "/home/vagrant/cwl_user_guide_work/08-arguments/Hello.class",
        "class": "File",
        "size": 184
    }
}
Final process status is success

実行結果確認

コンパイルされた結果のクラスファイルが存在することを確認できる

$ ls Hello.class
Hello.class

今回使ったファイル

cwl_user_guide_work/08-arguments at master · manabuishii/cwl_user_guide_work

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?