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

ImportError: cannot import name 'DatasetFilter' from 'huggingface_hub' (/opt/conda/lib/python3.10/site-packages/huggingface_hub/init.py) #2401

Closed
JayeetaP opened this issue Jul 18, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@JayeetaP
Copy link

Describe the bug

Hi,

I have been using Setfit for the last month with no errors. This morning when I tried to rerun the same code, with no changes, looks 'DatasetFilter' import from huggingface_hub is failing.

The associated issue in setfit branch: huggingface/setfit#544

Reproduction

from setfit import SetFitModel, Trainer, TrainingArguments

Logs

ImportError Traceback (most recent call last)
Cell In[15], line 8
6 from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay, precision_score, recall_score, f1_score, classification_report
7 import matplotlib.pyplot as plt
----> 8 from setfit import SetFitModel, Trainer, TrainingArguments
9 from sentence_transformers.losses import CosineSimilarityLoss
10 from datasets import Dataset

File /opt/conda/lib/python3.10/site-packages/setfit/init.py:8
5 import warnings
7 from .data import get_templated_dataset, sample_dataset
----> 8 from .model_card import SetFitModelCardData
9 from .modeling import SetFitHead, SetFitModel
10 from .span import AbsaModel, AbsaTrainer, AspectExtractor, AspectModel, PolarityModel

File /opt/conda/lib/python3.10/site-packages/setfit/model_card.py:14
12 import transformers
13 from datasets import Dataset
---> 14 from huggingface_hub import CardData, DatasetFilter, ModelCard, dataset_info, list_datasets, model_info
15 from huggingface_hub.repocard_data import EvalResult, eval_results_to_model_index
16 from huggingface_hub.utils import yaml_dump

ImportError: cannot import name 'DatasetFilter' from 'huggingface_hub' (/opt/conda/lib/python3.10/site-packages/huggingface_hub/init.py)

System info

Name: transformers
Version: 4.39.0
Name: setfit
Version: 1.0.3
Name: huggingface-hub
Version: 0.24.0
Python: 3.10
@JayeetaP JayeetaP added the bug Something isn't working label Jul 18, 2024
@Wauplin
Copy link
Contributor

Wauplin commented Jul 18, 2024

Hi @JayeetaP, sorry for the inconvenience this is caused by a recent breaking change introduce in 0.24.0 release. The use of DatasetFilter has been deprecated for a few months already and reached its end of life. Could you update SetFit to its latest version and retry? If the problem persists, then could you downgrade your local huggingface_hub version and open an issue on Setfit repository? Thanks!

@JayeetaP
Copy link
Author

JayeetaP commented Jul 18, 2024

Thanks for the response @Wauplin!

I am on the latest version of Setfit: 1.0.3. Can you confirm if that's not the latest release?
I downgraded huggingface_hub version to 0.23.0 and it still didn't work. Any recommendation on which version I should use?
I already have an issue open in the Setfit repository: huggingface/setfit#544

@chenmoneygithub
Copy link

+1, seeing the same issue.

@Wauplin
Copy link
Contributor

Wauplin commented Jul 19, 2024

I replied in huggingface/setfit#544 (comment) about the fuller context. 2 solutions while waiting for a proper fix: either downgrade huggingface_hub version or install setfit from source with the fix introduced in huggingface/setfit#527.

@JayeetaP I'm surprised installing huggingface_hub==0.23.0 did not work. I just tried with 0.23.5 and it works for me. Maybe the installation did not go well? Sometimes it's better to uninstall and reinstall completely to be sure of the change (and restart the runtime)

@RubTalha
Copy link

RubTalha commented Jul 24, 2024

https://stackoverflow.com/a/78788391/13086128

@JayeetaP
Copy link
Author

JayeetaP commented Jul 24, 2024

like I mentioned in huggingface/setfit#544 (comment), I had to uninstall, re-install, and restart so now huggingface_hub version 0.23.5 works. I am unblocked for now! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants