Merge branch 'master' into 1971-show-image-thumbnails
[arvados.git] / doc / user / reference / job-and-pipeline-reference.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: "Job and Pipeline Reference"
5 ...
6
7 h2. Submitting jobs
8
9 table(table table-bordered table-condensed).
10 |_. Attribute               |_. Type|_. Accepted values                            |_. Required|_. Description|
11 |script                 |string     |filename                                      |yes        |The actual script that will be run by crunch.  Must be the name of an executable file in the crunch_scripts/ directory at the git revision specified by script_version.|
12 |script_version         |string     |git branch, tag, or version hash              |yes        |The code version to run, which is available in the specified repository.  May be a git hash or tag to specify an exact version, or a branch.  If it is a branch, use the branch head.|
13 |repository             |string     |name of git repository hosted by Arvados      |yes        |The repository to search for script_version.|
14 |script_parameters      |object     |any JSON object                               |yes        |The input parameters for the job, with the parameter names as keys mapping to parameter values.|
15 |minimum_script_version |string     |git branch, tag, or version hash              |no         |The minimum acceptable script version when deciding whether to re-use a past job.|
16 |exclude_script_versions|array of strings|git branch, tag, or version hash|no         |Script versions to exclude when deciding whether to re-use a past job.|
17 |nondeterministic       |boolean    |                                              |no         |If true, never re-use a past job, and flag this job so it will never be considered for re-use.|
18 |no_reuse               |boolean    |                                              |no         |If true, do not re-use a past job, but this job may be re-used.|
19
20 When a job is executed, the 'script_version' field is resolved to an exact git revision and the git hash for that revision is recorded in 'script_version'.  If 'script_version' can't be resolved, the job submission will be rejected.
21
22 h3. Reusing jobs
23
24 Because Arvados records the exact version of the script, input parameters, and runtime environment [1] that was used to run the job, if the script is deterministic (meaning that the same code version is guaranteed to produce the same outputs from the same inputs) then it is possible to re-use the results of past jobs, and avoid re-running the computation to save time.  Arvados uses the following algorithm to determine if a past job can be re-used:
25
26 notextile. <div class="spaced-out">
27
28 # If 'nondeterministic' or 'no_reuse' are true, always create a new job.
29 # Find a list of acceptable values for 'script_version'.  If 'minimum_script_version' is specified, this is the set of all revisions in the git commit graph between 'minimum_script_version' and 'script_version' (inclusive) [2].  If 'minimum_script_version' is not specified, only 'script_version' is added to the list.  If 'exclude_script_versions' is specified, the listed versions are excluded from the list.
30 # Select jobs have the same 'script' and 'script_parameters' attributes, and where the 'script_version' attribute is in the list of acceptable versions.  Exclude jobs that failed or set 'nondeterministic' to true.
31 # If there is more than one candidate job, check that all selected past jobs actually did produce the same output.
32 # If everything passed, re-use one of the selected past jobs (if there is more than one match, which job will be returned is undefined).  Otherwise create a new job.
33
34 fn1. As of this writing, versioning the runtime environment is still under development.
35
36 fn2. This may include parallel branches if there is more than one path between 'minimum_script_version' and 'script_version' in the git commit graph.  Use 'exclude_script_versions' to blacklist specific versions.
37
38 </div>
39
40 h3. Examples
41
42 Run the script "crunch_scripts/hash.py" in the repository "you" using the "master" branch head.  Arvados is allowed to re-use a previous job if the script_version of the past job is the same as the "master" branch head (i.e., there have not been any subsequent commits to "master").
43
44 <notextile><pre>
45 {
46   "script": "hash.py",
47   "repository": "<b>you</b>",
48   "script_version": "master",
49   "script_parameters": {
50     "input": "c1bad4b39ca5a924e481008009d94e32+210"
51   }
52 }
53 </pre></notextile>
54
55 Run using exactly the version "d00220fb38d4b85ca8fc28a8151702a2b9d1dec5". Arvados is allowed to re-use a previous job if the "script_version" of that job is also "d00220fb38d4b85ca8fc28a8151702a2b9d1dec5".
56
57 <notextile><pre>
58 {
59   "script": "hash.py",
60   "repository": "<b>you</b>",
61   "script_version": "d00220fb38d4b85ca8fc28a8151702a2b9d1dec5",
62   "script_parameters": {
63     "input": "c1bad4b39ca5a924e481008009d94e32+210"
64   }
65 }
66 </pre></notextile>
67
68 Arvados is allowed to re-use a previous job if the "script_version" of the past job is between "earlier_version_tag" and the head of the "master" branch (inclusive), but not "blacklisted_version_tag".  If there are no previous jobs, run the job using the head of the "master" branch as specified in "script_version".
69
70 <notextile><pre>
71 {
72   "script": "hash.py",
73   "repository": "<b>you</b>",
74   "minimum_script_version": "earlier_version_tag",
75   "script_version": "master",
76   "exclude_script_versions": ["blacklisted_version_tag"],
77   "script_parameters": {
78     "input": "c1bad4b39ca5a924e481008009d94e32+210"
79   }
80 }
81 </pre></notextile>
82
83 Run the script "crunch_scripts/monte-carlo.py" in the repository "you" using the "master" branch head.  Because it is marked as "nondeterministic", never re-use previous jobs, and never re-use this job.
84
85 <notextile><pre>
86 {
87   "script": "monte-carlo.py",
88   "repository": "<b>you</b>",
89   "script_version": "master",
90   "nondeterministic": true,
91   "script_parameters": {
92     "input": "c1bad4b39ca5a924e481008009d94e32+210"
93   }
94 }
95 </pre></notextile>
96
97 h2. Pipelines
98
99 Pipelines consist of a set of "components".  Each component is an Arvados job submission, so when a component job is submitted, Arvados may re-use past jobs based on the rules described above.
100
101 table(table table-bordered table-condensed).
102 |_. Attribute    |_. Type |_. Accepted values                           |_. Required|_. Description|
103 |name            |string  |any                                          |yes        |The human-readable name of the pipeline template.|
104 |components      |object  |JSON object containing job submission objects|yes        |The component jobs that make up the pipeline, with the component name as the key. |
105
106 h3. Script parameters
107
108 When used in a pipeline, each parameter in the 'script_parameters' attribute of a component job can specify that the input parameter must be supplied by the user, or the input parameter should be linked to the output of another component.  To do this, the value of the parameter should be JSON object containing one of the following attributes:
109
110 table(table table-bordered table-condensed).
111 |_. Attribute    |_. Type |_. Accepted values                               |_. Description|
112 |default         |any     |any                                              |The default value for this parameter.|
113 |required        |boolean |true or false                                    |Specifies whether the parameter is required to have a value or not.|
114 |dataclass       |string  |One of 'Collection', 'File' [3], 'number', or 'text' |Data type of this parameter.|
115 |output_of       |string  |the name of another component in the pipeline    |Specifies that the value of this parameter should be set to the 'output' attribute of the job that corresponds to the specified component.|
116
117 The 'output_of' parameter is especially important, as this is how components are actually linked together to form a pipeline.  Component jobs that depend on the output of other components do not run until the parent job completes and has produced output.  If the parent job fails, the entire pipeline fails.
118
119 fn3. The 'File' type refers to a specific file within a Keep collection in the form 'collection_hash/filename', for example '887cd41e9c613463eab2f0d885c6dd96+83/bob.txt'.
120
121 h3. Examples
122
123 This is a pipeline named "Filter md5 hash values" with two components, "do_hash" and "filter".  The "input" script parameter of the "do_hash" component is required to be filled in by the user, and the expected data type is "Collection".  This also specifies that the "input" script parameter of the "filter" component is the output of "do_hash", so "filter" will not run until "do_hash" completes successfully.  When the pipeline runs, past jobs that meet the criteria described above may be substituted for either or both components to avoid redundant computation.
124
125 <notextile><pre>
126 {
127   "name": "Filter md5 hash values",
128   "components": {
129     "do_hash": {
130       "script": "hash.py",
131       "repository": "<b>you</b>",
132       "script_version": "master",
133       "script_parameters": {
134         "input": {
135           "required": true,
136           "dataclass": "Collection"
137         }
138       },
139     },
140     "filter": {
141       "script": "0-filter.py",
142       "repository": "<b>you</b>",
143       "script_version": "master",
144       "script_parameters": {
145         "input": {
146           "output_of": "do_hash"
147         }
148       },
149     }
150   }
151 }
152 </pre></notextile>
153
154 This pipeline consists of three components.  The components "thing1" and "thing2" both depend on "cat_in_the_hat".  Once the "cat_in_the_hat" job is complete, both "thing1" and "thing2" can run in parallel, because they do not depend on each other.
155
156 <notextile><pre>
157 {
158   "name": "Wreck the house",
159   "components": {
160     "cat_in_the_hat": {
161       "script": "cat.py",
162       "repository": "<b>you</b>",
163       "script_version": "master",
164       "script_parameters": { }
165     },
166     "thing1": {
167       "script": "thing1.py",
168       "repository": "<b>you</b>",
169       "script_version": "master",
170       "script_parameters": {
171         "input": {
172           "output_of": "cat_in_the_hat"
173         }
174       },
175     },
176     "thing2": {
177       "script": "thing2.py",
178       "repository": "<b>you</b>",
179       "script_version": "master",
180       "script_parameters": {
181         "input": {
182           "output_of": "cat_in_the_hat"
183         }
184       },
185     },
186   }
187 }
188 </pre></notextile>
189
190 This pipeline consists of three components.  The component "cleanup" depends on "thing1" and "thing2".  Both "thing1" and "thing2" are started immediately and can run in parallel, because they do not depend on each other, but "cleanup" cannot begin until both "thing1" and "thing2" have completed.
191
192 <notextile><pre>
193 {
194   "name": "Clean the house",
195   "components": {
196     "thing1": {
197       "script": "thing1.py",
198       "repository": "<b>you</b>",
199       "script_version": "master",
200       "script_parameters": { }
201     },
202     "thing2": {
203       "script": "thing2.py",
204       "repository": "<b>you</b>",
205       "script_version": "master",
206       "script_parameters": { }
207     },
208     "cleanup": {
209       "script": "cleanup.py",
210       "repository": "<b>you</b>",
211       "script_version": "master",
212       "script_parameters": {
213         "mess1": {
214           "output_of": "thing1"
215         },
216         "mess2": {
217           "output_of": "thing2"
218         }
219       }
220     }
221   }
222 }
223 </pre></notextile>