1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
6 from arvados.errors import ApiError
8 def get_intermediate_collection_info(workflow_step_name, current_container, intermediate_output_ttl):
10 name = "Intermediate collection for step %s" % (workflow_step_name)
12 name = "Intermediate collection"
14 if intermediate_output_ttl > 0:
15 trash_time = datetime.datetime.utcnow() + datetime.timedelta(seconds=intermediate_output_ttl)
18 container_uuid = current_container['uuid']
19 props = {"type": "intermediate", "container": container_uuid}
21 return {"name" : name, "trash_at" : trash_time, "properties" : props}
23 def get_current_container(api, num_retries=0, logger=None):
24 current_container = None
26 current_container = api.containers().current().execute(num_retries=num_retries)
28 # Status code 404 just means we're not running in a container.
29 if e.resp.status != 404 and logger:
30 logger.info("Getting current container: %s", e)
31 return current_container