Skip to content

Commit

Permalink
if tasks fails, store error traceback. Show on hover in process queue…
Browse files Browse the repository at this point in the history
…. Add button to copy it to clipboard
  • Loading branch information
dcnieho committed Oct 18, 2024
1 parent 8ea3dc8 commit df80b2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/gazeMapper/GUI/_impl/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,8 @@ def _action_done_callback(self, future: process_pool.ProcessFuture, job_id: int,
if not session_level:
lbl += f', recording "{job.recording}"'
lbl += f' (work item {job_id}, action {job.action.displayable_name})'
if isinstance(exc, concurrent.futures.TimeoutError):
gt_gui.utils.push_popup(self, gt_gui.msg_box.msgbox, "Processing error", f"A worker process has failed for {lbl}:\n{type(exc).__name__}: {str(exc) or 'No further details'}\n\nPossible causes include:\n - You are running with too many workers, try lowering them in settings", gt_gui.msg_box.MsgBox.warn, more=tb)
return
gt_gui.utils.push_popup(self, gt_gui.msg_box.msgbox, "Processing error", f"Something went wrong in a worker process for {lbl}:\n\n{tb}", gt_gui.msg_box.MsgBox.error)
self.job_scheduler.jobs[job_id].error = tb

# clean up, if needed, when a task failed or was canceled
if job.action==process.Action.IMPORT and state in [process.State.Canceled, process.State.Failed]:
Expand Down Expand Up @@ -809,9 +807,15 @@ def _action_list_pane_drawer(self):
case 1:
# Status
session_lister.draw_process_state((job_state:=jobs[job_id].get_state()))
if jobs[job_id].error:
gt_gui.utils.draw_hover_text(jobs[job_id].error, text='')
imgui.same_line()
if imgui.small_button(ifa6.ICON_FA_COPY+f'##{job_id}_copy_error'):
imgui.set_clipboard_text(jobs[job_id].error)
gt_gui.utils.draw_hover_text('Copy error to clipboard', text='')
if job_state in [process.State.Pending, process.State.Running]:
imgui.same_line()
if imgui.button(ifa6.ICON_FA_HAND+f' Cancel##{job_id}'):
if imgui.small_button(ifa6.ICON_FA_HAND+f' Cancel##{job_id}'):
self.job_scheduler.cancel_job(job_id)
case 2:
# Session
Expand Down
1 change: 1 addition & 0 deletions src/gazeMapper/GUI/_impl/process_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class JobDescription(typing.Generic[_UserDataT]):
_pool_job_id: typing.Optional[int] = None
_future: typing.Optional[ProcessFuture] = dataclasses.field(init=False, default = None)
_final_state: typing.Optional[process.State] = dataclasses.field(init=False, default = None)
error: typing.Optional[str] = None

def get_state(self) -> process.State:
if self._final_state is not None:
Expand Down

0 comments on commit df80b2f

Please sign in to comment.