add job pages
[arvados.git] / doc / user / intro-jobs.textile
1 ---
2 layout: default
3 navsection: userguide
4 title: "Intro: Jobs"
5 navorder: 8
6 ---
7
8 h1. Intro: Jobs
9
10 You can run MapReduce jobs by storing a job script in a git repository and creating a [job](api-Jobs.html).
11
12 Batch jobs offer several advantages over running programs on your own local machine:
13
14 * Increase concurrency by running tasks asynchronously, using many CPUs and network interfaces at once (especially beneficial for CPU-bound and I/O-bound tasks respectively).
15
16 * Track inputs, outputs, and settings so you can verify that the inputs, settings, and sequence of programs you used to arrive at an output is really what you think it was. See [provenance](provenance.html).
17
18 * Ensure that your programs and workflows are repeatable with different versions of your code, OS updates, etc.
19
20 * Interrupt and resume long-running jobs consisting of many short tasks.
21
22 * Maintain timing statistics automatically, so they're there when you want them.
23
24 h3. Structure of a job
25
26 A job consists of a number of tasks which can be executed asynchronously.
27
28 A single batch job program, or "mr-function", executes each task of a given job.  The logic of a typical mr-function looks like this:
29
30 * If this is the first task: examine the input, divide it into a number of asynchronous tasks, instruct the Job Manager to queue these tasks, output nothing, and indicate successful completion.
31
32 * Otherwise, fetch a portion of the input from the cloud storage system, do some computation, store some output in the cloud, output a fragment of the output manifest, and indicate successful completion.
33
34 When all job tasks have completed, the output fragments are assembled into a single output manifest.
35
36 If a job task fails, it is automatically re-attempted.  If the same step fails 3 times, any tasks still running are allowed to complete, and the job is abandoned.
37
38 h3. Developing and testing job scripts
39
40 Usually, it makes sense to test your job script locally on small data sets.  When you are satisfied that it works, commit it to the git repository and run it in Arvados.
41
42 Save your job script (say, @foo@) in @{git-repo}/job_scripts/foo@
43
44 Test your function:
45
46 <pre>
47 arv-jobmanager revision={git-repo} script=foo ...
48 </pre>
49
50 The arguments to arv-jobmanager(1) are the same as the arguments to "arv jobs create" (see arv(1)) with these exceptions:
51
52 * script_version=/path/to/repo specifies the path to the working copy of a repository instead of a git commit or tag.
53
54 * resource constraints like nodes and RAM are not required.
55
56 You will see the progress of the job in your terminal.  Press Control-C to create a checkpoint and stop the job.