Skip to content

Commit

Permalink
Add exception when unpickling
Browse files Browse the repository at this point in the history
  • Loading branch information
mirand863 committed Mar 18, 2024
1 parent ee7c294 commit 88c26fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hiclass/LocalClassifierPerLevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ def _fit_classifier(self, level, separator):
f"Loaded trained model for local classifier {level} from file {filename}"
)
return classifier
except pickle.UnpicklingError:
self.logger_.warning(f"Could not load model from file {filename}")
except (pickle.UnpicklingError, EOFError):
self.logger_.error(f"Could not load model from file {filename}")
self.logger_.info(f"Training local classifier {level}")
X, y, sample_weight = self._remove_empty_leaves(
separator, self.X_, self.y_[:, level], self.sample_weight_
Expand Down
4 changes: 2 additions & 2 deletions hiclass/LocalClassifierPerNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def _fit_classifier(self, node):
f"Loaded trained model for local classifier {node.split(self.separator_)[-1]} from file {filename}"
)
return classifier
except pickle.UnpicklingError:
self.logger_.warning(f"Could not load model from file {filename}")
except (pickle.UnpicklingError, EOFError):
self.logger_.error(f"Could not load model from file {filename}")
self.logger_.info(
f"Training local classifier {str(node).split(self.separator_)[-1]}"
)
Expand Down
4 changes: 2 additions & 2 deletions hiclass/LocalClassifierPerParentNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def _fit_classifier(self, node):
f"Loaded trained model for local classifier {node.split(self.separator_)[-1]} from file {filename}"
)
return classifier
except pickle.UnpicklingError:
self.logger_.warning(f"Could not load model from file {filename}")
except (pickle.UnpicklingError, EOFError):
self.logger_.error(f"Could not load model from file {filename}")
self.logger_.info(
f"Training local classifier {str(node).split(self.separator_)[-1]}"
)
Expand Down

0 comments on commit 88c26fb

Please sign in to comment.