MIT-LCP / waveform-annotation

Platform for annotating physiological waveform data.
11 stars 4 forks source link

Crash if record has more than four signals #16

Closed bemoody closed 3 years ago

bemoody commented 3 years ago

I have loaded some new records and created new RECORDS_VTVF files.

The following occurs upon loading /waveform-annotation/waveforms/0d0140/0d0140_0002/:

Internal Server Error: /waveform-annotation/waveforms/django_plotly_dash/app/waveform_graph/initial/dpd-initial-args-72b2d68b033d491bace78dd9f1f703b9/_dash-update-component
Traceback (most recent call last):
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/plotly/subplots.py", line 1319, in _set_trace_grid_reference
    subplot_refs = grid_ref[row - 1][col - 1]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django_plotly_dash/views.py", line 74, in update
    return _update(request, ident, stateless, **kwargs)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django_plotly_dash/views.py", line 93, in _update
    resp = view_func()
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django_plotly_dash/dash_wrapper.py", line 560, in dispatch
    return self.dispatch_with_args(body, argMap=dict())
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/django_plotly_dash/dash_wrapper.py", line 647, in dispatch_with_args
    res = self.callback_map[target_id]['callback'](*args, **argMap)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/dash/dash.py", line 985, in add_context
    output_value = func(*args, **kwargs)  # %% callback invoked %%
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/waveform-django/./waveforms/dash_apps/finished_apps/waveform_vis.py", line 1066, in update_graph
    fig.add_trace(
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/plotly/basedatatypes.py", line 1648, in add_trace
    return self.add_traces(
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/plotly/basedatatypes.py", line 1766, in add_traces
    self._set_trace_grid_position(trace, row, col, secondary_y)
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/plotly/basedatatypes.py", line 1848, in _set_trace_grid_position
    return _set_trace_grid_reference(
  File "/var/www/vhosts/breadboard-lcp.mit.edu/Flask/waveform-annotation/env3/lib64/python3.9/site-packages/plotly/subplots.py", line 1321, in _set_trace_grid_reference
    raise Exception(
Exception: The (row, col) pair sent is out of range. Use Figure.print_grid to view the subplot grid. 
bemoody commented 3 years ago

It appears that update_graph always tries create a graph with four "rows" (waveform_vis.py line 1014), regardless of how many signals are present.

Obviously not all records will have exactly four signals and we need to sensibly handle records with a larger (or smaller?) number of signals.

Lucas-Mc commented 3 years ago

This should've been fixed in #18 and #20.