Skip to content

Commit a0ed550

Browse files
authored
bug(medcat): CU-869b36xv7 Avoid meta cat issue when getting model card (#217)
* CU-869b36xv7: Avoid import error when getting model card * CU-869b36xv7: Fix minor typing issue
1 parent b583483 commit a0ed550

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

medcat-v2/medcat/cat.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,19 @@ def get_model_card(self, as_dict: bool = False) -> Union[str, ModelCard]:
910910
Returns:
911911
Union[str, ModelCard]: The model card.
912912
"""
913-
from medcat.components.addons.meta_cat import MetaCATAddon
914-
met_cat_model_cards = [
915-
mc.mc.get_model_card(True) for mc in
916-
self.get_addons_of_type(MetaCATAddon)
917-
]
913+
has_meta_cat = True
914+
try:
915+
from medcat.components.addons.meta_cat import MetaCATAddon
916+
except MissingDependenciesError:
917+
has_meta_cat = False
918+
met_cat_model_cards: list[dict]
919+
if has_meta_cat:
920+
met_cat_model_cards = [
921+
mc.mc.get_model_card(True) for mc in
922+
self.get_addons_of_type(MetaCATAddon)
923+
]
924+
else:
925+
met_cat_model_cards = []
918926
cdb_info = self.cdb.get_basic_info()
919927
model_card: ModelCard = {
920928
'Model ID': self.config.meta.hash,

0 commit comments

Comments
 (0)