21700: Install Bundler system-wide in Rails postinst
[arvados.git] / doc / api / crunch-scripts.html.textile.liquid
1 ---
2 layout: default
3 navsection: api
4 navmenu: Concepts
5 title: Crunch scripts
6
7 ...
8 {% comment %}
9 Copyright (C) The Arvados Authors. All rights reserved.
10
11 SPDX-License-Identifier: CC-BY-SA-3.0
12 {% endcomment %}
13
14 {% include 'notebox_begin_warning' %}
15 This is a legacy API.  This endpoint is deprecated, disabled by default in new installations, and slated to be removed entirely in a future major release of Arvados.  It is replaced by "container requests.":methods/container_requests.html
16 {% include 'notebox_end' %}
17
18 h2. Crunch scripts
19
20 A crunch script is responsible for completing a single JobTask. In doing so, it will:
21
22 * (optionally) read some input from Keep
23 * (optionally) store some output in Keep
24 * (optionally) create some new JobTasks and add them to the current Job
25 * (optionally) update the current JobTask record with the "output" attribute set to a Keep locator or a fragment of a manifest
26 * update the current JobTask record with the "success" attribute set to True
27
28 A task's context is provided in environment variables.
29
30 table(table table-bordered table-condensed).
31 |Environment variable|Description|
32 |@JOB_UUID@|UUID of the current "Job":methods/jobs.html|
33 |@TASK_UUID@|UUID of the current "JobTask":methods/job_tasks.html|
34 |@ARVADOS_API_HOST@|Hostname and port number of API server|
35 |@ARVADOS_API_TOKEN@|Authentication token to use with API calls made by the current task|
36
37 The crunch script typically uses the Python SDK (or another suitable client library / SDK) to connect to the Arvados service and retrieve the rest of the details about the current job and task.
38
39 The Python SDK has some shortcuts for common operations.
40
41 In general, a crunch script can access information about the current job and task like this:
42
43 <pre>
44 import arvados
45 import os
46
47 job = arvados.api().jobs().get(uuid=os.environ['JOB_UUID']).execute()
48 $sys.stderr.write("script_parameters['foo'] == %s"
49                   % job['script_parameters']['foo'])
50
51 task = arvados.api().job_tasks().get(uuid=os.environ['TASK_UUID']).execute()
52 $sys.stderr.write("current task sequence number is %d"
53                   % task['sequence'])
54 </pre>