Skip to content

Commit

Permalink
convered check celery task status to be generic
Browse files Browse the repository at this point in the history
  • Loading branch information
Formartha committed Mar 11, 2024
1 parent f98025a commit c7c6f8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ai1899/api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from lm_module import client, model
from tasks import upsert_collection as uc
from tasks import celery as celery_app

ai_api = Blueprint('ai', __name__)

Expand Down Expand Up @@ -164,11 +165,11 @@ async def upsert_collection():
return jsonify({'error': str(e)}), 500


@swag_from("swag/check_upsert_status.yaml")
@ai_api.route('/check_upsert_status/<task_id>', methods=["GET"])
@swag_from("swag/celery_status.yaml")
@ai_api.route('/celery-status/<task_id>', methods=["GET"])
def check_task_status(task_id):
if request.method == "GET":
result = uc.AsyncResult(task_id)
result = celery_app.AsyncResult(task_id)
return jsonify({"status": result.state}), 200 # This will return the state of the task as a string
else:
return jsonify({"error": "Method Not Allowed"}), 405
Expand Down
File renamed without changes.

0 comments on commit c7c6f8d

Please sign in to comment.