From 0784f115c28f7ac65f9ba9368b22b22dec623114 Mon Sep 17 00:00:00 2001 From: Samuel Larkin Date: Wed, 2 Oct 2024 14:02:21 -0400 Subject: [PATCH] feat: handling wrong model type --- dfaligner/model.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dfaligner/model.py b/dfaligner/model.py index e26e113..03f8ab8 100644 --- a/dfaligner/model.py +++ b/dfaligner/model.py @@ -42,7 +42,17 @@ def __init__( ) -> None: super().__init__() if isinstance(config, dict): - config = AlignerConfig(**config) + from pydantic import ValidationError + + try: + config = AlignerConfig(**config) + except ValidationError as e: + from loguru import logger + + logger.error(f"{e}") + raise TypeError( + "Unable to load config. Possible causes: is it really a AlignerConfig? or the correct version?" + ) self.config: AlignerConfig = config # type: ignore self.preprocessed_dir = Path(self.config.preprocessing.save_dir) self.sep = "--"