From c3746539b389bfd1b8f3f75c3c048f3cb99e6c55 Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:57:20 -0600 Subject: [PATCH] superscript.py v 0.0.1.002 --- data analysis/__pycache__/data.cpython-37.pyc | Bin 3039 -> 3007 bytes data analysis/data.py | 14 ++- data analysis/superscript.py | 81 +++--------------- 3 files changed, 18 insertions(+), 77 deletions(-) diff --git a/data analysis/__pycache__/data.cpython-37.pyc b/data analysis/__pycache__/data.cpython-37.pyc index 893d83c0ff18807826cb7300722c5a5c9b356cc4..3a5788584c97369b15d44cf40f0e2a904a408ebd 100644 GIT binary patch literal 3007 zcmcguTW=f36`t7}m!vMXtT>^Ywn;Ck7{p?t^lG?9^)NOH1tcmp}Jn4u{aaC-f)fN16)_>(0PGP$_ol0K}p}Tzu(f>rzu&Hm@5f{AS zuQK65{KhZ12)^;A!2z3wCruN~ygB=b{jHuxO(en|YrNN(h#rRO9rRm0CgO)4+TqMc zzujXdFyZ2E=&xXY6|&Z2kG;qIJ9F#jb69-^y{k`yIp^%rJNKE1X3?BYTTKXSHg->M z9vV~YTZ6&z@$t4flzZh^W@TAqRW7&l(QuH}#o+7r2l8uKnZfD$V3?WwQ0jp$hIJ`V z*S@%U@9qaTKNy?C^iw(M^Q3hsGa;2ux>;_#cD?O-V&mIoHrx~0ofRnf4}_h*RgcRu zt>kfP_OkT3$=kQfQJ$6h4jPLMN&5^cZ399sX&adh(}!}Rt*@j=t{fLtRa6J**}{Hc zL#I!*agd_eu@Nnjs^7A)l8?qx8|*%iCJB!8sIpO3*Rm2eC<|?@Kg?g(+x#J~pHM{iKCSx{4w&tv?zY%Zp@{wx(sKO**cH18q@6v}*HZhSQ951mgj} z0a@d(^Lsqz>NU)~kPGAkmkYaS7&hY#oAW6$;0V#*1V{cfEZ8(U*+Ogw4R1WbpL%nS zT-ZcRwgf!fM5z59yS<3laE2V2lh=dYzNa>!H(7Bg>l`LY;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Kf*!Cr0TtLtuq-Gbhb{u7D2}&^(3%S6&Ufy#k{2~)kFY6>~Ht?AEwb4{@8aKpDG8Ft+2v7;u^Nt8_} zUf~|Uz~{M~KwnHwqK5{QP^`0-p=dUMdxo3>c-`rHxwr22ODXI7Thn=I;N=`n;4k0; zIBmQi=|pl8 z!i09WR<~*VxLC{)E7;G@c45PbD4rt}?M%Cs_4X+&r^X-{p!D&2i2QLbKSa-Kh0`8P zzJYD!6p0HEwLrc}`dcI}Lezs!s_BsOZR&c5#3hKs;K+BWmzYexPvSC(4@jI8S!eb! z!O9j9GT|gduAqNE6Nw3kcx-@aCts zW2xxP!34XRKaI>sa0;;QGjQ&6uz_|pF+SS4yW{MDnR5rhI96~3czEBS|Dy&;A9pE1 zp5N0CNI{OEZ<_i?A+|4eTgd73aj!9-okRwb!sV4Ve)%dJ*Y-B9m5fJZBF~}6ctjP( z%TlF{+l)Fjzdn*hy#&P55NWIrTx#4%2ounFOgDV}ID1qN9f*QMorPeC^f45Vp9O)O zMv>RhyMHedh3tE{gT_9EfUiLzL?kW|$-paaOpr@KC^z#GB4D8(^rm%5`|vZ@Ae0@x z;|{_h8Zc9)H815f7e5iT@&WS}= 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): @@ -22,14 +21,11 @@ def get_team_match_data(apikey, competition, team_num): out[i['match']] = i['data'] return pd.DataFrame(out) -def get_team_pit_data(apikey, competition, team_num): +def get_team_metrics_data(apikey, competition, team_num): client = pymongo.MongoClient(apikey) - db = client.data_scouting - mdata = db.pitdata - out = {} - for i in mdata.find({"competition" : competition, "team_scouted": team_num}): - out[i['match']] = i['data'] - return pd.DataFrame(out) + db = client.data_processing + mdata = db.team_metrics + return mdata.find_one({"competition" : competition, "team": team_num}) def unkeyify_2l(layered_dict): out = {} diff --git a/data analysis/superscript.py b/data analysis/superscript.py index ccc3b9b1..35cd1ffe 100644 --- a/data analysis/superscript.py +++ b/data analysis/superscript.py @@ -3,10 +3,12 @@ # Notes: # setup: -__version__ = "0.0.1.001" +__version__ = "0.0.1.002" # changelog should be viewed using print(analysis.__changelog__) __changelog__ = """changelog: + 0.0.1.002: + - started implement of metrics 0.0.1.001: - cleaned up imports 0.0.1.000: @@ -59,6 +61,8 @@ from analysis import analysis as an import data as d import time +main() + def main(): while(True): current_time = time.time() @@ -70,6 +74,7 @@ def main(): print("loading database keys") apikey = an.load_csv("keys.txt")[0][0] + tbakey = an.load_csv("keys.txt")[1][0] print("loaded keys") print("loading data") @@ -79,6 +84,10 @@ def main(): print("running tests") results = simpleloop(data, config) print("finished tests") + + print("running metrics") + metrics = metricsloop(apikey, competition, current_time) + print("finished metrics") print("pushing to database") push_to_database(apikey, competition, results, None) @@ -138,72 +147,8 @@ def push_to_database(apikey, competition, results, metrics): d.push_team_tests_data(apikey, competition, team, results[team]) -def metricsloop(group_data, observations, database, tests): # listener based metrics update +def metricsloop(apikey, competition, timestamp): # listener based metrics update - pass + matches = d.pull_new_tba_matches(apikey, competition, timestamp) -""" -class database: - - data = {} - - elo_starting_score = 1500 - N = 1500 - K = 32 - - gl2_starting_score = 1500 - gl2_starting_rd = 350 - gl2_starting_vol = 0.06 - - def __init__(self, team_lookup): - super().__init__() - - for team in team_lookup: - - elo = elo_starting_score - gl2 = {"score": gl2_starting_score, "rd": gl2_starting_rd, "vol": gl2_starting_vol} - ts = Trueskill.Rating() - - data[str(team)] = {"elo": elo, "gl2": gl2, "ts": ts} - - def get_team(self, team): - - return data[team] - - def get_elo(self, team): - - return data[team]["elo"] - - def get_gl2(self, team): - - return data[team]["gl2"] - - def get_ts(self, team): - - return data[team]["ts"] - - def set_team(self, team, ndata): - - data[team] = ndata - - def set_elo(self, team, nelo): - - data[team]["elo"] = nelo - - def set_gl2(self, team, ngl2): - - data[team]["gl2"] = ngl2 - - def set_ts(self, team, nts): - - data[team]["ts"] = nts - - def save_database(self, location): - - pickle.dump(data, open(location, "wb")) - - def load_database(self, location): - - data = pickle.load(open(location, "rb")) -""" -main() \ No newline at end of file + return \ No newline at end of file