How to expose Jupyter cells based on R language as REST API via Jupyter Kernel Gateway?

135 Views Asked by At

In Jupyter notebook I created a R cell that has the R following code:

#GET /r/test

data <- read.csv("/home/jovyan/work/data/heart-failure.csv")

# Split the data into training and test sets. (0.75, 0.25) split.
sampled <- sample(1:nrow(data), 0.75 * nrow(data))
train <- data[sampled, ]
test <- data[-sampled, ]
print(train,quote = TRUE, row.names = FALSE)

In order to expose the cell as REST API, I have annotated the cell with the Jupyter Kernel Gateway annotation

#GET /r/test

When I started a docker container that enables the usage of Jupyter Kernel Gateway, I got the error

RuntimeError: No endpoints were discovered. Check your notebook to make sure your cells are annotated correctly.

Does Jupyter Kernel Gateway support R language based cells to be exposed as REST API? If yes, how can I achieve this functionality?

1

There are 1 best solutions below

0
On BEST ANSWER

According to the documentation, there is always a space between # and GET, so you need to write # GET /r/test instead:

# GET /r/test

data <- read.csv("/home/jovyan/work/data/heart-failure.csv")

# Split the data into training and test sets. (0.75, 0.25) split.
sampled <- sample(1:nrow(data), 0.75 * nrow(data))
train <- data[sampled, ]
test <- data[-sampled, ]
print(train,quote = TRUE, row.names = FALSE)