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

adding User.jobs() #2035

Merged
merged 8 commits into from
Jan 4, 2017
Merged

adding User.jobs() #2035

merged 8 commits into from
Jan 4, 2017

Conversation

antgonza
Copy link
Member

This retrieves the jobs for a user. Note that this only retrieves the processing jobs, AKA no moi jobs. However, AFAIK only the analysis is currently using moi jobs and @josenavas is working on removing that as part of the refactor. I'll do another PR to add the GUI part of this functionality. This should be reviewed and merged before the other PR.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 83d0b2b on antgonza:user-jobs into ** on biocore:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b6ab4ed on antgonza:user-jobs into ** on biocore:master**.

@antgonza
Copy link
Member Author

antgonza commented Jan 2, 2017

Turns out that you can remove processingjobs via the processingworkflow method, which is much cleaner than adding a processingjob remove. However, the processing job didn't have a method to return its processingworkflow. Just added it.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 6b3c252 on antgonza:user-jobs into ** on biocore:master**.

@antgonza antgonza mentioned this pull request Jan 3, 2017
6 tasks
qdb.sql_connection.TRN.add(sql, [self.id])
r = qdb.sql_connection.TRN.execute_fetchindex()

return (None if not r
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about return qdb.processing_job.ProcessingWorkflow(r[0][0]) if r else None? I don't think the use of a negative conditional is necessary

cmds = {}
for j in user.jobs():
cmd = j.command
if cmd not in cmds:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a valid situation in which the same command will appear multiple times?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, multiple and the idea of cache; basically, the command is the definition of the command (split libs, demux, etc) and the job is the command with the specific params.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this caches anything though? cmds is reset prior to the forloop so the only compute that is avoided is the assignment of a value to a key in a dict?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...on closer inspection, it doesn't look like cmds is needed at all

cmd = j.command
if cmd not in cmds:
cmds[cmd] = cmd
ccmd = cmds[cmd]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccmd is cmd -> True, is there a need for this additional variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary but I like it cause that makes the subsequent calls smaller. However, we are only retrieving the name of the command so change it a little bit.

class UserJobs(BaseHandler):
@authenticated
def get(self):
response = user_jobs_get_req(self.current_user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this executes as a transaction and has the potential to block as it is performing IO. Should this method be a tornado coroutine instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, changing

Copy link
Member Author

@antgonza antgonza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @wasade !

cmds = {}
for j in user.jobs():
cmd = j.command
if cmd not in cmds:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, multiple and the idea of cache; basically, the command is the definition of the command (split libs, demux, etc) and the job is the command with the specific params.

cmd = j.command
if cmd not in cmds:
cmds[cmd] = cmd
ccmd = cmds[cmd]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary but I like it cause that makes the subsequent calls smaller. However, we are only retrieving the name of the command so change it a little bit.

class UserJobs(BaseHandler):
@authenticated
def get(self):
response = user_jobs_get_req(self.current_user)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, changing

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c2582e9 on antgonza:user-jobs into ** on biocore:master**.

@authenticated
@coroutine
def get(self):
response = user_jobs_get_req(self.current_user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs take the result of a yield?

http://www.tornadoweb.org/en/stable/gen.html

@@ -1,8 +1,10 @@
from tornado.web import authenticated, HTTPError
from tornado.gen import coroutine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are flake8 errors because this import is not being used.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 88367bf on antgonza:user-jobs into ** on biocore:master**.

@josenavas josenavas merged commit 46b7d0b into qiita-spots:master Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants