{"record":{"id":"7be6c3c989b2e860","repo":"unslothai/unsloth","slug":"scan-dataset-requires-a-single-dataset-split-not","errorCode":null,"errorMessage":"scan_dataset requires a single Dataset split, not a DatasetDict. Available splits: {list(dataset.keys())}. Pass dataset[<split>] or use load_dataset(..., split='train').","messagePattern":"scan_dataset requires a single Dataset split, not a DatasetDict\\. Available splits: (.+?)\\. Pass dataset\\[<split>\\] or use load_dataset\\(\\.\\.\\., split='train'\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/utils/datasets/dataset_none_detect.py","lineNumber":519,"sourceCode":"    Raises ValueError if the format is unknown or unsupported.\n    \"\"\"\n    # Reject a DatasetDict / IterableDatasetDict (load_dataset without split):\n    # its column_names is a split map and would yield a confusing \"unknown\n    # format\". Check both (IterableDatasetDict is not a DatasetDict subclass);\n    # import locally so this module never hard-requires them.\n    _dict_types = []\n    try:\n        from datasets import DatasetDict as _DatasetDict\n        _dict_types.append(_DatasetDict)\n    except ImportError:\n        pass\n    try:\n        from datasets import IterableDatasetDict as _IterableDatasetDict\n        _dict_types.append(_IterableDatasetDict)\n    except ImportError:\n        pass\n    if _dict_types and isinstance(dataset, tuple(_dict_types)):\n        raise ValueError(\n            \"scan_dataset requires a single Dataset split, not a DatasetDict. \"\n            f\"Available splits: {list(dataset.keys())}. \"\n            \"Pass dataset[<split>] or use load_dataset(..., split='train').\"\n        )\n    # Streaming IterableDataset has no len()/column_names; give a clear error\n    # instead of a confusing downstream TypeError.\n    try:\n        from datasets import IterableDataset as _IterableDataset\n        if isinstance(dataset, _IterableDataset):\n            raise ValueError(\n                \"scan_dataset requires a materialized Dataset, not an IterableDataset. \"\n                \"Load without streaming=True, or materialize a slice first: \"\n                \"Dataset.from_list(list(dataset.take(N))).\"\n            )\n    except ImportError:\n        pass\n    fmt = FORMAT_ALIASES.get(fmt, fmt)\n    was_auto = fmt == \"auto\"","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/datasets/dataset_none_detect.py#L501-L537","documentation":"ValueError from scan_dataset's input-type guard: the object passed is a DatasetDict or IterableDatasetDict (a mapping of splits), but the scanner needs one materialized Dataset because it iterates rows and reads column_names/len. The error message enumerates the available splits so the caller can immediately pick one.","triggerScenarios":"scan_dataset(load_dataset('repo')) — without split= the result is a DatasetDict; also passing dataset['train'] style access forgotten after refactoring, or handing an IterableDatasetDict from streaming loads.","commonSituations":"New users forgetting load_dataset(..., split='train'); datasets with only a 'test' or custom split name; helper code that accepted Dataset but now receives whatever load_dataset returns.","solutions":["Select a split: scan_dataset(dataset['train']) (use a split name from the error message)","Load with a split from the start: load_dataset('repo', split='train')","For multi-split audits, loop: for split in d.keys(): scan_dataset(d[split])"],"exampleFix":"# before\ndataset = load_dataset('reddit_tifu')\nstats = scan_dataset(dataset)  # DatasetDict -> raises\n\n# after\ndataset = load_dataset('reddit_tifu', split='train')\nstats = scan_dataset(dataset)","handlingStrategy":"type-guard","validationCode":"from datasets import Dataset, DatasetDict\n\ndef is_single_split(dataset) -> bool:\n    return isinstance(dataset, Dataset)","typeGuard":"def is_single_split(dataset) -> bool:\n    \"\"\"True only for a materialized single-split Dataset.\"\"\"\n    from datasets import Dataset, DatasetDict, IterableDataset, IterableDatasetDict\n    return isinstance(dataset, Dataset) and not isinstance(\n        dataset, (DatasetDict, IterableDataset, IterableDatasetDict)\n    )","tryCatchPattern":null,"preventionTips":["Always load with split=... when the result feeds row-level scanners","Write a small is_single_split guard in shared dataset utility code and call it before scanning","Handle multi-split datasets by looping over .keys() explicitly"],"tags":["datasets","huggingface","validation","data-quality"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}