Skip to content

Transfer update delete templates #2274

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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9481d42
Moving update_sample_template
josenavas Aug 31, 2017
998197e
Transfer update_sample_template
josenavas Sep 1, 2017
656ac7f
Porting update prep template
josenavas Sep 5, 2017
37a5a74
Moving delete sample or column
josenavas Sep 5, 2017
4a6b3b2
Removing tests
josenavas Sep 5, 2017
0aaa53f
Solving merge conflicts
josenavas Sep 5, 2017
6f52ebd
Removing dispatchable and its tests
josenavas Sep 5, 2017
c2e7d8b
Updating interface to use the new functionality'
josenavas Sep 5, 2017
c450079
Adapting the prep template GUI
josenavas Sep 5, 2017
22ce457
Submitting jobs
josenavas Sep 6, 2017
d2259b0
Fixing tests
josenavas Sep 6, 2017
6ec24d9
Removing qiita_ware/context.py
josenavas Sep 6, 2017
e9901ed
flake8ing
josenavas Sep 6, 2017
2019e71
Fixing _system_call
josenavas Sep 7, 2017
830312d
Safeguarding the call to rollback
josenavas Sep 7, 2017
3f4cdcd
Unmasking more errors
josenavas Sep 7, 2017
d9d51e6
Forcing different connections on different processes
josenavas Sep 7, 2017
4339eda
Moving job completion to internal plugin structure
josenavas Sep 7, 2017
fa391d0
Removing unused code
josenavas Sep 7, 2017
dd74e11
Forcing the creation of a new transaction on the jobs
josenavas Sep 7, 2017
407fd8b
Fixing tests
josenavas Sep 7, 2017
966eb0f
forcing the commit
josenavas Sep 7, 2017
1a4026c
Fixing all tests
josenavas Sep 7, 2017
dc960a3
Addressing @antgonza's comments
josenavas Sep 8, 2017
63519f6
Addressing @antgonza's comment
josenavas Sep 8, 2017
eb2d314
Addressing @ElDeveloper's comments
josenavas Sep 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixing tests
  • Loading branch information
josenavas committed Sep 6, 2017
commit d2259b0290e2281d0926e97d550a7d92a1cc7ff7
2 changes: 1 addition & 1 deletion qiita_pet/handlers/api_proxy/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def prep_template_ajax_get_req(user_id, prep_id):
alert_msg = job.log.msg.replace('\n', '</br>')
else:
alert_type = job_info['alert_type']
alert_msg = job_info['alert_msg']
alert_msg = job_info['alert_msg'].replace('\n', '</br>')

artifact_attached = pt.artifact is not None
study_id = pt.study_id
Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/handlers/api_proxy/sample_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_sample_template_processing_status(st_id):
alert_msg = job.log.msg.replace('\n', '</br>')
else:
alert_type = job_info['alert_type']
alert_msg = job_info['alert_msg']
alert_msg = job_info['alert_msg'].replace('\n', '</br>')

return processing, alert_type, alert_msg

Expand Down Expand Up @@ -541,7 +541,7 @@ def sample_template_patch_request(user_id, req_op, req_path, req_value=None,
cmd, values_dict={'obj_class': 'SampleTemplate',
'obj_id': int(st_id), 'sample_or_col': attribute,
'name': attr_id})
job = ProcessingJob(User(user_id), params)
job = ProcessingJob.create(User(user_id), params)

