From 4ed4ead5033feb4b00eb0fd693d397833dc27ac8 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 17 Jul 2017 15:01:19 -0600 Subject: [PATCH 01/17] improving analysis listing --- .../handlers/analysis_handlers/__init__.py | 4 +- .../analysis_handlers/sharing_handlers.py | 68 +++++++++++++++++ .../tests/test_sharing_handlers.py | 59 +++++++++++++++ qiita_pet/static/js/qiita.js | 3 +- qiita_pet/static/js/sharing.js | 3 +- qiita_pet/templates/analysis_description.html | 51 +++++++++++-- .../artifact_ajax/artifact_summary.html | 39 ++++++---- .../artifact_ajax/processing_artifact.html | 13 +++- qiita_pet/templates/list_analyses.html | 74 ++++++++++--------- qiita_pet/templates/sitebase.html | 13 +++- .../templates/study_ajax/prep_summary.html | 3 +- .../study_ajax/processing_artifact.html | 3 +- .../study_ajax/processing_study.html | 3 +- qiita_pet/templates/study_base.html | 1 + qiita_pet/webserver.py | 3 +- 15 files changed, 276 insertions(+), 64 deletions(-) create mode 100644 qiita_pet/handlers/analysis_handlers/sharing_handlers.py create mode 100644 qiita_pet/handlers/analysis_handlers/tests/test_sharing_handlers.py diff --git a/qiita_pet/handlers/analysis_handlers/__init__.py b/qiita_pet/handlers/analysis_handlers/__init__.py index 0c130e6b4..868abfa1b 100644 --- a/qiita_pet/handlers/analysis_handlers/__init__.py +++ b/qiita_pet/handlers/analysis_handlers/__init__.py @@ -11,8 +11,10 @@ AnalysisGraphHandler, AnalysisJobsHandler) from .listing_handlers import (ListAnalysesHandler, AnalysisSummaryAJAX, SelectedSamplesHandler) +from .sharing_handlers import ShareAnalysisAJAX __all__ = ['CreateAnalysisHandler', 'AnalysisDescriptionHandler', 'AnalysisGraphHandler', 'AnalysisJobsHandler', 'ListAnalysesHandler', 'AnalysisSummaryAJAX', - 'SelectedSamplesHandler', 'check_analysis_access'] + 'SelectedSamplesHandler', 'check_analysis_access', + 'ShareAnalysisAJAX'] diff --git a/qiita_pet/handlers/analysis_handlers/sharing_handlers.py b/qiita_pet/handlers/analysis_handlers/sharing_handlers.py new file mode 100644 index 000000000..b06335083 --- /dev/null +++ b/qiita_pet/handlers/analysis_handlers/sharing_handlers.py @@ -0,0 +1,68 @@ +# ----------------------------------------------------------------------------- +# 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 json import dumps + +from tornado.web import authenticated, HTTPError +from tornado.gen import coroutine, Task + +from qiita_core.qiita_settings import qiita_config +from qiita_core.util import execute_as_transaction +from qiita_pet.handlers.base_handlers import BaseHandler +from qiita_pet.handlers.util import get_shared_links +from qiita_db.user import User +from qiita_db.analysis import Analysis +from qiita_db.util import add_message + + +class ShareAnalysisAJAX(BaseHandler): + @execute_as_transaction + def _get_shared_for_study(self, analysis, callback): + shared_links = get_shared_links(analysis) + users = [u.email for u in analysis.shared_with] + callback((users, shared_links)) + + @execute_as_transaction + def _share(self, analysis, user, callback): + user = User(user) + add_message('Analysis \'%s\' ' + 'has been shared with you.' % + (qiita_config.portal_dir, analysis.id, analysis.name), + [user]) + callback(analysis.share(user)) + + @execute_as_transaction + def _unshare(self, analysis, user, callback): + user = User(user) + add_message('Analysis \'%s\' has been unshared with you.' % + analysis.name, [user]) + callback(analysis.unshare(user)) + + @authenticated + @coroutine + @execute_as_transaction + def get(self): + analysis_id = int(self.get_argument('id')) + analysis = Analysis(analysis_id) + if self.current_user != analysis.owner and \ + self.current_user not in analysis.shared_with: + raise HTTPError(403, 'User %s does not have permissions to share ' + 'analysis %s' % ( + self.current_user.id, analysis.id)) + + selected = self.get_argument('selected', None) + deselected = self.get_argument('deselected', None) + + if selected is not None: + yield Task(self._share, analysis, selected) + if deselected is not None: + yield Task(self._unshare, analysis, deselected) + + users, links = yield Task(self._get_shared_for_study, analysis) + + self.write(dumps({'users': users, 'links': links})) diff --git a/qiita_pet/handlers/analysis_handlers/tests/test_sharing_handlers.py b/qiita_pet/handlers/analysis_handlers/tests/test_sharing_handlers.py new file mode 100644 index 000000000..551385358 --- /dev/null +++ b/qiita_pet/handlers/analysis_handlers/tests/test_sharing_handlers.py @@ -0,0 +1,59 @@ +# ----------------------------------------------------------------------------- +# 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 main +from json import loads + +from qiita_db.analysis import Analysis +from qiita_db.user import User +from qiita_pet.test.tornado_test_base import TestHandlerBase + + +class TestShareStudyAjax(TestHandlerBase): + + def test_get(self): + a = Analysis(1) + u = User('shared@foo.bar') + self.assertEqual(a.shared_with, [u]) + + # deselecting + args = {'deselected': u.id, 'id': a.id} + response = self.get('/analysis/sharing/', args) + self.assertEqual(response.code, 200) + exp = {'users': [], 'links': ''} + self.assertEqual(loads(response.body), exp) + self.assertEqual(a.shared_with, []) + + # Make sure unshared message added to the system + self.assertEqual("Analysis 'SomeAnalysis' has been unshared with you.", + u.messages()[0][1]) + + # selecting + args = {'selected': u.id, 'id': a.id} + response = self.get('/analysis/sharing/', args) + self.assertEqual(response.code, 200) + exp = { + 'users': ['shared@foo.bar'], + 'links': + ('Shared')} + self.assertEqual(loads(response.body), exp) + self.assertEqual(a.shared_with, [u]) + + # Make sure shared message added to the system + self.assertEqual('Analysis \'SomeAnalys' + 'is\' has been shared with you.', + u.messages()[0][1]) + + def test_get_no_access(self): + args = {'selected': 'demo@microbio.me', 'id': 2} + response = self.get('/analysis/sharing/', args) + self.assertEqual(response.code, 403) + + +if __name__ == '__main__': + main() diff --git a/qiita_pet/static/js/qiita.js b/qiita_pet/static/js/qiita.js index 77ff78d11..24b900562 100644 --- a/qiita_pet/static/js/qiita.js +++ b/qiita_pet/static/js/qiita.js @@ -147,6 +147,7 @@ function draw_processing_graph(nodes, edges, target, artifactFunc, jobFunc) { edges: edges }; var options = { + clickToUse: true, nodes: { shape: 'dot', font: { @@ -172,7 +173,7 @@ function draw_processing_graph(nodes, edges, target, artifactFunc, jobFunc) { zoomView: true, selectConnectedEdges: true, navigationButtons: true, - keyboard: true + keyboard: false }, groups: { jobs: { diff --git a/qiita_pet/static/js/sharing.js b/qiita_pet/static/js/sharing.js index 455768375..cdd6347d4 100644 --- a/qiita_pet/static/js/sharing.js +++ b/qiita_pet/static/js/sharing.js @@ -26,7 +26,6 @@ function init_sharing(portal) { function modify_sharing(id) { var shared_list; - $('#shares-select').attr('data-current-id', id); $.get($('#shares-select').attr('data-share-url'), {id: id}) .done(function(data) { var users_links = JSON.parse(data); @@ -51,4 +50,4 @@ function update_share(params) { links = users_links.links; $("#shared_html_"+share_id).html(links); }); -} \ No newline at end of file +} diff --git a/qiita_pet/templates/analysis_description.html b/qiita_pet/templates/analysis_description.html index 0c991eec5..5a81b5d5f 100644 --- a/qiita_pet/templates/analysis_description.html +++ b/qiita_pet/templates/analysis_description.html @@ -1,7 +1,10 @@ {% extends sitebase.html %} {% block head %} - + + @@ -233,8 +240,12 @@
-

