In that exemple of an opencpu app, a file uploaded is used by the function printsummary
once imbricated into the call to readcsvnew
.
I am looking for a way to apply to the same dataset a number of functions one after each other independently.
I think it is possible in the R code to save the data into the server and return the name of the data, then in each R function, begin by loading the data and finishing by saving it but it is a bit absurd, because loading and saving the data each time slow the process. And the server need to be cleaned at some point. So my question, is it possible to save the session detail and call it later on? Or is there a better way to do it, maybe with a js twick?
Looking at the js, the current call is:
// on click, call uploadcsv
$("#submitbutton").on("click", function(){
function uploadcsv(file, header){
//perform the request
var req = ocpu.call("readcsvnew", {
file : file,
header : header
}, function(session){
//on success call printsummary()
printsummary(session);
});
So the session details are passed on to the imbricated function.
Is it possible to move to something like:
// on click on first button, call uploadcsv
$("#submitbutton").on("click", function(){
function uploadcsv(file, header){
//perform the request
var req = ocpu.call("readcsvnew", {
file : file,
header : header
}, function(session){
//on success, store the data or store the session details
__storing code here__
__ maybe save session details on the fly__
});
// on click on second button, call printsummary on uploaded data
$("#submitbutton2").on("click", function(){
//perform the request
var req = ocpu.call("printsummary", {
__parameters to call, here__
__ session saved__
}, function(session){
// exploit the result of printsummary
session.getConsole(function(output){
$("#output code").text(output);
});
});