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

Add traceback and new error json #102

Merged
merged 3 commits into from
Jun 19, 2023
Merged
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
5 changes: 4 additions & 1 deletion src/data_gradients/managers/abstract_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import abc
import logging
import json
import traceback
from typing import Iterable, List, Dict, Optional
from itertools import zip_longest
from logging import getLogger
Expand Down Expand Up @@ -58,6 +59,7 @@ def __init__(
session_id = datetime.now().strftime("%Y%m%d-%H%M%S")
self.report_name = "Report.pdf"
self.log_filename = "summary.json"
self.errors_filename = "errors.json"
self.log_dir = log_dir # Main logging directory. Latest run results will be saved here.
self.archive_dir = os.path.join(log_dir, "archive_" + session_id) # A duplicate of the results will be saved here as well.

Expand Down Expand Up @@ -159,11 +161,12 @@ def post_process(self, interrupted=False):
feature_error = ""
except Exception as e:
f = None
feature_json = {"error": str(e)}
feature_json = {"error": traceback.format_exception(type(e), e, e.__traceback__)}
feature_error = (
f"Feature extraction error. Check out the log file for more details:<br/>"
f"<em>{os.path.join(self.archive_dir, self.log_filename)}</em>"
)
self.write_json(data=dict(title=feature_extractor.title, data=feature_json), output_dir=self.archive_dir, filename=self.errors_filename)

if f is not None:
image_name = feature_extractor.__class__.__name__ + ".png"
Expand Down