-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_worker.py
More file actions
31 lines (22 loc) · 877 Bytes
/
array_worker.py
File metadata and controls
31 lines (22 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/env python
from argparse import ArgumentParser
from glob import glob
from slurm_utils import Chunk, Context
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("data_dir", help="Directory containing data files to process")
args = parser.parse_args()
data_files = glob(f"{args.data_dir}/*")
with Context( verbosity=2 ) as context:
if( context.is_array() ):
context.log.debug(f"Running in a SLURM array")
else:
pass
with Chunk( data_files, context=context ) as chunk:
for file in chunk:
with context.mkTempFile() as f:
with open(file) as input:
for line in input:
f.write(line.upper())
# Do stuff...
context.collect()