MP-002: Add ml dependency injection#3
Conversation
| pass | ||
|
|
||
| @classmethod | ||
| def create(cls, config: Union[str, Dict[str, Any]]): |
There was a problem hiding this comment.
Seems a bit of duplication between other base classes. This could be exported into a factory class
| self.model.set_params(params) | ||
|
|
||
|
|
||
| class Adam(Optimizer): |
| return self.transform(data) | ||
|
|
||
| @classmethod | ||
| def create(cls, config: Union[str, Dict[str, Any]]): |
There was a problem hiding this comment.
Same as above, could be just Factory.create()
|
|
||
| base_classes = [ | ||
| DataLoader, MetricFunction, Tracker, Preprocessor, | ||
| TrainLoop, Optimizer, Model |
There was a problem hiding this comment.
Instead of creating this list here, can we use Factory. register_component_type to add it to this list? Also this decorator could register the keyword in yaml (e.g. 'preprocessor' that you can leverage in create().
| (hasattr(param_type, "__origin__") and | ||
| param_type.__origin__ is Optional and | ||
| param_type.__args__[0] == bc)): | ||
| if bc.__name__.lower() not in self.dependency_graph[class_name]: |
There was a problem hiding this comment.
As we chatted last time - now it makes more sense why you asked about scalability with lots of classes. Normally we would not be explicit on the dependency graph but construct the part as needed (in create() method we would recursively collect everything we need).
No description provided.