From 27bef674d6a76f96c73581463c631ecca762473d Mon Sep 17 00:00:00 2001 From: Nils Reimers Date: Wed, 10 Mar 2021 11:37:40 +0100 Subject: [PATCH] Update OpusMT.py Fix #19 --- easynmt/models/OpusMT.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/easynmt/models/OpusMT.py b/easynmt/models/OpusMT.py index a82155e..f67dd57 100644 --- a/easynmt/models/OpusMT.py +++ b/easynmt/models/OpusMT.py @@ -33,10 +33,10 @@ def load_model(self, model_name): if len(self.models) >= self.max_loaded_models: oldest_time = time.time() oldest_model = None - for model_name in self.models: - if self.models[model_name]['last_loaded'] <= oldest_time: - oldest_model = model_name - oldest_time = self.models[model_name]['last_loaded'] + for loaded_model_name in self.models: + if self.models[loaded_model_name]['last_loaded'] <= oldest_time: + oldest_model = loaded_model_name + oldest_time = self.models[loaded_model_name]['last_loaded'] del self.models[oldest_model] self.models[model_name] = {'tokenizer': tokenizer, 'model': model, 'last_loaded': time.time()}