# Store the job id attaching it to the sample template id
r_client.set(SAMPLE_TEMPLATE_KEY_FORMAT % st_id,
Expand Down
7 changes: 2 additions & 5 deletions qiita_pet/handlers/api_proxy/tests/test_prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from os.path import join, exists
from string import ascii_letters
from random import choice
from time import sleep
from json import loads

import pandas as pd
import numpy.testing as npt

from qiita_core.util import qiita_test_checker
from qiita_core.qiita_settings import r_client
from qiita_core.testing import wait_for_processing_job
from qiita_db.artifact import Artifact
from qiita_db.metadata_template.prep_template import PrepTemplate
from qiita_db.ontology import Ontology
Expand Down Expand Up @@ -288,10 +288,7 @@ def _wait_for_parallel_job(self, key):
# so we need to make sure that all processes are done before we reset
# the test database
obs = r_client.get(key)
redis_info = loads(r_client.get(loads(obs)['job_id']))
while redis_info['status_msg'] == 'Running':
sleep(0.5)
redis_info = loads(r_client.get(loads(obs)['job_id']))
wait_for_processing_job(loads(obs)['job_id'])

def test_prep_template_graph_get_req(self):
obs = prep_template_graph_get_req(1, 'test@foo.bar')
Expand Down
73 changes: 24 additions & 49 deletions qiita_pet/handlers/api_proxy/tests/test_sample_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from unittest import TestCase, main
from os import remove, mkdir
from os.path import join, exists
from time import sleep
from json import loads, dumps

from qiita_core.util import qiita_test_checker
from qiita_core.qiita_settings import r_client
from qiita_core.testing import wait_for_processing_job
import qiita_db as qdb
from qiita_pet.handlers.api_proxy.sample_template import (
sample_template_summary_get_req, sample_template_post_req,
Expand Down Expand Up @@ -140,55 +140,42 @@ def test_get_sample_template_processing_status(self):
self.assertEqual(obs_at, "")
self.assertEqual(obs_am, "")

# Without job id
r_client.set(key, dumps({'job_id': None, 'status': "success",
'message': ""}))
obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
self.assertFalse(obs_proc)
self.assertEqual(obs_at, "success")
self.assertEqual(obs_am, "")

# With job id and processing
r_client.set(key, dumps({'job_id': "test_job_id"}))
r_client.set("test_job_id", dumps({'status_msg': 'Running'}))
qiita_plugin = qdb.software.Software.from_name_and_version('Qiita',
'alpha')
cmd = qiita_plugin.get_command('update_sample_template')
params = qdb.software.Parameters.load(
cmd, values_dict={'study': 1, 'template_fp': 'ignored'})
job = qdb.processing_job.ProcessingJob.create(
qdb.user.User('test@foo.bar'), params)
job._set_status('running')
r_client.set(key, dumps({'job_id': job.id}))
obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
self.assertTrue(obs_proc)
self.assertEqual(obs_at, "info")
self.assertEqual(
obs_am, "This sample template is currently being processed")

# With job id and success
r_client.set(key, dumps({'job_id': "test_job_id"}))
r_client.set("test_job_id",
dumps({'status_msg': 'Success',
'return': {'status': 'success',
'message': 'Some\nwarning'}}))
job._set_status('success')
r_client.set(key, dumps({'job_id': job.id, 'alert_type': 'warning',
'alert_msg': 'Some\nwarning'}))
obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
self.assertFalse(obs_proc)
self.assertEqual(obs_at, "success")
self.assertEqual(obs_at, "warning")
self.assertEqual(obs_am, "Some</br>warning")
obs = loads(r_client.get(key))
self.assertEqual(obs, {'job_id': None, 'status': 'success',
'message': 'Some</br>warning'})

# With job and not success
r_client.set(key, dumps({'job_id': "test_job_id"}))
r_client.set("test_job_id",
dumps({'status_msg': 'Failed',
'return': {'status': 'error',
'message': 'Some\nerror'}}))
job = qdb.processing_job.ProcessingJob.create(
qdb.user.User('test@foo.bar'), params)
job._set_status('running')
job._set_error('Some\nerror')
r_client.set(key, dumps({'job_id': job.id}))
obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
self.assertFalse(obs_proc)
self.assertEqual(obs_at, "error")
self.assertEqual(obs_at, "danger")
self.assertEqual(obs_am, "Some</br>error")

# With job expired
r_client.set(key, dumps({'job_id': "non_existent_job"}))
obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
self.assertFalse(obs_proc)
self.assertEqual(obs_at, "")
self.assertEqual(obs_am, "")

def test_sample_template_summary_get_req(self):
obs = sample_template_summary_get_req(1, 'test@foo.bar')
exp = {
Expand Down Expand Up @@ -396,10 +383,7 @@ def test_sample_template_post_req(self):
# This is needed so the clean up works - this is a distributed system
# so we need to make sure that all processes are done before we reset
# the test database
redis_info = loads(r_client.get(loads(obs)['job_id']))
while redis_info['status_msg'] == 'Running':
sleep(0.5)
redis_info = loads(r_client.get(loads(obs)['job_id']))
wait_for_processing_job(loads(obs)['job_id'])

def test_sample_template_post_req_no_access(self):
obs = sample_template_post_req(1, 'demo@microbio.me', '16S',
Expand All @@ -422,10 +406,7 @@ def test_sample_template_put_req(self):
# This is needed so the clean up works - this is a distributed system
# so we need to make sure that all processes are done before we reset
# the test database
redis_info = loads(r_client.get(loads(obs)['job_id']))
while redis_info['status_msg'] == 'Running':
sleep(0.5)
redis_info = loads(r_client.get(loads(obs)['job_id']))
wait_for_processing_job(loads(obs)['job_id'])

def test_sample_template_put_req_no_access(self):
obs = sample_template_put_req(1, 'demo@microbio.me', 'filepath')
Expand All @@ -452,10 +433,7 @@ def test_sample_template_delete_req(self):
# This is needed so the clean up works - this is a distributed system
# so we need to make sure that all processes are done before we reset
# the test database
redis_info = loads(r_client.get(loads(obs)['job_id']))
while redis_info['status_msg'] == 'Running':
sleep(0.5)
redis_info = loads(r_client.get(loads(obs)['job_id']))
wait_for_processing_job(loads(obs)['job_id'])

def test_sample_template_delete_req_no_access(self):
obs = sample_template_delete_req(1, 'demo@microbio.me')
Expand Down Expand Up @@ -552,10 +530,7 @@ def test_sample_template_patch_request(self):
# the test database
obs = r_client.get('sample_template_1')
self.assertIsNotNone(obs)
redis_info = loads(r_client.get(loads(obs)['job_id']))
while redis_info['status_msg'] == 'Running':
sleep(0.5)
redis_info = loads(r_client.get(loads(obs)['job_id']))
wait_for_processing_job(loads(obs)['job_id'])

ST = qdb.metadata_template.sample_template.SampleTemplate
self.assertNotIn("season_environment", ST(1).categories())
Expand Down