Skip to content

Commit

Permalink
add an ImportError to tell the user that datasets must be install t…
Browse files Browse the repository at this point in the history
…o fit a model (#3020)
  • Loading branch information
h4c5 authored Oct 29, 2024
1 parent 96052ad commit 96a4bd7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sentence_transformers/fit_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def fit(
checkpoint_save_total_limit: Total number of checkpoints to
store
"""
if not is_datasets_available():
raise ImportError("Please install `datasets` to use this function: `pip install datasets`.")

# Delayed import to counter the SentenceTransformers -> FitMixin -> SentenceTransformerTrainer -> SentenceTransformers circular import
from sentence_transformers.trainer import SentenceTransformerTrainer

Expand Down

0 comments on commit 96a4bd7

Please sign in to comment.