Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ before_install:
- wget ftp://ftp.microbio.me/pub/qiita/ascp-install-3.5.4.102989-linux-64-qiita.sh -O ascp-install-3.5.4.102989-linux-64-qiita.sh
- chmod +x ascp-install-3.5.4.102989-linux-64-qiita.sh
- ./ascp-install-3.5.4.102989-linux-64-qiita.sh
- if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then openssl aes-256-cbc -K $encrypted_a2e23aea5f14_key -iv $encrypted_a2e23aea5f14_iv -in qiita_core/support_files/config_test_travis.cfg.enc -out qiita_core/support_files/config_test_travis.cfg -d ; fi
# once we have ebi testing we should uncomment this line
# - if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then openssl aes-256-cbc -K $encrypted_a2e23aea5f14_key -iv $encrypted_a2e23aea5f14_iv -in qiita_core/support_files/config_test_travis.cfg.enc -out qiita_core/support_files/config_test_travis.cfg -d ; fi
install:
# install a few of the dependencies that pip would otherwise try to install
# when intalling scikit-bio
Expand Down
4 changes: 2 additions & 2 deletions qiita_core/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ def wait_for_processing_job(job_id):
"""
job = ProcessingJob(job_id)
while job.status not in ('success', 'error'):
sleep(0.5)
sleep(0.5)
sleep(1.2)
sleep(1.2)
3 changes: 1 addition & 2 deletions qiita_db/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,7 @@ def build_files(self, merge_duplicated_sample_ids):
# different stages and possible errors.
samples = self.samples
# gettin the info of all the artifacts to save SQL time
bioms_info = qdb.util.get_artifacts_bioms_information(
samples.keys())
bioms_info = qdb.util.get_artifacts_information(samples.keys())

# figuring out if we are going to have duplicated samples, again
# doing it here cause it's computational cheaper
Expand Down
4 changes: 2 additions & 2 deletions qiita_db/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,10 @@ def test_generate_study_list(self):
obs_info = qdb.util.generate_study_list([1, 2, 3, 4], False)
self.assertEqual(obs_info, exp_info)

def test_get_artifacts_bioms_information(self):
def test_get_artifacts_information(self):
# we are gonna test that it ignores 1 and 2 cause they are not biom,
# 4 has all information and 7 and 8 don't
obs = qdb.util.get_artifacts_bioms_information([1, 2, 4, 7, 8])
obs = qdb.util.get_artifacts_information([1, 2, 4, 7, 8])
# not testing timestamp
for i in range(len(obs)):
del obs[i]['timestamp']
Expand Down
15 changes: 10 additions & 5 deletions qiita_db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,18 +1324,20 @@ def generate_study_list(study_ids, public_only=False):
return infolist


def get_artifacts_bioms_information(artifact_ids):
"""Returns processing information about the bioms in the artifact
def get_artifacts_information(artifact_ids, only_biom=True):
"""Returns processing information about the artifact ids

Parameters
----------
artifact_ids : list of ints
The artifact ids to look for. Non-existing ids will be ignored
only_biom : bool
If true only the biom artifacts are retrieved

Returns
-------
dict
The info of the bioms if artifact_type is BIOM or None if not.
The info of the artifacts
"""
if not artifact_ids:
return {}
Expand All @@ -1348,10 +1350,13 @@ def get_artifacts_bioms_information(artifact_ids):
array_agg(parent_info.command_parameters),
array_agg(filepaths.filepath),
qiita.find_artifact_roots(a.artifact_id) AS root_id
FROM qiita.artifact a
FROM qiita.artifact a"""
if only_biom:
sql += """
JOIN qiita.artifact_type at ON (
a.artifact_type_id = at .artifact_type_id
AND artifact_type = 'BIOM')
AND artifact_type = 'BIOM')"""
sql += """
LEFT JOIN qiita.parent_artifact pa ON (
a.artifact_id = pa.artifact_id)
LEFT JOIN qiita.data_type dt USING (data_type_id)
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/handlers/analysis_handlers/sharing_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _get_shared_for_study(self, analysis, callback):
@execute_as_transaction
def _share(self, analysis, user, callback):
user = User(user)
add_message('Analysis <a href="%s/analysis/results/%d">\'%s\'</a> '
add_message('Analysis <a href="%s/analysis/description/%d">\'%s\'</a> '
'has been shared with you.' %
(qiita_config.portal_dir, analysis.id, analysis.name),
[user])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def test_get(self):
self.assertEqual(a.shared_with, [u])

# Make sure shared message added to the system
self.assertEqual('Analysis <a href="/analysis/results/1">\'SomeAnalys'
'is\'</a> has been shared with you.',
u.messages()[0][1])
self.assertEqual(
'Analysis <a href="/analysis/description/1">\'SomeAnalysis\'</a> '
'has been shared with you.', u.messages()[0][1])

def test_get_no_access(self):
args = {'selected': 'demo@microbio.me', 'id': 2}
Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/handlers/api_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .artifact import (artifact_graph_get_req, artifact_types_get_req,
artifact_post_req, artifact_get_req,
artifact_status_put_req, artifact_get_prep_req,
artifact_patch_request, artifact_get_biom_info)
artifact_patch_request, artifact_get_info)
from .ontology import ontology_patch_handler
from .processing import (
list_commands_handler_get_req, process_artifact_handler_get_req,
Expand All @@ -53,7 +53,7 @@
'prep_template_get_req', 'study_delete_req',
'study_prep_get_req', 'sample_template_get_req',
'artifact_graph_get_req', 'artifact_types_get_req',
'artifact_post_req', 'artifact_get_biom_info',
'artifact_post_req', 'artifact_get_info',
'sample_template_meta_cats_get_req',
'sample_template_samples_get_req', 'prep_template_samples_get_req',
'sample_template_category_get_req', 'new_prep_template_get_req',
Expand Down
8 changes: 5 additions & 3 deletions qiita_pet/handlers/api_proxy/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from qiita_db.user import User
from qiita_db.metadata_template.prep_template import PrepTemplate
from qiita_db.util import (
get_mountpoint, get_visibilities, get_artifacts_bioms_information)
get_mountpoint, get_visibilities, get_artifacts_information)
from qiita_db.software import Command, Parameters
from qiita_db.processing_job import ProcessingJob

