Skip to content

Commit

Permalink
[NLP] Prevent TypeError with None check (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle authored Apr 3, 2023
1 parent cebee64 commit 8e0d897
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions eland/ml/pytorch/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,13 @@ def from_pretrained(model_id: str) -> Optional[Any]:

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(
Expand Down

0 comments on commit 8e0d897

Please sign in to comment.