簡體   English   中英

如何通過 Jupyter Kernel Gateway 將基於 R 語言的 Jupyter 單元公開為 REST API?

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

在 Jupyter notebook 中,我創建了一個 R 單元,其中包含以下 R 代碼:

#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)

為了將單元格公開為 REST API,我使用 Jupyter Kernel Gateway 注釋對單元格進行了注釋

#GET /r/test

當我啟動一個啟用 Jupyter 內核網關的 docker 容器時,我收到了錯誤

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

Jupyter 內核網關是否支持將基於 R 語言的單元公開為 REST API? 如果是,我該如何實現這個功能?

根據文檔#GET之間總是有一個空格,所以你需要寫# GET /r/test代替:

# 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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM