AMP-SCZ / eeg-qc-dash

Plotly/Dash based web application for checking quality of EEGs
Apache License 2.0
2 stars 1 forks source link

Empty props_file #19

Open tashrifbillah opened 2 years ago

tashrifbillah commented 2 years ago

Even though props_file exists, it is sometimes empty: https://github.com/AMP-SCZ/eeg-qc-dash/blob/44b1b65babb7600e6c46032bc11e9dc810341255/app.py#L331-L337

Hence the following error:

  File "/home/tb571/eeg-qc-dash/./app.py", line 354, in render_table
    if f'{sub}_{ses}' not in props:
  TypeError: argument of type 'NoneType' is not iterable

The issue is probably stemming from experimental flask server's sudden process killing. One solution would be to insert the following after line 337:

if not props:
  props={}
tashrifbillah commented 1 year ago

Dealt with by removing complex initial rendering logic: https://github.com/AMP-SCZ/eeg-qc-dash/commit/bb06d02952cba27a4181c3b7d54a20daf09cf5e7

And also by combining render_table and avg_render_table: https://github.com/AMP-SCZ/eeg-qc-dash/commit/46275acaf134b7d280a1916c286170f8df1118b3

tashrifbillah commented 1 year ago

https://github.com/unbit/uwsgi/issues/1623#issuecomment-368520213

*

uwsgi_connect_timeout 180;
uwsgi_read_timeout 180;
uwsgi_send_timeout 180;

https://stackoverflow.com/questions/24133315/fixing-broken-pipe-error-in-uwsgi-with-python

* uwsgi_ignore_client_abort on; https://stackoverflow.com/questions/34768527/uwsgi-ioerror-write-error

* Few other ideas: https://github.com/unbit/uwsgi/issues/1623


The above have advised extending Nginx-uWSGI timeout, uwsgi program timeout, and uwsgi_ignore_client_abort on;

tashrifbillah commented 1 year ago
uwsgi_connect_timeout 180;
uwsgi_read_timeout 180;
uwsgi_send_timeout 180;

We inserted the above in nginx.conf. Now, instead of 60 seconds, the webpage reached 404 Not Found screen after 180 seconds. So there should be something not right with how the production instance is launched and which folders it traverses during initialization. Remember that the mock instance launches almost immediately having nearly the same number of EEGs. So I don't think the above timeouts were the reason for our failure.

tashrifbillah commented 1 year ago

uwsgi_read_timeout 300; in Nginx.conf allowed browser to render website after 2 mins 15 secs! Reference: https://stackoverflow.com/a/19293752/11932012

If next restart is successful, make a note of it in README.md.

tashrifbillah commented 1 year ago

I am most positive that the empty .scores.pkl gets written only when the code gets past this line without any filtered data: https://github.com/AMP-SCZ/eeg-qc-dash/blob/a399a3874c68207a8eedb29846d00ecf97db5a3b/app.py#L275

So the solution should be to pickle dump only when len(props_file)>0: https://github.com/AMP-SCZ/eeg-qc-dash/blob/a399a3874c68207a8eedb29846d00ecf97db5a3b/app.py#L555


Also, we need to revisit the scenario of what happens in render_table() and save_date() when filtered data is empty.

Answer: if all data are loaded from .scores.pkl, then even if filters result in an empty list, all data get written in .scores.pkl.


Development: score saving is disabled within render_table()

tashrifbillah commented 1 year ago

If the dashboard is empty like this and SAVE is pressed, then the current empty state gets written i.e. empty .scores.pkl file.


Save action is prevented now if the current state is empty.

tashrifbillah commented 1 year ago

Can we write

if not props:
  props={}

after this line? https://github.com/AMP-SCZ/eeg-qc-dash/blob/a399a3874c68207a8eedb29846d00ecf97db5a3b/app.py#L368-L371


The idea is already suggested in the issue description. It's not desirable though because we would lose all past scores!