Open psolymos opened 3 years ago
Cassic watchdog:
of-watchdog:
Would be nice to have a bare bones solution with Rserve.
Having JSON POST issues.
Rook serves web apps using R's help server and forces the routes to prepend /custom
. There was a hack
to overwrite tools:::httpd
but we get locked binding of ‘httpd’ cannot be changed
.
The following starts, but R help says 'Only NEWS and URLs under /doc and /library are allowed':
library(Rook)
s <- Rhttpd$new()
s$add(RhttpdApp$new(system.file('exampleApps/RookTestApp.R',package='Rook'), name='httpd'))
s$start(listen='127.0.0.1', port=5000)
A nice minimalist framework, somewhere between httpuv and fiery in terms of complexity.
Use local server, as a microservice. GET works, POST has similar JSON issues as RestRserve.
Lack of websocket connection can be behind the problems identified (https://github.com/openfaas/of-watchdog/issues/20). Closing this for now.
As it turns out, Rserve, RestRserve and opencpu works fine.
of-watchdog needs http_buffer_req_body="true"
.
See https://docs.openfaas.com/deployment/troubleshooting/#my-function-gets-a-nil-or-empty-body.
This causes the HTTP request to be buffered in memory, then sent in one shot to the upstream function.
This is the roadmap for revising the R/rstats templates for OpenFaaS.
Base images
We need the following base image options (BASEIMAGE below):
rocker/r-base
: consistency for most adopted base images, call this base;rocker/r-ubuntu
: long term support can be important in corporate context and it jives with RSPM, call this ubuntu;r-hub/r-minimal
: small size is always a good thing, call this minimal.Watchdog version
Existing server frameworks
The following are server frameworks capable of running R based APIs:
Template structure and workflows
template.yml
: yaml file for OpenFaaS, docker user, function name etc might have to be edited, see OpenFaaS config.Dockerfile
: usually does not need editing.index.R
: this file abstracts the server framework. Templates are set up for JSON in JSON out re/res types. This file only needs to be edited if the mime type depends on different midlewear, headers need to be changed etc.function/PACKAGES
: file listing required packages and remotes to be installed for thefunction/handler.R
file, plus additional sysreqs.function/handler.R
: R script implementing the handler:handle = function(req, res) { ... }
function called byindex.R
.I really like how the r-minimal image implements
remotes::install_deps()
with the_R_SHLIB_STRIP_=true
envvar. This behavior should be implemented for other templates through the Dockerfile as added by @mrchypark for the r-minimal template.