Skip to content
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

App stats #311

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
9 changes: 6 additions & 3 deletions api/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,12 @@ exports.compose_pub_datacite_metadata = function(pub) {
exports.get_next_app_doi = function(cb) {
//console.log("querying for next doi")
db.Apps.find({}).select("doi").sort("-doi").limit(1).exec().then(recs=>{
let rec = recs[0];
let doi_tokens = rec.doi.split(".");
let num = parseInt(doi_tokens[doi_tokens.length-1])+1;
let num = 1;
if(recs.length) {
let rec = recs[0];
let doi_tokens = rec.doi.split(".");
num = parseInt(doi_tokens[doi_tokens.length-1])+1;
}
//console.debug("next doi token will be", num);
cb(null, config.datacite.prefix+"app."+num);
}).catch(cb);
Expand Down
1 change: 1 addition & 0 deletions api/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ var appSchema = mongoose.Schema({
],

examples: Number, //number of example workflows found
monthlyCounts: [Number]
},

removed: { type: Boolean, default: false} ,
Expand Down
11 changes: 8 additions & 3 deletions bin/appinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ function handle_app(app, cb) {
app.stats.runtime_mean = info.runtime_mean;
app.stats.runtime_std = info.runtime_std;
app.stats.requested = info.counts.requested,

app.stats.monthlyCounts = info.monthlyCounts;
// console.log(app.stats.monthlyCounts,app.name);
next();
}).catch(next);
},

//cache example workflow

async ()=>{
const cachefname = "/tmp/example.app-"+app.id+".json"; //needs to match the path used in controller/app.js

Expand Down Expand Up @@ -128,6 +130,7 @@ function handle_app(app, cb) {
fs.writeFileSync(cachefname, JSON.stringify(subsetProvs));

app.stats.examples = subsetProvs.length;
// console.log(app.name,app.stats);
app.markModified('stats');
},

Expand All @@ -154,16 +157,17 @@ function handle_app(app, cb) {
name: resource.name,
}
});
app.markModified('stats');

app.markModified('stats');
common.update_appinfo(app, next);
}).catch(next);
},

