ultralytics/yolov5 · error · ValueError

More than one yaml file was found in the dataset root, canno

Error message

More than one yaml file was found in the dataset root, cannot determine which one contains the dataset definition this way.

What it means

clearml_utils.construct_dataset raises ValueError when the local copy of a 'clearml://' dataset contains more than one .yaml/.yml file in its root. The loader globs *.yaml and *.yml and must pick exactly one dataset definition unambiguously; multiple matches (e.g. a data yaml plus an unrelated config yaml uploaded alongside) make the choice undefined, so it aborts.

Source

Thrown at utils/loggers/clearml/clearml_utils.py:50

    "host is required in init or config",
    "Could not get access credentials",
)


class ClearmlNotConfiguredError(ValueError):
    """Raised when ClearML is installed but not configured for task logging."""


def construct_dataset(clearml_info_string):
    """Load in a clearml dataset and fill the internal data_dict with its contents."""
    dataset_id = clearml_info_string.replace("clearml://", "")
    dataset = Dataset.get(dataset_id=dataset_id)
    dataset_root_path = Path(dataset.get_local_copy())

    # We'll search for the yaml file definition in the dataset
    yaml_filenames = list(glob.glob(str(dataset_root_path / "*.yaml")) + glob.glob(str(dataset_root_path / "*.yml")))
    if len(yaml_filenames) > 1:
        raise ValueError(
            "More than one yaml file was found in the dataset root, cannot determine which one contains "
            "the dataset definition this way."
        )
    elif not yaml_filenames:
        raise ValueError(
            "No yaml definition found in dataset root path, check that there is a correct yaml file "
            "inside the dataset root path."
        )
    with open(yaml_filenames[0]) as f:
        dataset_definition = yaml.safe_load(f)

    assert set(dataset_definition.keys()).issuperset({"train", "test", "val", "nc", "names"}), (
        "The right keys were not found in the yaml file, make sure it at least has the following keys: ('train', 'test', 'val', 'nc', 'names')"
    )

    data_dict = {
        "train": (
            str((dataset_root_path / dataset_definition["train"]).resolve()) if dataset_definition["train"] else None

View on GitHub (pinned to 20d1d78a08)

Solutions

  1. Create a new ClearML dataset version whose root contains exactly one yaml/yml dataset definition; remove extras with dataset.remove_files or by re-uploading a clean folder.
  2. Keep auxiliary configs (hyperparameters, readme) out of the dataset root or under a subdirectory the glob does not hit.
  3. After cleanup, rerun with the new clearml://<id> in --data.

Example fix

# before: dataset root contains data.yaml + hyp.yaml -> ValueError
# clearml-data sync --project yolo --name mydata --folder ./data_root

# after: root contains only data.yaml
clearml-data sync --project yolo --name mydata --folder ./clean_root  # clean_root/data.yaml only
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
import glob as _glob

def clearml_yaml_unique(root: str) -> bool:
    hits = _glob.glob(str(Path(root) / '*.yaml')) + _glob.glob(str(Path(root) / '*.yml'))
    return len(hits) == 1

Try / catch

try:
    data_dict = construct_dataset(f'clearml://{dataset_id}')
except ValueError as e:
    if 'More than one yaml' in str(e):
        raise SystemExit('remove extra yaml/yml files from the dataset root and publish a new version') from e

Prevention

When it happens

Trigger: Passing data='clearml://<dataset_id>' where the ClearML dataset version was uploaded with both data.yaml and, say, hyp.yml or a README yaml in the root; re-uploading a dataset with an extra yaml artifact; syncing a folder that already contained a yolov5 yaml.

Common situations: Iterating on ClearML dataset versions and accidentally adding config files; teams uploading the whole repo directory into the dataset; yaml backups (data.yaml.bak renamed to .yml).

Related errors


AI-assisted analysis of ultralytics/yolov5@20d1d78a08 (2026-08-15). Data as JSON: /api/errors/1539362c86de3a75. Report an issue: GitHub.