Expand Down Expand Up @@ -110,7 +110,7 @@ def artifact_get_prep_req(user_id, artifact_ids):


@execute_as_transaction
def artifact_get_biom_info(user_id, artifact_ids):
def artifact_get_info(user_id, artifact_ids, only_biom=True):
"""Returns all artifact info for the given artifact_ids

Parameters
Expand All @@ -119,6 +119,8 @@ def artifact_get_biom_info(user_id, artifact_ids):
user making the request
artifact_ids : list of int
list of artifact ids
only_biom : bool
If true only the biom artifacts are retrieved

Returns
-------
Expand All @@ -130,7 +132,7 @@ def artifact_get_biom_info(user_id, artifact_ids):
"""
artifact_info = {}

artifact_info = get_artifacts_bioms_information(artifact_ids)
artifact_info = get_artifacts_information(artifact_ids, only_biom)

return {'status': 'success', 'msg': '', 'data': artifact_info}

Expand Down
23 changes: 13 additions & 10 deletions qiita_pet/handlers/api_proxy/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,19 @@ def prep_template_ajax_get_req(user_id, prep_id):
alert_msg = (job.log.msg.replace('\n', '</br>')
if job.log is not None else "")
else:
redis_info = loads(r_client.get(job_id))
processing = redis_info['status_msg'] == 'Running'
success = redis_info['status_msg'] == 'Success'
if redis_info['return'] is not None:
alert_type = redis_info['return']['status']
alert_msg = redis_info['return']['message'].replace(
'\n', '</br>')
else:
alert_type = 'info'
alert_msg = ''
alert_type = 'info'
alert_msg = ''
# this is not actually necessary but in case of a system
# failure this will avoid the error
ji = r_client.get(job_id)
if ji:
redis_info = loads(ji)
processing = redis_info['status_msg'] == 'Running'
success = redis_info['status_msg'] == 'Success'
if redis_info['return'] is not None:
alert_type = redis_info['return']['status']
alert_msg = redis_info['return']['message'].replace(
'\n', '</br>')

if processing:
alert_type = 'info'
Expand Down
6 changes: 3 additions & 3 deletions qiita_pet/handlers/api_proxy/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from qiita_pet.handlers.api_proxy.artifact import (
artifact_get_req, artifact_status_put_req, artifact_graph_get_req,
artifact_types_get_req, artifact_post_req, artifact_patch_request,
artifact_get_prep_req, artifact_get_biom_info)
artifact_get_prep_req, artifact_get_info)


