Skip to content

Commit cd95d50

Browse files
committed
revert?
1 parent 4ee22fa commit cd95d50

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/lightning/pytorch/cli.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,19 +558,18 @@ def _parse_ckpt_path(self) -> None:
558558
if not self.config.get("subcommand"):
559559
return
560560
ckpt_path = self.config[self.config.subcommand].get("ckpt_path")
561-
if not ckpt_path or not Path(ckpt_path).is_file():
562-
return
563-
ckpt = torch.load(ckpt_path, weights_only=True, map_location="cpu")
564-
hparams = ckpt.get("hyper_parameters", {})
565-
hparams.pop("_instantiator", None)
566-
if not hparams:
567-
return
568-
hparams = {self.config.subcommand: {"model": hparams}}
569-
try:
570-
self.config = self.parser.parse_object(hparams, self.config)
571-
except SystemExit:
572-
sys.stderr.write("Parsing of ckpt_path hyperparameters failed!\n")
573-
raise
561+
if ckpt_path and Path(ckpt_path).is_file():
562+
ckpt = torch.load(ckpt_path, weights_only=True, map_location="cpu")
563+
hparams = ckpt.get("hyper_parameters", {})
564+
hparams.pop("_instantiator", None)
565+
if not hparams:
566+
return
567+
hparams = {self.config.subcommand: {"model": hparams}}
568+
try:
569+
self.config = self.parser.parse_object(hparams, self.config)
570+
except SystemExit:
571+
sys.stderr.write("Parsing of ckpt_path hyperparameters failed!\n")
572+
raise
574573

575574
def _dump_config(self) -> None:
576575
if hasattr(self, "config_dump"):

0 commit comments

Comments
 (0)