Merge branch 'master' into 1971-show-image-thumbnails
[arvados.git] / doc / user / topics / running-pipeline-command-line.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: "Running a pipeline on the command line"
5 ...
6
7 In "Writing a pipeline":{{ site.baseurl }}/user/tutorials/tutorial-firstscript.html, we learned how to create a pipeline template on the command-line.  Let's create one that doesn't require any user input to start:
8
9 <notextile>
10 <pre><code>~$ <span class="userinput">cat &gt;the_pipeline &lt;&lt;EOF
11 {
12   "name":"Filter md5 hash values",
13   "components":{
14     "do_hash":{
15       "script":"hash.py",
16       "script_parameters":{
17         "input": "887cd41e9c613463eab2f0d885c6dd96+83"
18       },
19       "repository":"$USER",
20       "script_version":"master"
21     },
22     "filter":{
23       "script":"0-filter.py",
24       "script_parameters":{
25         "input":{
26           "output_of":"do_hash"
27         }
28       },
29       "repository":"$USER",
30       "script_version":"master"
31     }
32   }
33 }
34 EOF</span>
35 ~$ <span class="userinput">arv pipeline_template create --pipeline-template "$(cat the_pipeline)"</span></code></pre>
36 </notextile>
37
38 (Your shell should automatically fill in @$USER@ with your login name.  The JSON that gets saved should have @"repository"@ pointed at your personal git repository.)
39
40 You can run this pipeline from the command line using @arv pipeline run@, filling in the UUID that you received from @arv pipeline_template create@:
41
42 <notextile>
43 <pre><code>~$ <span class="userinput">arv pipeline run --run-here --template qr1hi-p5p6p-xxxxxxxxxxxxxxx</span>
44 2013-12-16 14:08:40 +0000 -- pipeline_instance qr1hi-d1hrv-vxzkp38nlde9yyr
45 do_hash qr1hi-8i9sb-hoyc2u964ecv1s6 queued 2013-12-16T14:08:40Z
46 filter  -                           -
47
48 2013-12-16 14:08:51 +0000 -- pipeline_instance qr1hi-d1hrv-vxzkp38nlde9yyr
49 do_hash qr1hi-8i9sb-hoyc2u964ecv1s6 1ed9ed18ef31ad21bcabcfeff7777bae+162
50 filter  qr1hi-8i9sb-w5k40fztqgg9i2x queued 2013-12-16T14:08:50Z
51
52 2013-12-16 14:09:01 +0000 -- pipeline_instance qr1hi-d1hrv-vxzkp38nlde9yyr
53 do_hash qr1hi-8i9sb-hoyc2u964ecv1s6 1ed9ed18ef31ad21bcabcfeff7777bae+162
54 filter  qr1hi-8i9sb-w5k40fztqgg9i2x d3bcc2ee0f0ea31049000c721c0f3a2a+56
55 </code></pre>
56 </notextile>
57
58 This instantiates your pipeline and displays a live feed of its status.  The new pipeline instance will also show up on Workbench *Activity* %(rarr)&rarr;% *Recent&nbsp;pipeline&nbsp;instances* page.
59
60 Arvados adds each pipeline component to the job queue as its dependencies are satisfied (or immediately if it has no dependencies) and finishes when all components are completed or failed and there is no more work left to do.
61
62 The Keep locators of the output of each of @"do_hash"@ and @"filter"@ component are available from the output log shown above.  The output is also available on the Workbench by navigating to *Activity* %(rarr)&rarr;% *Recent&nbsp;pipeline&nbsp;instances* %(rarr)&rarr;% pipeline UUID under the *Instance* column %(rarr)&rarr;% *output* column.
63
64 <notextile>
65 <pre><code>~$ <span class="userinput">arv keep get 1ed9ed18ef31ad21bcabcfeff7777bae+162/md5sum.txt</span>
66 0f1d6bcf55c34bed7f92a805d2d89bbf 887cd41e9c613463eab2f0d885c6dd96+83/./alice.txt
67 504938460ef369cd275e4ef58994cffe 887cd41e9c613463eab2f0d885c6dd96+83/./bob.txt
68 8f3b36aff310e06f3c5b9e95678ff77a 887cd41e9c613463eab2f0d885c6dd96+83/./carol.txt
69 ~$ <span class="userinput">arv keep get d3bcc2ee0f0ea31049000c721c0f3a2a+56/0-filter.txt</span>
70 0f1d6bcf55c34bed7f92a805d2d89bbf 887cd41e9c613463eab2f0d885c6dd96+83/./alice.txt
71 </code></pre>
72 </notextile>
73
74 Indeed, the filter has picked out just the "alice" file as having a hash that starts with 0.
75
76 h3. Running a pipeline with different parameters
77
78 Notice that the pipeline template explicitly specifies the Keep locator for the input:
79
80 <notextile>
81 <pre><code>...
82     "do_hash":{
83       "script_parameters":{
84         "input": "887cd41e9c613463eab2f0d885c6dd96+83"
85       },
86     }
87 ...
88 </code></pre>
89 </notextile>
90
91 You can specify values for pipeline component script_parameters like this:
92
93 <notextile>
94 <pre><code>~$ <span class="userinput">arv pipeline run --run-here --template qr1hi-p5p6p-xxxxxxxxxxxxxxx do_hash::input=c1bad4b39ca5a924e481008009d94e32+210</span>
95 2013-12-17 20:31:24 +0000 -- pipeline_instance qr1hi-d1hrv-tlkq20687akys8e
96 do_hash qr1hi-8i9sb-rffhuay4jryl2n2 queued 2013-12-17T20:31:24Z
97 filter  -                           -
98
99 2013-12-17 20:31:34 +0000 -- pipeline_instance qr1hi-d1hrv-tlkq20687akys8e
100 do_hash qr1hi-8i9sb-rffhuay4jryl2n2 {:done=>1, :running=>1, :failed=>0, :todo=>0}
101 filter  -                           -
102
103 2013-12-17 20:31:55 +0000 -- pipeline_instance qr1hi-d1hrv-tlkq20687akys8e
104 do_hash qr1hi-8i9sb-rffhuay4jryl2n2 50cafdb29cc21dd6eaec85ba9e0c6134+56
105 filter  qr1hi-8i9sb-j347g1sqovdh0op queued 2013-12-17T20:31:55Z
106
107 2013-12-17 20:32:05 +0000 -- pipeline_instance qr1hi-d1hrv-tlkq20687akys8e
108 do_hash qr1hi-8i9sb-rffhuay4jryl2n2 50cafdb29cc21dd6eaec85ba9e0c6134+56
109 filter  qr1hi-8i9sb-j347g1sqovdh0op 490cd451c8108824b8a17e3723e1f236+19
110 </code></pre>
111 </notextile>
112
113 Now check the output:
114
115 <notextile>
116 <pre><code>~$ <span class="userinput">arv keep get 50cafdb29cc21dd6eaec85ba9e0c6134+56/md5sum.txt</span>
117 44b8ae3fde7a8a88d2f7ebd237625b4f c1bad4b39ca5a924e481008009d94e32+210/./var-GS000016015-ASM.tsv.bz2
118 ~$ <span class="userinput">arv keep get 490cd451c8108824b8a17e3723e1f236+19/0-filter.txt</span>
119 </code></pre>
120 </notextile>
121
122 Since none of the files in the collection have hash code that start with 0, the output of the filter component is empty.