Skip to content

Commit

Permalink
celery syncs
Browse files Browse the repository at this point in the history
  • Loading branch information
dartpain committed Oct 1, 2023
1 parent a619269 commit cd9b03b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions application/api/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from bson.objectid import ObjectId
from werkzeug.utils import secure_filename
import http.client
from celery.result import AsyncResult

from application.api.user.tasks import ingest

Expand Down Expand Up @@ -142,7 +141,8 @@ def upload_file():
def task_status():
"""Get celery job status."""
task_id = request.args.get("task_id")
task = AsyncResult(task_id, backend=settings.CELERY_RESULT_BACKEND)
from application.celery import celery
task = celery.AsyncResult(task_id)
task_meta = task.info
return {"status": task.status, "result": task_meta}

Expand Down
2 changes: 1 addition & 1 deletion application/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from application.core.settings import settings

def make_celery(app_name=__name__):
celery = Celery(app_name, broker=settings.CELERY_BROKER_URL)
celery = Celery(app_name, broker=settings.CELERY_BROKER_URL, backend=settings.CELERY_RESULT_BACKEND)
celery.conf.update(settings)
return celery

Expand Down
4 changes: 3 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ download_locally() {
#pip install -r application/requirements.txt
#pip install llama-cpp-python
#pip install sentence-transformers
export LLM_NAME=llama.cpp
export EMBEDDINGS_NAME=huggingface_sentence-transformers/all-mpnet-base-v2
export FLASK_APP=application/app.py
export FLASK_DEBUG=true
export CELERY_BROKER_URL=redis://localhost:6379/0
export CELERY_RESULT_BACKEND=redis://localhost:6379/1
echo "The application is now running on http://localhost:5173"
echo "You can stop the application by running the following command:"
echo "Ctrl + C and then"
echo "Then pkill -f "flask run" and then"
echo "Then pkill -f 'flask run' and then"
echo "docker-compose down"
flask run --host=0.0.0.0 --port=7091 &
celery -A application.app.celery worker -l INFO
Expand Down

0 comments on commit cd9b03b

Please sign in to comment.