8860b8e1af774bfb017804e0021facd87e82980c
[arvados.git] / doc / user / tutorial-job1.textile
1 ---
2 layout: default
3 navsection: userguide
4 title: "Tutorial: Your first job"
5 navorder: 20
6 ---
7
8 h1. Tutorial: Your first job
9
10 Here you will use the "arv" command line tool to run a simple Crunch script on some sample data.
11
12 h3. Prerequisites
13
14 * Log in to a VM "using SSH":ssh-access.html
15 * Put an "API token":api-tokens.html in your @ARVADOS_API_TOKEN@ environment variable
16 * Put the API host name in your @ARVADOS_API_HOST@ environment variable
17
18 If everything is set up correctly, the command @arv -h user current@ will display your account information.
19
20 h3. Submit a job
21
22 We will run the "hash" program, which computes the MD5 hash of each file in a collection.
23
24 Pick a data collection. We'll use @f815ec01d5d2f11cb12874ab2ed50daa@ here.
25
26 <pre>
27 the_collection=f815ec01d5d2f11cb12874ab2ed50daa
28 </pre>
29
30 Pick a code version. We'll use @cdde7f246fec59bc99da86145fd4cf4efcf37a68@ here.
31
32 <pre>
33 the_version=cdde7f246fec59bc99da86145fd4cf4efcf37a68
34 </pre>
35
36 Make a JSON object describing the job.
37
38 <pre>
39 read -rd "\000" the_job <<EOF
40 {
41  "script":"hash",
42  "script_version":"$the_version",
43  "script_parameters":
44  {
45   "input":"$the_collection"
46  }
47 }
48 EOF
49 </pre>
50
51 (The @read -rd "\000"@ stuff just helps us get a multi-line string with lots of double quotation marks into a shell variable.)
52
53 Submit the job.
54
55 <pre>
56 arv -h job create --job "$the_job"
57 </pre>
58
59 Go to Workbench, drop down the Compute menu, and click Jobs. The job you submitted should appear at the top of the list.
60
61 Hit "Refresh" until it finishes.
62
63 You can also watch the log messages while the job runs:
64
65 <pre>
66 curl -s -H "Authorization: OAuth2 $ARVADOS_API_TOKEN" \
67   https://{{ site.arvados_api_host }}/arvados/v1/jobs/JOB_UUID_HERE/log_tail_follow
68 </pre>
69
70 Great. You ran a job!