21700: Install Bundler system-wide in Rails postinst
[arvados.git] / sdk / python / arvados / crunch.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 from builtins import object
6 import json
7 import os
8 from . import util
9
10 class TaskOutputDir(object):
11     """Keep-backed directory for staging outputs of Crunch tasks.
12
13     Example, in a crunch task whose output is a file called "out.txt"
14     containing "42":
15
16         import arvados
17         import arvados.crunch
18         import os
19
20         out = arvados.crunch.TaskOutputDir()
21         with open(os.path.join(out.path, 'out.txt'), 'w') as f:
22             f.write('42')
23         arvados.current_task().set_output(out.manifest_text())
24     """
25     @util._deprecated('3.0', 'arvados-cwl-runner or the containers API')
26     def __init__(self):
27         self.path = os.environ['TASK_KEEPMOUNT_TMP']
28
29     def __str__(self):
30         return self.path
31
32     def manifest_text(self):
33         snapshot = os.path.join(self.path, '.arvados#collection')
34         return json.load(open(snapshot))['manifest_text']