5 import arvados.collection
7 from cwltool.process import shortname
13 from arvados.api import OrderedJsonModel
14 from cwltool.process import adjustFiles
16 api = arvados.api("v1")
19 job_order_object = arvados.current_job()['script_parameters']
21 print job_order_object
24 if arvados.util.keep_locator_pattern.match(v):
25 return "file://%s/%s" % (os.environ['TASK_KEEPMOUNT'], v)
27 job_order_object["cwl:tool"] = keeppath(job_order_object["cwl:tool"])
29 adjustFiles(job_order_object, keeppath)
31 runner = arvados_cwl.ArvCwlRunner(api_client=arvados.api('v1', model=OrderedJsonModel()))
33 t = cwltool.main.load_tool(job_order_object, False, True, runner.arvMakeTool, True)
35 np = argparse.Namespace()
36 np.project_uuid = arvados.current_job()["owner_uuid"]
37 np.enable_reuse = True
38 outputObj = runner.arvExecutor(t, job_order_object, "", np, cwl_runner_job=arvados.current_job())
46 files[col].add("/".join(sp[1:]))
49 adjustFiles(outputObj, capture)
51 final = arvados.collection.Collection()
53 for k,v in files.iteritems():
54 with arvados.collection.Collection(k) as c:
56 final.copy(f, f, c, True)
58 def makeRelative(path):
59 return "/".join(path.split("/")[1:])
61 adjustFiles(outputObj, makeRelative)
63 with final.open("cwl.output.json", "w") as f:
64 json.dump(outputObj, f, indent=4)
66 api.job_tasks().update(uuid=arvados.current_task()['uuid'],
68 'output': final.save_new(create_collection_record=False),
72 except Exception as e:
73 logging.exception("Unhandled exception")
74 api.job_tasks().update(uuid=arvados.current_task()['uuid'],