Giter Site home page Giter Site logo

Comments (9)

jacobwegner avatar jacobwegner commented on July 17, 2024 1

@bkeifer I'll see if I can add something soon.

from jobtastic.

winhamwr avatar winhamwr commented on July 17, 2024

Hi Jacob,

Yup. The documentation on jquery-celery is pretty abysmal right now :(

Here's a todo-django project using Jobtastic and jquery-celery that did for a presentation. Hopefully it will help at least a little bit. site_base.html is where the djcelery magic gets hooked in.

It's a pretty good example, since it uses progress and has error/success callbacks, but it's a bit more complex than the simplest example possible.

Would you be willing to take some quick notes on the things that tripped you up starting from that example? Maybe then I could adapt the code there as jquery-celery documentation and then specifically address the things that were confusing/surprising to you.

I'm sorry that I don't have better documentation here already. If you have questions, definitely ask them here and I'll try and respond quickly (at least for the next couple of hours, since I'm already writing documentation for other things anyway).

Thanks for asking the question!
-Wes

from jobtastic.

jacobwegner avatar jacobwegner commented on July 17, 2024

Thanks; looking at todo-django was enough to get me started.

The error/success callbacks are a big part of why I'm excited to work what you're doing with jobtastic and jquery-celery into some of my projects. I'll come back to this issue later in the week to try and capture my thoughts and do whatever I can to help improve documentation...out of time for today.

Thanks for the great work to date on both of these projects.

from jobtastic.

bkeifer avatar bkeifer commented on July 17, 2024

I know this is old, but I'd also like to see a sample HTML file. The AJAX part of this whole stack is my weakest point, and that's the one that's not in the docs. =)

from jobtastic.

jacobwegner avatar jacobwegner commented on July 17, 2024

@bkeifer: I'd love if you took a look at the updated README on this branch with the sample file included.

Ask me follow-up questions here if you're still stuck, and we can iterate on the file/instructions until you're up and running.

Hopefully that way we can end up with a good PR to the README that assumes nothing but gets other new users to the project up and running/

from jobtastic.

bkeifer avatar bkeifer commented on July 17, 2024

Progress! I'm slowly working through this and getting close.

First thing I found is an extra semicolon on the closing } for on_other (line 39).

The task is started and completes successfully (verified via flower), but I'm getting the "Something went horribly wrong" message on the web page.

My console shows the following URL throwing a 404:
http://localhost:8080/task/f231d5df-fbc6-45b6-acf1-625f4a669134/status/?_=1462994476693

This makes sense, since I don't have anything at /task/ (that I know of, at least...). Where is that URL handled? Is that a part of the Celery setup I missed? If it matters, this is in a Django app.

EDIT: I'm getting there. I think I've almost gotten my view for /task/ working. I'll be happy to provide a copy for the readme once it's working.

from jobtastic.

bkeifer avatar bkeifer commented on July 17, 2024

So here's what I've got for my /task view. It's not pretty, but it works. Does this jive with what you'd expect to see from the method handling that call?

def task(request, task_id):

    data = 'Fail'
    task = AsyncResult(task_id)

    # Task is still in progress
    if type(task.result) is dict:
        data = {'task': {'result': {}}}
        data['task']['id'] = task_id
        data['task']['status'] = task.state
        data['task']['result']['progress_percent'] = task.result['progress_percent']
    # Task has finished.
    elif type(task.result) is list:
        data = {'task': {}}
        data['task'] = {
            'status': task.state,
            'id': task_id,
            'progress_percent' : 100,
        }

    return HttpResponse(json.dumps(data), content_type='application/json')

from jobtastic.

jacobwegner avatar jacobwegner commented on July 17, 2024

@bkeifer: You're on the right track.

Celery includes a task status view that you can wire up in the urls.py for your project. It corresponds to the path defined in jquery-celery:

from djcelery.views import task_status
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    ...
    url(r'^task/(?P<task_id>[\w\d\-\.]+)/status/', task_status),
]

from jobtastic.

bkeifer avatar bkeifer commented on July 17, 2024

That was the missing piece. Thank you!

from jobtastic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.