Add support for update pre/post processing code to a live endpoint

This commit is contained in:
allegroai 2022-06-07 00:52:08 +03:00
parent b5de243348
commit 5beb077f51

View File

@ -808,6 +808,7 @@ class ModelRequestProcessor(object):
self._task.mark_started(force=True) self._task.mark_started(force=True)
self._report_text("Launching - configuration sync every {} sec".format(poll_frequency_sec)) self._report_text("Launching - configuration sync every {} sec".format(poll_frequency_sec))
cleanup = False cleanup = False
model_monitor_update = False
self._update_serving_plot() self._update_serving_plot()
while True: while True:
try: try:
@ -823,21 +824,24 @@ class ModelRequestProcessor(object):
# update endpoints # update endpoints
self.deserialize(self._task) self.deserialize(self._task)
# mark clean up for next round # mark clean up for next round
cleanup = True model_monitor_update = True
# update serving layout plot # update serving layout plot
if cleanup: if cleanup or model_monitor_update:
self._update_serving_plot() self._update_serving_plot()
if cleanup:
self._engine_processor_lookup = dict()
except Exception as ex: except Exception as ex:
print("Exception occurred in monitoring thread: {}".format(ex)) print("Exception occurred in monitoring thread: {}".format(ex))
sleep(poll_frequency_sec) sleep(poll_frequency_sec)
try: try:
# we assume that by now all old deleted endpoints requests already returned # we assume that by now all old deleted endpoints requests already returned
if cleanup: if model_monitor_update and not cleanup:
cleanup = False
for k in list(self._engine_processor_lookup.keys()): for k in list(self._engine_processor_lookup.keys()):
if k not in self._endpoints: if k not in self._endpoints:
# atomic # atomic
self._engine_processor_lookup.pop(k, None) self._engine_processor_lookup.pop(k, None)
cleanup = False
model_monitor_update = False
except Exception as ex: except Exception as ex:
print("Exception occurred in monitoring thread: {}".format(ex)) print("Exception occurred in monitoring thread: {}".format(ex))