3
3
"""the DAG module of chef"""
4
4
5
5
import pandas as pd
6
- from . procedure import *
7
-
8
- # supported procedures
9
- supported_procs = {
10
- 'translate_column' : translate_column ,
11
- 'translate_header' : translate_header ,
12
- 'identity' : identity ,
13
- 'merge' : merge ,
14
- 'run_op' : run_op ,
15
- 'filter_row' : filter_row ,
16
- 'align' : align ,
17
- 'filter_item' : filter_item ,
18
- 'groupby' : groupby ,
19
- 'accumulate' : accumulate ,
20
- 'copy' : copy ,
21
- 'extract_concepts' : extract_concepts
22
- }
6
+ from . import procedure as pc
23
7
24
8
25
9
class BaseNode ():
@@ -94,12 +78,12 @@ def __init__(self, node_id, procedure, dag):
94
78
def evaluate (self ):
95
79
if self .result_ingredient :
96
80
return self .result_ingredient
97
- funcs = supported_procs
98
- func = self .procedure ['procedure' ]
99
81
100
- # raise error if procedure not supported
101
- if func not in funcs .keys () and func != 'serve' :
102
- raise NotImplementedError ("Not supported: " + func )
82
+ # get the procedure function, raise error if procedure not supported
83
+ try :
84
+ func = getattr (pc , self .procedure ['procedure' ])
85
+ except AttributeError :
86
+ raise NotImplementedError ("Not supported: " + self .procedure ['procedure' ])
103
87
104
88
# check the base ingredients and convert the string id to actual ingredient
105
89
ingredients = []
@@ -121,7 +105,7 @@ def evaluate(self):
121
105
else :
122
106
options = dict ()
123
107
124
- self .result_ingredient = funcs [ func ] (* ingredients , result = self .procedure ['result' ], ** options )
108
+ self .result_ingredient = func (* ingredients , result = self .procedure ['result' ], ** options )
125
109
return self .result_ingredient
126
110
127
111
0 commit comments