Reorganizing documentation work in progress, checkpointing so that Brett can start...
[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 h2. Create a new script
12
13 Our second script will filter the output of @hash.py@ and only include hashes that start with 0.  Create a new script in @crunch_scripts/@ called @0-filter.py@:
14
15 <notextile> {% code '0_filter_py' as python %} </notextile>
16
17 Now add it to git:
18
19 <notextile>
20 <pre><code>$ <span class="userinput">git add 0-filter.py</span>
21 $ <span class="userinput">git commit -m"zero filter"</span>
22 $ <span class="userinput">git push origin master</span>
23 </code></pre>
24 </notextile>
25
26 h2. Create a pipeline template
27
28 Next, create a file that contains the pipeline definition:
29
30 <notextile>
31 <pre><code>$ <span class="userinput">cat &gt;the_pipeline &lt;&lt;EOF
32 {
33   "name":"Filter md5 hash values",
34   "components":{
35     "do_hash":{
36       "script":"hash.py",
37       "script_parameters":{
38         "input":{
39           "required": true,
40           "dataclass": "Collection"
41         }
42       },
43       "script_version":"you:master"
44     },
45     "filter":{
46       "script":"0-filter.py",
47       "script_parameters":{
48         "input":{
49           "output_of":"do_hash"
50         }
51       },
52       "script_version":"you:master"
53     }
54   }
55 }
56 EOF
57 </span></code></pre>
58 </notextile>
59
60 * @"output_of"@ indicates that the @input@ of the @do_hash@ component is connected to the @output@ of @filter@.  This is a _dependency_.  Arvados uses the dependencies between jobs to automatically determine the correct order to run the jobs.
61
62 Now, use @arv pipeline_template create@ tell Arvados about your pipeline template:
63
64 <notextile>
65 <pre><code>$ <span class="userinput">arv pipeline_template create --pipeline-template "$(cat the_pipeline)"</span>
66 </code></pre>
67 </notextile>
68
69 Your new pipeline template will appear on the "Workbench %(rarr)&rarr;% Compute %(rarr)&rarr;% Pipeline&nbsp;templates":http://{{ site.arvados_workbench_host }}/pipeline_instances page.
70