class TestArtifactAPIReadOnly(TestCase):
Expand Down Expand Up @@ -219,8 +219,8 @@ def test_artifact_get_prep_req(self):
'message': 'User does not have access to study'}
self.assertEqual(obs, exp)

def test_artifact_get_biom_info(self):
obs = artifact_get_biom_info('test@foo.bar', [5, 6, 7])
def test_artifact_get_info(self):
obs = artifact_get_info('test@foo.bar', [5, 6, 7])
data = [
{'files': ['1_study_1001_closed_reference_otu_table_Silva.biom'],
'target_subfragment': ['V4'], 'algorithm': (
Expand Down
5 changes: 2 additions & 3 deletions qiita_pet/handlers/study_handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
ListOptionsHandler, WorkflowHandler,
WorkflowRunHandler, JobAJAX)
from .artifact import (ArtifactGraphAJAX, NewArtifactHandler,
ArtifactAdminAJAX, ArtifactGetSamples,
ArtifactGetBIOMInfo)
ArtifactAdminAJAX, ArtifactGetSamples, ArtifactGetInfo)
from .sample_template import SampleTemplateAJAX, SampleAJAX

__all__ = ['ListStudiesHandler', 'StudyApprovalList', 'ShareStudyAJAX',
Expand All @@ -36,4 +35,4 @@
'DataTypesMenuAJAX', 'StudyFilesAJAX', 'PrepTemplateSummaryAJAX',
'WorkflowHandler', 'WorkflowRunHandler',
'JobAJAX', 'AutocompleteHandler', 'StudyGetTags', 'StudyTags',
'ArtifactGetSamples', 'ArtifactGetBIOMInfo']
'ArtifactGetSamples', 'ArtifactGetInfo']
7 changes: 4 additions & 3 deletions qiita_pet/handlers/study_handlers/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from qiita_pet.handlers.api_proxy import (
artifact_graph_get_req, artifact_types_get_req, artifact_post_req,
artifact_status_put_req, artifact_get_req, artifact_get_prep_req,
artifact_get_biom_info)
artifact_get_info)
from qiita_core.util import execute_as_transaction
from qiita_core.qiita_settings import qiita_config

Expand Down Expand Up @@ -69,12 +69,13 @@ def get(self):
self.write(response)


class ArtifactGetBIOMInfo(BaseHandler):
class ArtifactGetInfo(BaseHandler):
@authenticated
def get(self):
aids = map(int, self.request.arguments.get('ids[]', []))
only_biom = self.get_argument('only_biom', 'True') == 'True'

response = artifact_get_biom_info(self.current_user.id, aids)
response = artifact_get_info(self.current_user.id, aids, only_biom)

self.write(response)

Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/handlers/study_handlers/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_get(self):
self.assertEqual(loads(response.body), exp)


class ArtifactGetBIOMInfoTest(TestHandlerBase):
class ArtifactGetInfoTest(TestHandlerBase):
def test_get(self):
response = self.get('/artifact/info/', {'ids[]': [6, 7]})
self.assertEqual(response.code, 200)
Expand Down
70 changes: 68 additions & 2 deletions qiita_pet/templates/list_analyses.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,74 @@
{% if analyses %}
$('#no-analyses').hide()
$('#analyses-table').dataTable({
"order": [[ 2, "desc" ]]
"order": [[ 2, "desc" ]],
columnDefs: [
{"render": function ( data, type, row, meta ) {
data = JSON.parse(data);
if (data !== null && data !== undefined && data.length != 0){
return '<div class="container" style="max-width: 5em;">'+
'<div class="row justify-content-md-center">' +
'<div class="col-md-1 text-center details-control">&nbsp;</div>' +
'<div class="col-md-1 text-center">' + data.length + '</div>' +
'</div>' +
'</div>';
} else {
return 'No artifacts';
}
}, targets: [0]}]
});

$('#analyses-table tbody').on('click', 'div.details-control', function () {
var table = $('#analyses-table').DataTable();
var tr = $(this).closest('tr');
var row = table.row( tr );

if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
} else {
// Open this row
// modified from: https://jsfiddle.net/8rejaL88/2/
tr.addClass('shown');
row.child('<p><center><img src="{% raw qiita_config.portal_dir %}/static/img/waiting.gif" style="display:block;margin-left: auto;margin-right: auto"/></center></p>', 'no-padding' ).show();
$.get('/artifact/info/', {ids: JSON.parse(row.data()[0]), only_biom: 'False' })
.done(function ( data ) {
if (data['status']=='success') {
$('td', row.child()).html(format_biom_rows(data.data, row.index())).show();
} else {
bootstrapAlert('ERROR: ' + data['msg'], "danger", 10000);
}
});
}
});

