X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e4c5f98f696c354638bbba22ee4a1db20a52837c..f423aff73c1927a74e39c738e08bd6f1100a94c5:/sdk/cwl/arvados_cwl/arvdocker.py diff --git a/sdk/cwl/arvados_cwl/arvdocker.py b/sdk/cwl/arvados_cwl/arvdocker.py index 68573aa48e..a8f56ad1d4 100644 --- a/sdk/cwl/arvados_cwl/arvdocker.py +++ b/sdk/cwl/arvados_cwl/arvdocker.py @@ -21,6 +21,9 @@ cached_lookups_lock = threading.Lock() def arv_docker_get_image(api_client, dockerRequirement, pull_image, project_uuid): """Check if a Docker image is available in Keep, if not, upload it using arv-keepdocker.""" + if "http://arvados.org/cwl#dockerCollectionPDH" in dockerRequirement: + return dockerRequirement["http://arvados.org/cwl#dockerCollectionPDH"] + if "dockerImageId" not in dockerRequirement and "dockerPull" in dockerRequirement: dockerRequirement = copy.deepcopy(dockerRequirement) dockerRequirement["dockerImageId"] = dockerRequirement["dockerPull"] @@ -31,7 +34,7 @@ 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, logger.isEnabledFor(logging.DEBUG)): sp = dockerRequirement["dockerImageId"].split(":") @@ -57,8 +60,10 @@ 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, install_sig_handlers=False) + 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 is None or zero, then keepdocker exited normally and we can continue if e.code: raise WorkflowException("keepdocker exited with code %s" % e.code) @@ -69,10 +74,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