@@ -77,11 +77,26 @@ def __call__(cls, *args, **kwargs):
77
77
78
78
obj = type .__call__ (cls , * args , ** kwargs )
79
79
80
- obj ._set_gnes_config (** kwargs )
80
+ # set attribute
81
+ for k , v in TrainableType .default_gnes_config .items ():
82
+ if k in kwargs :
83
+ v = kwargs [k ]
84
+ setattr (obj , k , v )
85
+
86
+ if not getattr (obj , 'name' , None ):
87
+ _id = str (uuid .uuid4 ()).split ('-' )[0 ]
88
+ _name = '%s-%s' % (obj .__class__ .__name__ , _id )
89
+ obj .logger .warning (
90
+ 'this object is not named ("- gnes_config: - name" is not found in YAML config), '
91
+ 'i will call it as "%s". '
92
+ 'naming the object is important especially when you need to '
93
+ 'serialize/deserialize/store/load the object.' % _name )
94
+ setattr (obj , 'name' , _name )
81
95
82
96
getattr (obj , '_post_init_wrapper' , lambda * x : None )()
83
97
return obj
84
98
99
+
85
100
@staticmethod
86
101
def register_class (cls ):
87
102
# print('try to register class: %s' % cls.__name__)
@@ -166,22 +181,6 @@ def post_init(self):
166
181
def pre_init (cls ):
167
182
pass
168
183
169
- def _set_gnes_config (self , ** kwargs ):
170
- # set attribute
171
- for k , v in TrainableType .default_gnes_config .items ():
172
- if k in kwargs :
173
- v = kwargs [k ]
174
- setattr (self , k , v )
175
-
176
- if not getattr (self , 'name' , None ):
177
- _id = str (uuid .uuid4 ()).split ('-' )[0 ]
178
- _name = '%s-%s' % (self .__class__ .__name__ , _id )
179
- self .logger .warning (
180
- 'this object is not named ("- gnes_config: - name" is not found in YAML config), '
181
- 'i will call it as "%s". '
182
- 'However, naming the object is important especially when you need to '
183
- 'serialize/deserialize/store/load the object.' % _name )
184
- setattr (self , 'name' , _name )
185
184
186
185
@property
187
186
def dump_full_path (self ):
0 commit comments