From f0fb7a9925a4b561a3684753fe3614ae2f5a1288 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 28 Nov 2013 13:09:27 -0800 Subject: [PATCH] Show how crunch job tasks get their runtime parameters. refs #1513 --- doc/api/crunch-scripts.textile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/api/crunch-scripts.textile b/doc/api/crunch-scripts.textile index f41d236d99..859e5a722b 100644 --- a/doc/api/crunch-scripts.textile +++ b/doc/api/crunch-scripts.textile @@ -21,9 +21,25 @@ table(table table-bordered table-condensed). |Environment variable|Description| |@JOB_UUID@|UUID of the current "Job":Jobs.html| |@TASK_UUID@|UUID of the current "JobTask":JobTasks.html| -|@TASK_QSEQUENCE@|Number of tasks added to this job before this one (in other words, 0-based queue entry order)| -|@TASK_SEQUENCE@|Task execution sequence specified when task was created — generally not unique to this task| |@ARVADOS_API_HOST@|Hostname and port number of API server| |@ARVADOS_API_TOKEN@|Authentication token to use with API calls made by the current task| 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. + +The Python SDK has some shortcuts for common operations. + +In general, a crunch script can access information about the current job and task like this: + +
+import arvados
+import os
+
+job = arvados.api().jobs().get(uuid=os.environ['JOB_UUID']).execute()
+$sys.stderr.write("script_parameters['foo'] == %s"
+                  % job['script_parameters']['foo'])
+
+task = arvados.api().job_tasks().get(uuid=os.environ['TASK_UUID']).execute()
+$sys.stderr.write("current task sequence number is %d"
+                  % task['sequence'])
+
+ -- 2.39.5