{{analysis_name}} - ID {{analysis_id}}

+

+ {{analysis_name}} - ID {{analysis_id}} + +

{{analysis_description}}

+ Shared with:
@@ -245,7 +256,11 @@

- +
+
+
+ +

+ + + + {% end %} diff --git a/qiita_pet/templates/artifact_ajax/artifact_summary.html b/qiita_pet/templates/artifact_ajax/artifact_summary.html index 32ee96484..de1ac57b4 100644 --- a/qiita_pet/templates/artifact_ajax/artifact_summary.html +++ b/qiita_pet/templates/artifact_ajax/artifact_summary.html @@ -127,31 +127,44 @@

{% if processing_jobs %} - Jobs using this set of files:
- {% end %} - {% for j_id, c_name, j_status, j_step, j_error in processing_jobs %} - Job {{j_id}} ({{c_name}}). Status: {{j_status}}. - {% if j_step %} - Step: {{j_step}} - {% end %} - {% if j_error %} - Error message: {{j_error}} - {% end %} -
+
+ +
+ {% for j_id, c_name, j_status, j_step, j_error in processing_jobs %} + Job {{j_id}} ({{c_name}}). Status: {{j_status}}. + {% if j_step %} + Step: {{j_step}} + {% end %} + {% if j_error %} + Error message: {{j_error}} + {% end %} +
+ {% end %} +
+
{% end %}
{% if summary is not None %} +
+
Open summary in a new window +
{% elif job is not None %} Job {{ job[0] }}: {{ job[1] }} {{ job[2] }} {% else %} Currently, no summary exists.

