Skip to content

Commit

Permalink
🎉 ModelCache: add get_loaded_model_ids method.
Browse files Browse the repository at this point in the history
  • Loading branch information
asaf-kali committed Jun 4, 2024
1 parent cd722c0 commit be3b17f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[tool.poetry]
name = "codenames-solvers"
version = "1.7.2"
version = "1.7.3"
description = "Solvers implementation for Codenames board game in python."
authors = ["Michael Kali <[email protected]>", "Asaf Kali <[email protected]>"]
readme = "README.md"
Expand Down
7 changes: 6 additions & 1 deletion solvers/models/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from os.path import expanduser
from threading import Lock
from typing import Dict
from typing import Dict, Set

import gensim.downloader as gensim_api
from generic_iterative_stemmer.models import StemmedKeyedVectors
Expand All @@ -25,6 +25,11 @@ def _get_model_lock(self, model_identifier: ModelIdentifier) -> Lock:
model_lock = self._model_locks.setdefault(model_identifier, Lock())
return model_lock

def get_loaded_model_ids(self) -> Set[ModelIdentifier]:
with self._main_lock:
keys = set(self._cache.keys())
return keys

def is_loaded(self, model_identifier: ModelIdentifier) -> bool:
return model_identifier in self._cache

Expand Down

0 comments on commit be3b17f

Please sign in to comment.