Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / doc / api / methods / jobs.html.textile.liquid
1 ---
2 layout: default
3 navsection: api
4 navmenu: API Methods
5 title: "jobs"
6
7 ...
8
9 See "REST methods for working with Arvados resources":{{site.baseurl}}/api/methods.html
10
11 API endpoint base: @https://{{ site.arvados_api_host }}/arvados/v1/jobs@
12
13 Required arguments are displayed in %{background:#ccffcc}green%.
14
15 h2. cancel
16
17 Cancel a job that is queued or running.
18
19 Arguments:
20
21 table(table table-bordered table-condensed).
22 |_. Argument |_. Type |_. Description |_. Location |_. Example |
23 {background:#ccffcc}.|uuid|string||path||
24
25 h2(#create). create
26
27 Create a new Job.
28
29 Arguments:
30
31 table(table table-bordered table-condensed).
32 |_. Argument |_. Type |_. Description |_. Location |_. Example |
33 {background:#ccffcc}.|job|object|See "Job resource":{{site.baseurl}}/api/schema/Job.html|request body||
34 |minimum_script_version |string     |Git branch, tag, or commit hash specifying the minimum acceptable script version (earliest ancestor) to consider when deciding whether to re-use a past job.[1]|query|@"c3e86c9"@|
35 |exclude_script_versions|array of strings|Git commit branches, tags, or hashes to exclude when deciding whether to re-use a past job.|query|@["8f03c71","8f03c71"]@
36 @["badtag1","badtag2"]@|
37 |filters|array|Conditions to find Jobs to reuse.|query||
38 |find_or_create         |boolean    |Before creating, look for an existing job that has identical script, script_version, and script_parameters to those in the present job, has nondeterministic=false, and did not fail (it could be queued, running, or completed). If such a job exists, respond with the existing job instead of submitting a new one.|query|@false@|
39
40 When a job is submitted to the queue using the **create** method, the @script_version@ attribute is updated to a full 40-character Git commit hash based on the current content of the specified repository. If @script_version@ cannot be resolved, the job submission is rejected.
41
42 fn1. See the "note about specifying Git commits on the Job resource page":{{site.baseurl}}/api/schema/Job.html#script_version for more detail.
43
44 h3. Specialized filters
45
46 Special filter operations are available for specific Job columns.
47
48 * @script_version@ @in git@ @REFSPEC@, @arvados_sdk_version@ @in git@ @REFSPEC@<br>Resolve @REFSPEC@ to a list of Git commits, and match jobs with a @script_version@ or @arvados_sdk_version@ in that list.  When creating a job and filtering @script_version@, the search will find commits between @REFSPEC@ and the submitted job's @script_version@; all other searches will find commits between @REFSPEC@ and HEAD.  This list may include parallel branches if there is more than one path between @REFSPEC@ and the end commit in the graph.  Use @not in@ or @not in git@ filters (below) to blacklist specific commits.
49
50 * @script_version@ @not in git@ @REFSPEC@, @arvados_sdk_version@ @not in git@ @REFSPEC@<br>Resolve @REFSPEC@ to a list of Git commits, and match jobs with a @script_version@ or @arvados_sdk_version@ not in that list.
51
52 * @docker_image_locator@ @in docker@ @SEARCH@<br>@SEARCH@ can be a Docker image hash, a repository name, or a repository name and tag separated by a colon (@:@).  The server will find collections that contain a Docker image that match that search criteria, then match jobs with a @docker_image_locator@ in that list.
53
54 * @docker_image_locator@ @not in docker@ @SEARCH@<br>Negate the @in docker@ filter.
55
56 h3. Reusing jobs
57
58 Because Arvados records the exact version of the script, input parameters, and runtime environment 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:
59
60 notextile. <div class="spaced-out">
61
62 # If @find_or_create@ is false or omitted, create a new job and skip the rest of these steps.
63 # If @filters@ are specified, find jobs that match those filters.  Filters *must* be specified to limit the @repository@ and @script@ attributes.  An error is returned if they are missing.
64 # If @filters@ are not specified, find jobs with the same @repository@ and @script@, with a @script_version@ between @minimum_script_version@ and @script_version@ (excluding @excluded_script_versions@), and a @docker_image_locator@ with the latest Collection that matches the submitted job's @docker_image@ constraint.  If the submitted job includes an @arvados_sdk_version@ constraint, jobs must have an @arvados_sdk_version@ between that refspec and HEAD to be found.
65 # If the found jobs include a completed job, and all found completed jobs have consistent output, return one of them.  Which specific job is returned is undefined.
66 # If the found jobs only include incomplete jobs, return one of them.  Which specific job is returned is undefined.
67 # If no job has been returned so far, create and return a new job.
68
69 </div>
70
71 h3. Examples
72
73 Run the script "crunch_scripts/hash.py" in the repository "you" using the "master" commit.  Arvados should re-use a previous job if the script_version of the previous job is the same as the current "master" commit. This works irrespective of whether the previous job was submitted using the name "master", a different branch name or tag indicating the same commit, a SHA-1 commit hash, etc.
74
75 <notextile><pre>
76 {
77   "job": {
78     "script": "hash.py",
79     "repository": "<b>you</b>",
80     "script_version": "master",
81     "script_parameters": {
82       "input": "c1bad4b39ca5a924e481008009d94e32+210"
83     }
84   },
85   "find_or_create": true
86 }
87 </pre></notextile>
88
89 Run using exactly the version "d00220fb38d4b85ca8fc28a8151702a2b9d1dec5". Arvados should re-use a previous job if the "script_version" of that job is also "d00220fb38d4b85ca8fc28a8151702a2b9d1dec5".
90
91 <notextile><pre>
92 {
93   "job": {
94     "script": "hash.py",
95     "repository": "<b>you</b>",
96     "script_version": "d00220fb38d4b85ca8fc28a8151702a2b9d1dec5",
97     "script_parameters": {
98       "input": "c1bad4b39ca5a924e481008009d94e32+210"
99     }
100   },
101   "find_or_create": true
102 }
103 </pre></notextile>
104
105 Arvados should re-use a previous job if the "script_version" of the previous job is between "earlier_version_tag" and the "master" commit (inclusive), but not the commit indicated by "blacklisted_version_tag". If there are no previous jobs matching these criteria, run the job using the "master" commit.
106
107 <notextile><pre>
108 {
109   "job": {
110     "script": "hash.py",
111     "repository": "<b>you</b>",
112     "script_version": "master",
113     "script_parameters": {
114       "input": "c1bad4b39ca5a924e481008009d94e32+210"
115     }
116   },
117   "minimum_script_version": "earlier_version_tag",
118   "exclude_script_versions": ["blacklisted_version_tag"],
119   "find_or_create": true
120 }
121 </pre></notextile>
122
123 The same behavior, using filters:
124
125 <notextile><pre>
126 {
127   "job": {
128     "script": "hash.py",
129     "repository": "<b>you</b>",
130     "script_version": "master",
131     "script_parameters": {
132       "input": "c1bad4b39ca5a924e481008009d94e32+210"
133     }
134   },
135   "filters": [["script", "=", "hash.py"],
136               ["repository", "=", "<b>you</b>"],
137               ["script_version", "in git", "earlier_version_tag"],
138               ["script_version", "not in git", "blacklisted_version_tag"]],
139   "find_or_create": true
140 }
141 </pre></notextile>
142
143 Run the script "crunch_scripts/monte-carlo.py" in the repository "you" using the current "master" commit. Because it is marked as "nondeterministic", this job will not be considered as a suitable candidate for future job submissions that use the "find_or_create" feature.
144
145 <notextile><pre>
146 {
147   "job": {
148     "script": "monte-carlo.py",
149     "repository": "<b>you</b>",
150     "script_version": "master",
151     "nondeterministic": true,
152     "script_parameters": {
153       "input": "c1bad4b39ca5a924e481008009d94e32+210"
154     }
155   }
156 }
157 </pre></notextile>
158
159 h2. delete
160
161 Delete an existing Job.
162
163 Arguments:
164
165 table(table table-bordered table-condensed).
166 |_. Argument |_. Type |_. Description |_. Location |_. Example |
167 {background:#ccffcc}.|uuid|string|The UUID of the Job in question.|path||
168
169 h2. get
170
171 Gets a Job's metadata by UUID.
172
173 Arguments:
174
175 table(table table-bordered table-condensed).
176 |_. Argument |_. Type |_. Description |_. Location |_. Example |
177 {background:#ccffcc}.|uuid|string|The UUID of the Job in question.|path||
178
179 h2. list
180
181 List jobs.
182
183 Arguments:
184
185 table(table table-bordered table-condensed).
186 |_. Argument |_. Type |_. Description |_. Location |_. Example |
187 |limit|integer (default 100)|Maximum number of jobs to return.|query||
188 |order|string|Order in which to return matching jobs.|query||
189 |filters|array|Conditions for filtering jobs.|query||
190
191 See the create method documentation for more information about Job-specific filters.
192
193 h2. log_tail_follow
194
195 log_tail_follow jobs
196
197 Arguments:
198
199 table(table table-bordered table-condensed).
200 |_. Argument |_. Type |_. Description |_. Location |_. Example |
201 {background:#ccffcc}.|uuid|string||path||
202 |buffer_size|integer (default 8192)||query||
203
204 h2. queue
205
206 Get the current job queue.
207
208 Arguments:
209
210 table(table table-bordered table-condensed).
211 |_. Argument |_. Type |_. Description |_. Location |_. Example |
212 |order|string||query||
213 |filters|array||query||
214
215 This method is equivalent to the "list method":#list, except that the results are restricted to queued jobs (i.e., jobs that have not yet been started or cancelled) and order defaults to queue priority.
216
217 h2. update
218
219 Update attributes of an existing Job.
220
221 Arguments:
222
223 table(table table-bordered table-condensed).
224 |_. Argument |_. Type |_. Description |_. Location |_. Example |
225 {background:#ccffcc}.|uuid|string|The UUID of the Job in question.|path||
226 |job|object||query||