patched issue in multiprocessing,

moved ConfigurationError to exceptions.py,
made pull use load_config in config.py


Former-commit-id: aed03369c9
This commit is contained in:
Arthur Lu 2022-01-10 20:23:14 +00:00
parent a940f3ffeb
commit 7d08194636
4 changed files with 64 additions and 62 deletions

View File

@ -3,6 +3,7 @@ import json
from multiprocessing import Pool from multiprocessing import Pool
import os import os
from cerberus import Validator from cerberus import Validator
from exceptions import ConfigurationError
from data import set_database_config, get_database_config from data import set_database_config, get_database_config
from interface import stderr, stdout, INF, ERR from interface import stderr, stdout, INF, ERR
@ -134,12 +135,6 @@ sample_json = """
} }
""" """
class ConfigurationError (Exception):
code = None
def __init__(self, str, code):
super().__init__(str)
self.code = code
def parse_config_persistent(send, config): def parse_config_persistent(send, config):
v = Validator(load_validation_schema(), allow_unknown = True) v = Validator(load_validation_schema(), allow_unknown = True)
isValidated = v.validate(config) isValidated = v.validate(config)

View File

@ -3,3 +3,9 @@ class APIError(Exception):
def __init__(self, str, endpoint): def __init__(self, str, endpoint):
super().__init__(str) super().__init__(str)
self.endpoint = endpoint self.endpoint = endpoint
class ConfigurationError (Exception):
code = None
def __init__(self, str, code):
super().__init__(str)
self.code = code

View File

@ -2,7 +2,7 @@ import abc
import data as d import data as d
import signal import signal
import numpy as np import numpy as np
import tra_analysis as an from tra_analysis import Analysis as an
class Module(metaclass = abc.ABCMeta): class Module(metaclass = abc.ABCMeta):
@ -54,7 +54,7 @@ class Match (Module):
def _load_data(self): def _load_data(self):
self.data = d.load_match(self.apikey, self.competition) self.data = d.load_match(self.apikey, self.competition)
def _simplestats(data_test): def _simplestats(self, data_test):
signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN)
@ -103,7 +103,10 @@ class Match (Module):
input_vector.append((team, variable, test, data[team][variable])) input_vector.append((team, variable, test, data[team][variable]))
self.data = input_vector self.data = input_vector
self.results = list(exec_threads.map(self._simplestats, self.data)) #self.results = list(exec_threads.map(self._simplestats, self.data))
self.results = []
for test_var_data in self.data:
self.results.append(self._simplestats(test_var_data))
def _push_results(self): def _push_results(self):

View File

@ -1,13 +1,11 @@
import requests import requests
import json import json
from exceptions import APIError from exceptions import APIError
from config import load_config
def load_config(path):
with open(path, "r") as f:
return json.load(f)
url = "https://titanscouting.epochml.org" url = "https://titanscouting.epochml.org"
config_tra = load_config("config.json") config_tra = {}
load_config("config.json", config_tra)
trakey = config_tra['persistent']['key']['tra'] trakey = config_tra['persistent']['key']['tra']
def get_team_competition(): def get_team_competition():