Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CV2-5640 only send responses to check api when we have a fully realized response from presto during sync requests #470

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/main/controller/presto_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def post(self, action, model_type):
if result:
result["is_search_result_callback"] = True
callback_url = data.get("body", {}).get("raw", {}).get("callback_url", app.config['CHECK_API_HOST']) or app.config['CHECK_API_HOST']
if result and data.get("body", {}).get("raw", {}).get("requires_callback"):
if result and result.get("results") is not None and data.get("body", {}).get("raw", {}).get("requires_callback"):
app.logger.info(f"Sending callback to {callback_url} for {action} for model of {model_type} with body of {result}")
Webhook.return_webhook(callback_url, action, model_type, result)
return_value = {"action": action, "model_type": model_type, "data": result}
Expand Down
2 changes: 1 addition & 1 deletion app/main/lib/elastic_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_blocked_presto_response(task, model, modality):
callback_url = Presto.add_item_callback_url(app.config['ALEGRE_HOST'], modality)
if requires_encoding(obj):
blocked_results = []
for model_key in obj.pop("models", []):
for model_key in obj.get("models", []):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the problem that we are destructively modifying the 'obj' object when the "models" list is removed? It seems like it shouldn't make a difference since it isn't referenced later, but .get seems like better syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we send these requests out, with the pop in place, it "tells" the alegre callback that is expecting fewer models than it really should be - by enforcing the get we (a) bring it in line with async and (b) probably eliminate erroneous calls back to check-api when alegre mistakenly things work is complete for every in-process vector

if model_key != "elasticsearch" and not obj.get('model_'+model_key):
response = get_presto_request_response(model_key, callback_url, obj)
blocked_results.append({"model": model_key, "response": Presto.blocked_response(response, modality)})
Expand Down
Loading