mirror of
https://github.com/titanscouting/tra-superscript.git
synced 2024-11-10 06:54:45 +00:00
formalized module interface
This commit is contained in:
parent
0fd24d42e1
commit
108284a94b
@ -1,24 +1,37 @@
|
|||||||
|
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
|
import tra_analysis as an
|
||||||
|
|
||||||
class Module:
|
class Module(metaclass = abc.ABCMeta):
|
||||||
config = None
|
|
||||||
data = None
|
|
||||||
results = None
|
|
||||||
def __init__(self, config, apikey, tbakey, timestamp):
|
|
||||||
pass
|
|
||||||
def validate_config(self):
|
|
||||||
pass
|
|
||||||
def load_data(self):
|
|
||||||
pass
|
|
||||||
def process_data(self, exec_threads):
|
|
||||||
pass
|
|
||||||
def push_results(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Match:
|
@classmethod
|
||||||
|
def __subclasshook__(cls, subclass):
|
||||||
|
return (hasattr(subclass, 'validate_config') and
|
||||||
|
callable(subclass.validate_config) and
|
||||||
|
hasattr(subclass, 'load_data') and
|
||||||
|
callable(subclass.load_data) and
|
||||||
|
hasattr(subclass, 'process_data') and
|
||||||
|
callable(subclass.process_data) and
|
||||||
|
hasattr(subclass, 'push_results') and
|
||||||
|
callable(subclass.push_results)
|
||||||
|
)
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def validate_config(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
@abc.abstractmethod
|
||||||
|
def load_data(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
@abc.abstractmethod
|
||||||
|
def process_data(self, exec_threads):
|
||||||
|
raise NotImplementedError
|
||||||
|
@abc.abstractmethod
|
||||||
|
def push_results(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
class Match (Module):
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
apikey = None
|
apikey = None
|
||||||
@ -128,7 +141,7 @@ class Match:
|
|||||||
|
|
||||||
d.push_match(self.apikey, self.competition, self.results)
|
d.push_match(self.apikey, self.competition, self.results)
|
||||||
|
|
||||||
class Metric:
|
class Metric (Module):
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
apikey = None
|
apikey = None
|
||||||
@ -248,7 +261,7 @@ class Metric:
|
|||||||
def push_results(self):
|
def push_results(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Pit:
|
class Pit (Module):
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
apikey = None
|
apikey = None
|
||||||
|
Loading…
Reference in New Issue
Block a user