{"record":{"id":"1a6850dc63db3287","repo":"Unity-Technologies/ml-agents","slug":"previous-data-from-this-run-id-was-not-found-trai","errorCode":null,"errorMessage":"Previous data from this run ID was not found. Train a new run by removing the --resume flag.","messagePattern":"Previous data from this run ID was not found\\. Train a new run by removing the --resume flag\\.","errorType":"exception","errorClass":"UnityTrainerException","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/directory_utils.py","lineNumber":33,"sourceCode":"    :param model_path: The model path specified.\n    :param summary_path: The summary path to be used.\n    :param resume: Whether or not the --resume flag was passed.\n    :param force: Whether or not the --force flag was passed.\n    :param init_path: Path to run-id dir to initialize from\n    \"\"\"\n\n    output_path_exists = os.path.isdir(output_path)\n\n    if output_path_exists:\n        if not resume and not force:\n            raise UnityTrainerException(\n                \"Previous data from this run ID was found. \"\n                \"Either specify a new run ID, use --resume to resume this run, \"\n                \"or use the --force parameter to overwrite existing data.\"\n            )\n    else:\n        if resume:\n            raise UnityTrainerException(\n                \"Previous data from this run ID was not found. \"\n                \"Train a new run by removing the --resume flag.\"\n            )\n\n    # Verify init path if specified.\n    if init_path is not None:\n        if not os.path.isdir(init_path):\n            raise UnityTrainerException(\n                \"Could not initialize from {}. \"\n                \"Make sure models have already been saved with that run ID.\".format(\n                    init_path\n                )\n            )\n\n\ndef setup_init_path(\n    behaviors: TrainerSettings.DefaultTrainerDict, init_dir: str\n) -> None:","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/directory_utils.py#L15-L51","documentation":"validate_existing_directories raises UnityTrainerException when --resume was passed but the output directory for the run ID does not exist — there is no previous data to resume from. ML-Agents requires an existing run to resume into; starting fresh must be requested by omitting --resume.","triggerScenarios":"Running mlagents-learn with --resume (or resume=True in run_training) and a run_id for which no results/<run_id> directory exists — e.g. first-time run, typo'd run_id, or different --results-dir than the original run.","commonSituations":"Typo in run-id when resuming; resuming on another machine or container where the results directory wasn't copied; pointing --results-dir at a different location than the original run.","solutions":["Remove the --resume flag to start a fresh run (as the message suggests).","Fix the run-id typo or use the run-id of the actual existing run.","Copy the original results/<run_id> directory (or mount the same volume) and/or pass the correct --results-dir before resuming."],"exampleFix":"// before\nmlagents-learn config.yaml --run-id=ppo_! --resume\n// after\nmlagents-learn config.yaml --run-id=ppo_1 --resume","handlingStrategy":"validation","validationCode":"import os\nrun_dir = os.path.join(results_dir, run_id)\nif resume and not os.path.isdir(run_dir):\n    raise SystemExit(f\"cannot resume: {run_dir} does not exist; drop --resume or fix run-id\")","typeGuard":"def can_resume(run_id: str, results_dir: str) -> bool:\n    import os\n    return os.path.isdir(os.path.join(results_dir, run_id))","tryCatchPattern":"try:\n    validate_existing_directories(model_path, summary_path, run_id, resume, force, init_path)\nexcept UnityTrainerException as e:\n    if \"was not found\" in str(e):\n        logger.error(f\"No previous run at {results_dir}/{run_id}: drop --resume or fix run-id\")\n        raise SystemExit(1)\n    raise","preventionTips":["Copy/mount the original results/<run_id> directory before resuming on a new machine","Verify the run-id spelling and the --results-dir against the original run","List existing runs (ls results/) before choosing resume"],"tags":["ml-agents","trainer","resume","run-id"],"backgroundTag":"resume-run-not-found","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}