[Fixing #2149] load_from_disk for rl tpye training #2193
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.
Here’s a draft for the PR message:
Description
This PR enhances the dataset loading functionality by introducing additional checks for loading datasets from disk. If the provided dataset path exists, it now attempts to load the dataset using
load_from_disk
. Additionally, it verifies if a specific split exists when dealing with aDatasetDict
and raises a clear error message if the split is not found. If the path does not exist or an error occurs, the existing behavior of loading the dataset usingload_dataset
is retained.Motivation and Context
This change is required to handle cases where datasets are stored locally on disk, improving flexibility and robustness. It solves potential issues when users provide a valid path to a local dataset that was previously not being handled correctly. The new implementation also adds split validation for
DatasetDict
, preventing silent failures when accessing invalid splits.How has this been tested?
The changes have been tested by:
load_from_disk
.DatasetDict
.load_dataset
when the path does not exist or errors occur.Test scenarios include both valid and invalid paths, as well as valid and missing dataset splits.
Screenshots (if appropriate)
N/A
Types of changes
Social Handles (Optional)
Let me know if you need further refinements!