LowellObservatory / NightWatch

A system to display a set of important information at an observatory.
2 stars 0 forks source link

Weather plot broken? #37

Closed astrobokonon closed 4 years ago

astrobokonon commented 5 years ago

Seems like the weather plot/section is broken in some way, it's not displaying the table and it doesn't seem to be updating automatically anymore. Need to fix that before the shutdown is over!

astrobokonon commented 5 years ago

Noticed that the instruments plot is busted too; that one is probably because everything is warm and there's no recent data to plot, but it should be fixed to at least show the plot so you can see it's empty.

astrobokonon commented 5 years ago

Seems like this is the problem; there are a few of them, some of which are probably related to finding no data within the query window:

2019-07-16 20:34:43,509 ERROR Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 501, in callback result_list.append(f.result()) File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run yielded = self.gen.send(value) File "/opt/conda/lib/python3.7/site-packages/bokeh/server/session.py", line 70, in _needs_document_lock_wrapper result = yield yield_for_all_futures(func(self, *args, kwargs)) File "/opt/conda/lib/python3.7/site-packages/bokeh/server/session.py", line 191, in with_document_locked return func(*args, *kwargs) File "/opt/conda/lib/python3.7/site-packages/bokeh/document/document.py", line 1127, in wrapper return doc._with_self_as_curdoc(invoke) File "/opt/conda/lib/python3.7/site-packages/bokeh/document/document.py", line 1113, in _with_self_as_curdoc return f() File "/opt/conda/lib/python3.7/site-packages/bokeh/document/document.py", line 1126, in invoke return f(args, kwargs) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/dctWeather.py", line 189, in grabNew nf = dataGatherer(m, qdata, timeFilter=lastTimedt) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/dctWeather.py", line 70, in dataGatherer r2ipydt = r2.index.to_pydatetime() AttributeError: 'dict' object has no attribute 'index'

2019-07-16 20:34:46,395 INFO 200 GET /dctweather/autoload.js?bokeh-autoload-element=1119&bokeh-app-path=/dctweather&bokeh-absolute-url=http://dctsleeperservice:5000/dctweather&resources=none (192.168.168.194) 177.41ms 2019-07-16 20:34:46,402 ERROR Uncaught exception GET /dctweathertable/autoload.js?bokeh-autoload-element=1120&bokeh-app-path=/dctweathertable&bokeh-absolute-url=http://dctsleeperservice:5000/dctweathertable&resources=none (192.168.168.194) HTTPServerRequest(protocol='http', host='dctsleeperservice:5000', method='GET', uri='/dctweathertable/autoload.js?bokeh-autoload-element=1120&bokeh-app-path=/dctweathertable&bokeh-absolute-url=http://dctsleeperservice:5000/dctweathertable&resources=none', version='HTTP/1.1', remote_ip='192.168.168.194') Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute result = await result File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/autoload_js_handler.py", line 60, in get session = yield self.get_session() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/session_handler.py", line 77, in get_session session = yield self.application_context.create_session_if_needed(session_id, self.request) File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run yielded = self.gen.send(value) File "/opt/conda/lib/python3.7/site-packages/bokeh/server/contexts.py", line 215, in create_session_if_needed self._application.initialize_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/application.py", line 178, in initialize_document h.modify_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/handlers/function.py", line 133, in modify_document self._func(doc) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/dctWeatherTable.py", line 86, in makeTable cds = filterAndJudge(r) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/dctWeatherTable.py", line 44, in filterAndJudge compTime=now, nullVal=-1, fstr="%.1f") File "/home/lig/Codes/NightShift/nightshift/bokeh/plotting/helpers.py", line 182, in getLast val = getattr(p1, fieldname)[lastIdx] File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5067, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'MountTemp'

