-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunme.py
119 lines (94 loc) · 3.82 KB
/
runme.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
"""ESCALATE Capture
Main point of entry for for EscalateCAPTURE
"""
import os
import sys
import ast
import xlrd
import logging
import argparse as ap
from log import init
from capture import specify
from capture import devconfig
from utils import globals, data_handling
def escalatecapture(rxndict, vardict):
"""Point of entry into the data pipeline
Manages processing calls to specify, generate, and prepare --> leads to execute
:param rxndict: dictionary of Excel-specified params
:param vardict: dictionary of dev-specified params
:return None:
"""
modlog = logging.getLogger('capture.escalatecapture')
modlog.info("Initializing specify")
specify.datapipeline(rxndict, vardict)
def linkprocess(linkfile):
"""TODO: what was this going to be for?"""
return
def build_rxndict(rxnvarfile):
"""Read Template file and return a dict representation
The rxndict is a mapping of Variables => Values (column B => column d) in the
uncommented rows of the reaction excel file
:param rxnvarfile: path to excel file containing reaction specification
:return rxndict: dictionary representation of reaction specification
"""
rxndict = {}
varfile = rxnvarfile
wb = xlrd.open_workbook(varfile)
sheet = wb.sheet_by_name('WF1')
for i in range(sheet.nrows):
commentval = sheet.cell(i, 0).value
if commentval == '#':
continue
else:
cell_dict_value = sheet.cell(i, 3).value
cell_dict_id = sheet.cell(i, 1).value
cell_dict_type = sheet.cell(i, 4).value
if cell_dict_id == "":
pass
if cell_dict_type == 'list':
rxndict[cell_dict_id] = ast.literal_eval(cell_dict_value)
else:
rxndict[cell_dict_id.strip()] = cell_dict_value
# cannot use globals.get_lab() here since it has not been set
# if rxndict['lab'] == 'MIT_PVLab':
# data_handling.get_user_actions(rxndict, sheet)
return rxndict
if __name__ == "__main__":
parser = ap.ArgumentParser(description='Generate experimental run data')
parser.add_argument('Variables', type=str,
help='Target xls file containing run information specified by the user\
format should be "filename.xlsx"')
parser.add_argument('-s', '--ss', default=0, type=int, choices=[0, 1, 2],
help='0 - quasi-random experiments generate, 1 - Generates stateset\
for exp_1 user specified reagents, 2 - generate prototype run for\
exp_1 user specified reagents')
parser.add_argument('-d', '--debug', default=0, type=int, choices=[0,1,2],
help='0 - complete run generation and upload to google drive,\
1 - retain all tables from gdrive & keep runtime content,\
2 - full offline debugging (no uploading)')
args = parser.parse_args()
challengeproblem = args.ss
rxndict = build_rxndict(args.Variables)
rxndict['challengeproblem'] = challengeproblem
# vardict will hold variables configured by developers
vardict = {
'exefilename': args.Variables,
'challengeproblem': challengeproblem,
'debug': args.debug,
'lab': rxndict['lab']
}
if not os.path.exists('./localfiles'):
os.mkdir('./localfiles')
globals.set_lab(rxndict['lab'])
init.runuidgen(rxndict, vardict)
loggerfile = init.buildlogger(rxndict)
rxndict['logfile'] = loggerfile
# log the initial state of the run
init.initialize(rxndict, vardict)
# TODO: >>>> insert variable tests here <<<<
escalatecapture(rxndict, vardict)
if vardict['debug'] == 0: # if no debuggin
if os.path.exists("./mycred.txt"):
os.remove("./mycred.txt")
if os.path.exists("./capture/user_cli_variables.py"):
os.remove("./capture/user_cli_variables.py")