Last active
April 21, 2020 14:13
-
-
Save cbare/4180915 to your computer and use it in GitHub Desktop.
create a new directory and put a checkpoint in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# crontab -e | |
# */20 * * * * /home/ubuntu/checkpoint.py > /home/ubuntu/checkpoint.log 2>&1 | |
import os | |
hosts = [] | |
with open('/usr/local/Rmpi/hostfile.plain') as f: | |
for line in f: | |
hosts.append(line.split()[0]) | |
os.chdir("/home/ubuntu/large1") | |
if os.path.exists('checkpoint_counter'): | |
with open('checkpoint_counter') as f: | |
i = int(f.read()) | |
else: | |
i = 1 | |
try: | |
os.mkdir("checkpoint%d" % i) | |
os.chdir("checkpoint%d" % i) | |
for host in hosts: | |
print('scp -i ~/cbare-sage.pem ubuntu@%s:/home/ubuntu/dose.large.node*.tsv .' % host) | |
os.system('scp -i ~/cbare-sage.pem ubuntu@%s:/home/ubuntu/dose.large.node*.tsv .' % host) | |
os.chdir('..') | |
with open("checkpoint_counter", "w") as f: | |
f.write("%d\n" % (i+1)) | |
except Exception, e: | |
print("Error: " + str(e)) | |
finally: | |
os.chdir("/home/ubuntu/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment