Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NLP] Prevent TypeError with None check #525

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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