- {% for j_id, j_error in errored_jobs %} - Job {{ j_id }}: {% raw j_error.replace('\n', '
') %}

+ {% if errored_jobs %} +
+ +
+ {% for j_id, j_error in errored_jobs %} + Job {{ j_id }}: {% raw j_error.replace('\n', '
') %}

+ {% end %} +
{% end %} {% end %}
diff --git a/qiita_pet/templates/artifact_ajax/processing_artifact.html b/qiita_pet/templates/artifact_ajax/processing_artifact.html index e970b0a70..26aa6359c 100644 --- a/qiita_pet/templates/artifact_ajax/processing_artifact.html +++ b/qiita_pet/templates/artifact_ajax/processing_artifact.html @@ -338,7 +338,7 @@ } $("
").appendTo("#cmd-opts-div").attr('id', 'opt-vals-div').attr('name', 'opt-vals-div'); - sel.change(function(event){ + sel.change(function(){ var v = $("#params-sel").val(); $("#opt-vals-div").empty(); if (v !== "") { @@ -356,6 +356,14 @@ $("#add-cmd-btn-div").hide(); } }); + + sel.show(function(){ + // select first option if only 2 options ("Choose parameter set", "unique value") + if ($("#params-sel option").length == 2) { + $("#params-sel")[0].selectedIndex = 1; + $("#params-sel").trigger("change"); + } + }); }); } @@ -422,6 +430,7 @@ var data = {nodes: nodes, edges: edges}; var options = { + clickToUse: true, nodes: { shape: 'dot', font: { @@ -447,7 +456,7 @@ zoomView: true, selectConnectedEdges: false, navigationButtons: true, - keyboard: true + keyboard: false }, groups: { jobs: { diff --git a/qiita_pet/templates/list_analyses.html b/qiita_pet/templates/list_analyses.html index af408ee59..7c215961a 100644 --- a/qiita_pet/templates/list_analyses.html +++ b/qiita_pet/templates/list_analyses.html @@ -2,9 +2,15 @@ {% block head %} @@ -18,43 +24,43 @@

Create an analysis {% if analyses %} - - - - - - - - - - - {% for analysis in analyses %} - {% set _id = analysis.id %} +
Analysis NameAnalysis DescriptionTimestampMapping FileBiom Filestgz FilesDelete?
+ - - - - - - - + + + + + - {% end %} + + {% for analysis in analyses %} + {% set _id = analysis.id %} + + + + + + + + {% end %} + +
- {{analysis.name}} - - {{analysis.description}} - - {{ analysis.timestamp.strftime("%m/%d/%y %H:%M:%S")}} - - {% raw mappings[_id] %} - - {% raw bioms[_id] %} - - {% raw tgzs[_id] %} - - - ArtifactsAnalysis NameTimestampMapping FileDelete?
+ {{len(analysis.artifacts)}} + + {{analysis.name}} + {% if analysis.description %} + ({{analysis.description}}) + {% end %} + + {{ analysis.timestamp.strftime("%m/%d/%y %H:%M:%S")}} + + {% raw mappings[_id] %} + + +
+ {% end %} {% end %} diff --git a/qiita_pet/templates/sitebase.html b/qiita_pet/templates/sitebase.html index 31409d7f8..246637e47 100644 --- a/qiita_pet/templates/sitebase.html +++ b/qiita_pet/templates/sitebase.html @@ -54,6 +54,14 @@ diff --git a/qiita_pet/templates/sitebase.html b/qiita_pet/templates/sitebase.html index 246637e47..12a3ccb57 100644 --- a/qiita_pet/templates/sitebase.html +++ b/qiita_pet/templates/sitebase.html @@ -55,11 +55,11 @@ @@ -37,7 +105,7 @@

Create an analysis - {{len(analysis.artifacts)}} + {{[ar.id for ar in analysis.artifacts]}} {{analysis.name}} From 0488cc51ed5dc8976a0d67d1fa699265313e55b7 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 18 Jul 2017 12:19:39 -0600 Subject: [PATCH 04/17] changing names --- .travis.yml | 3 ++- qiita_db/analysis.py | 3 +-- qiita_db/test/test_util.py | 4 ++-- qiita_db/util.py | 15 ++++++++++----- qiita_pet/handlers/api_proxy/__init__.py | 4 ++-- qiita_pet/handlers/api_proxy/artifact.py | 8 +++++--- .../handlers/api_proxy/tests/test_artifact.py | 6 +++--- qiita_pet/handlers/study_handlers/__init__.py | 5 ++--- qiita_pet/handlers/study_handlers/artifact.py | 6 +++--- .../study_handlers/tests/test_artifact.py | 2 +- qiita_pet/webserver.py | 4 ++-- 11 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09bb31864..960c63889 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/qiita_db/analysis.py b/qiita_db/analysis.py index 53d836b4f..aa66f9f39 100644 --- a/qiita_db/analysis.py +++ b/qiita_db/analysis.py @@ -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 diff --git a/qiita_db/test/test_util.py b/qiita_db/test/test_util.py index 5af9576a4..eb8da3d52 100644 --- a/qiita_db/test/test_util.py +++ b/qiita_db/test/test_util.py @@ -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'] diff --git a/qiita_db/util.py b/qiita_db/util.py index edb8c25c9..23b820200 100644 --- a/qiita_db/util.py +++ b/qiita_db/util.py @@ -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 {} @@ -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) diff --git a/qiita_pet/handlers/api_proxy/__init__.py b/qiita_pet/handlers/api_proxy/__init__.py index 294661c7a..e28118cce 100644 --- a/qiita_pet/handlers/api_proxy/__init__.py +++ b/qiita_pet/handlers/api_proxy/__init__.py @@ -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, @@ -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', diff --git a/qiita_pet/handlers/api_proxy/artifact.py b/qiita_pet/handlers/api_proxy/artifact.py index 6fe8c62ed..e18ddbd4f 100644 --- a/qiita_pet/handlers/api_proxy/artifact.py +++ b/qiita_pet/handlers/api_proxy/artifact.py @@ -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 @@ -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 @@ -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 ------- @@ -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} diff --git a/qiita_pet/handlers/api_proxy/tests/test_artifact.py b/qiita_pet/handlers/api_proxy/tests/test_artifact.py index 15e774bf5..23ff33302 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_artifact.py +++ b/qiita_pet/handlers/api_proxy/tests/test_artifact.py @@ -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): @@ -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': ( diff --git a/qiita_pet/handlers/study_handlers/__init__.py b/qiita_pet/handlers/study_handlers/__init__.py index 0832aebb2..464f31271 100644 --- a/qiita_pet/handlers/study_handlers/__init__.py +++ b/qiita_pet/handlers/study_handlers/__init__.py @@ -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', @@ -36,4 +35,4 @@ 'DataTypesMenuAJAX', 'StudyFilesAJAX', 'PrepTemplateSummaryAJAX', 'WorkflowHandler', 'WorkflowRunHandler', 'JobAJAX', 'AutocompleteHandler', 'StudyGetTags', 'StudyTags', - 'ArtifactGetSamples', 'ArtifactGetBIOMInfo'] + 'ArtifactGetSamples', 'ArtifactGetInfo'] diff --git a/qiita_pet/handlers/study_handlers/artifact.py b/qiita_pet/handlers/study_handlers/artifact.py index 4539c3a17..f8ee328f2 100644 --- a/qiita_pet/handlers/study_handlers/artifact.py +++ b/qiita_pet/handlers/study_handlers/artifact.py @@ -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 @@ -69,12 +69,12 @@ def get(self): self.write(response) -class ArtifactGetBIOMInfo(BaseHandler): +class ArtifactGetInfo(BaseHandler): @authenticated def get(self): aids = map(int, self.request.arguments.get('ids[]', [])) - response = artifact_get_biom_info(self.current_user.id, aids) + response = artifact_get_info(self.current_user.id, aids) self.write(response) diff --git a/qiita_pet/handlers/study_handlers/tests/test_artifact.py b/qiita_pet/handlers/study_handlers/tests/test_artifact.py index 8cc26db63..7cc8339fd 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_artifact.py +++ b/qiita_pet/handlers/study_handlers/tests/test_artifact.py @@ -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) diff --git a/qiita_pet/webserver.py b/qiita_pet/webserver.py index 8baf92bea..60c91fa1d 100644 --- a/qiita_pet/webserver.py +++ b/qiita_pet/webserver.py @@ -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, @@ -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), From f60c0ef6309518fa094ad4e832e7a7fbda2e5848 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 18 Jul 2017 14:48:09 -0600 Subject: [PATCH 05/17] fixing . -> , --- qiita_pet/handlers/api_proxy/artifact.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_pet/handlers/api_proxy/artifact.py b/qiita_pet/handlers/api_proxy/artifact.py index e18ddbd4f..34226da6e 100644 --- a/qiita_pet/handlers/api_proxy/artifact.py +++ b/qiita_pet/handlers/api_proxy/artifact.py @@ -132,7 +132,7 @@ def artifact_get_info(user_id, artifact_ids, only_biom=True): """ artifact_info = {} - artifact_info = get_artifacts_information(artifact_ids. only_biom) + artifact_info = get_artifacts_information(artifact_ids, only_biom) return {'status': 'success', 'msg': '', 'data': artifact_info} From 0044678580e24c63ef14f079c41ac033462cc663 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 18 Jul 2017 15:24:09 -0600 Subject: [PATCH 06/17] only_biom --- qiita_pet/handlers/study_handlers/artifact.py | 1 + qiita_pet/templates/list_analyses.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/qiita_pet/handlers/study_handlers/artifact.py b/qiita_pet/handlers/study_handlers/artifact.py index f8ee328f2..c3da34a82 100644 --- a/qiita_pet/handlers/study_handlers/artifact.py +++ b/qiita_pet/handlers/study_handlers/artifact.py @@ -73,6 +73,7 @@ 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_info(self.current_user.id, aids) diff --git a/qiita_pet/templates/list_analyses.html b/qiita_pet/templates/list_analyses.html index e84306b6b..5cd865a34 100644 --- a/qiita_pet/templates/list_analyses.html +++ b/qiita_pet/templates/list_analyses.html @@ -43,7 +43,7 @@ // modified from: https://jsfiddle.net/8rejaL88/2/ tr.addClass('shown'); row.child('

', 'no-padding' ).show(); - $.get('/artifact/info/', {ids: JSON.parse(row.data()[0]) }) + $.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(); From 81d9d37d85c08976e0abf0a9beb1b093012f2c7c Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 18 Jul 2017 15:27:24 -0600 Subject: [PATCH 07/17] actually using only_biom --- qiita_pet/handlers/study_handlers/artifact.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_pet/handlers/study_handlers/artifact.py b/qiita_pet/handlers/study_handlers/artifact.py index c3da34a82..51d18d32e 100644 --- a/qiita_pet/handlers/study_handlers/artifact.py +++ b/qiita_pet/handlers/study_handlers/artifact.py @@ -75,7 +75,7 @@ def get(self): aids = map(int, self.request.arguments.get('ids[]', [])) only_biom = self.get_argument('only_biom', 'True') == 'True' - response = artifact_get_info(self.current_user.id, aids) + response = artifact_get_info(self.current_user.id, aids, only_biom) self.write(response) From e3cf4cf23ac24e9c9fbd8a4cc80c8b3fae94a8a2 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 06:09:23 -0600 Subject: [PATCH 08/17] sleep --- qiita_pet/handlers/api_proxy/tests/test_prep_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiita_pet/handlers/api_proxy/tests/test_prep_template.py b/qiita_pet/handlers/api_proxy/tests/test_prep_template.py index c8a8d172d..cf80fda9e 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_prep_template.py +++ b/qiita_pet/handlers/api_proxy/tests/test_prep_template.py @@ -282,6 +282,7 @@ def tearDown(self): f.write('') r_client.flushdb() + sleep(0.5) def _wait_for_parallel_job(self, key): # This is needed so the clean up works - this is a distributed system From 95e6d9153e621f5458fa1a37180da5fd12908f9c Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 07:03:28 -0600 Subject: [PATCH 09/17] moving sleep --- qiita_pet/handlers/api_proxy/tests/test_prep_template.py | 1 - qiita_pet/handlers/study_handlers/tests/test_prep_template.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_pet/handlers/api_proxy/tests/test_prep_template.py b/qiita_pet/handlers/api_proxy/tests/test_prep_template.py index cf80fda9e..c8a8d172d 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_prep_template.py +++ b/qiita_pet/handlers/api_proxy/tests/test_prep_template.py @@ -282,7 +282,6 @@ def tearDown(self): f.write('') r_client.flushdb() - sleep(0.5) def _wait_for_parallel_job(self, key): # This is needed so the clean up works - this is a distributed system diff --git a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py index 31cb99ca2..627497895 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py +++ b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py @@ -59,6 +59,7 @@ def test_get(self): class TestPrepTemplateAJAXReadOnly(TestHandlerBase): def test_get(self): + sleep(1) response = self.get('/study/description/prep_template/', {'prep_id': 1, 'study_id': 1}) self.assertEqual(response.code, 200) From b38b3eac54babdbd88af6d96d46bdb20fd7d2370 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 08:11:52 -0600 Subject: [PATCH 10/17] import sleep --- qiita_pet/handlers/study_handlers/tests/test_prep_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py index 627497895..3cfecd963 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py +++ b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py @@ -7,6 +7,7 @@ # ----------------------------------------------------------------------------- from unittest import main from json import loads +from time import sleep from qiita_pet.test.tornado_test_base import TestHandlerBase From a63a031e519d24c1ba4b177b2195bbd1de91926d Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 11:34:27 -0600 Subject: [PATCH 11/17] sleep(0.8) --- qiita_core/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiita_core/testing.py b/qiita_core/testing.py index bde147825..ffe123cf0 100644 --- a/qiita_core/testing.py +++ b/qiita_core/testing.py @@ -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(0.8) + sleep(0.8) From 75836bcba2eabd49b2c231ae3c59556f8e7b58f9 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 12:35:05 -0600 Subject: [PATCH 12/17] sleep(1) --- qiita_core/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiita_core/testing.py b/qiita_core/testing.py index ffe123cf0..327dc74c2 100644 --- a/qiita_core/testing.py +++ b/qiita_core/testing.py @@ -58,5 +58,5 @@ def wait_for_processing_job(job_id): """ job = ProcessingJob(job_id) while job.status not in ('success', 'error'): - sleep(0.8) - sleep(0.8) + sleep(1) + sleep(1) From e2915deefe2711748f460dd94ab6cf2e14f5a558 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 14:52:50 -0600 Subject: [PATCH 13/17] addressing @ElDeveloper comments --- qiita_core/testing.py | 4 ++-- .../study_handlers/tests/test_prep_template.py | 1 - qiita_pet/templates/list_analyses.html | 5 +---- qiita_pet/templates/list_studies.html | 10 ++-------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/qiita_core/testing.py b/qiita_core/testing.py index 327dc74c2..22bc9201c 100644 --- a/qiita_core/testing.py +++ b/qiita_core/testing.py @@ -58,5 +58,5 @@ def wait_for_processing_job(job_id): """ job = ProcessingJob(job_id) while job.status not in ('success', 'error'): - sleep(1) - sleep(1) + sleep(1.2) + sleep(1.2) diff --git a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py index 3cfecd963..2fa783d18 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py +++ b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py @@ -60,7 +60,6 @@ def test_get(self): class TestPrepTemplateAJAXReadOnly(TestHandlerBase): def test_get(self): - sleep(1) response = self.get('/study/description/prep_template/', {'prep_id': 1, 'study_id': 1}) self.assertEqual(response.code, 200) diff --git a/qiita_pet/templates/list_analyses.html b/qiita_pet/templates/list_analyses.html index 5cd865a34..2a9a165c4 100644 --- a/qiita_pet/templates/list_analyses.html +++ b/qiita_pet/templates/list_analyses.html @@ -13,10 +13,7 @@ {"render": function ( data, type, row, meta ) { data = JSON.parse(data); var len = 0; - if (data !== null && data !== undefined){ - len = data.length; - } - if (len != 0){ + if (data !== null && data !== undefined && data.length != 0){ return '
'+ '
' + '
 
' + diff --git a/qiita_pet/templates/list_studies.html b/qiita_pet/templates/list_studies.html index 2b4a3d89b..8d5b841dd 100644 --- a/qiita_pet/templates/list_studies.html +++ b/qiita_pet/templates/list_studies.html @@ -131,10 +131,7 @@ // 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 '
'+ '
' + '
 
' + @@ -204,10 +201,7 @@ // 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 '
'+ '
' + '
 
' + From 957b9b20cafbe799302dd0491cb902f44abb8d2c Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 16:01:48 -0600 Subject: [PATCH 14/17] flake8 --- qiita_pet/handlers/study_handlers/tests/test_prep_template.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py index 2fa783d18..31cb99ca2 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py +++ b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py @@ -7,7 +7,6 @@ # ----------------------------------------------------------------------------- from unittest import main from json import loads -from time import sleep from qiita_pet.test.tornado_test_base import TestHandlerBase From b13ac986a48b4bd72e90c24632ac9735568ead04 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 17:14:59 -0600 Subject: [PATCH 15/17] is_qiita_job --- qiita_pet/handlers/api_proxy/prep_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_pet/handlers/api_proxy/prep_template.py b/qiita_pet/handlers/api_proxy/prep_template.py index fb0cf5bf9..11f01bd0d 100644 --- a/qiita_pet/handlers/api_proxy/prep_template.py +++ b/qiita_pet/handlers/api_proxy/prep_template.py @@ -114,7 +114,7 @@ def prep_template_ajax_get_req(user_id, prep_id): job_info = loads(job_info) job_id = job_info['job_id'] if job_id: - if job_info['is_qiita_job']: + if 'is_qiita_job' in job_info and job_info['is_qiita_job']: job = ProcessingJob(job_id) processing = job.status in ('queued', 'running') success = job.status == 'success' From afe13b6aa668fea5292238ff833a451a40d99694 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 19 Jul 2017 17:37:42 -0600 Subject: [PATCH 16/17] job_info -> ji --- qiita_pet/handlers/api_proxy/prep_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qiita_pet/handlers/api_proxy/prep_template.py b/qiita_pet/handlers/api_proxy/prep_template.py index 11f01bd0d..f71a525f7 100644 --- a/qiita_pet/handlers/api_proxy/prep_template.py +++ b/qiita_pet/handlers/api_proxy/prep_template.py @@ -114,7 +114,7 @@ def prep_template_ajax_get_req(user_id, prep_id): job_info = loads(job_info) job_id = job_info['job_id'] if job_id: - if 'is_qiita_job' in job_info and job_info['is_qiita_job']: + if job_info['is_qiita_job']: job = ProcessingJob(job_id) processing = job.status in ('queued', 'running') success = job.status == 'success' @@ -126,9 +126,9 @@ def prep_template_ajax_get_req(user_id, prep_id): alert_msg = '' # this is not actually necessary but in case of a system # failure this will avoid the error - job_info = r_client.get(job_id) - if job_info: - redis_info = loads(job_info) + 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: From aac47c83ff67ca1b766642b7a3fe43620352255f Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 20 Jul 2017 10:46:12 -0600 Subject: [PATCH 17/17] addressing @ElDeveloper comments --- qiita_pet/templates/list_analyses.html | 3 +-- qiita_pet/templates/list_studies.html | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/qiita_pet/templates/list_analyses.html b/qiita_pet/templates/list_analyses.html index 2a9a165c4..9498d825e 100644 --- a/qiita_pet/templates/list_analyses.html +++ b/qiita_pet/templates/list_analyses.html @@ -12,12 +12,11 @@ columnDefs: [ {"render": function ( data, type, row, meta ) { data = JSON.parse(data); - var len = 0; if (data !== null && data !== undefined && data.length != 0){ return '
'+ '
' + '
 
' + - '
' + len + '
' + + '
' + data.length + '
' + '
' + '
'; } else { diff --git a/qiita_pet/templates/list_studies.html b/qiita_pet/templates/list_studies.html index 8d5b841dd..6b13975a5 100644 --- a/qiita_pet/templates/list_studies.html +++ b/qiita_pet/templates/list_studies.html @@ -130,12 +130,11 @@ {"targets": [ 2 ], "visible": false}, // render zero {"render": function ( data, type, row, meta ) { - var len = 0; if (data !== null && data !== undefined && data.length != 0){ return '
'+ '
' + '
 
' + - '
' + len + '
' + + '
' + data.length + '
' + '
' + '
'; } else { @@ -200,12 +199,11 @@ {"targets": [ 2 ], "visible": false}, // render zero {"render": function ( data, type, row, meta ) { - var len = 0; if (data !== null && data !== undefined && data.length != 0){ return '
'+ '
' + '
 
' + - '
' + len + '
' + + '
' + data.length + '
' + '
' + '
'; } else {