Skip to content

Commit

Permalink
add traceback and new error json (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis-Dupont authored Jun 19, 2023
1 parent 66eb37a commit 0aad939
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 0aad939

Please sign in to comment.