From 1a97d02443d2e1f00db496dbe180eac493955080 Mon Sep 17 00:00:00 2001 From: Giuseppe Ambrosio Date: Mon, 9 Dec 2024 15:27:56 +0100 Subject: [PATCH] refactor(focoos): get_model_by_name found logic --- focoos/focoos.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/focoos/focoos.py b/focoos/focoos.py index cf1d1d4..7b8d68d 100644 --- a/focoos/focoos.py +++ b/focoos/focoos.py @@ -165,16 +165,10 @@ def get_dataset_by_name(self, name: str) -> Optional[DatasetMetadata]: def get_model_by_name( self, name: str, remote=True ) -> Optional[Union[RemoteModel, LocalModel]]: - found = False models = self.list_models() for model in models: if name.lower() == model.name.lower(): - found = True - break - if found: - if remote: - return self.get_remote_model(model.ref) - else: - return self.get_local_model(model.ref) - else: - return None + if remote: + return self.get_remote_model(model.ref) + else: + return self.get_local_model(model.ref)