fix: raise error in FolderBasedBuilder when data_dir and data_files are missing #7623
+7
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues/PRs
Fixes #6152
What changes are proposed in this pull request?
This PR adds a dedicated validation check in the
_info()
method of theFolderBasedBuilder
class to ensure that users provide eitherdata_dir
ordata_files
when loading folder-based datasets (such asaudiofolder
,imagefolder
, etc.).Why this change?
Previously, when calling:
without specifying
data_dir
ordata_files
, the loader would silently fallback to the current working directory, leading to:This behavior was discussed in issue #6152. As suggested by maintainers, the fix has now been implemented directly inside the
FolderBasedBuilder._info()
method — keeping the logic localized to the specific builder instead of a generic loader function.How is this PR tested?
load_dataset("audiofolder")
with nodata_dir
ordata_files
→ aValueError
is now raised early.Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s) does this PR affect?
area/datasets
area/load
How should the PR be classified?
rn/bug-fix
- A user-facing bug fixShould this be included in the next patch release?