X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ad4344e21db3c894869d09fdcb09e3202bf9cf78..9777970b61c21a55565b09e0a918ed64f59b0b22:/crunch_scripts/cwl-runner?ds=sidebyside diff --git a/crunch_scripts/cwl-runner b/crunch_scripts/cwl-runner index 3f2d53d038..0c79844d5f 100755 --- a/crunch_scripts/cwl-runner +++ b/crunch_scripts/cwl-runner @@ -1,15 +1,33 @@ #!/usr/bin/env python - -# Crunch script integration for running arvados-cwl-runner (importing -# arvados_cwl module) inside a crunch job. +# Copyright (C) The Arvados Authors. All rights reserved. # +# SPDX-License-Identifier: Apache-2.0 + +# Crunch script integration for running arvados-cwl-runner inside a crunch job. + +import arvados_cwl +import sys + +try: + # Use the crunch script defined in the arvados_cwl package. This helps + # prevent the crunch script from going out of sync with the rest of the + # arvados_cwl package. + import arvados_cwl.crunch_script + arvados_cwl.crunch_script.run() + sys.exit() +except ImportError: + pass + +# When running against an older arvados-cwl-runner package without +# arvados_cwl.crunch_script, fall back to the old code. + + # This gets the job record, transforms the script parameters into a valid CWL # input object, then executes the CWL runner to run the underlying workflow or # tool. When the workflow completes, record the output object in an output # collection for this runner job. import arvados -import arvados_cwl import arvados.collection import arvados.util import cwltool.main @@ -57,7 +75,13 @@ try: normalizeFilesDirs(job_order_object) adjustDirObjs(job_order_object, functools.partial(getListing, arvados_cwl.fsaccess.CollectionFsAccess("", api_client=api))) - runner = arvados_cwl.ArvCwlRunner(api_client=arvados.api('v1', model=OrderedJsonModel())) + output_name = None + if "arv:output_name" in job_order_object: + output_name = job_order_object["arv:output_name"] + del job_order_object["arv:output_name"] + + runner = arvados_cwl.ArvCwlRunner(api_client=arvados.api('v1', model=OrderedJsonModel()), + output_name=output_name) t = load_tool(job_order_object, runner.arv_make_tool)