1. 提交代码,初始化项目;
This commit is contained in:
2
algos/__init__.py
Normal file
2
algos/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from algos.base import BaseRunner, BaseAlgoModel
|
||||
from algos.blank import BlankAlgo, BlankRunner
|
||||
23
algos/base.py
Normal file
23
algos/base.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class BaseRunner(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def build_model(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def run_test(self):
|
||||
pass
|
||||
|
||||
|
||||
class BaseAlgoModel(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def forward(self, *args, **kwargs):
|
||||
pass
|
||||
35
algos/blank.py
Normal file
35
algos/blank.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import logging
|
||||
from algos import BaseRunner, BaseAlgoModel
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BlankAlgo(BaseAlgoModel):
|
||||
|
||||
def forward(self, *args, **kwargs):
|
||||
logger.warning("There is no such algo type, running blank algo class.")
|
||||
|
||||
|
||||
class BlankRunner(BaseRunner):
|
||||
|
||||
def build_model(self):
|
||||
logger.warning("There is no such algo runner, running blank building process.")
|
||||
|
||||
def run(self):
|
||||
logger.warning("There is no such algo runner, running blank runner.")
|
||||
|
||||
def run_test(self):
|
||||
logger.warning("There is no such algo runner, running blank testing process.")
|
||||
|
||||
|
||||
def test_blank_runner():
|
||||
runner = BlankRunner()
|
||||
runner.run()
|
||||
runner.run_test()
|
||||
|
||||
def test_blank_algo():
|
||||
algo = BlankAlgo()
|
||||
algo.forward()
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_blank_algo()
|
||||
test_blank_runner()
|
||||
Reference in New Issue
Block a user