Skip to content

fix uninitialized subset loading #34

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

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion yourbench/utils/dataset_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ def custom_load_dataset(config: Dict[str, Any], subset: Optional[str] = None) ->

# TODO: add an optional loading from a local path
logger.info(f"Loading dataset HuggingFace Hub with repo_id='{dataset_repo_name}'")
return load_dataset(dataset_repo_name, name=subset, split="train")
# If subset name does NOT exist, return an empty dataset to avoid the crash:
try:
return load_dataset(dataset_repo_name, name=subset, split="train")
except ValueError as e:
# If the config was not found, we create an empty dataset
if "BuilderConfig" in str(e) and "not found" in str(e):
logger.warning(f"No existing subset '{subset}'. Returning empty dataset.")
return Dataset.from_dict({})
else:
raise


def custom_save_dataset(
Expand Down