Skip to content

Analysis refactor GUI part2 #2077

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 all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
3601c29
fix #1505
antgonza Jan 2, 2017
0d6788e
improving some GUI stuff
antgonza Jan 3, 2017
12406cc
improving some GUI stuff - missing lines
antgonza Jan 3, 2017
958fcbe
pull upstream master
antgonza Jan 4, 2017
a57ef23
addressing all comments
antgonza Jan 5, 2017
2ead7a6
ready for review
antgonza Jan 5, 2017
73a78e7
fix #1987
antgonza Jan 16, 2017
e64a22a
Merge pull request #2036 from antgonza/fix-1505
josenavas Jan 16, 2017
0dcae8b
Merge pull request #2047 from antgonza/fix-1987
josenavas Jan 17, 2017
4a5bbbc
initial commit
antgonza Jan 18, 2017
f99975c
requested changes
antgonza Jan 18, 2017
ed899a8
Merge pull request #2049 from antgonza/add-processing-suggestions
josenavas Jan 18, 2017
d508320
fix filter job list
antgonza Jan 18, 2017
025cc1e
Merge pull request #2050 from antgonza/fix-filter-job-list
josenavas Jan 18, 2017
599bcde
Fixing server cert (#2051)
josenavas Jan 19, 2017
d12ccfe
fix get_studies
antgonza Jan 20, 2017
b33983b
flake8
antgonza Jan 20, 2017
b4f1b1f
fix #503
antgonza Jan 20, 2017
62a1b93
fix #2010
antgonza Jan 20, 2017
2e36141
fix #1913
antgonza Jan 21, 2017
e006e20
fix errors
antgonza Jan 21, 2017
c174693
Merge pull request #2052 from antgonza/fix-get_studies
josenavas Jan 23, 2017
131dd6a
Merge pull request #2053 from antgonza/fix-by-blinking
josenavas Jan 23, 2017
ccb55bd
addressing @josenavas comment
antgonza Jan 24, 2017
dfe2e83
flake8
antgonza Jan 24, 2017
15fcceb
Merge pull request #2056 from antgonza/fix-1913
josenavas Jan 24, 2017
7f97f2a
fix #1010
antgonza Jan 26, 2017
9eb9dbb
fix #1066 (#2058)
antgonza Jan 26, 2017
23104d7
addressing @josenavas comments
antgonza Jan 27, 2017
1f1e826
fix #1961
antgonza Jan 27, 2017
19a9dda
fix #1837
antgonza Jan 27, 2017
19889f9
Automatic jobs & new stats (#2057)
antgonza Jan 27, 2017
4e380e0
Merge pull request #2060 from antgonza/fix-1961
wasade Jan 28, 2017
6f0dd71
generalizing this functionality
antgonza Jan 28, 2017
ed9fc65
fix #1816
antgonza Jan 29, 2017
4b19b45
fix #1959
antgonza Jan 30, 2017
d9b41e8
addressing @josenavas comments
antgonza Feb 1, 2017
5ef06ae
addressing @josenavas comments
antgonza Feb 2, 2017
5e3504a
fixing error
antgonza Feb 2, 2017
d10096a
Merge branch 'master' of https://github.com/biocore/qiita into fix-1010
antgonza Feb 2, 2017
661342f
fixed?
antgonza Feb 2, 2017
fcd249b
addressing @josenavas comments
antgonza Feb 3, 2017
f3c1216
Merge pull request #2063 from antgonza/fix-1816
josenavas Feb 3, 2017
a91a6fd
Merge pull request #2064 from antgonza/fix-1959
tanaes Feb 3, 2017
7b9fa6f
addressing @wasade comments
antgonza Feb 3, 2017
33bcbe5
Merge pull request #2059 from antgonza/fix-1010
josenavas Feb 3, 2017
5e4bd9b
Merge branch 'master' of https://github.com/biocore/qiita into fix-1837
antgonza Feb 3, 2017
8bf3d6e
fix flake8
antgonza Feb 3, 2017
7807bac
Merge pull request #2061 from antgonza/fix-1837
josenavas Feb 3, 2017
6360675
generate biom and metadata release (#2066)
antgonza Feb 3, 2017
811b7a7
database changes to fix 969
antgonza Feb 3, 2017
751d4ad
adding delete
antgonza Feb 3, 2017
65a86df
addressing @josenavas comments
antgonza Feb 3, 2017
b1817dd
addressing @ElDeveloper comments
antgonza Feb 4, 2017
18d77e1
duh!
antgonza Feb 4, 2017
01c656c
Merge pull request #2071 from antgonza/fix-969-db
josenavas Feb 6, 2017
53188a6
fix generate_biom_and_metadata_release (#2072)
antgonza Feb 7, 2017
1ab4e3b
Fixing merge conflicts with master
josenavas Feb 8, 2017
1e8332e
Merge branch 'analysis-refactor' of https://github.com/biocore/qiita …
josenavas Feb 9, 2017
cb67d3d
Removing qiita ware code that will not be used anymore
josenavas Feb 9, 2017
5a5127d
Merge branch 'analysis-refactor' of https://github.com/biocore/qiita …
josenavas Feb 9, 2017
0033480
Organizing the handlers and new analysis description page
josenavas Feb 9, 2017
3809ad5
Connecting the analysis creation and making interface responsive
josenavas Feb 9, 2017
067f14f
Addressing @antgonza's comments
josenavas Feb 10, 2017
cf4862d
Solving merge conflicts
josenavas Feb 10, 2017
a6595a9
Removing unused code
josenavas Feb 10, 2017
378d7ff
Fixing merge conflicts
josenavas Feb 15, 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
8 changes: 4 additions & 4 deletions qiita_pet/handlers/analysis_handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from .util import check_analysis_access
from .base_handlers import (CreateAnalysisHandler, AnalysisDescriptionHandler,
AnalysisGraphHandler)
AnalysisGraphHandler, AnalysisJobsHandler)
from .listing_handlers import (ListAnalysesHandler, AnalysisSummaryAJAX,
SelectedSamplesHandler)

__all__ = ['CreateAnalysisHandler', 'AnalysisDescriptionHandler',
'AnalysisGraphHandler', 'ListAnalysesHandler',
'AnalysisSummaryAJAX', 'SelectedSamplesHandler',
'check_analysis_access']
'AnalysisGraphHandler', 'AnalysisJobsHandler',
'ListAnalysesHandler', 'AnalysisSummaryAJAX',
'SelectedSamplesHandler', 'check_analysis_access']
37 changes: 35 additions & 2 deletions qiita_pet/handlers/analysis_handlers/base_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,41 @@ def analyisis_graph_handler_get_request(analysis_id, user):
class AnalysisGraphHandler(BaseHandler):
@authenticated
@execute_as_transaction
def get(self):
analysis_id = to_int(self.get_argument('analysis_id'))
def get(self, analysis_id):
analysis_id = to_int(analysis_id)
response = analyisis_graph_handler_get_request(
analysis_id, self.current_user)
self.write(response)


def analyisis_job_handler_get_request(analysis_id, user):
"""Returns the job information of the analysis

Parameters
----------
analysis_id: int
The analysis id
user : qiita_db.user.User
The user performing the request

Returns
-------
dict with the jobs information
"""
analysis = Analysis(analysis_id)
# Check if the user actually has access to the analysis
check_analysis_access(user, analysis)
return {
j.id: {'status': j.status, 'step': j.step,
'error': j.log.msg if j.log else ""}
for j in analysis.jobs}


class AnalysisJobsHandler(BaseHandler):
@authenticated
@execute_as_transaction
def get(self, analysis_id):
analysis_id = to_int(analysis_id)
response = analyisis_job_handler_get_request(
analysis_id, self.current_user)
self.write(response)
24 changes: 23 additions & 1 deletion qiita_pet/handlers/analysis_handlers/tests/test_base_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def test_analyisis_graph_handler_get_request(self):

class TestBaseHandlers(TestHandlerBase):
def test_post_create_analysis_handler(self):
user = User('test@foo.bar')
dflt_analysis = user.default_analysis
dflt_analysis.add_samples(
{4: ['1.SKB8.640193', '1.SKD8.640184', '1.SKB7.640196',
'1.SKM9.640192', '1.SKM4.640180']})
args = {'name': 'New Test Analysis',
'description': 'Test Analysis Description'}
response = self.post('/analysis/create/', args)
Expand All @@ -64,7 +69,7 @@ def test_get_analysis_description_handler(self):
self.assertEqual(response.code, 200)

def test_get_analysis_graph_handler(self):
response = self.get('/analysis/description/graph/', {'analysis_id': 1})
response = self.get('/analysis/description/1/graph/')
self.assertEqual(response.code, 200)
# The job id is randomly generated in the test environment. Gather
# it here. There is only 1 job in the first artifact of the analysis
Expand All @@ -78,6 +83,23 @@ def test_get_analysis_graph_handler(self):
self.assertItemsEqual(obs['edges'], exp['edges'])
self.assertItemsEqual(obs['nodes'], exp['nodes'])

def test_get_analysis_jobs_handler(self):
user = User('test@foo.bar')
dflt_analysis = user.default_analysis
dflt_analysis.add_samples(
{4: ['1.SKB8.640193', '1.SKD8.640184', '1.SKB7.640196',
'1.SKM9.640192', '1.SKM4.640180']})
new = Analysis.create(user, "newAnalysis", "A New Analysis",
from_default=True)
response = self.get('/analysis/description/%s/jobs/' % new.id)
self.assertEqual(response.code, 200)

# There is only one job
job_id = new.jobs[0].id
obs = loads(response.body)
exp = {job_id: {'status': 'queued', 'step': None, 'error': ""}}
self.assertEqual(obs, exp)


if __name__ == '__main__':
main()
118 changes: 89 additions & 29 deletions qiita_pet/templates/analysis_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,94 @@
}
};

