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

[BUGFIX] argilla: Prevent errors checking Dataset instances when datasets is not installed. #5045

Conversation

frascuchon
Copy link
Member

Description

When datasets package is not installed, checks to identify if a list of records is a Dataset instance fails:

File ~/Projects/argilla-io/argilla/argilla/src/argilla/records/_dataset_records.py:358, in DatasetRecords._ingest_records(self, records, mapping, user_id)
    356 if len(records) == 0:
    357     raise ValueError("No records provided to ingest.")
--> 358 if HFDatasetsIO._is_hf_dataset(dataset=records):
    359     records = HFDatasetsIO._record_dicts_from_datasets(dataset=records)
    360 if all(map(lambda r: isinstance(r, dict), records)):
    361     # Records as flat dicts of values to be matched to questions as suggestion or response

File ~/Projects/argilla-io/argilla/argilla/src/argilla/records/_io/_datasets.py:52, in HFDatasetsIO._is_hf_dataset(dataset)
     43 """Check if the object is a Hugging Face dataset.
     44
     45 Parameters:
   (...)
     49     bool: True if the object is a Hugging Face dataset, False otherwise.
     50 """
     51 HFDataset = _resolve_hf_datasets_type()
---> 52 return isinstance(dataset, HFDataset)

TypeError: isinstance() arg 2 must be a type or tuple of types

Thanks for reporting this, @maxserras

Type of change

(Please delete options that are not relevant. Remember to title the PR according to the type of change)

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested

(Please describe the tests that you ran to verify your changes. And ideally, reference tests)

  • Test A
  • Test B

Checklist

  • I followed the style guidelines of this project
  • I did a self-review of my code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I filled out the contributor form (see text above)
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

@frascuchon frascuchon merged commit 3614fe6 into feat/v2.0.0 Jun 18, 2024
7 checks passed
@frascuchon frascuchon deleted the bugfix/argilla/prevent-error-when-datasets-is-not-installed branch June 18, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants