forked from broadinstitute/seqr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_new_project_directory.py
executable file
·47 lines (40 loc) · 1.85 KB
/
add_new_project_directory.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python2.7
import sys
import os
import argparse
import yaml
from datetime import datetime, date
p = argparse.ArgumentParser("")
p.add_argument("directories", help="The project directory", nargs=1)
p.add_argument("-r", dest="run", action="store_true", help="Actually run the commands")
p.add_argument("-f", dest="force", action="store_true", help="Force annotations")
p.add_argument("-i", dest="project_id", help="optional project id")
opts = p.parse_args()
project_dir = opts.directories[0]
project_id = opts.project_id
if not opts.project_id:
project_yaml = yaml.load(open(os.path.join(project_dir, "project.yaml")))
project_id = project_yaml['project_id']
commands = [
# "kill `pgrep -f continuously_reload_all_projects_daemon.sh`",
"python2.7 -u manage.py add_project %(project_id)s",
"python2.7 -u manage.py add_custom_population_to_project %(project_id)s gnomad-exomes",
"python2.7 -u manage.py add_custom_population_to_project %(project_id)s gnomad-genomes",
"python2.7 -u manage.py load_project_dir %(project_id)s %(project_dir)s",
"python2.7 -u manage.py load_project --force-annotations --force-clean %(project_id)s",
"python2.7 -u manage.py load_project_datastore %(project_id)s",
# "nohup ./continuously_reload_all_projects_daemon.sh &> logs/continuously_load_all_projects_daemon.log &"
]
commands = map(lambda s: s % globals(), commands )
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S -- Will run: "))
for c in commands:
print(c)
#i = input("Do you want to continue? [y/n] ")
if opts.run:
for c in commands:
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S") + " -- Running: " + c)
sys.stdout.flush()
r = os.system(c)
if r != 0:
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S") + " -- Command failed: " + c + "\nExiting.." )
break