function format_biom_rows(data, row) {
var proc_data_table = '<table class="table" cellpadding="0" cellspacing="0" border="0" style="padding-left:0px;width:95%">';
proc_data_table += '<tr>';
proc_data_table += '<th>Name</th>';
proc_data_table += '<th>Processing method</th>';
proc_data_table += '<th>Parameters</th>';
proc_data_table += '<th>Files</th>';
proc_data_table += '</tr>';
$.each(data, function (idx, info) {
if (typeof info !== 'string' && !(info instanceof String)) {
proc_data_table += '<tr>';
proc_data_table += '<td>' + info.name + ' (' + info.artifact_id + ' - ' + info.timestamp.split('.')[0] + ')</td>';
proc_data_table += '<td>' + info.algorithm + '</td>';
var params = '';
for (var key in info.parameters) {
params += '<i>' + key + '</i>: ' + info.parameters[key] + '<br/>';
}
proc_data_table += '<td><small>' + params + '</small></td>';
proc_data_table += '<td><small>' + info.files.join('<br/>') + '</small></td>';
proc_data_table += '</tr>';
}
});

proc_data_table += '</table>';
return proc_data_table;
}
{% end %}
});
</script>
Expand Down Expand Up @@ -37,7 +103,7 @@ <h3><a href="{% raw qiita_config.portal_dir %}/study/list/">Create an analysis</
{% set _id = analysis.id %}
<tr>
<td>
{{len(analysis.artifacts)}}
{{[ar.id for ar in analysis.artifacts]}}
</td>
<td>
<a href="{% raw qiita_config.portal_dir %}/analysis/description/{{_id}}/">{{analysis.name}}</a>
Expand Down
16 changes: 4 additions & 12 deletions qiita_pet/templates/list_studies.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,11 @@
{"targets": [ 2 ], "visible": false},
// render zero
{"render": function ( data, type, row, meta ) {
var len = 0;
if (data !== null && data !== undefined){
len = data.length;
}
if (len != 0){
if (data !== null && data !== undefined && data.length != 0){
return '<div class="container" style="max-width: 5em;">'+
'<div class="row justify-content-md-center">' +
'<div class="col-md-1 text-center details-control">&nbsp;</div>' +
'<div class="col-md-1 text-center">' + len + '</div>' +
'<div class="col-md-1 text-center">' + data.length + '</div>' +
'</div>' +
'</div>';
} else {
Expand Down Expand Up @@ -203,15 +199,11 @@
{"targets": [ 2 ], "visible": false},
// render zero
{"render": function ( data, type, row, meta ) {
var len = 0;
if (data !== null && data !== undefined){
len = data.length;
}
if (len != 0){
if (data !== null && data !== undefined && data.length != 0){
return '<div class="container" style="max-width: 5em;">'+
'<div class="row justify-content-md-center">' +
'<div class="col-md-1 text-center details-control">&nbsp;</div>' +
'<div class="col-md-1 text-center">' + len + '</div>' +
'<div class="col-md-1 text-center">' + data.length + '</div>' +
'</div>' +
'</div>';
} else {
Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ListCommandsHandler, ListOptionsHandler, PrepTemplateSummaryAJAX,
PrepTemplateAJAX, NewArtifactHandler, SampleAJAX, StudyDeleteAjax,
ArtifactAdminAJAX, NewPrepTemplateAjax, DataTypesMenuAJAX, StudyFilesAJAX,
ArtifactGetSamples, ArtifactGetBIOMInfo, WorkflowHandler,
ArtifactGetSamples, ArtifactGetInfo, WorkflowHandler,
WorkflowRunHandler, JobAJAX, AutocompleteHandler)
from qiita_pet.handlers.artifact_handlers import (
ArtifactSummaryAJAX, ArtifactAJAX, ArtifactSummaryHandler,
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(self):
(r"/analysis/description/(.*)/", AnalysisDescriptionHandler),
(r"/analysis/sharing/", ShareAnalysisAJAX),
(r"/artifact/samples/", ArtifactGetSamples),
(r"/artifact/info/", ArtifactGetBIOMInfo),
(r"/artifact/info/", ArtifactGetInfo),
(r"/moi-ws/", MOIMessageHandler),
(r"/consumer/", MessageHandler),
(r"/admin/error/", LogEntryViewerHandler),
Expand Down