2019-07-16 20:34:46,402 ERROR 500 GET /dctweathertable/autoload.js?bokeh-autoload-element=1120&bokeh-app-path=/dctweathertable&bokeh-absolute-url=http://dctsleeperservice:5000/dctweathertable&resources=none (192.168.168.194) 6.41ms 2019-07-16 20:34:46,560 INFO 200 GET /dctwind/autoload.js?bokeh-autoload-element=1121&bokeh-app-path=/dctwind&bokeh-absolute-url=http://dctsleeperservice:5000/dctwind&resources=none (192.168.168.194) 157.39ms 2019-07-16 20:34:46,572 INFO 200 GET /dctwindtable/autoload.js?bokeh-autoload-element=1122&bokeh-app-path=/dctwindtable&bokeh-absolute-url=http://dctsleeperservice:5000/dctwindtable&resources=none (192.168.168.194) 169.13ms 2019-07-16 20:34:46,579 INFO 200 GET /facsum_tcs/autoload.js?bokeh-autoload-element=1124&bokeh-app-path=/facsum_tcs&bokeh-absolute-url=http://dctsleeperservice:5000/facsum_tcs&resources=none (192.168.168.194) 175.60ms 2019-07-16 20:34:46,579 ERROR Uncaught exception GET /lmitemps/autoload.js?bokeh-autoload-element=1123&bokeh-app-path=/lmitemps&bokeh-absolute-url=http://dctsleeperservice:5000/lmitemps&resources=none (192.168.168.194) HTTPServerRequest(protocol='http', host='dctsleeperservice:5000', method='GET', uri='/lmitemps/autoload.js?bokeh-autoload-element=1123&bokeh-app-path=/lmitemps&bokeh-absolute-url=http://dctsleeperservice:5000/lmitemps&resources=none', version='HTTP/1.1', remote_ip='192.168.168.194') Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute result = await result File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/autoload_js_handler.py", line 60, in get session = yield self.get_session() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/session_handler.py", line 77, in get_session session = yield self.application_context.create_session_if_needed(session_id, self.request) File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run yielded = self.gen.send(value) File "/opt/conda/lib/python3.7/site-packages/bokeh/server/contexts.py", line 215, in create_session_if_needed self._application.initialize_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/application.py", line 178, in initialize_document h.modify_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/handlers/function.py", line 133, in modify_document self._func(doc) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/instrumentTelem.py", line 113, in make_plot r = dataGatherer(m, qdata) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/instrumentTelem.py", line 37, in dataGatherer r = pdata['q_insttemps']['deveny'] KeyError: 'deveny'

2019-07-16 20:34:46,580 ERROR 500 GET /lmitemps/autoload.js?bokeh-autoload-element=1123&bokeh-app-path=/lmitemps&bokeh-absolute-url=http://dctsleeperservice:5000/lmitemps&resources=none (192.168.168.194) 176.73ms 2019-07-16 20:34:46,587 ERROR Uncaught exception GET /dctweathertable/autoload.js?bokeh-autoload-element=1120&bokeh-app-path=/dctweathertable&bokeh-absolute-url=http://dctsleeperservice:5000/dctweathertable&resources=none (192.168.168.194) HTTPServerRequest(protocol='http', host='dctsleeperservice:5000', method='GET', uri='/dctweathertable/autoload.js?bokeh-autoload-element=1120&bokeh-app-path=/dctweathertable&bokeh-absolute-url=http://dctsleeperservice:5000/dctweathertable&resources=none', version='HTTP/1.1', remote_ip='192.168.168.194') Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute result = await result File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/autoload_js_handler.py", line 60, in get session = yield self.get_session() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/session_handler.py", line 77, in get_session session = yield self.application_context.create_session_if_needed(session_id, self.request) File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run yielded = self.gen.send(value) File "/opt/conda/lib/python3.7/site-packages/bokeh/server/contexts.py", line 215, in create_session_if_needed self._application.initialize_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/application.py", line 178, in initialize_document h.modify_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/handlers/function.py", line 133, in modify_document self._func(doc) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/dctWeatherTable.py", line 86, in makeTable cds = filterAndJudge(r) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/dctWeatherTable.py", line 44, in filterAndJudge compTime=now, nullVal=-1, fstr="%.1f") File "/home/lig/Codes/NightShift/nightshift/bokeh/plotting/helpers.py", line 182, in getLast val = getattr(p1, fieldname)[lastIdx] File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5067, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'MountTemp'

