One simple solution is to delete analysis_obj.topic_plots and analysis_obj.frame_plots in the beginning of compute_analysis. But the problem is, do you really want to do delete it? What if running the new analysis fails, you'll be left with nothing.
The ideal solution is to prevent sending analysis_obj.topic_plots and analysis_obj.frame_plots while the celery state is in PROGRESS. If its PENDING, SUCCESS, or FAILED it should send the entire object.
As of the time of writing this, the method for getting an analysis looks like
@marshal_with(analysis_marshall)
def get(self, id):
"""
Return percent complete (meta).
Return either empty json or completed frame and topic plot (text).
"""
analysis_obj = Analysis.get(Analysis.id == id)
info = analysis_obj.check_if_complete()
data = get_dictionary_from_model(analysis_obj)
data['topic_plot'] = eval(data['topic_plot']) if data['topic_plot'] else None
data['frame_plot'] = eval(data['frame_plot']) if data['frame_plot'] else None
return { 'meta': info, 'data': data }
We can change it so that we add a conditional after it computes info to check the state property.
One simple solution is to delete
analysis_obj.topic_plots
andanalysis_obj.frame_plots
in the beginning of compute_analysis. But the problem is, do you really want to do delete it? What if running the new analysis fails, you'll be left with nothing.The ideal solution is to prevent sending
analysis_obj.topic_plots
andanalysis_obj.frame_plots
while the celery state is inPROGRESS
. If itsPENDING
,SUCCESS
, orFAILED
it should send the entire object.As of the time of writing this, the method for getting an analysis looks like
We can change it so that we add a conditional after it computes
info
to check thestate
property.