Skip to content

Commit

Permalink
moving ValueError for missing metrics in config_meta.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lujzi05 committed Jan 24, 2025
1 parent 4053801 commit 6663d2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 3 additions & 7 deletions views_pipeline_core/managers/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,10 @@ def _execute_model_tasks(
df_predictions = self._evaluate_ensemble(self._eval_type)
self._handle_log_creation()
# Evaluate the model
if self.config["metrics"]:
self._evaluate_prediction_dataframe(
self._evaluate_prediction_dataframe(
df_predictions, ensemble=True
) # Calculate evaluation metrics with the views-evaluation package
else:
raise ValueError(
'No evaluation metrics specified in config_meta.py. Add a field "metrics" with a list of metrics to calculate. E.g "metrics": ["RMSLE", "CRPS"]'
)
) # Calculate evaluation metrics with the views-evaluation package

except Exception as e:
logger.error(f"Error evaluating model: {e}", exc_info=True)
self._wandb_alert(
Expand Down
8 changes: 7 additions & 1 deletion views_pipeline_core/managers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,13 @@ def _evaluate_prediction_dataframe(self, df_predictions, ensemble=False) -> None
Raises:
None
"""
metrics_manager = MetricsManager(self.config["metrics"])
if "metrics" in self.config:
metrics_manager = MetricsManager(self.config["metrics"])
else:
logger.error('Missing "metrics" in config_meta.py')
raise ValueError(
'No evaluation metrics specified in config_meta.py. Add a field "metrics" with a list of metrics to calculate. E.g "metrics": ["RMSLE", "CRPS"]'
)
if not ensemble:
df_path = self._model_path.data_raw / f"{self.config['run_type']}_viewser_df{PipelineConfig().dataframe_format}"
df_viewser = read_dataframe(df_path)
Expand Down

0 comments on commit 6663d2a

Please sign in to comment.