Merge branch 'master' into 1971-show-image-thumbnails
[arvados.git] / doc / user / tutorials / tutorial-new-pipeline.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: "Writing a multi-step pipeline"
5 ...
6
7 A pipeline in Arvados is a collection of crunch scripts, in which the output from one script may be used as the input to another script.
8
9 *This tutorial assumes that you are "logged into an Arvados VM instance":{{site.baseurl}}/user/getting_started/ssh-access.html#login, and have a "working environment.":{{site.baseurl}}/user/getting_started/check-environment.html*
10
11 This tutorial uses *@you@* to denote your username.  Replace *@you@* with your user name in all the following examples.
12
13 h2. Create a new script
14
15 Our second script will filter the output of @hash.py@ and only include hashes that start with 0.  Create a new script in <notextile><code>~/<b>you</b>/crunch_scripts/</code></notextile> called @0-filter.py@:
16
17 <notextile> {% code '0_filter_py' as python %} </notextile>
18
19 Now add it to git:
20
21 <notextile>
22 <pre><code>~/<b>you</b>/crunch_scripts$ <span class="userinput">chmod +x 0-filter.py</span>
23 ~/<b>you</b>/crunch_scripts$ <span class="userinput">git add 0-filter.py</span>
24 ~/<b>you</b>/crunch_scripts$ <span class="userinput">git commit -m"zero filter"</span>
25 ~/<b>you</b>/crunch_scripts$ <span class="userinput">git push origin master</span>
26 </code></pre>
27 </notextile>
28
29 h2. Create a pipeline template
30
31 Next, create a file that contains the pipeline definition:
32
33 <notextile>
34 <pre><code>~/<b>you</b>/crunch_scripts$ <span class="userinput">cat &gt;~/the_pipeline &lt;&lt;EOF
35 {
36   "name":"Filter md5 hash values",
37   "components":{
38     "do_hash":{
39       "script":"hash.py",
40       "script_parameters":{
41         "input":{
42           "required": true,
43           "dataclass": "Collection"
44         }
45       },
46       "repository":"$USER",
47       "script_version":"master",
48       "output_is_persistent":false
49     },
50     "do_filter":{
51       "script":"0-filter.py",
52       "script_parameters":{
53         "input":{
54           "output_of":"do_hash"
55         }
56       },
57       "repository":"$USER",
58       "script_version":"master",
59       "output_is_persistent":true
60     }
61   }
62 }
63 EOF
64 </span></code></pre>
65 </notextile>
66
67 * @"output_of"@ indicates that the @output@ of the @do_hash@ component should be used as the @"input"@ of @do_filter@.  Arvados uses these dependencies between jobs to automatically determine the correct order to run them.
68
69 (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.)
70
71 Now, use @arv pipeline_template create@ to register your pipeline template in Arvados:
72
73 <notextile>
74 <pre><code>~/<b>you</b>/crunch_scripts$ <span class="userinput">arv pipeline_template create --pipeline-template "$(cat ~/the_pipeline)"</span>
75 </code></pre>
76 </notextile>
77
78 Your new pipeline template will appear on the Workbench "Compute %(rarr)&rarr;% Pipeline&nbsp;templates":https://{{ site.arvados_workbench_host }}/pipeline_instances page.