/**
* Draws the aritfact + job graph in the `analysis-network-div`
*
*/
function populate_grap_div() {
// Put the loading gif in the div
show_loading('{% raw qiita_config.portal_dir %}', 'analysis-network-div');
// Retrieve the information for the graph
$.get("{% raw qiita_config.portal_dir %}/analysis/description/graph/", { analysis_id: {{analysis_id}}}, function(data) {
var nodes = [];
var edges = [];
// Format edge list data
for(var i = 0; i < data.edges.length; i++) {
edges.push({from: data.edges[i][0], to: data.edges[i][1], arrows:'to'});
}
// Format node list data
for(var i = 0; i < data.nodes.length; i++) {
nodes.push({id: data.nodes[i][1], label: data.nodes[i][2], group: data.nodes[i][0]});
$(document).ready(function(){
// Create the new VUE component that is going to hold the artifact + job graph
Vue.component('analysis-graph', {
template: '<div class="col-md-12 graph" style="width:90%" id="analysis-network-div">',
props: ['nodes', 'edges']
});

new Vue({
el: "#analysis-graph-vue",
data: {
nodes: [],
edges: []
},
methods: {
update_graph: function () {
let vm = this;
$.get("{% raw qiita_config.portal_dir %}/analysis/description/" + {{analysis_id}} + "/graph/", function(data) {
// If there are no nodes in the graph, it means that we are waiting
// for the jobs to generate the initial set of artifacts. Update
// the job list
if (data.nodes.length == 0) {
vm.update_jobs();
}
else {
// The initial set of artifacts has been created! Format the graph
// data in a way that Vis.Network likes it
// Format edge list data
for(var i = 0; i < data.edges.length; i++) {
vm.edges.push({from: data.edges[i][0], to: data.edges[i][1], arrows:'to'});
}
// Format node list data
for(var i = 0; i < data.nodes.length; i++) {
vm.nodes.push({id: data.nodes[i][1], label: data.nodes[i][2], group: data.nodes[i][0]});
}
draw_processing_graph(vm.nodes, vm.edges, 'analysis-network-div', populateContentArtifact, populateContentJob);
// At this point we can show the graph and hide the job list
$("#analysis-network-div").show();
$("#analysis-job-div").hide();
}
})
.fail(function(object, status, error_msg) {
// Show an error message if something wrong happen, rather than
// leaving the spinning wheel of death in there.
$("#analysis-network-div").html("Error loading graph: " + status + " " + error_msg);
$("#analysis-network-div").show();
$("#analysis-job-div").hide();
}
);
},
update_jobs: function () {
let vm = this;
$.get("{% raw qiita_config.portal_dir %}/analysis/description/" + {{analysis_id}} + "/jobs/", function(data) {
$("#analysis-job-div").html("");
$("#analysis-job-div").append("<p>Hang tight, we are generating the initial set of files for your analysis: </p>");
for(var jobid in data){
var contents = "<b> Job: " + jobid + "</b> Status: " + data[jobid]['status'];
// Only show step if error if they actually have a useful message
if (data[jobid]['step']) {
contents = contents + " Step: " + data[jobid]['step'] + "</br>";
}
if (data[jobid]['error']) {
contents = contents + " Error: " + data[jobid]['error'] + "</br>";
}
$("#analysis-job-div").append(contents);
}
})
.fail(function(object, status, error_msg) {
$("#analysis-job-div").html("Error loading job information: " + status + " " + error_msg);
}
);
}
},
mounted() {
let vm = this;
show_loading('{% raw qiita_config.portal_dir %}', 'analysis-network-div');
$("#analysis-network-div").hide();
// This call to udpate graph will take care of updating the jobs
// if the graph is not available
vm.update_graph();
setInterval(function() {
// Only update if the graph has not been generated yet
if (vm.nodes.length == 0) {
vm.update_graph();
}
}, 5000);
}
draw_processing_graph(nodes, edges, 'analysis-network-div', populateContentArtifact, populateContentJob);
})
.fail(function(object, status, error_msg) {
$("#analysis-network-div").html("Error loading graph: " + status + " " + error_msg);
}
);
}

$(document).ready(function(){
populate_grap_div();
});

</script>
<style>
.graph {
Expand All @@ -131,8 +188,11 @@ <h4><a class="btn btn-info" id="show-hide-network-btn" onclick="toggle_network_g
<b>(Click nodes for more information, blue are jobs)</b>
</div>
</div>
<div class='row' id="analysis-graph-vue">
<analysis-graph></analysis-graph>
</div>
<div class='row'>
<div class='col-md-12 graph' style='width:90%' id='analysis-network-div'>
<div class='col-md-12' style='width:90%' id='analysis-job-div'>
</div>
</div>
<div class='row'>
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/templates/list_analyses.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h3><a href="{% raw qiita_config.portal_dir %}/study/list/">Create an analysis</
{% set _id = analysis.id %}
<tr>
<td>
<a href="{% raw qiita_config.portal_dir %}/analysis/description/{{analysis.id}}">{{analysis.name}}</a>
<a href="{% raw qiita_config.portal_dir %}/analysis/description/{{analysis.id}}/">{{analysis.name}}</a>
</td>
<td>
{{analysis.description}}
Expand Down
6 changes: 4 additions & 2 deletions qiita_pet/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
UserMessagesHander, UserJobs)
from qiita_pet.handlers.analysis_handlers import (
ListAnalysesHandler, AnalysisSummaryAJAX, SelectedSamplesHandler,
AnalysisDescriptionHandler, AnalysisGraphHandler, CreateAnalysisHandler)
AnalysisDescriptionHandler, AnalysisGraphHandler, CreateAnalysisHandler,
AnalysisJobsHandler)
from qiita_pet.handlers.study_handlers import (
StudyIndexHandler, StudyBaseInfoAJAX, SampleTemplateAJAX,
StudyEditHandler, ListStudiesHandler, SearchStudiesAJAX, EBISubmitHandler,
Expand Down Expand Up @@ -96,7 +97,8 @@ def __init__(self):
(r"/analysis/create/", CreateAnalysisHandler),
(r"/analysis/selected/", SelectedSamplesHandler),
(r"/analysis/selected/socket/", SelectedSocketHandler),
(r"/analysis/description/graph/", AnalysisGraphHandler),
(r"/analysis/description/(.*)/graph/", AnalysisGraphHandler),
(r"/analysis/description/(.*)/jobs/", AnalysisJobsHandler),
(r"/analysis/description/(.*)/", AnalysisDescriptionHandler),
(r"/moi-ws/", MOIMessageHandler),
(r"/consumer/", MessageHandler),
Expand Down