{"record":{"id":"40881fd883befd95","repo":"Unity-Technologies/ml-agents","slug":"there-are-no-demo-files-in-the-provided-directo","errorCode":null,"errorMessage":"There are no '.demo' files in the provided directory.","messagePattern":"There are no '\\.demo' files in the provided directory\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/demo_loader.py","lineNumber":165,"sourceCode":"    \"\"\"\n    Retrieves the demonstration file(s) from a path.\n    :param path: Path of demonstration file or directory.\n    :return: List of demonstration files\n\n    Raises errors if |path| is invalid.\n    \"\"\"\n    if os.path.isfile(path):\n        if not path.endswith(\".demo\"):\n            raise ValueError(\"The path provided is not a '.demo' file.\")\n        return [path]\n    elif os.path.isdir(path):\n        paths = [\n            os.path.join(path, name)\n            for name in os.listdir(path)\n            if name.endswith(\".demo\")\n        ]\n        if not paths:\n            raise ValueError(\"There are no '.demo' files in the provided directory.\")\n        return paths\n    else:\n        raise FileNotFoundError(\n            f\"The demonstration file or directory {path} does not exist.\"\n        )\n\n\n@timed\ndef load_demonstration(\n    file_path: str,\n) -> Tuple[BehaviorSpec, List[AgentInfoActionPairProto], int]:\n    \"\"\"\n    Loads and parses a demonstration file.\n    :param file_path: Location of demonstration file (.demo).\n    :return: BrainParameter and list of AgentInfoActionPairProto containing demonstration data.\n    \"\"\"\n\n    # First 32 bytes of file dedicated to meta-data.","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/demo_loader.py#L147-L183","documentation":"When the given path is a directory, get_demo_files lists files ending in '.demo'. If none are found, it raises this ValueError because there is no demonstration data to load. The directory exists but contains no usable demonstration recordings.","triggerScenarios":"Passing an existing but empty (of '.demo' files) directory as the demo path to load_demonstration, e.g. a directory holding only .meta files, .py files, or checkpoints.","commonSituations":"Pointing at the wrong folder (e.g. results/ or summaries/) instead of the demo recording folder; demos deleted or moved; Unity recorded demos with a different extension into that directory.","solutions":["Verify the directory actually contains '.demo' files (ls *.demo) and pass the directory containing them.","Pass the single '.demo' file path directly instead of a directory.","Re-record demonstrations if the recording files were lost or saved elsewhere (check Unity Academy recorder output path)."],"exampleFix":"// before\ntrainer_config.demo_path = \"demos/\"  # empty directory\n// after\ntrainer_config.demo_path = \"demos/recordings/\"  # contains *.demo files","handlingStrategy":"validation","validationCode":"import glob, os\npath = \"demos/\"\nif os.path.isdir(path) and not glob.glob(os.path.join(path, \"*.demo\")):\n    raise ValueError(f\"no .demo files in {path}\")","typeGuard":"def dir_has_demo_files(path: str) -> bool:\n    import glob, os\n    return os.path.isdir(path) and bool(glob.glob(os.path.join(path, \"*.demo\")))","tryCatchPattern":"try:\n    demo_spec, pairs, _ = load_demonstration(demo_dir)\nexcept ValueError as e:\n    if \"no '.demo' files\" in str(e):\n        logger.error(\"Point demo_path at a directory containing *.demo files\")\n        raise SystemExit(1)\n    raise","preventionTips":["Confirm 'ls *.demo' shows files in the demo directory before launching training","Record demos to a dedicated, known directory and reference that path in config","Check that demo recordings were copied into containers/images used for training"],"tags":["ml-agents","file-path","demonstrations","empty-directory"],"backgroundTag":"no-demo-files-found","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}