//issue doi
next=>{
if(app.doi) return next();
logger.debug("minting doi");
if(!config.datacite) return next();
console.log("minting doi",app._id,app.doi);
common.get_next_app_doi((err, doi)=>{
if(err) return next(err);
app.doi = doi;
Expand All @@ -178,6 +182,7 @@ function handle_app(app, cb) {

//check doi
next=>{
if(!config.datacite) return next();
let url = "https://doi.org/"+app.doi;
console.log("checking doi", url);
//if(config.debug) url = "https://doi.org/10.25663/brainlife.app.448";
Expand Down
48 changes: 36 additions & 12 deletions ui/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<b-container>
<h3 style="padding: 50px 0 15px 0;opacity: 0.7"><icon name="lock" class="text-secondary" scale="1.5"/> Private App</h3>
<b-alert show variant="secondary">
The App you are trying access is a private App (belongs to a specific brainlife project). You must be logged in and also must be a member
The App you are trying access is a private App (belongs to a specific brainlife project). You must be logged in and also must be a member
of the project to which this App belongs. Please contact the current maintainer of this App.
</b-alert>
</b-container>
Expand All @@ -14,7 +14,7 @@
<b-container style="position: relative;">
<div style="float: right; position: relative; z-index: 3">
<a :href="'https://github.com/'+app.github" :target="app.github"><span class="button" title="github"><icon name="brands/github" scale="1.25"/></span></a>
<span class="button" @click="go('/app/'+app._id+'/edit')" v-if="app._canedit" title="Edit"><icon name="edit" scale="1.25"/></span>
<span class="button" @click="go('/app/'+app._id+'/edit')" v-if="app._canedit" title="Edit"><icon name="edit" scale="1.25"/></span>
<b-dropdown size="sm" variant="link" toggle-class="text-decoration-none" no-caret>
<template v-slot:button-content style="padding: 0px;">
<span class="button"><icon name="ellipsis-v" scale="1.25"/></span>
Expand All @@ -32,7 +32,7 @@
<icon name="certificate" scale="1.25" style="width: 20px"/>&nbsp;&nbsp;&nbsp;Generate Badge
</b-dropdown-item>
</b-dropdown>
<b-btn @click="execute" variant="primary" size="sm" style="margin-top: 3px;"><icon name="play"/>&nbsp;&nbsp;&nbsp;<b>Execute</b></b-btn>
<b-btn @click="execute" variant="primary" size="sm" style="margin-top: 3px;"><icon name="play"/>&nbsp;&nbsp;&nbsp;<b>Execute</b></b-btn>
</div>

<h5>
Expand Down Expand Up @@ -104,6 +104,11 @@

<!--detail header-->
<b-row>
<b-col>
<div v-if="app.stats && app.stats.monthlyCounts && app.stats.monthlyCounts.length">
<ExportablePlotly v-if="appStats" :data="appStats" :layout="statsLayout"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhatiadheeraj Like you were saying, I think plotly graph might be too heavy for this? You can use visjs also which is a bit lighter than plotly graph. You can also just render a simple graph manually with a few simple

or SVG drawing.

</div>
</b-col>
<b-col>
<p v-if="app.stats && app.stats.success_rate" v-b-tooltip.hover.d1000.right title="finished/(failed+finished). Same request could be re-submitted / rerun.">
<svg width="70" height="70">
Expand All @@ -115,9 +120,9 @@
</p>
</b-col>
<b-col>
<div class='altmetric-embed'
data-badge-type='donut'
data-badge-details="right"
<div class='altmetric-embed'
data-badge-type='donut'
data-badge-details="right"
data-hide-no-mentions="true"
:data-doi="app.doi||config.debug_doi"/>
</b-col>
Expand Down Expand Up @@ -163,8 +168,8 @@
<div v-if="app.outputs && app.outputs.length > 0">
<div v-for="output in app.outputs" :key="output.id" class="io-card">
<small class="ioid">{{output.id}}</small><!--internal output id-->
<datatype :datatype="output.datatype"
:datatype_tags="output.datatype_tags"
<datatype :datatype="output.datatype"
:datatype_tags="output.datatype_tags"
:tag_pass="output.datatype_tags_pass">
<template slot="tag_extra">
<span v-if="output.datatype_tags_pass" title="tag pass through from this input dataset"
Expand Down Expand Up @@ -228,7 +233,7 @@
<div v-if="resources_considered" class="box" style="padding: 20px">
<span class="form-header">Computing Resources</span>
<b-alert show variant="secondary" v-if="resources_considered.length == 0" style="margin-bottom: 10px;">
This App is not registered to run on any resource that you have access to.
This App is not registered to run on any resource that you have access to.
</b-alert>
<b-alert show variant="secondary" v-else-if="!preferred_resource" style="margin-bottom: 10px;">
This App can not run on any resources that you have access to at the moment.
Expand All @@ -247,7 +252,7 @@
<b>{{resource.status}}</b>
<span class="score">Score {{resource.score}}</span>
</div>
<div v-else-if="resource.detail.running >= resource.detail.maxtask" class="resource-status bg-warning"
<div v-else-if="resource.detail.running >= resource.detail.maxtask" class="resource-status bg-warning"
title="This App is registered to this resource but the resource is currently busy running other Apps.">
<icon name="hourglass" style="position: relative; top: -3px;"/>
&nbsp;
Expand Down Expand Up @@ -399,7 +404,7 @@ export default {
taskRecord,
projectcard,
exampleworkflow,

ExportablePlotly: ()=>import('@/components/ExportablePlotly'),
editor: ()=>import('vue2-ace-editor'),
},

Expand All @@ -421,6 +426,8 @@ export default {
{id: "recentJobs"},
{id: "example"},
],
appStats: null,
statsLayout:null,

tasks: [], //recent tasks submitted
serviceinfo: null,
Expand Down Expand Up @@ -521,11 +528,28 @@ export default {
if(task.resource_id) this.resource_cache(task.resource_id, (err, resource)=>{
task._resource = resource;
});
});
});
}).catch(console.error);

this.$http.get(Vue.config.amaretti_api+'/service/info', {params: {service: this.app.github}}).then(res=>{
this.serviceinfo = res.data;
this.appStats = [{
y : this.serviceinfo.monthlyCounts,
x: [],
type: "bar",
}];
console.log(this.serviceinfo.monthlyCounts.length);

this.serviceinfo.monthlyCounts.forEach(async(count,index)=>{
if(!count) count = 0;
const startDate = new Date("01/01/2017");
const dataDate = new Date(startDate.setMonth(startDate.getMonth()+index));
this.appStats[0].x[index] = dataDate.toLocaleString('en-us',{month:'short', year:'numeric'});
})
this.statsLayout = {
height: 500,
width:500,
};
}).catch(console.error);

}
Expand Down