mirror of
https://github.com/titanscouting/tra-superscript.git
synced 2024-11-10 06:54:45 +00:00
added file logging with default,
added basic progress bars for each module
This commit is contained in:
parent
5885224231
commit
0024a94f4e
@ -23,7 +23,7 @@ class Logger(L):
|
||||
|
||||
self.file = file
|
||||
|
||||
if file != None:
|
||||
if file is not None:
|
||||
self.targets.append(self._send_file)
|
||||
|
||||
if profile:
|
||||
|
@ -2,6 +2,7 @@ import abc
|
||||
import signal
|
||||
import numpy as np
|
||||
from tra_analysis import Analysis as an
|
||||
from tqdm import tqdm
|
||||
|
||||
class Module(metaclass = abc.ABCMeta):
|
||||
|
||||
@ -87,7 +88,7 @@ class Match (Module):
|
||||
|
||||
input_vector = []
|
||||
|
||||
for team in data:
|
||||
for team in tqdm(data, desc = "Match Module ", unit = " team"):
|
||||
|
||||
for variable in data[team]:
|
||||
|
||||
@ -174,7 +175,7 @@ class Metric (Module):
|
||||
red = {}
|
||||
blu = {}
|
||||
|
||||
for match in matches:
|
||||
for match in tqdm(matches, desc = "Metric Module ", unit = " match"):
|
||||
|
||||
red = self.client.load_metric(match, "red", self.config["tests"])
|
||||
blu = self.client.load_metric(match, "blue", self.config["tests"])
|
||||
@ -290,7 +291,7 @@ class Pit (Module):
|
||||
def _process_data(self):
|
||||
tests = self.config["tests"]
|
||||
return_vector = {}
|
||||
for team in self.data:
|
||||
for team in tqdm(self.data, desc = "Pit Module ", unit = " team"):
|
||||
for variable in self.data[team]:
|
||||
if variable in tests:
|
||||
if not variable in return_vector:
|
||||
|
@ -250,12 +250,12 @@ def main(logger, verbose, profile, debug, config_path):
|
||||
close_all()
|
||||
return 1
|
||||
|
||||
def start(verbose, profile, debug, config_path):
|
||||
def start(verbose, profile, debug, config_path, log_path):
|
||||
|
||||
logger = Logger(verbose, profile, debug, file = log_path)
|
||||
|
||||
if profile:
|
||||
|
||||
logger = Logger(verbose, profile, debug)
|
||||
|
||||
import cProfile, pstats, io
|
||||
profile = cProfile.Profile()
|
||||
profile.enable()
|
||||
@ -268,15 +268,11 @@ def start(verbose, profile, debug, config_path):
|
||||
|
||||
elif verbose:
|
||||
|
||||
logger = Logger(verbose, profile, debug)
|
||||
|
||||
exit_code = main(logger, verbose, profile, debug, config_path)
|
||||
sys.exit(exit_code)
|
||||
|
||||
elif debug:
|
||||
|
||||
logger = Logger(verbose, profile, debug)
|
||||
|
||||
exit_code = main(logger, verbose, profile, debug, config_path)
|
||||
sys.exit(exit_code)
|
||||
|
||||
@ -289,7 +285,7 @@ if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description = "TRA data processing application.")
|
||||
parser.add_argument("mode", metavar = "MODE", type = str, nargs = 1, choices = ["verbose", "profile", "debug"], help = "verbose, debug, profile")
|
||||
parser.add_argument("--config", dest = "config", default = "config.json", type = str, help = "path to config file")
|
||||
parser.add_argument("--logfile", dest = "logfile", default = "logfile", type = str, help = "path to log file")
|
||||
parser.add_argument("--logfile", dest = "logfile", default = "logfile.log", type = str, help = "path to log file")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -297,10 +293,10 @@ if __name__ == "__main__":
|
||||
config_path = args.config
|
||||
log_path = args.logfile
|
||||
if mode == "verbose":
|
||||
start(True, False, False, config_path = config_path)
|
||||
start(True, False, False, config_path = config_path, log_path = log_path)
|
||||
elif mode == "profile":
|
||||
start(False, True, False, config_path = config_path)
|
||||
start(False, True, False, config_path = config_path, log_path = log_path)
|
||||
elif mode == "debug":
|
||||
start(False, False, True, config_path = config_path)
|
||||
start(False, False, True, config_path = config_path, log_path = log_path)
|
||||
|
||||
exit(0)
|
Loading…
Reference in New Issue
Block a user