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

Create get new task function and expose in API #25

Closed
rufuspollock opened this issue Dec 21, 2011 · 7 comments
Closed

Create get new task function and expose in API #25

rufuspollock opened this issue Dec 21, 2011 · 7 comments
Assignees
Milestone

Comments

@rufuspollock
Copy link
Contributor

Location: /{api}/app/{id}/newtask/[{user-id}]

user-id is optional (may not be logged in!)

@lucasmation
Copy link

I have some ideas on how tasks should be atributed, which probably should be incorporated into PyBossa structure. Basically there are two ways people can colaborate:

  • sequentially: with one volunteer building on the work of a previous volunteer. This is how a "wiki" works.
  • in parallel: with the same task beeing done in parallel by many volunteers and the results compared for consistency.
    In the case of the table transcription we need both. Given a page (i) we can define a sej (j) of sequetitial translations (t).
    So a Job is described by: JOBi,j,t.
    Professional and academic table transcriptions using humans always use two parallel transcriptions, which are compared for consistency.
    Lets put some indexes as this could help in coding. So in this case, for translating page i=1, we would have:

Sequence j=1: JOB i=1,j=1,t=1 > JOB i=1,j=1,t=2 > JOB i=1,j=1,t=3 > ... > JOB i=1,j=1,t=n1 (when a user declares the transcription to be over.

Sequence j=2: JOB i=1,j=2,t=1 > JOB i=1,j=2,t=2 > JOB i=1,j=2,t=3 > ... > JOB i=1,j=2,t=n2

we would then have to compare (authomatically or by experienced users or project supervisors) the final iterations of each sequence: JOB i=1,j=1,t=n1 and JOB i=1,j=2,t=n2

@teleyinex , @rgrp : is this flexible sequential and/or parallel way of atributing tasks already build into PyBossa?

@ghost ghost assigned nigini Feb 17, 2012
@nigini
Copy link
Contributor

nigini commented Feb 17, 2012

@teleyinex @rgrp
This is maybe a Flask noob question, but I've searched the web and could not solve it yet! Can you try to help me with this?

I'm trying to create a new route at the API, but I can't stop receiving an 'HTTP 404'! As the route is different from the default ones (e.g. /app/1/newtask/1), I started creating a new 'MethodView', with a GET method. Then registered it with a different algorithm then 'register_api'. Is this the idea? The code is bellow (consider it a early^2 version).

class AppTaskAPI(MethodView):

    @jsonpify
    def get(self, app_id, command, user_id=None):
        bossa_app = model.Session.query(model.App).filter(model.App.id == app_id).one()
        if( bossa_app and not bossa_app.hidden ):
            #ToDo: This is a temporary solution!
            import random
            tasks = bossa_app.tasks
            task = tasks[random.randint(0,len(tasks))]
            return json.dumps(task)
        else:
            abort(404)

def register_apptask_api(view, endpoint, url, app='<int:app_id>', cmd='newtask', user='<int:user_id>'):
    view_func = view.as_view(endpoint)
    blueprint.add_url_rule('%s/%s/%s/%s' % (url, app, cmd, user),
        view_func=view_func,
        methods=['GET']
        )
    blueprint.add_url_rule('%s/%s/%s' % (url, app, cmd),
        view_func=view_func,
        methods=['GET']
        )

register_apptask_api(AppTaskAPI, 'api_apptask', '/app')

@nigini nigini reopened this Feb 25, 2012
@nigini
Copy link
Contributor

nigini commented Feb 25, 2012

I'm making some tests with the Flickr demo... It appears that the "newtask" algorithm is working on the premise that TaskRuns are already existent; what is not true. I'll examine this now!

@nigini
Copy link
Contributor

nigini commented Feb 25, 2012

Yep! The "join(TaskRun)" at line 307 of new_task at model.py will crash if there is no TaskRun in the system yet! Yet! I could not capture this with a unit test (I'm learning how to use it!). @rgrp Can this like be commented until I finish a new algorithm for TaskRun creation? For the Flickr App it has no problem, but it may be used at other site!

@rufuspollock
Copy link
Contributor Author

nigini no I would not comment this out. I'm also surprised it crashes if there are no TaskRuns (it just should not return anything). The real fix is probably a left join.

Aside: I'd also suggest not writing new core code until you are happy with unit tests as we should wherever possibly only add new code with tests ;-)

BTW: this issue is closed and can I assume you are not working on it?

@nigini nigini closed this as completed Feb 26, 2012
@nigini
Copy link
Contributor

nigini commented Feb 26, 2012

OK! Issue closed. Not working on this, but yes on the algorithm to choose tasks.

BTW: I'm actually able to use unit tests, but never used it in a production environment in Python. Already got the idea of how it is used at PyBossa.

@rufuspollock
Copy link
Contributor Author

But this task included the algorithm to choose tasks :-)

Would you like to update on what you want from algorithm to choose tasks so we can see if more work is needed on this issue?

At the moment the algorithm does crude randomization ...

teleyinex added a commit that referenced this issue Feb 28, 2012
…25

@rgrp was right, the problem was a bad SQL statement. This commit includes the unit test and the solution for the newtask method.
jayflo referenced this issue in bloomberg/pybossa May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants