-
Notifications
You must be signed in to change notification settings - Fork 80
adding User.jobs() #2035
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
Merged
Merged
adding User.jobs() #2035
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
da218e8
adding User.jobs()
antgonza 83d0b2b
adding webserver.py
antgonza 747059c
reponse {} -> []
antgonza b6ab4ed
flake8
antgonza 6b3c252
add job.processing_job_worflow
antgonza c2582e9
addressing @wasade comments
antgonza d00e117
@wasade clarifications
antgonza 88367bf
fix flake8
antgonza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) 2014--, The Qiita Development Team. | ||
# | ||
# Distributed under the terms of the BSD 3-clause License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ----------------------------------------------------------------------------- | ||
from unittest import TestCase, main | ||
from os.path import exists, isdir | ||
from os import remove | ||
from shutil import rmtree | ||
|
||
from qiita_core.util import qiita_test_checker | ||
import qiita_db as qdb | ||
from qiita_pet.handlers.api_proxy.user import (user_jobs_get_req) | ||
|
||
|
||
@qiita_test_checker() | ||
class TestSUserAPI(TestCase): | ||
def setUp(self): | ||
self._clean_up_files = [] | ||
|
||
def tearDown(self): | ||
for fp in self._clean_up_files: | ||
if exists(fp): | ||
if isdir(fp): | ||
rmtree(fp) | ||
else: | ||
remove(fp) | ||
|
||
def test_user_jobs_get_req(self): | ||
obs = user_jobs_get_req(qdb.user.User('shared@foo.bar')) | ||
exp = { | ||
'status': 'success', | ||
'message': '', | ||
'jobs': [ | ||
{'id': 'd19f76ee-274e-4c1b-b3a2-a12d73507c55', | ||
'status': 'error', | ||
'heartbeat': '2015-11-22 21:30:00', | ||
'params': { | ||
'reference': 1, | ||
'similarity': 0.97, | ||
'sortmerna_e_value': 1, | ||
'sortmerna_max_pos': 10000, | ||
'input_data': 2, | ||
'threads': 1, | ||
'sortmerna_coverage': 0.97}, | ||
'name': 'Pick closed-reference OTUs', | ||
'processing_job_workflow_id': ''}, | ||
{'id': 'b72369f9-a886-4193-8d3d-f7b504168e75', | ||
'status': 'success', | ||
'heartbeat': '2015-11-22 21:15:00', | ||
'params': { | ||
'max_barcode_errors': 1.5, | ||
'sequence_max_n': 0, | ||
'max_bad_run_length': 3, | ||
'phred_offset': u'auto', | ||
'rev_comp': False, | ||
'phred_quality_threshold': 3, | ||
'input_data': 1, | ||
'rev_comp_barcode': False, | ||
'rev_comp_mapping_barcodes': True, | ||
'min_per_read_length_fraction': 0.75, | ||
'barcode_type': u'golay_12'}, | ||
'name': 'Split libraries FASTQ', | ||
'processing_job_workflow_id': 1}]} | ||
self.assertEqual(obs, exp) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) 2014--, The Qiita Development Team. | ||
# | ||
# Distributed under the terms of the BSD 3-clause License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ----------------------------------------------------------------------------- | ||
from __future__ import division | ||
|
||
from qiita_core.util import execute_as_transaction | ||
|
||
|
||
@execute_as_transaction | ||
def user_jobs_get_req(user): | ||
"""Gets the json of jobs | ||
|
||
Parameters | ||
---------- | ||
prep_id : int | ||
PrepTemplate id to get info for | ||
user_id : str | ||
User requesting the sample template info | ||
|
||
Returns | ||
------- | ||
dict of objects | ||
{'status': status, | ||
'message': message, | ||
'template': {sample: {column: value, ...}, ...} | ||
""" | ||
|
||
response = [] | ||
for j in user.jobs(): | ||
name = j.command.name | ||
hb = j.heartbeat | ||
hb = "" if hb is None else hb.strftime("%Y-%m-%d %H:%M:%S") | ||
pjw = j.processing_job_worflow | ||
wid = '' if pjw is None else pjw.id | ||
response.append({ | ||
'id': j.id, | ||
'name': name, | ||
'params': j.parameters.values, | ||
'status': j.status, | ||
'heartbeat': hb, | ||
'processing_job_workflow_id': wid}) | ||
|
||
return {'status': 'success', | ||
'message': '', | ||
'jobs': response} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from wtforms import Form, StringField, validators | ||
|
||
from qiita_pet.handlers.base_handlers import BaseHandler | ||
from qiita_pet.handlers.api_proxy import user_jobs_get_req | ||
from qiita_db.user import User | ||
from qiita_db.logger import LogEntry | ||
from qiita_db.exceptions import QiitaDBUnknownIDError, QiitaDBError | ||
|
@@ -185,3 +186,10 @@ def post(self): | |
|
||
self.render("user_messages.html", | ||
messages=self.current_user.messages()) | ||
|
||
|
||
class UserJobs(BaseHandler): | ||
@authenticated | ||
def get(self): | ||
response = user_jobs_get_req(self.current_user) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this needs take the result of a |
||
self.write(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, changing