1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 from builtins import object
9 class TaskOutputDir(object):
10 """Keep-backed directory for staging outputs of Crunch tasks.
12 Example, in a crunch task whose output is a file called "out.txt"
19 out = arvados.crunch.TaskOutputDir()
20 with open(os.path.join(out.path, 'out.txt'), 'w') as f:
22 arvados.current_task().set_output(out.manifest_text())
25 self.path = os.environ['TASK_KEEPMOUNT_TMP']
30 def manifest_text(self):
31 snapshot = os.path.join(self.path, '.arvados#collection')
32 return json.load(open(snapshot))['manifest_text']