'Is there any way to run another cell of R code which depends on current python flask app cell's input by user in google-colaboratory?
I am running a flask app in google colab using flask_ngrok and in that I am asking user to upload a .pssm file. Now I want to run a R package at same time as it depends on file uploaded by user, along with app cell running (basically I want to jump back and forth to cells without affecting current cell which is running my app).
I'm using %load_ext rpy2.ipython to use R and Python in one notebook.
I have seen some multithreading packages like parsl but problem is that I want R cell not Python cell.
Or Is there any other way to this problem like making request to another colab notebook and getting response in current notebook (getting a Response : csv file, Request with a: input file).
Is it possible technically?
Solution 1:[1]
I solved my problem like this:
filenm=""
%%R -i filenm -o fun1
f1<-function(filenm)
{
d1<-NULL
d1<-rbind(d1,some_function(filenm))
write.csv(d1,file="/content/t1.csv")
}
Here -i is used for passing input variable from python to R in our case "filenm" and -o is used to pass the output variable from R to python in our case we get fun1 as output in python Now that R function is converted into python so that we can use it like this:
fun1(filenm) #in Python shell
Hope this helps ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Patel Krishil |
