Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metahyper): Print useful information in logs for exception occuring #53

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions neps/metahyper/api.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed an essential feature. However, I'm a bit puzzled, shouldn't the traceback already be logged with the outer try-except statement, especially since we're using logger.exception? If I'm mistaken or if this behaves differently in certain scenarios, please correct me.

Additionally, I'm wondering if it might be more appropriate to catch the error from the 'except statement' of the initial try block as well. What are your thoughts on this?

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import shutil
import time
import traceback
import warnings
from abc import ABC, abstractmethod
from contextlib import contextmanager
Expand Down Expand Up @@ -383,10 +384,15 @@ def _evaluate_config(
)
directory_params.append(previous_pipeline_directory)

result = evaluation_fn(
*directory_params,
**config,
)
try:
result = evaluation_fn(
*directory_params,
**config,
)
except Exception as e:
tb = traceback.format_exc()
logger.exception(f"{tb}\n{type(e).__name__}: {e}")
raise e

# Ensuring the result have the correct format that can be exploited by other functions
if isinstance(result, dict):
Expand Down