Skip to content

Commit

Permalink
Update OpusMT.py
Browse files Browse the repository at this point in the history
Fix #19
  • Loading branch information
nreimers authored Mar 10, 2021
1 parent db9a17d commit 27bef67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions easynmt/models/OpusMT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down

0 comments on commit 27bef67

Please sign in to comment.