-
Notifications
You must be signed in to change notification settings - Fork 0
/
hot_to_cool.py
32 lines (25 loc) · 1.15 KB
/
hot_to_cool.py
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
32
import argparse, datetime, subprocess, traceback
from multiprocessing.pool import Pool
def parse_args():
parser = argparse.ArgumentParser(description='Update BlobAccessTier for specified date to specified tier')
parser.add_argument('--date', type=int, required=True,
help="Date for which the data's BlobAccessTier should be changed. Format: YYYYMMDD")
args = parser.parse_args()
return args
def set_properties_directory(dt_dir):
try:
subprocess.run(["azcopy",
"set-properties",
f"https://wofsdltornado.blob.core.windows.net/wofs-dl-preds/{dt_dir}",
"--block-blob-tier=cool",
"--recursive=true"])
except Exception as e:
print(traceback.format_exc())
if __name__ == '__main__':
args = parse_args()
dt_start = datetime.datetime.strptime(f'{args.date}1700', '%Y%m%d%H%M')
dts = [dt_start + datetime.timedelta(minutes=x) for x in range(0, 630, 30)]
dts.sort()
dirs = [dt.strftime('%Y%m%d%H%M') for dt in dts]
with Pool(7) as p:
p.map(set_properties_directory, dirs)