X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/57647945b08a74bab02fed6adf947eb9adb8321f..8e36cb0c7568f687e0287c06d987553d2921ad8b:/sdk/cwl/arvados_cwl/arvdocker.py diff --git a/sdk/cwl/arvados_cwl/arvdocker.py b/sdk/cwl/arvados_cwl/arvdocker.py index 6b736a5a7d..6bca07c883 100644 --- a/sdk/cwl/arvados_cwl/arvdocker.py +++ b/sdk/cwl/arvados_cwl/arvdocker.py @@ -31,9 +31,9 @@ def arv_docker_get_image(api_client, dockerRequirement, pull_image, project_uuid global cached_lookups_lock with cached_lookups_lock: if dockerRequirement["dockerImageId"] in cached_lookups: - return dockerRequirement["dockerImageId"] + return cached_lookups[dockerRequirement["dockerImageId"]] - with SourceLine(dockerRequirement, "dockerImageId", WorkflowException): + with SourceLine(dockerRequirement, "dockerImageId", WorkflowException, logger.isEnabledFor(logging.DEBUG)): sp = dockerRequirement["dockerImageId"].split(":") image_name = sp[0] image_tag = sp[1] if len(sp) > 1 else "latest" @@ -44,7 +44,10 @@ def arv_docker_get_image(api_client, dockerRequirement, pull_image, project_uuid if not images: # Fetch Docker image if necessary. - cwltool.docker.get_image(dockerRequirement, pull_image) + try: + cwltool.docker.DockerCommandLineJob.get_image(dockerRequirement, pull_image) + except OSError as e: + raise WorkflowException("While trying to get Docker image '%s', failed to execute 'docker': %s" % (dockerRequirement["dockerImageId"], e)) # Upload image to Arvados args = [] @@ -54,7 +57,8 @@ def arv_docker_get_image(api_client, dockerRequirement, pull_image, project_uuid args.append(image_tag) logger.info("Uploading Docker image %s:%s", image_name, image_tag) try: - arvados.commands.keepdocker.main(args, stdout=sys.stderr) + arvados.commands.put.api_client = api_client + arvados.commands.keepdocker.main(args, stdout=sys.stderr, install_sig_handlers=False, api=api_client) except SystemExit as e: if e.code: raise WorkflowException("keepdocker exited with code %s" % e.code) @@ -66,10 +70,12 @@ def arv_docker_get_image(api_client, dockerRequirement, pull_image, project_uuid if not images: raise WorkflowException("Could not find Docker image %s:%s" % (image_name, image_tag)) + pdh = api_client.collections().get(uuid=images[0][0]).execute()["portable_data_hash"] + with cached_lookups_lock: - cached_lookups[dockerRequirement["dockerImageId"]] = True + cached_lookups[dockerRequirement["dockerImageId"]] = pdh - return dockerRequirement["dockerImageId"] + return pdh def arv_docker_clear_cache(): global cached_lookups