Commit b959fa81 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

updated processor module

parent 7e6af829
Loading
Loading
Loading
Loading
+35 −9
Original line number Diff line number Diff line
from abc import ABCMeta, abstractmethod
from abc import ABC, ABCMeta, abstractmethod
from enum import Enum


@@ -8,26 +8,52 @@ class CsstProcStatus(Enum):
    ioerror = 1
    runtimeerror = 2


#     self['empty'].info = 'Not run yet.'
#     self['normal'].info = 'This is a normal run.'
#     self['ioerror'].info = 'This run is exceptionally stopped due to IO error.'
#     self['runtimeerror'].info = 'This run is exceptionally stopped due to runtime error.'

class CsstProcessor(metaclass=ABCMeta):

class CsstProcessor(ABC):

    def __init__(self, **kwargs):
        self._status = CsstProcStatus()
        # self._status = CsstProcStatus()
        pass

    @abstractmethod
    def prepare(self, **kwargs):
        pass
        # do your preparation here
        raise NotImplementedError

    @abstractmethod
    def run(self, kwargs):
        """ """
        return self._status
    def run(self, **kwargs):
        # run your pipeline
        raise NotImplementedError

    @abstractmethod
    def cleanup(self):
        pass
        # clean up environment
        raise NotImplementedError


class CsstDemoProcessor(CsstProcessor):

    def __init__(self, **kwargs):
        super().__init__()

    def some_function(self, **kwargs):
        print("some function")

    def prepare(self):
        print("prepare")

    def run(self):
        print("run")

    def cleanup(self):
        print("clear up")


if __name__ == "__main__":
    cp = CsstDemoProcessor()