ultralytics/yolov5 · error · ValueError

No yaml definition found in dataset root path, check that th

Error message

No yaml definition found in dataset root path, check that there is a correct yaml file inside the dataset root path.

What it means

clearml_utils.construct_dataset raises ValueError when the downloaded ClearML dataset root contains zero .yaml or .yml files. The clearml:// loading protocol depends on finding a dataset definition yaml inside the local copy; if the dataset was created without one (e.g. only images were uploaded), there is nothing to derive train/val paths from and the load aborts.

Source

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

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
        )
    }
    data_dict["test"] = (
        str((dataset_root_path / dataset_definition["test"]).resolve()) if dataset_definition["test"] else None
    )

View on GitHub (pinned to 20d1d78a08)

Solutions

  1. Add a valid dataset yaml (with train/test/val/nc/names keys) to the ClearML dataset root and bump the version.
  2. Ensure the yaml is at the top level of the uploaded folder, not nested, and named .yaml or .yml.
  3. Alternatively skip clearml:// and pass a local yaml whose paths point at a manually fetched dataset copy.

Example fix

# before: dataset uploaded with images only -> 'No yaml definition found'
# after
clearml-data add --files clean_root/data.yaml  # plus images, yaml at root
clearml-data upload
python train.py --data clearml://<new_dataset_id> ...
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
import glob as _glob

def clearml_yaml_present(root: str) -> bool:
    return bool(_glob.glob(str(Path(root) / '*.yaml')) + _glob.glob(str(Path(root) / '*.yml')))

Try / catch

try:
    data_dict = construct_dataset(f'clearml://{dataset_id}')
except ValueError as e:
    if 'No yaml definition found' in str(e):
        raise SystemExit('add a data.yaml with train/val/test/nc/names to the dataset root and re-upload') from e

Prevention

When it happens

Trigger: Passing data='clearml://<id>' for a dataset whose upload folder had the yaml excluded or nested in a subdirectory (glob only checks the root); uploading raw images with clearml-data add without adding data.yaml; the yaml named with an unrecognized extension (e.g. .yam).

Common situations: First attempts at ClearML integration; packaging scripts that filter out yaml files; datasets created from a parent folder while the yaml sat one level down.

Related errors


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