From 94dd51566a9ea64c3ba5b23ec1211510d7de420b Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:42:54 -0600 Subject: [PATCH] refactors --- .gitignore | 1 + data analysis/__pycache__/data.cpython-37.pyc | Bin 2684 -> 3039 bytes data analysis/data.py | 33 +++++++++++------- data analysis/superscript.py | 12 ++++--- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index fc736545..89255a74 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ data analysis/.ipynb_checkpoints/test-checkpoint.ipynb .vscode data analysis/arthur_pull.ipynb data analysis/keys.txt +data analysis/check_for_new_matches.ipynb \ No newline at end of file diff --git a/data analysis/__pycache__/data.cpython-37.pyc b/data analysis/__pycache__/data.cpython-37.pyc index 1205aa50feb35bf145a1e7f1a035fe68732678dd..893d83c0ff18807826cb7300722c5a5c9b356cc4 100644 GIT binary patch delta 596 zcmb_YO;5r=5bd_mZVLnr1tfYw5z=^76u%&P(1SNUX(H5aqa=J~TW?F$#IuRns|WlA z#=p~x2mgi#XAq($9^J{ld9yRKJ8wViw|r$Um9i9ACAD?_0PG!u>C%8SU;w)Q!^24c+E|_dP!d+P%xj3VpZR4E-PsJbiMd37*2< z$6F5pLS;mR@=S)h&_%4E3=Lt3ICv`PNEJk=j68u4HR+i3vnsUk0>FtArH~T$5(t?mXCXZt_k5ELwrbuTOJ-6#ehS%>P;ft7BLMX|imbtM9*TEIcJRQ7= zqH2&2aB78Ego5!M;8Aj1*7ZZ)_WnhoQ00nQuJN(Rb$9|aZh-qz@war2!|_clHsy<% z)weL-mUlEGm$mdk?px4g(y^pERQ;BOCyvTjv3>0a-$kC3rd8EZHLuHtRi3kf;!l9Z Ms6kDz1Wj4`CwS&}&Hw-a delta 290 zcmcaF{zpXJiI*24Qm#2En5xS0+t%a8m1J+ zIZQQ-C9IPhxHKl$af-W}0JRiJ0*Me!wjyZ|M+Qhl@uwt~B*qsM= 0 and i["comp_level"] == "qm"): + out.append({"match" : i['match_number'], "blue" : list(map(lambda x: int(x[3:]), i['alliances']['blue']['team_keys'])), "red" : list(map(lambda x: int(x[3:]), i['alliances']['red']['team_keys'])), "winner": i["winning_alliance"]}) + time_last_upd = time.time() + return out def get_team_match_data(apikey, competition, team_num): client = pymongo.MongoClient(apikey) @@ -54,8 +55,14 @@ def get_data_formatted(apikey, competition): pass return out -def push_team_data(apikey, competition, team_num, data): +def push_team_tests_data(apikey, competition, team_num, data, dbname = "data_processing", colname = "team_tests"): client = pymongo.MongoClient(apikey) - db = client.data_processing - mdata = db.team_tests + db = client[dbname] + mdata = db[colname] + mdata.replace_one({"competition" : competition, "team": team_num}, {"_id": competition+str(team_num)+"am", "competition" : competition, "team" : team_num, "data" : data}, True) + +def push_team_metrics_data(apikey, competition, team_num, data, dbname = "data_processing", colname = "team_metrics"): + client = pymongo.MongoClient(apikey) + db = client[dbname] + mdata = db[colname] mdata.replace_one({"competition" : competition, "team": team_num}, {"_id": competition+str(team_num)+"am", "competition" : competition, "team" : team_num, "data" : data}, True) \ No newline at end of file diff --git a/data analysis/superscript.py b/data analysis/superscript.py index fc96b002..bf651faa 100644 --- a/data analysis/superscript.py +++ b/data analysis/superscript.py @@ -57,9 +57,12 @@ __all__ = [ from analysis import analysis as an import data as d +import time def main(): while(True): + current_time = time.time() + print("time is: " + time) print("loading config") competition, config = load_config("config.csv") print("config loaded") @@ -73,7 +76,7 @@ def main(): results = simpleloop(data, config) print("finished tests") print("pushing to database") - push_to_database(apikey, competition, results) + push_to_database(apikey, competition, results, None) print("pushed to database") def load_config(file): @@ -124,16 +127,17 @@ def simplestats(data, test): if(test == "regression_sigmoidal"): return an.regression('cpu', list(range(len(data))), data, ['sig']) -def push_to_database(apikey, competition, results): +def push_to_database(apikey, competition, results, metrics): for team in results: - d.push_team_data(apikey, competition, team, results[team]) + d.push_team_tests_data(apikey, competition, team, results[team]) def metricsloop(group_data, observations, database, tests): # listener based metrics update pass +""" class database: data = {} @@ -196,5 +200,5 @@ class database: def load_database(self, location): data = pickle.load(open(location, "rb")) - +""" main() \ No newline at end of file