{"record":{"id":"3fda1e5c9ab024ee","repo":"Lightning-AI/pytorch-lightning","slug":"method-method-r-is-invalid-should-be-one-of-su","errorCode":null,"errorMessage":"method {method!r} is invalid. Should be one of {supported_methods}.","messagePattern":"method (.+?) is invalid\\. Should be one of (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/tuner/tuning.py","lineNumber":213,"sourceCode":"        lr_finder_callback._early_exit = True\n        self._trainer.callbacks = [lr_finder_callback] + self._trainer.callbacks\n\n        self._trainer.fit(model, train_dataloaders, val_dataloaders, datamodule)\n\n        self._trainer.callbacks = [cb for cb in self._trainer.callbacks if cb is not lr_finder_callback]\n\n        return lr_finder_callback.optimal_lr\n\n\ndef _check_tuner_configuration(\n    train_dataloaders: Optional[Union[TRAIN_DATALOADERS, \"pl.LightningDataModule\"]] = None,\n    val_dataloaders: Optional[EVAL_DATALOADERS] = None,\n    dataloaders: Optional[EVAL_DATALOADERS] = None,\n    method: Literal[\"fit\", \"validate\", \"test\", \"predict\"] = \"fit\",\n) -> None:\n    supported_methods = (\"fit\", \"validate\", \"test\", \"predict\")\n    if method not in supported_methods:\n        raise ValueError(f\"method {method!r} is invalid. Should be one of {supported_methods}.\")\n\n    if method == \"fit\":\n        if dataloaders is not None:\n            raise MisconfigurationException(\n                f\"In tuner with method={method!r}, `dataloaders` argument should be None,\"\n                \" please consider setting `train_dataloaders` and `val_dataloaders` instead.\"\n            )\n    else:\n        if train_dataloaders is not None or val_dataloaders is not None:\n            raise MisconfigurationException(\n                f\"In tuner with `method`={method!r}, `train_dataloaders` and `val_dataloaders`\"\n                \" arguments should be None, please consider setting `dataloaders` instead.\"\n            )\n\n\ndef _check_lr_find_configuration(trainer: \"pl.Trainer\") -> None:\n    # local import to avoid circular import\n    from lightning.pytorch.callbacks.lr_finder import LearningRateFinder","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/tuner/tuning.py#L195-L231","documentation":"The internal _check_tuner_configuration helper validates the method string used by tuner methods. It raises ValueError when method is not one of ('fit', 'validate', 'test', 'predict') — e.g. a typo like 'training' or 'Validate'.","triggerScenarios":"Passing method=\"training\", \"fit_train\", or any unrecognized string to tuner.lr_find or tuner.scale_batch_size.","commonSituations":"Typos or assuming method accepts strategy names or custom stage names.","solutions":["Use one of the exact strings: 'fit', 'validate', 'test', 'predict'","Omit method entirely if 'fit' is what you want"],"exampleFix":"// before\ntrainer.tuner.scale_batch_size(model, method=\"training\")\n// after\ntrainer.tuner.scale_batch_size(model, method=\"fit\")","handlingStrategy":"validation","validationCode":"assert method in (\"fit\", \"validate\", \"test\", \"predict\"), method","typeGuard":"def is_valid_tuner_method(m: str) -> bool:\n    return m in (\"fit\", \"validate\", \"test\", \"predict\")","tryCatchPattern":null,"preventionTips":["Type method as Literal['fit','validate','test','predict'] in your own wrappers"],"tags":["tuner","validation","method-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}