{"record":{"id":"be5f085c6d18bce8","repo":"Stability-AI/generative-models","slug":"n-name-and-r-resume-cannot-be-specified-both","errorCode":null,"errorMessage":"-n/--name and -r/--resume cannot be specified both.If you want to resume training in a new log folder, use -n/--name in combination with --resume_from_checkpoint","messagePattern":"-n/--name and -r/--resume cannot be specified both\\.If you want to resume training in a new log folder, use -n/--name in combination with --resume_from_checkpoint","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"main.py","lineNumber":552,"sourceCode":"    #   callbacks:\n    #       callback1:\n    #           target: importpath\n    #           params:\n    #               key: value\n\n    now = datetime.datetime.now().strftime(\"%Y-%m-%dT%H-%M-%S\")\n\n    # add cwd for convenience and to make classes in this file available when\n    # running as `python main.py`\n    # (in particular `main.DataModuleFromConfig`)\n    sys.path.append(os.getcwd())\n\n    parser = get_parser()\n\n    opt, unknown = parser.parse_known_args()\n\n    if opt.name and opt.resume:\n        raise ValueError(\n            \"-n/--name and -r/--resume cannot be specified both.\"\n            \"If you want to resume training in a new log folder, \"\n            \"use -n/--name in combination with --resume_from_checkpoint\"\n        )\n    melk_ckpt_name = None\n    name = None\n    if opt.resume:\n        if not os.path.exists(opt.resume):\n            raise ValueError(\"Cannot find {}\".format(opt.resume))\n        if os.path.isfile(opt.resume):\n            paths = opt.resume.split(\"/\")\n            # idx = len(paths)-paths[::-1].index(\"logs\")+1\n            # logdir = \"/\".join(paths[:idx])\n            logdir = \"/\".join(paths[:-2])\n            ckpt = opt.resume\n            _, melk_ckpt_name = get_checkpoint_name(logdir)\n        else:\n            assert os.path.isdir(opt.resume), opt.resume","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/Stability-AI/generative-models/blob/e8cd657656fa5d61688191730d0e03242bf4ed44/main.py#L534-L570","documentation":"main.py's CLI argument validation rejects a launch that passes both -n/--name and -r/--resume, because --resume derives the log folder from the checkpoint path while --name would create a new one — the two are mutually exclusive. The library forces you to choose: resume in-place (only --resume) or resume in a fresh folder (--name plus --resume_from_checkpoint). This check runs immediately after argument parsing, before any model or data loading.","triggerScenarios":"Running the training entrypoint with both -n/--name and -r/--resume set to non-empty values, e.g. `python main.py -n myrun -r logs/2023-.../checkpoints/last.ckpt --base configs/...`. The ValueError fires in the argparse post-processing block at main.py:552 whenever `opt.name and opt.resume` are both truthy.","commonSituations":"Shell scripts or SLURM launchers that append `-n $RUN_NAME` unconditionally while also enabling resume; developers copying a working resume command and adding a custom run name; shell variable expansion leaving both flags populated (e.g. `-n \"\"` vs `-n \"foo\"`).","solutions":["Drop -n/--name and keep only -r/--resume to resume inside the original log folder.","Keep -n/--name but replace -r/--resume with --resume_from_checkpoint <path> to resume into a new log folder.","Fix the launcher script so name and resume flags are set mutually exclusively (e.g. only emit -r when -n is absent)."],"exampleFix":"// before\npython main.py --base configs/stable-diffusion/v1-finetune.yaml -n myrun -r logs/2024-01-01T00-00-00/checkpoints/last.ckpt\n// after\npython main.py --base configs/stable-diffusion/v1-finetune.yaml -n myrun --resume_from_checkpoint logs/2024-01-01T00-00-00/checkpoints/last.ckpt","handlingStrategy":"validation","validationCode":"import sys\nassert not ('--name' in sys.argv and '--resume' in sys.argv), \\\n    \"Use -n with --resume_from_checkpoint, not -r\"\n# then run: python main.py ...","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In launcher scripts, emit -r only when no -n is provided (mutually exclusive flags).","Prefer the documented pattern: -n <new_name> + --resume_from_checkpoint <ckpt>."],"tags":["cli","argument-validation","resume-training"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"e8cd657656fa5d61688191730d0e03242bf4ed44","analyzedAt":"2026-08-29T11:23:43.234Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}