{"record":{"id":"90f27a571826d0f6","repo":"huggingface/open-r1","slug":"either-dataset-name-or-dataset-mixture-must-be","errorCode":null,"errorMessage":"Either `dataset_name` or `dataset_mixture` must be provided","messagePattern":"Either `dataset_name` or `dataset_mixture` must be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/open_r1/configs.py","lineNumber":80,"sourceCode":"                      - col1\n                      - col2\n                    weight: 0.5\n                seed: 42\n                test_split_size: 0.1\n    \"\"\"\n\n    # Override the dataset_name to make it optional\n    dataset_name: Optional[str] = field(\n        default=None, metadata={\"help\": \"Dataset name. Can be omitted if using dataset_mixture.\"}\n    )\n    dataset_mixture: Optional[dict[str, Any]] = field(\n        default=None,\n        metadata={\"help\": \"Configuration for creating dataset mixtures with advanced options like shuffling.\"},\n    )\n\n    def __post_init__(self):\n        if self.dataset_name is None and self.dataset_mixture is None:\n            raise ValueError(\"Either `dataset_name` or `dataset_mixture` must be provided\")\n\n        if self.dataset_mixture is not None:\n            if not isinstance(self.dataset_mixture, dict) or \"datasets\" not in self.dataset_mixture:\n                raise ValueError(\n                    \"dataset_mixture must be a dictionary with a 'datasets' key. \"\n                    \"Expected format: {'datasets': [...], 'seed': int}\"\n                )\n\n            datasets_list = []\n            datasets_data = self.dataset_mixture.get(\"datasets\", [])\n\n            if isinstance(datasets_data, list):\n                for dataset_config in datasets_data:\n                    datasets_list.append(\n                        DatasetConfig(\n                            id=dataset_config.get(\"id\"),\n                            config=dataset_config.get(\"config\"),\n                            split=dataset_config.get(\"split\", \"train\"),","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/configs.py#L62-L98","documentation":"The training script's dataset config (DatasetConfig.__post_init__) requires that you identify the training data either via dataset_name (a single HF Hub dataset) or dataset_mixture (a multi-dataset mixture dict). If both are None, the dataclass immediately raises this ValueError at config-construction time, because the trainer would otherwise have no data to load.","triggerScenarios":"Instantiating the SFT/GRPO/DPO config dataclass (e.g. via HfArgumentParser from CLI args or in Python) with neither --dataset_name nor --dataset_mixture set.","commonSituations":"New training configs copied from templates where the dataset fields were deleted; CLI runs that omitted the dataset flag; YAML/JSON configs where the key is misspelled (e.g. dataset_names) so it lands nowhere; script defaults where dataset_name=None was left in place.","solutions":["Pass a dataset name: dataset_name=\"HuggingFaceH4/ultrachat_200k\" (or --dataset_name on the CLI).","Or provide a mixture dict: dataset_mixture={\"datasets\": [{\"id\": \"ds1\"}, {\"id\": \"ds2\"}], \"seed\": 42}.","Check your YAML/JSON/CLI arg spelling so the value actually populates dataset_name/dataset_mixture."],"exampleFix":"// before\nargs = SFTConfig(output_dir=\"out\")  # dataset_name=None, dataset_mixture=None -> ValueError\n// after\nargs = SFTConfig(output_dir=\"out\", dataset_name=\"HuggingFaceH4/ultrachat_200k\")","handlingStrategy":"validation","validationCode":"cfg = DatasetConfig(dataset_name=args.get(\"dataset_name\"), dataset_mixture=args.get(\"dataset_mixture\"))\nif cfg.dataset_name is None and cfg.dataset_mixture is None:\n    raise SystemExit(\"Set --dataset_name or --dataset_mixture before launching training\")","typeGuard":"def has_dataset(cfg) -> bool:\n    return getattr(cfg, \"dataset_name\", None) is not None or getattr(cfg, \"dataset_mixture\", None) is not None","tryCatchPattern":"try:\n    cfg = DatasetConfig(**raw_args)\nexcept ValueError as e:\n    if \"dataset_name\" in str(e) or \"dataset_mixture\" in str(e):\n        sys.exit(\"Config error: provide --dataset_name or --dataset_mixture\")\n    raise","preventionTips":["Always set dataset_name or dataset_mixture in training YAML templates","Validate configs with a dry-run/parse-only step before launching multi-GPU jobs","Keep exact key names dataset_name/dataset_mixture; avoid near-miss spellings"],"tags":["python","configuration","validation","datasets"],"backgroundTag":"missing-required-config-field","analyzedSha":"1416fa0cf21595d2083b399a2a0bbddd7f6e9563","analyzedAt":"2026-08-30T08:56:53.400Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}