2019-07-16 20:34:46,587 ERROR 500 GET /dctweathertable/autoload.js?bokeh-autoload-element=1120&bokeh-app-path=/dctweathertable&bokeh-absolute-url=http://dctsleeperservice:5000/dctweathertable&resources=none (192.168.168.194) 6.63ms 2019-07-16 20:34:46,594 INFO 200 GET /facsum_lpi/autoload.js?bokeh-autoload-element=1125&bokeh-app-path=/facsum_lpi&bokeh-absolute-url=http://dctsleeperservice:5000/facsum_lpi&resources=none (192.168.168.194) 6.35ms 2019-07-16 20:34:46,639 ERROR Uncaught exception GET /lmitemps/autoload.js?bokeh-autoload-element=1123&bokeh-app-path=/lmitemps&bokeh-absolute-url=http://dctsleeperservice:5000/lmitemps&resources=none (192.168.168.194) HTTPServerRequest(protocol='http', host='dctsleeperservice:5000', method='GET', uri='/lmitemps/autoload.js?bokeh-autoload-element=1123&bokeh-app-path=/lmitemps&bokeh-absolute-url=http://dctsleeperservice:5000/lmitemps&resources=none', version='HTTP/1.1', remote_ip='192.168.168.194') Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute result = await result File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/autoload_js_handler.py", line 60, in get session = yield self.get_session() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 736, in run yielded = self.gen.throw(exc_info) # type: ignore File "/opt/conda/lib/python3.7/site-packages/bokeh/server/views/session_handler.py", line 77, in get_session session = yield self.application_context.create_session_if_needed(session_id, self.request) File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 729, in run value = future.result() File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run yielded = self.gen.send(value) File "/opt/conda/lib/python3.7/site-packages/bokeh/server/contexts.py", line 215, in create_session_if_needed self._application.initialize_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/application.py", line 178, in initialize_document h.modify_document(doc) File "/opt/conda/lib/python3.7/site-packages/bokeh/application/handlers/function.py", line 133, in modify_document self._func(doc) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/instrumentTelem.py", line 113, in make_plot r = dataGatherer(m, qdata) File "/home/lig/Codes/NightShift/nightshift/bokeh/dct/instrumentTelem.py", line 37, in dataGatherer r = pdata['q_insttemps']['deveny'] KeyError: 'deveny' 2019-07-16 20:34:46,640 ERROR 500 GET /lmitemps/autoload.js?bokeh-autoload-element=1123&bokeh-app-path=/lmitemps&bokeh-absolute-url=http://dctsleeperservice:5000/lmitemps&resources=none (192.168.168.194) 1.50ms

astrobokonon commented 5 years ago

To properly fix this, I need to make sure that the dict that gets filled with the query results (qdata) always has the expected keys in it. That's the only way to not have the downstream queries in the dataGatherer functions not completely blow up, though I might not be able to avoid that without re-doing those as well; the .index.to_pydatetime() lines will likely still fail unless I store a blank DataFrame I'm guessing.

astrobokonon commented 5 years ago

Even though I fixed the weather plot failure, it's still not automatically updating the time range if you leave it open for a while. I wonder if I'm having a failure related to the MountTemp that I haven't noticed yet?

astrobokonon commented 4 years ago

This one has to be worked on, when the site is closed all the queries start failing and bokeh ends up in a sort of crash loop, continually gaining memory and getting out of hand. Needs to be fixed so this can be 99.99999% hands off on the backend!

astrobokonon commented 4 years ago

A side note - bokeh 2.0.1 fixes at least the memory leak portion of this, but the crash/exceptions still occur because the dataGather functions fail when they try to pick things out of the (empty) dataframes returned from queries in which no data was found. Interesting, and it gives me a little more buffer time to sort this out properly during the pandemic at least.

astrobokonon commented 4 years ago

I "fixed" the problem by putting in a definitely old/obvious date and a NaN for each column in the dataframe returned by a given query. But it's up to the consumer to actually check to make sure if a dataframe that has data that's just a single NaN point with a date of my birthday makes sense or not. I'm closing this because I'm mainly tired of this issue being open and I think it's at least better, now.