From 6204d3732684e67a56e970ad24f9a90e2a0706e6 Mon Sep 17 00:00:00 2001 From: gdewael Date: Tue, 30 Jan 2024 13:15:50 +0000 Subject: [PATCH 1/3] added check --- casanovo/config.yaml | 2 +- casanovo/denovo/model_runner.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/casanovo/config.yaml b/casanovo/config.yaml index 896f67bc..7cfde9fe 100644 --- a/casanovo/config.yaml +++ b/casanovo/config.yaml @@ -100,7 +100,7 @@ max_epochs: 30 # Number of validation steps to run before training begins num_sanity_val_steps: 0 # Set to "False" to further train a pre-trained Casanovo model -train_from_scratch: True +train_from_scratch: False # Calculate peptide and amino acid precision during training. this # is expensive, so we recommend against it. calculate_precision: False diff --git a/casanovo/denovo/model_runner.py b/casanovo/denovo/model_runner.py index 85446118..de86e57b 100644 --- a/casanovo/denovo/model_runner.py +++ b/casanovo/denovo/model_runner.py @@ -256,6 +256,11 @@ def initialize_model(self, train: bool) -> None: self.config.train_from_scratch, self.model_filename is None, ) + + if train and (not self.config.train_from_scratch) and (self.model_filename is None): + logger.error("Training with `train_from_scratch: False` requires an input `--model`.") + raise ValueError("Training with `train_from_scratch: False` requires an input `--model`.") + if train and any(from_scratch): self.model = Spec2Pep(**model_params) return From f5de11713e8da812c164e471716985827812079d Mon Sep 17 00:00:00 2001 From: gdewael Date: Tue, 30 Jan 2024 13:23:44 +0000 Subject: [PATCH 2/3] black format --- casanovo/denovo/model_runner.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/casanovo/denovo/model_runner.py b/casanovo/denovo/model_runner.py index de86e57b..358fdbad 100644 --- a/casanovo/denovo/model_runner.py +++ b/casanovo/denovo/model_runner.py @@ -257,10 +257,18 @@ def initialize_model(self, train: bool) -> None: self.model_filename is None, ) - if train and (not self.config.train_from_scratch) and (self.model_filename is None): - logger.error("Training with `train_from_scratch: False` requires an input `--model`.") - raise ValueError("Training with `train_from_scratch: False` requires an input `--model`.") - + if ( + train + and (not self.config.train_from_scratch) + and (self.model_filename is None) + ): + logger.error( + "Training with `train_from_scratch: False` requires an input `--model`." + ) + raise ValueError( + "Training with `train_from_scratch: False` requires an input `--model`." + ) + if train and any(from_scratch): self.model = Spec2Pep(**model_params) return From d8954b30ee0526c3e2e29e8dc6e469f0122a156f Mon Sep 17 00:00:00 2001 From: gdewael Date: Tue, 30 Jan 2024 13:24:52 +0000 Subject: [PATCH 3/3] reconfigure to default config --- casanovo/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casanovo/config.yaml b/casanovo/config.yaml index 7cfde9fe..896f67bc 100644 --- a/casanovo/config.yaml +++ b/casanovo/config.yaml @@ -100,7 +100,7 @@ max_epochs: 30 # Number of validation steps to run before training begins num_sanity_val_steps: 0 # Set to "False" to further train a pre-trained Casanovo model -train_from_scratch: False +train_from_scratch: True # Calculate peptide and amino acid precision during training. this # is expensive, so we recommend against it. calculate_precision: False