Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Mar 16, 2024
1 parent 048e820 commit 194e0c0
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,8 @@ def get_model_instance(self, model_type: ModelType) -> AIModel:
parent_module = '.'.join(self.__class__.__module__.split('.')[:-1])
mod = load_module_from_source(
f"{parent_module}.{model_type_name}.{model_type_name}", model_type_py_path)
classes = get_subclasses(mod, AIModel)
model_class = None
for obj in classes:
if not obj.__abstractmethods__ and obj.__module__ == mod.__name__:
model_class = obj
break

model_class = next(filter(lambda x: x.__module__ == mod.__name__ and not x.__abstractmethods__,
get_subclasses(mod, AIModel)), None)
if not model_class:
raise Exception(f'Missing AIModel Class for model type {model_type} in {model_type_py_path}')

Expand Down

0 comments on commit 194e0c0

Please sign in to comment.