From: Peter Amstutz Date: Wed, 21 Nov 2018 17:41:11 +0000 (-0500) Subject: 14198: Call validate_cluster_target on --submit-runner-cluster X-Git-Tag: 1.3.0~30^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/3081e02da59e46d5e913a0ec3ea228e57c5c5e00?hp=200cc5eb5d3e6fbc93977a7dd11a263ad1fcffb6 14198: Call validate_cluster_target on --submit-runner-cluster Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- diff --git a/sdk/cwl/arvados_cwl/__init__.py b/sdk/cwl/arvados_cwl/__init__.py index 605d330052..7b2731ea90 100644 --- a/sdk/cwl/arvados_cwl/__init__.py +++ b/sdk/cwl/arvados_cwl/__init__.py @@ -146,16 +146,18 @@ def arg_parser(): # type: () -> argparse.ArgumentParser default=None) parser.add_argument("--always-submit-runner", action="store_true", - help="Always submit a runner to manage the workflow, even when running only a single CommandLineTool", + help="When invoked with --submit --wait, always submit a runner to manage the workflow, even when only running a single CommandLineTool", default=False) exgroup = parser.add_mutually_exclusive_group() exgroup.add_argument("--submit-request-uuid", type=str, - default=None, - help="Update and commit to supplied container request instead of creating a new one (containers API only).") + default=None, + help="Update and commit to supplied container request instead of creating a new one (containers API only).", + metavar="UUID") exgroup.add_argument("--submit-runner-cluster", type=str, - help="Submit toplevel runner to a remote cluster (containers API only)", - default=None) + help="Submit workflow runner to a remote cluster (containers API only)", + default=None, + metavar="CLUSTER_ID") parser.add_argument("--name", type=str, help="Name to use for workflow execution instance.", diff --git a/sdk/cwl/arvados_cwl/arvtool.py b/sdk/cwl/arvados_cwl/arvtool.py index 014cedb75c..5257645304 100644 --- a/sdk/cwl/arvados_cwl/arvtool.py +++ b/sdk/cwl/arvados_cwl/arvtool.py @@ -10,6 +10,12 @@ from functools import partial from schema_salad.sourceline import SourceLine from cwltool.errors import WorkflowException +def validate_cluster_target(arvrunner, runtimeContext): + if (runtimeContext.submit_runner_cluster and + runtimeContext.submit_runner_cluster not in arvrunner.api._rootDesc["remoteHosts"] and + runtimeContext.submit_runner_cluster != arvrunner.api._rootDesc["uuidPrefix"]): + raise WorkflowException("Unknown or invalid cluster id '%s' known remote clusters are %s" % (runtimeContext.submit_runner_cluster, + ", ".join(arvrunner.api._rootDesc["remoteHosts"].keys()))) def set_cluster_target(tool, arvrunner, builder, runtimeContext): cluster_target_req = None for field in ("hints", "requirements"): @@ -26,11 +32,8 @@ def set_cluster_target(tool, arvrunner, builder, runtimeContext): runtimeContext = runtimeContext.copy() runtimeContext.submit_runner_cluster = builder.do_eval(cluster_target_req.get("cluster_id")) or runtimeContext.submit_runner_cluster runtimeContext.project_uuid = builder.do_eval(cluster_target_req.get("project_uuid")) or runtimeContext.project_uuid - if (runtimeContext.submit_runner_cluster and - runtimeContext.submit_runner_cluster not in arvrunner.api._rootDesc["remoteHosts"] and - runtimeContext.submit_runner_cluster != arvrunner.api._rootDesc["uuidPrefix"]): - raise WorkflowException("Unknown or invalid cluster id '%s' known remote clusters are %s" % (runtimeContext.submit_runner_cluster, - ", ".join(arvrunner.api._rootDesc["remoteHosts"].keys()))) + validate_cluster_target(arvrunner, runtimeContext) + return runtimeContext class ArvadosCommandTool(CommandLineTool): diff --git a/sdk/cwl/arvados_cwl/executor.py b/sdk/cwl/arvados_cwl/executor.py index 994594023a..6cac709260 100644 --- a/sdk/cwl/arvados_cwl/executor.py +++ b/sdk/cwl/arvados_cwl/executor.py @@ -27,7 +27,7 @@ import arvados_cwl.util from .arvcontainer import RunnerContainer from .arvjob import RunnerJob, RunnerTemplate from .runner import Runner, upload_docker, upload_job_order, upload_workflow_deps -from .arvtool import ArvadosCommandTool +from .arvtool import ArvadosCommandTool, validate_cluster_target from .arvworkflow import ArvadosWorkflow, upload_workflow from .fsaccess import CollectionFsAccess, CollectionFetcher, collectionResolver, CollectionCache from .perf import Perf @@ -178,6 +178,8 @@ http://doc.arvados.org/install/install-api-server.html#disable_api_methods self.runtimeContext.make_fs_access = partial(CollectionFsAccess, collection_cache=self.collection_cache) + validate_cluster_target(self, self.runtimeContext) + def arv_make_tool(self, toolpath_object, loadingContext): if "class" in toolpath_object and toolpath_object["class"] == "CommandLineTool":