Merge branch '16678-login-tokens-lifetime-config'
[arvados.git] / doc / user / topics / tutorial-job1.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: "Running a Crunch job on the command line"
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 This tutorial introduces how to run individual Crunch jobs using the @arv@ command line tool.
13
14 {% include 'tutorial_expectations' %}
15
16 You will create a job to run the "hash" Crunch script.  The "hash" script computes the MD5 hash of each file in a collection.
17
18 h2. Jobs
19
20 Crunch pipelines consist of one or more jobs.  A "job" is a single run of a specific version of a Crunch script with a specific input.  You can also run jobs individually.
21
22 A request to run a Crunch job are is described using a JSON object.  For example:
23
24 <notextile>
25 <pre><code>~$ <span class="userinput">cat &gt;~/the_job &lt;&lt;EOF
26 {
27  "script": "hash",
28  "repository": "arvados",
29  "script_version": "master",
30  "script_parameters": {
31   "input": "c1bad4b39ca5a924e481008009d94e32+210"
32  },
33  "no_reuse": "true"
34 }
35 EOF
36 </code></pre>
37 </notextile>
38
39 * @cat@ is a standard Unix utility that writes a sequence of input to standard output.
40 * @<<EOF@ tells the shell to direct the following lines into the standard input for @cat@ up until it sees the line @EOF@.
41 * @>~/the_job@ redirects standard output to a file called @~/the_job@.
42 * @"repository"@ is the name of a Git repository to search for the script version.  You can access a list of available git repositories on the Arvados Workbench under "*Code repositories*":{{site.arvados_workbench_host}}/repositories.
43 * @"script_version"@ specifies the version of the script that you wish to run.  This can be in the form of an explicit Git revision hash, a tag, or a branch.  Arvados logs the script version that was used in the run, enabling you to go back and re-run any past job with the guarantee that the exact same code will be used as was used in the previous run.
44 * @"script"@ specifies the name of the script to run.  The script must be given relative to the @crunch_scripts/@ subdirectory of the Git repository.
45 * @"script_parameters"@ are provided to the script.  In this case, the input is the PGP data Collection that we "put in Keep earlier":{{site.baseurl}}/user/tutorials/tutorial-keep.html.
46 * Setting the @"no_reuse"@ flag tells Crunch not to reuse work from past jobs.  This helps ensure that you can watch a new Job process for the rest of this tutorial, without reusing output from a past run that you made, or somebody else marked as public.  (If you want to experiment, after the first run below finishes, feel free to edit this job to remove the @"no_reuse"@ line and resubmit it.  See what happens!)
47
48 Use @arv job create@ to actually submit the job.  It should print out a JSON object which describes the newly created job:
49
50 <notextile>
51 <pre><code>~$ <span class="userinput">arv job create --job "$(cat ~/the_job)"</span>
52 {
53  "href":"https://qr1hi.arvadosapi.com/arvados/v1/jobs/qr1hi-8i9sb-1pm1t02dezhupss",
54  "kind":"arvados#job",
55  "etag":"ax3cn7w9whq2hdh983yxvq09p",
56  "uuid":"qr1hi-8i9sb-1pm1t02dezhupss",
57  "owner_uuid":"qr1hi-tpzed-9zdpkpni2yddge6",
58  "created_at":"2013-12-16T20:44:32Z",
59  "modified_by_client_uuid":"qr1hi-ozdt8-obw7foaks3qjyej",
60  "modified_by_user_uuid":"qr1hi-tpzed-9zdpkpni2yddge6",
61  "modified_at":"2013-12-16T20:44:32Z",
62  "updated_at":"2013-12-16T20:44:33Z",
63  "submit_id":null,
64  "priority":null,
65  "script":"hash",
66  "script_parameters":{
67   "input":"c1bad4b39ca5a924e481008009d94e32+210"
68  },
69  "script_version":"d9cd657b733d578ac0d2167dd75967aa4f22e0ac",
70  "cancelled_at":null,
71  "cancelled_by_client_uuid":null,
72  "cancelled_by_user_uuid":null,
73  "started_at":null,
74  "finished_at":null,
75  "output":null,
76  "success":null,
77  "running":null,
78  "is_locked_by_uuid":null,
79  "log":null,
80  "runtime_constraints":{},
81  "tasks_summary":{}
82 }
83 </code></pre>
84 </notextile>
85
86 The job is now queued and will start running as soon as it reaches the front of the queue.  Fields to pay attention to include:
87
88  * @"uuid"@ is the unique identifier for this specific job.
89  * @"script_version"@ is the actual revision of the script used.  This is useful if the version was described using the "repository:branch" format.
90
91 h2. Monitor job progress
92
93 Go to "*Recent jobs*":{{site.arvados_workbench_host}}/jobs in Workbench.  Your job should be near the top of the table.  This table refreshes automatically.  When the job has completed successfully, it will show <span class="label label-success">finished</span> in the *Status* column.
94
95 h2. Inspect the job output
96
97 On the "Workbench Dashboard":{{site.arvados_workbench_host}}, look for the *Output* column of the *Recent jobs* table.  Click on the link under *Output* for your job to go to the files page with the job output.  The files page lists all the files that were output by the job.  Click on the link under the *file* column to view a file, or click on the download button <span class="glyphicon glyphicon-download-alt"></span> to download the output file.
98
99 On the command line, you can use @arv job get@ to access a JSON object describing the output:
100
101 <notextile>
102 <pre><code>~$ <span class="userinput">arv job get --uuid qr1hi-8i9sb-xxxxxxxxxxxxxxx</span>
103 {
104  "href":"https://qr1hi.arvadosapi.com/arvados/v1/jobs/qr1hi-8i9sb-1pm1t02dezhupss",
105  "kind":"arvados#job",
106  "etag":"1bk98tdj0qipjy0rvrj03ta5r",
107  "uuid":"qr1hi-8i9sb-1pm1t02dezhupss",
108  "owner_uuid":"qr1hi-tpzed-9zdpkpni2yddge6",
109  "created_at":"2013-12-16T20:44:32Z",
110  "modified_by_client_uuid":null,
111  "modified_by_user_uuid":"qr1hi-tpzed-9zdpkpni2yddge6",
112  "modified_at":"2013-12-16T20:44:55Z",
113  "updated_at":"2013-12-16T20:44:55Z",
114  "submit_id":null,
115  "priority":null,
116  "script":"hash",
117  "script_parameters":{
118   "input":"c1bad4b39ca5a924e481008009d94e32+210"
119  },
120  "script_version":"d9cd657b733d578ac0d2167dd75967aa4f22e0ac",
121  "cancelled_at":null,
122  "cancelled_by_client_uuid":null,
123  "cancelled_by_user_uuid":null,
124  "started_at":"2013-12-16T20:44:36Z",
125  "finished_at":"2013-12-16T20:44:53Z",
126  "output":"dd755dbc8d49a67f4fe7dc843e4f10a6+54",
127  "success":true,
128  "running":false,
129  "is_locked_by_uuid":"qr1hi-tpzed-9zdpkpni2yddge6",
130  "log":"2afdc6c8b67372ffd22d8ce89d35411f+91",
131  "runtime_constraints":{},
132  "tasks_summary":{
133   "done":2,
134   "running":0,
135   "failed":0,
136   "todo":0
137  }
138 }
139 </code></pre>
140 </notextile>
141
142 * @"output"@ is the unique identifier for this specific job's output.  This is a Keep collection.  Because the output of Arvados jobs should be deterministic, the known expected output is <code>dd755dbc8d49a67f4fe7dc843e4f10a6+54</code>.
143
144 Now you can list the files in the collection:
145
146 <notextile>
147 <pre><code>~$ <span class="userinput">arv keep ls dd755dbc8d49a67f4fe7dc843e4f10a6+54</span>
148 ./md5sum.txt
149 </code></pre>
150 </notextile>
151
152 This collection consists of the @md5sum.txt@ file.  Use @arv-get@ to show the contents of the @md5sum.txt@ file:
153
154 <notextile>
155 <pre><code>~$ <span class="userinput">arv-get dd755dbc8d49a67f4fe7dc843e4f10a6+54/md5sum.txt</span>
156 44b8ae3fde7a8a88d2f7ebd237625b4f ./var-GS000016015-ASM.tsv.bz2
157 </code></pre>
158 </notextile>
159
160 This MD5 hash matches the MD5 hash which we "computed earlier":{{site.baseurl}}/user/tutorials/tutorial-keep.html.
161
162 h2. The job log
163
164 When the job completes, you can access the job log.  On the Workbench, visit "*Recent jobs*":{{site.arvados_workbench_host}}/jobs %(rarr)&rarr;% your job's UUID under the *uuid* column %(rarr)&rarr;% the collection link on the *log* row.
165
166 On the command line, the Keep identifier listed in the @"log"@ field from @arv job get@ specifies a collection.  You can list the files in the collection:
167
168 <notextile>
169 <pre><code>~$ <span class="userinput">arv keep ls xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+91</span>
170 ./qr1hi-8i9sb-xxxxxxxxxxxxxxx.log.txt
171 </code></pre>
172 </notextile>
173
174 The log collection consists of one log file named with the job's UUID.  You can access it using @arv-get@:
175
176 <notextile>
177 <pre><code>~$ <span class="userinput">arv-get xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+91/qr1hi-8i9sb-xxxxxxxxxxxxxxx.log.txt</span>
178 2013-12-16_20:44:35 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  check slurm allocation
179 2013-12-16_20:44:35 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  node compute13 - 8 slots
180 2013-12-16_20:44:36 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  start
181 2013-12-16_20:44:36 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  Install revision d9cd657b733d578ac0d2167dd75967aa4f22e0ac
182 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  Clean-work-dir exited 0
183 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  Install exited 0
184 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  script hash
185 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  script_version d9cd657b733d578ac0d2167dd75967aa4f22e0ac
186 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  script_parameters {"input":"c1bad4b39ca5a924e481008009d94e32+210"}
187 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  runtime_constraints {"max_tasks_per_node":0}
188 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  start level 0
189 2013-12-16_20:44:37 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  status: 0 done, 0 running, 1 todo
190 2013-12-16_20:44:38 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 0 job_task qr1hi-ot0gb-23c1k3kwrf8da62
191 2013-12-16_20:44:38 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 0 child 7681 started on compute13.1
192 2013-12-16_20:44:38 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  status: 0 done, 1 running, 0 todo
193 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 0 child 7681 on compute13.1 exit 0 signal 0 success=true
194 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 0 success in 1 seconds
195 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 0 output
196 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  wait for last 0 children to finish
197 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  status: 1 done, 0 running, 1 todo
198 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  start level 1
199 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  status: 1 done, 0 running, 1 todo
200 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 1 job_task qr1hi-ot0gb-iwr0o3unqothg28
201 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 1 child 7716 started on compute13.1
202 2013-12-16_20:44:39 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  status: 1 done, 1 running, 0 todo
203 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 1 child 7716 on compute13.1 exit 0 signal 0 success=true
204 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 1 success in 13 seconds
205 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575 1 output dd755dbc8d49a67f4fe7dc843e4f10a6+54
206 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  wait for last 0 children to finish
207 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  status: 2 done, 0 running, 0 todo
208 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  release job allocation
209 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  Freeze not implemented
210 2013-12-16_20:44:52 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  collate
211 2013-12-16_20:44:53 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  output dd755dbc8d49a67f4fe7dc843e4f10a6+54+K@qr1hi
212 2013-12-16_20:44:53 qr1hi-8i9sb-xxxxxxxxxxxxxxx 7575  finish
213 </code></pre>
214 </notextile>