1+ import inspect
12from abc import ABC , abstractmethod
23from functools import wraps
3- from typing import Any , Dict , List , Protocol , Union
4+ from typing import Any , Dict , List , Protocol , Type , Union
45
56from dingo .io import MetaData , SummaryModel
67
@@ -19,35 +20,18 @@ def summarize(self, inputs: MetaData) -> SummaryModel:
1920 ...
2021
2122
22- class Executor (ABC ):
23- exec_map : Dict [str , Any ] = {}
24-
25- @abstractmethod
26- def load_data (self ) -> List [MetaData ]:
27- raise NotImplementedError ()
28-
29- @abstractmethod
30- def execute (self , * args , ** kwargs ) -> List [SummaryModel ]:
31- raise NotImplementedError ()
32-
33- @abstractmethod
34- def evaluate (self , * args , ** kwargs ) -> Union [SummaryModel , List [SummaryModel ], Any ]:
35- raise NotImplementedError ()
36-
37- @abstractmethod
38- def summarize (self ) -> SummaryModel :
39- raise NotImplementedError ()
23+ class Executor :
24+ exec_map : Dict [str , Type [ExecProto ]] = {}
4025
4126 @classmethod
4227 def register (cls , exec_name : str ):
4328
4429 def decorator (root_exec ):
4530 cls .exec_map [exec_name ] = root_exec
4631
47- @wraps (root_exec )
48- def wrapped_function (* args , ** kwargs ):
49- return root_exec (* args , ** kwargs )
50-
51- return wrapped_function
32+ if inspect .isclass (root_exec ):
33+ return root_exec
34+ else :
35+ raise ValueError ("root_exec must be a class" )
5236
5337 return decorator
0 commit comments