Error: No such option: -b while running celery and redis as message broker

Viewed 343

I am having a flask app which is doing inference on a ml model and I added celery and redis as message broker to do queue based predictions

from celery import Celery

app.config.update(
CELERY_BROKER_URL='redis://localhost:6379/0',
CELERY_RESULT_BACKEND='redis://localhost:6379/0'
)
def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery


app = Flask(__name__)
CORS(app)

celery = make_celery(app)


@celery.task
response = {}
@app.route('/predict', methods=["POST", "GET"])
def predict():
    if request.method=='POST':
        solute = request.form["solute"]
        solvent = request.form["solvent"]

    else:
        solute = request.args.get("solute")
        solvent = request.args.get("solvent")

    results = predictions(solute, solvent)
    
    response["predictions"] = results[0].item()
    response["interaction_map"] = (results[1].detach().numpy()).tolist()
    return flask.jsonify({'result': response})

I have ran celery worker -b redis://localhost:6379 --app= main.celery -l here -b is broker but I got Error: No such option: -b. I don't know where I am doing wrong.

I am running this in windows WSL configured ubuntu in vscode.

1 Answers

I just had the same issue, then I ran celery which displayed: Usage: celery [OPTIONS] COMMAND [ARGS]... and listed -b in OPTIONS. So running celery -b redis://localhost:6379 worker in that order will work.

Related