X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/07ff7264dc3ff32c8edf08e5e6827ff7f1f48cf7..8851415af9ae0bd1a6362f1877e34d6c5ff0c46f:/sdk/cwl/arvados_cwl/executor.py?ds=sidebyside diff --git a/sdk/cwl/arvados_cwl/executor.py b/sdk/cwl/arvados_cwl/executor.py index dbbea9f4ef..447c14b8bf 100644 --- a/sdk/cwl/arvados_cwl/executor.py +++ b/sdk/cwl/arvados_cwl/executor.py @@ -70,6 +70,10 @@ class RuntimeStatusLoggingHandler(logging.Handler): kind = 'error' elif record.levelno >= logging.WARNING: kind = 'warning' + if kind == 'warning' and record.name == "salad": + # Don't send validation warnings to runtime status, + # they're noisy and unhelpful. + return if kind is not None and self.updatingRuntimeStatus is not True: self.updatingRuntimeStatus = True try: @@ -112,6 +116,9 @@ class ArvCwlExecutor(object): arvargs.output_tags = None arvargs.thread_count = 1 arvargs.collection_cache_size = None + arvargs.git_info = True + arvargs.submit = False + arvargs.defer_downloads = False self.api = api_client self.processes = {} @@ -137,6 +144,8 @@ class ArvCwlExecutor(object): self.fs_access = None self.secret_store = None self.stdout = stdout + self.fast_submit = False + self.git_info = arvargs.git_info if keep_client is not None: self.keep_client = keep_client @@ -203,6 +212,8 @@ The 'jobs' API is no longer supported. self.toplevel_runtimeContext.make_fs_access = partial(CollectionFsAccess, collection_cache=self.collection_cache) + self.defer_downloads = arvargs.submit and arvargs.defer_downloads + validate_cluster_target(self, self.toplevel_runtimeContext) @@ -358,8 +369,8 @@ The 'jobs' API is no longer supported. page = keys[:pageSize] try: proc_states = table.list(filters=[["uuid", "in", page]]).execute(num_retries=self.num_retries) - except Exception: - logger.exception("Error checking states on API server: %s") + except Exception as e: + logger.exception("Error checking states on API server: %s", e) remain_wait = self.poll_interval continue @@ -520,14 +531,17 @@ The 'jobs' API is no longer supported. for req in job_reqs: tool.requirements.append(req) - def get_git_info(self, tool): + @staticmethod + def get_git_info(tool): in_a_git_repo = False cwd = None + filepath = None if tool.tool["id"].startswith("file://"): # check if git is installed try: - cwd = os.path.dirname(uri_file_path(tool.tool["id"])) + filepath = uri_file_path(tool.tool["id"]) + cwd = os.path.dirname(filepath) subprocess.run(["git", "log", "--format=%H", "-n1", "HEAD"], cwd=cwd, check=True, capture_output=True, text=True) in_a_git_repo = True except Exception as e: @@ -539,9 +553,12 @@ The 'jobs' API is no longer supported. git_commit = subprocess.run(["git", "log", "--format=%H", "-n1", "HEAD"], cwd=cwd, capture_output=True, text=True).stdout git_date = subprocess.run(["git", "log", "--format=%cD", "-n1", "HEAD"], cwd=cwd, capture_output=True, text=True).stdout git_committer = subprocess.run(["git", "log", "--format=%cn <%ce>", "-n1", "HEAD"], cwd=cwd, capture_output=True, text=True).stdout - git_branch = subprocess.run(["git", "branch", "--show-current"], cwd=cwd, capture_output=True, text=True).stdout + git_branch = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=cwd, capture_output=True, text=True).stdout git_origin = subprocess.run(["git", "remote", "get-url", "origin"], cwd=cwd, capture_output=True, text=True).stdout git_status = subprocess.run(["git", "status", "--untracked-files=no", "--porcelain"], cwd=cwd, capture_output=True, text=True).stdout + git_describe = subprocess.run(["git", "describe", "--always", "--tags"], cwd=cwd, capture_output=True, text=True).stdout + git_toplevel = subprocess.run(["git", "rev-parse", "--show-toplevel"], cwd=cwd, capture_output=True, text=True).stdout + git_path = filepath[len(git_toplevel):] gitproperties = { "http://arvados.org/cwl#gitCommit": git_commit.strip(), @@ -550,6 +567,8 @@ The 'jobs' API is no longer supported. "http://arvados.org/cwl#gitBranch": git_branch.strip(), "http://arvados.org/cwl#gitOrigin": git_origin.strip(), "http://arvados.org/cwl#gitStatus": git_status.strip(), + "http://arvados.org/cwl#gitDescribe": git_describe.strip(), + "http://arvados.org/cwl#gitPath": git_path.strip(), } else: for g in ("http://arvados.org/cwl#gitCommit", @@ -557,18 +576,26 @@ The 'jobs' API is no longer supported. "http://arvados.org/cwl#gitCommitter", "http://arvados.org/cwl#gitBranch", "http://arvados.org/cwl#gitOrigin", - "http://arvados.org/cwl#gitStatus"): + "http://arvados.org/cwl#gitStatus", + "http://arvados.org/cwl#gitDescribe", + "http://arvados.org/cwl#gitPath"): if g in tool.metadata: - gitproperties = tool.metadata[g] + gitproperties[g] = tool.metadata[g] return gitproperties + def set_container_request_properties(self, container, properties): + resp = self.api.container_requests().list(filters=[["container_uuid", "=", container["uuid"]]], select=["uuid", "properties"]).execute(num_retries=self.num_retries) + for cr in resp["items"]: + cr["properties"].update({k.replace("http://arvados.org/cwl#", "arv:"): v for k, v in properties.items()}) + self.api.container_requests().update(uuid=cr["uuid"], body={"container_request": {"properties": cr["properties"]}}).execute(num_retries=self.num_retries) + def arv_executor(self, updated_tool, job_order, runtimeContext, logger=None): self.debug = runtimeContext.debug - git_info = self.get_git_info(updated_tool) + git_info = self.get_git_info(updated_tool) if self.git_info else {} if git_info: - logger.info("Provenance of %s", updated_tool.tool["id"]) + logger.info("Git provenance") for g in git_info: if git_info[g]: logger.info(" %s: %s", g.split("#", 1)[1], git_info[g]) @@ -578,7 +605,8 @@ The 'jobs' API is no longer supported. controller = self.api.config()["Services"]["Controller"]["ExternalURL"] logger.info("Using cluster %s (%s)", self.api.config()["ClusterID"], workbench2 or workbench1 or controller) - updated_tool.visit(self.check_features) + if not self.fast_submit: + updated_tool.visit(self.check_features) self.pipeline = None self.fs_access = runtimeContext.make_fs_access(runtimeContext.basedir) @@ -606,7 +634,10 @@ The 'jobs' API is no longer supported. runtimeContext.intermediate_storage_classes = default_storage_classes if not runtimeContext.name: - runtimeContext.name = self.name = updated_tool.tool.get("label") or updated_tool.metadata.get("label") or os.path.basename(updated_tool.tool["id"]) + self.name = updated_tool.tool.get("label") or updated_tool.metadata.get("label") or os.path.basename(updated_tool.tool["id"]) + if git_info.get("http://arvados.org/cwl#gitDescribe"): + self.name = "%s (%s)" % (self.name, git_info.get("http://arvados.org/cwl#gitDescribe")) + runtimeContext.name = self.name if runtimeContext.copy_deps is None and (runtimeContext.create_workflow or runtimeContext.update_workflow): # When creating or updating workflow record, by default @@ -643,7 +674,7 @@ The 'jobs' API is no longer supported. loadingContext = self.loadingContext.copy() loadingContext.do_validate = False loadingContext.disable_js_validation = True - if submitting: + if submitting and not self.fast_submit: loadingContext.do_update = False # Document may have been auto-updated. Reload the original # document with updating disabled because we want to @@ -656,9 +687,12 @@ The 'jobs' API is no longer supported. # Upload direct dependencies of workflow steps, get back mapping of files to keep references. # Also uploads docker images. - logger.info("Uploading workflow dependencies") - with Perf(metrics, "upload_workflow_deps"): - merged_map = upload_workflow_deps(self, tool, runtimeContext) + if not self.fast_submit: + logger.info("Uploading workflow dependencies") + with Perf(metrics, "upload_workflow_deps"): + merged_map = upload_workflow_deps(self, tool, runtimeContext) + else: + merged_map = {} # Recreate process object (ArvadosWorkflow or # ArvadosCommandTool) because tool document may have been @@ -764,6 +798,7 @@ The 'jobs' API is no longer supported. current_container = arvados_cwl.util.get_current_container(self.api, self.num_retries, logger) if current_container: logger.info("Running inside container %s", current_container.get("uuid")) + self.set_container_request_properties(current_container, git_info) self.poll_api = arvados.api('v1', timeout=runtimeContext.http_timeout) self.polling_thread = threading.Thread(target=self.poll_states)