2016-12-13 10 views
2

では、printsummaryによってアップロードされたファイルは、readcsvnewへの呼び出しに一度埋め込まれています。opencpuでのデータアップロード後に今後の再利用のためにセッションの詳細を保存します

私は同じデータセットにいくつかの関数を互いに独立して適用する方法を模索しています。

私は、Rコードでデータをサーバーに保存してデータの名前を返すことができ、各R関数でデータをロードして保存して終了することができますが、ちょっとばかげていると思いますプロセスを遅くするたびにデータをロードして保存するためです。サーバーはある時点でクリーニングする必要があります。だから私の質問は、セッションの詳細を保存し、後でそれを呼び出すことは可能ですか?または、それを行うためのよりよい方法がありますか、おそらくjs twickでですか?

JSを見てみると、現在のコールは次のとおりです。

// 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はセッションの詳細は、入り組んだ機能に渡されます。それが誰かを助けることができるならば、ここ

// 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); 
    }); 
}); 
+0

:) Rよりもdefinetely困難である:[あり、そこに-a-mechanism-to-persist-record-data-from-opencpu-server?rq = 1](http://stackoverflow.com/questions/21398584/is-there-a-mechanism- opencpu-server?rq = 1) – YCR

+0

また、[access-objects-in-opencpu-sessions](http://stackoverflow.com/questions/)にアクセスしてください。 24722550/access-objects-in-opencpu-sessions?rq = 1) – YCR

答えて

2

ポストそれを::

は、それは次のように移動することは可能です

私はそのjsfiddle使用:jsfiddle.net/opencpu/tmqab/を。

それを行うための最善の方法は、グローバル変数にセッションを保存することです。

// 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){ 
// store session as global variable: 
mysession = session; 

}); 

// on click on second button, call printsummary on uploaded data 
$("#submitbutton2").on("click", function(){ 
//perform the request 
    var req = ocpu.call("printsummary", { 
mydata : mysession 
}, function(session){ 
// exploit the result of printsummary 
    session.getConsole(function(output){ 
    $("#output code").text(output); 
    }); 
}); 

JSまだそれに取り組んで、多分参考になっ

関連する問題