1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
6 from arvados.errors import ApiError
8 collectionUUID = "http://arvados.org/cwl#collectionUUID"
10 def get_intermediate_collection_info(workflow_step_name, current_container, intermediate_output_ttl):
11 if workflow_step_name:
12 name = "Intermediate collection for step %s" % (workflow_step_name)
14 name = "Intermediate collection"
16 if intermediate_output_ttl > 0:
17 trash_time = datetime.datetime.utcnow() + datetime.timedelta(seconds=intermediate_output_ttl)
19 props = {"type": "intermediate"}
21 props["container_uuid"] = current_container['uuid']
23 return {"name" : name, "trash_at" : trash_time, "properties" : props}
25 def get_current_container(api, num_retries=0, logger=None):
26 current_container = None
28 current_container = api.containers().current().execute(num_retries=num_retries)
30 # Status code 404 just means we're not running in a container.
31 if e.resp.status != 404:
33 logger.info("Getting current container: %s", e)
36 return current_container
39 def common_prefix(firstfile, all_files):
40 common_parts = firstfile.split('/')
43 f_parts = f.split('/')
44 for index, (a, b) in enumerate(zip(common_parts, f_parts)):
46 common_parts = common_parts[:index + 1]
49 if not any(common_parts):
51 return '/'.join(common_parts)