Skip to content

Commit

Permalink
Handle corrupt ckpt
Browse files Browse the repository at this point in the history
  • Loading branch information
melihyilmaz committed Nov 29, 2023
1 parent bfb168e commit 0e3bcb8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions casanovo/denovo/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,18 @@ def initialize_model(self, train: bool) -> None:
f"using the checkpoint."
)
except RuntimeError:
raise RuntimeError(
"Weights file incompatible with the current version of Casanovo."
)
# This only doesn't work if the weights are from an older version
try:
self.model = Spec2Pep.load_from_checkpoint(
self.model_filename,
map_location=device,
**model_params,
)
except RuntimeError:
raise RuntimeError(
"Weights file incompatible "
"with the current version of Casanovo. "
)

def initialize_data_module(
self,
Expand Down

0 comments on commit 0e3bcb8

Please sign in to comment.