1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
10 rtg_install_path = None
13 global rtg_install_path
15 return rtg_install_path
16 rtg_path = arvados.util.zipball_extract(
17 zipball = arvados.current_job()['script_parameters']['rtg_binary_zip'],
19 rtg_license_path = arvados.util.collection_extract(
20 collection = arvados.current_job()['script_parameters']['rtg_license'],
24 # symlink to rtg-license.txt
25 license_txt_path = os.path.join(rtg_license_path, 'rtg-license.txt')
27 os.symlink(license_txt_path, os.path.join(rtg_path,'rtg-license.txt'))
29 if not os.path.exists(os.path.join(rtg_path,'rtg-license.txt')):
30 os.symlink(license_txt_path, os.path.join(rtg_path,'rtg-license.txt'))
32 rtg_install_path = rtg_path
35 def run_rtg(command, output_dir, command_args, **kwargs):
36 global rtg_install_path
37 execargs = [os.path.join(rtg_install_path, 'rtg'),
40 execargs += command_args
41 sys.stderr.write("run_rtg: exec %s\n" % str(execargs))
42 arvados.util.run_command(
44 cwd=arvados.current_task().tmpdir,
48 # Exit status cannot be trusted in rtg 1.1.1.
49 assert_done(output_dir)
51 # Copy log files to stderr and delete them to avoid storing them
52 # in Keep with the output data.
53 for dirent in arvados.util.listdir_recursive(output_dir):
54 if is_log_file(dirent):
55 log_file = os.path.join(output_dir, dirent)
56 sys.stderr.write(' '.join(['==>', dirent, '<==\n']))
57 with open(log_file, 'rb') as f:
63 sys.stderr.write('\n') # in case log does not end in newline
66 def assert_done(output_dir):
67 # Sanity-check exit code.
68 done_file = os.path.join(output_dir, 'done')
69 if not os.path.exists(done_file):
70 raise Exception("rtg exited 0 but %s does not exist. abort.\n" % done_file)
72 def is_log_file(filename):
73 return re.search(r'^(.*/)?(progress|done|\S+.log)$', filename)