mirror of
https://github.com/titanscouting/tra-superscript.git
synced 2024-11-10 06:54:45 +00:00
Merge pull request #13 from titanscouting/superscript-v1
Pull recent changes from superscript-v1 to database-config
Former-commit-id: e18ddcec9d
This commit is contained in:
commit
09b8cca884
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
**/profile.*
|
**/profile.*
|
||||||
|
|
||||||
|
**/*.log
|
||||||
**/errorlog.txt
|
**/errorlog.txt
|
||||||
/dist/superscript.*
|
/dist/superscript.*
|
||||||
/dist/superscript
|
/dist/superscript
|
@ -9,11 +9,11 @@ def simplestats(data_test):
|
|||||||
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||||
|
|
||||||
data = np.array(data_test[0])
|
data = np.array(data_test[3])
|
||||||
data = data[np.isfinite(data)]
|
data = data[np.isfinite(data)]
|
||||||
ranges = list(range(len(data)))
|
ranges = list(range(len(data)))
|
||||||
|
|
||||||
test = data_test[1]
|
test = data_test[2]
|
||||||
|
|
||||||
if test == "basic_stats":
|
if test == "basic_stats":
|
||||||
return an.basic_stats(data)
|
return an.basic_stats(data)
|
||||||
@ -48,13 +48,7 @@ def matchloop(client, competition, data, tests, exec_threads):
|
|||||||
value = self[item] = type(self)()
|
value = self[item] = type(self)()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
return_vector = {}
|
input_vector = []
|
||||||
|
|
||||||
team_filtered = []
|
|
||||||
variable_filtered = []
|
|
||||||
variable_data = []
|
|
||||||
test_filtered = []
|
|
||||||
result_filtered = []
|
|
||||||
return_vector = AutoVivification()
|
return_vector = AutoVivification()
|
||||||
|
|
||||||
for team in data:
|
for team in data:
|
||||||
@ -65,25 +59,24 @@ def matchloop(client, competition, data, tests, exec_threads):
|
|||||||
|
|
||||||
for test in tests[variable]:
|
for test in tests[variable]:
|
||||||
|
|
||||||
team_filtered.append(team)
|
input_vector.append((team, variable, test, data[team][variable]))
|
||||||
variable_filtered.append(variable)
|
|
||||||
variable_data.append((data[team][variable], test))
|
|
||||||
test_filtered.append(test)
|
|
||||||
|
|
||||||
result_filtered = exec_threads.map(simplestats, variable_data)
|
result_filtered = exec_threads.map(simplestats, input_vector)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
result_filtered = list(result_filtered)
|
result_filtered = list(result_filtered)
|
||||||
|
|
||||||
for result in result_filtered:
|
for result in result_filtered:
|
||||||
|
|
||||||
filtered = test_filtered[i]
|
filtered = input_vector[i][2]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
short = short_mapping[filtered]
|
short = short_mapping[filtered]
|
||||||
return_vector[team_filtered[i]][variable_filtered[i]][test_filtered[i]] = result[short]
|
return_vector[input_vector[i][0]][input_vector[i][1]][input_vector[i][2]] = result[short]
|
||||||
except KeyError: # not in mapping
|
except KeyError: # not in mapping
|
||||||
return_vector[team_filtered[i]][variable_filtered[i]][test_filtered[i]] = result
|
return_vector[input_vector[i][0]][input_vector[i][1]][input_vector[i][2]] = result
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
return return_vector
|
return return_vector
|
||||||
|
@ -10,10 +10,12 @@ __changelog__ = """changelog:
|
|||||||
1.0.0:
|
1.0.0:
|
||||||
- superscript now runs in PEP 3143 compliant well behaved daemon on Linux systems
|
- superscript now runs in PEP 3143 compliant well behaved daemon on Linux systems
|
||||||
- linux superscript daemon has integrated websocket output to monitor progress/status remotely
|
- linux superscript daemon has integrated websocket output to monitor progress/status remotely
|
||||||
- linux daemon now sends stderr to errorlog.txt
|
- linux daemon now sends stderr to errorlog.log
|
||||||
- added verbose option to linux superscript to allow for interactive output
|
- added verbose option to linux superscript to allow for interactive output
|
||||||
- moved pymongo import to superscript.py
|
- moved pymongo import to superscript.py
|
||||||
- added profile option to linux superscript to profile runtime of script
|
- added profile option to linux superscript to profile runtime of script
|
||||||
|
- reduced memory usage slightly by consolidating the unwrapped input data
|
||||||
|
- added debug option, which performs one loop of analysis and dumps results to local files
|
||||||
- added event and time delay options to config
|
- added event and time delay options to config
|
||||||
- event delay pauses loop until even listener recieves an update
|
- event delay pauses loop until even listener recieves an update
|
||||||
- time delay pauses loop until the time specified has elapsed since the BEGINNING of previous loop
|
- time delay pauses loop until the time specified has elapsed since the BEGINNING of previous loop
|
||||||
@ -211,10 +213,10 @@ sample_json = """{
|
|||||||
"loop-delay":60
|
"loop-delay":60
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
def main(send, verbose = False, profile = False):
|
def main(send, verbose = False, profile = False, debug = False):
|
||||||
|
|
||||||
warnings.filterwarnings("ignore")
|
warnings.filterwarnings("ignore")
|
||||||
sys.stderr = open("errorlog.txt", "w")
|
sys.stderr = open("errorlog.log", "w")
|
||||||
loop_exit_code = 0
|
loop_exit_code = 0
|
||||||
loop_stored_exception = None
|
loop_stored_exception = None
|
||||||
|
|
||||||
@ -353,6 +355,11 @@ def main(send, verbose = False, profile = False):
|
|||||||
results = matchloop(client, competition, match_data, match_tests, exec_threads)
|
results = matchloop(client, competition, match_data, match_tests, exec_threads)
|
||||||
send(stdout, INF, "finished match analysis in " + str(time.time() - start) + " seconds")
|
send(stdout, INF, "finished match analysis in " + str(time.time() - start) + " seconds")
|
||||||
|
|
||||||
|
if debug:
|
||||||
|
f = open("matchloop.log", "w+")
|
||||||
|
json.dump(results, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
send(stdout, INF, "uploading match results to database")
|
send(stdout, INF, "uploading match results to database")
|
||||||
push_match(client, competition, results)
|
push_match(client, competition, results)
|
||||||
@ -373,6 +380,11 @@ def main(send, verbose = False, profile = False):
|
|||||||
results = pitloop(client, competition, pit_data, pit_tests)
|
results = pitloop(client, competition, pit_data, pit_tests)
|
||||||
send(stdout, INF, "finished pit analysis in " + str(time.time() - start) + " seconds")
|
send(stdout, INF, "finished pit analysis in " + str(time.time() - start) + " seconds")
|
||||||
|
|
||||||
|
if debug:
|
||||||
|
f = open("pitloop.log", "w+")
|
||||||
|
json.dump(results, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
send(stdout, INF, "uploading pit results to database")
|
send(stdout, INF, "uploading pit results to database")
|
||||||
push_pit(client, competition, results)
|
push_pit(client, competition, results)
|
||||||
@ -400,7 +412,7 @@ def main(send, verbose = False, profile = False):
|
|||||||
loop_exit_code = 0
|
loop_exit_code = 0
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
send(stderr, ERR, "encountered an exception while running")
|
send(stderr, ERR, "encountered an exception while running", code = 1)
|
||||||
print(e, file = stderr)
|
print(e, file = stderr)
|
||||||
loop_exit_code = 1
|
loop_exit_code = 1
|
||||||
break
|
break
|
||||||
@ -431,7 +443,7 @@ def save_config(path, config_vector):
|
|||||||
except:
|
except:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def start(pid_path, verbose = False, profile = False):
|
def start(pid_path, verbose = False, profile = False, debug = False):
|
||||||
|
|
||||||
if profile:
|
if profile:
|
||||||
|
|
||||||
@ -451,6 +463,10 @@ def start(pid_path, verbose = False, profile = False):
|
|||||||
|
|
||||||
main(log, verbose = verbose)
|
main(log, verbose = verbose)
|
||||||
|
|
||||||
|
elif debug:
|
||||||
|
|
||||||
|
main(log, verbose = True, profile = True, debug = debug)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
f = open('errorlog.txt', 'w+')
|
f = open('errorlog.txt', 'w+')
|
||||||
@ -538,10 +554,12 @@ if __name__ == "__main__":
|
|||||||
start(None, verbose = True)
|
start(None, verbose = True)
|
||||||
elif 'profile' == sys.argv[1]:
|
elif 'profile' == sys.argv[1]:
|
||||||
start(None, profile=True)
|
start(None, profile=True)
|
||||||
|
elif 'debug' == sys.argv[1]:
|
||||||
|
start(None, debug = True)
|
||||||
else:
|
else:
|
||||||
print("usage: %s start|stop|restart|verbose|profile" % sys.argv[0])
|
print("usage: %s start|stop|restart|verbose|profile|debug" % sys.argv[0])
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print("usage: %s start|stop|restart|verbose|profile" % sys.argv[0])
|
print("usage: %s start|stop|restart|verbose|profile|debug" % sys.argv[0])
|
||||||
sys.exit(2)
|
sys.exit(2)
|
Loading…
Reference in New Issue
Block a user