Skip to content

Commit

Permalink
logging fixes for GOLEM main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
MorrisNein committed Dec 4, 2023
1 parent 75d2da8 commit 358f832
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions fedot/core/caching/pipelines_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions fedot/core/caching/preprocessing_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions fedot/core/composer/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions fedot/core/optimisers/objective/data_objective_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 358f832

Please sign in to comment.