From ac8002aaf8bc1cb50b4593194ac9ae92a6602029 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Mon, 28 Mar 2022 14:43:24 -0500 Subject: [PATCH] delete on start --- competition/data.py | 7 +++++++ competition/module.py | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/competition/data.py b/competition/data.py index bd833ee..1cf0131 100644 --- a/competition/data.py +++ b/competition/data.py @@ -11,6 +11,7 @@ def pull_new_tba_matches(apikey, competition, cutoff): for i in json: if i["actual_time"] != None 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"]}) + out.sort(key=lambda x: x['match']) return out def pull_new_tba_matches_manual(apikey, competition, cutoff): @@ -27,6 +28,12 @@ def get_team_match_data(client, competition, team_num): out[i['match']] = i['data'] return pd.DataFrame(out) +def clear_metrics(client, competition): + db = client.data_processing + data = db.team_metrics + data.delete_many({competition: competition}) + return True + def get_team_pit_data(client, competition, team_num): db = client.data_scouting mdata = db.pitdata diff --git a/competition/module.py b/competition/module.py index f5d5023..eaeed4c 100644 --- a/competition/module.py +++ b/competition/module.py @@ -3,6 +3,7 @@ import data as d import signal import numpy as np from tra_analysis import Analysis as an +from tqdm import tqdm class Module(metaclass = abc.ABCMeta): @@ -173,6 +174,8 @@ class Metric (Module): def _process_data(self): + d.clear_metrics(self.apikey, self.competition) + elo_N = self.config["tests"]["elo"]["N"] elo_K = self.config["tests"]["elo"]["K"] @@ -180,9 +183,7 @@ class Metric (Module): red = {} blu = {} - - for match in matches: - + for match in tqdm(matches, desc="Metrics"): red = d.load_metric(self.apikey, self.competition, match, "red", self.config["tests"]) blu = d.load_metric(self.apikey, self.competition, match, "blue", self.config["tests"])