Skip to content

Commit

Permalink
Merge pull request #3057 from h-mayorquin/improve_error_log_in_json
Browse files Browse the repository at this point in the history
Improve error log to json in run_sorter
  • Loading branch information
samuelgarcia authored Jun 28, 2024
2 parents 47dd371 + 6176495 commit c9d4511
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/spikeinterface/sorters/basesorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ def run_from_folder(cls, output_folder, raise_error, verbose):
has_error = True
run_time = None
log["error"] = True
log["error_trace"] = traceback.format_exc()
error_log_to_display = traceback.format_exc()
trace_lines = error_log_to_display.strip().split("\n")
error_to_json = ["Traceback (most recent call last):"] + [
f" {line}" if not line.startswith(" ") else line for line in trace_lines[1:]
]
log["error_trace"] = error_to_json

log["error"] = has_error
log["run_time"] = run_time
Expand Down Expand Up @@ -290,7 +295,7 @@ def run_from_folder(cls, output_folder, raise_error, verbose):

if has_error and raise_error:
raise SpikeSortingError(
f"Spike sorting error trace:\n{log['error_trace']}\n"
f"Spike sorting error trace:\n{error_log_to_display}\n"
f"Spike sorting failed. You can inspect the runtime trace in {output_folder}/spikeinterface_log.json."
)

Expand Down

0 comments on commit c9d4511

Please sign in to comment.