diff --git a/fedot/core/caching/pipelines_cache.py b/fedot/core/caching/pipelines_cache.py index 371b49247e..23a9acc6e8 100644 --- a/fedot/core/caching/pipelines_cache.py +++ b/fedot/core/caching/pipelines_cache.py @@ -35,8 +35,12 @@ def save_nodes(self, nodes: Union[PipelineNode, List[PipelineNode]], fold_id: Op ] self._db.add_operations(mapped) except Exception as ex: - unexpected_exc = not (isinstance(ex, sqlite3.DatabaseError) and 'disk is full' in str(ex)) - self.log.warning(f'Nodes can not be saved: {ex}. Continue', exc=ex, raise_if_test=unexpected_exc) + exc_is_expected = (isinstance(ex, sqlite3.DatabaseError) and 'disk is full' in str(ex)) + msg = 'Nodes can not be saved' + if exc_is_expected: + self.log.warning(msg, exc_info=ex) + else: + self.log.log_or_raise('warning', ValueError(msg)) def save_pipeline(self, pipeline: 'Pipeline', fold_id: Optional[int] = None): """ @@ -61,8 +65,8 @@ def try_load_nodes(self, nodes: Union[PipelineNode, List[PipelineNode]], fold_id nodes_lst[idx].fitted_operation = cached_op else: nodes_lst[idx].fitted_operation = None - except Exception as ex: - self.log.warning(f'Cache can not be loaded: {ex}. Continue.', exc=ex, raise_if_test=True) + except Exception: + self.log.log_or_raise('info', ValueError('Cache can not be loaded.')) def try_load_into_pipeline(self, pipeline: 'Pipeline', fold_id: Optional[int] = None): """ diff --git a/fedot/core/caching/preprocessing_cache.py b/fedot/core/caching/preprocessing_cache.py index 4b0de47870..25299bae45 100644 --- a/fedot/core/caching/preprocessing_cache.py +++ b/fedot/core/caching/preprocessing_cache.py @@ -30,8 +30,8 @@ def try_load_preprocessor(self, pipeline: 'Pipeline', fold_id: Union[int, None]) processors = self._db.get_preprocessor(structural_id) if processors: pipeline.encoder, pipeline.imputer = processors - except Exception as ex: - self.log.warning(f'Preprocessor search error: {ex}', raise_if_test=True) + except Exception: + self.log.log_or_raise('warning', ValueError('Preprocessor search error')) def add_preprocessor(self, pipeline: 'Pipeline', fold_id: Optional[Union[int, None]] = None): """ diff --git a/fedot/core/composer/metrics.py b/fedot/core/composer/metrics.py index 20c6fdd395..221ca27588 100644 --- a/fedot/core/composer/metrics.py +++ b/fedot/core/composer/metrics.py @@ -89,8 +89,8 @@ def get_value(cls, pipeline: Pipeline, reference_data: InputData, title=f'Forecast with metric {round(metric, 4)}', save_path=Path(save_path, 'forecast.png')) - except Exception as ex: - pipeline.log.info(f'Metric can not be evaluated because of: {ex}', raise_if_test=True) + except Exception: + pipeline.log.log_or_raise('info', ValueError('Metric can not be evaluated')) return metric diff --git a/fedot/core/optimisers/objective/data_objective_eval.py b/fedot/core/optimisers/objective/data_objective_eval.py index 7c6d125f30..a5c7b944f8 100644 --- a/fedot/core/optimisers/objective/data_objective_eval.py +++ b/fedot/core/optimisers/objective/data_objective_eval.py @@ -80,8 +80,8 @@ def evaluate(self, graph: Pipeline) -> Fitness: if evaluated_fitness.valid: folds_metrics.append(evaluated_fitness.values) else: - self._log.warning(f'Invalid fitness after objective evaluation. ' - f'Skipping the graph: {graph_id}', raise_if_test=True) + self._log.log_or_raise('warning', ValueError(f'Invalid fitness after objective evaluation. ' + f'Skipping the graph: {graph_id}')) if self._do_unfit: graph.unfit() if folds_metrics: