From 8e0d8971710f8dc7b041978d0be14421843810a6 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Mon, 3 Apr 2023 14:56:19 +0100 Subject: [PATCH] [NLP] Prevent TypeError with None check (#525) --- eland/ml/pytorch/transformers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eland/ml/pytorch/transformers.py b/eland/ml/pytorch/transformers.py index ae60f48..69ef7db 100644 --- a/eland/ml/pytorch/transformers.py +++ b/eland/ml/pytorch/transformers.py @@ -393,11 +393,13 @@ class _DPREncoderWrapper(nn.Module): # type: ignore def is_compatible() -> bool: is_dpr_model = config.model_type == "dpr" - has_architectures = len(config.architectures) == 1 - is_supported_architecture = ( + has_architectures = ( + config.architectures is not None and len(config.architectures) == 1 + ) + is_supported_architecture = has_architectures and ( config.architectures[0] in _DPREncoderWrapper._SUPPORTED_MODELS_NAMES ) - return is_dpr_model and has_architectures and is_supported_architecture + return is_dpr_model and is_supported_architecture if is_compatible(): model = getattr(transformers, config.architectures[0]).from_pretrained(