From fa35120448ea1cb3ca0a5121c96be105589b4931 Mon Sep 17 00:00:00 2001 From: Alessandro Sordoni Date: Thu, 24 Oct 2024 10:46:01 -0700 Subject: [PATCH] fix fallback for model --- mttl/models/library/expert.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mttl/models/library/expert.py b/mttl/models/library/expert.py index 6e693d843..6b3667501 100644 --- a/mttl/models/library/expert.py +++ b/mttl/models/library/expert.py @@ -29,12 +29,16 @@ def model(self): """Returns the expert model associated with the expert. Tries to get it from training_config if expert_model is None for back-compatibility. """ - return self.expert_model or getattr(self.training_config, "model", None) + if self.expert_model: + return self.expert_model + elif self.training_config: + # fallback to training config + return self.training_config.get("model") @property def dataset(self): """Returns the dataset name from training config or an empty string.""" - return getattr(getattr(self, "training_config", {}), "dataset", "") + return getattr(self, "training_config", {}).get("dataset", "") @property def modifier_name(self):