Skip to content

Commit 002b913

Browse files
psolymosalexellis
authored andcommitted
Update post date and fix links
Signed-off-by: Peter Solymos <psolymos@gmail.com>
1 parent 8efe4ab commit 002b913

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

_posts/2021-03-05-r-templates.md renamed to _posts/2021-05-14-r-templates.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Functions for data science with R templates for OpenFaaS"
33
description: "Let's bring R to the cloud! Use the power of R for data science serverless-style."
4-
date: 2021-02-26
5-
image: /images/2021-03-r/background.jpg
4+
date: 2021-05-14
5+
image: /images/2021-05-r/background.jpg
66
categories:
77
- kubernetes
88
- r
@@ -49,7 +49,7 @@ The template naming follows the pattern `rstats-<base_image>-<server_framework>`
4949

5050
R has an ever increasing number of server frameworks available. There are templates for the following frameworks (R packages): [httpuv](https://CRAN.R-project.org/package=httpuv), [plumber](https://www.rplumber.io/), [fiery](https://CRAN.R-project.org/package=fiery), [beakr](https://CRAN.R-project.org/package=beakr), [ambiorix](https://ambiorix.john-coene.com/). Each of these frameworks have their own pros and cons for building standalone applications. But for our serverless purposes, the most important aspect of picking one comes down to support and ease of use.
5151

52-
In this post I focus on the [plumber](https://www.rplumber.io/) R package and the `rstats-base-plumber` template. Plumber is one of the oldest of these frameworks. It has gained popularity, corporate adoption, and there are many [examples](https://github.com/rstudio/plumber/tree/master/inst/plumber) and tutorials out there to get you get started.
52+
In this post I focus on the [plumber](https://www.rplumber.io/) R package and the `rstats-base-plumber` template. Plumber is one of the oldest of these frameworks. It has gained popularity, corporate adoption, and there are many [examples](https://github.com/rstudio/plumber/tree/master/inst/plumber) and tutorials out there to get you started.
5353

5454
### Make a new function
5555

@@ -74,13 +74,13 @@ The `covid-forecast.yml` is the stack file used to configure functions (read mor
7474

7575
### Time series forecast
7676

77-
I will use [exponential smoothing](https://en.wikipedia.org/wiki/Exponential_smoothing) as a time series forecasting method. The method needs a _time series_ data, that is a series of numeric values collected at some interval. I use here daily updated COVID-19 case counts. The [data source](https://github.com/CSSEGISandData/COVID-19) is the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University. The flat files provided by the CSSE are further processed to provide a JSON API (read more about the [API](https://blog.analythium.io/data-integration-and-automated-updates-for-web-applications/) and its [endpoints](https://github.com/analythium/covid-19#readme), or explore the data interactively [here](https://hub.analythium.io/covidapp/)).
77+
I will use [exponential smoothing](https://en.wikipedia.org/wiki/Exponential_smoothing) as a time series forecasting method. The method needs _time series_ data, that is a series of numeric values collected at some interval. I use here daily updated COVID-19 case counts. The [data source](https://github.com/CSSEGISandData/COVID-19) is the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University. The flat files provided by the CSSE are further processed to provide a JSON API (read more about the [API](https://blog.analythium.io/data-integration-and-automated-updates-for-web-applications/) and its [endpoints](https://github.com/analythium/covid-19#readme), or explore the data interactively [here](https://hub.analythium.io/covidapp/)).
7878

7979
### Customize the function
8080

81-
The `covid-forecast/handler.R` contains the actual R code implementing the function logic. You'll see an example for that below. The dependencies required by the handler need to be added to the `covid-forecast/DESCRIPTION` file. Read more about how the dependencies specified in the `DESCRIPTION` file are installed [here](https://github.com/analythium/openfaas-rstats-templates#customize-your-function).
81+
The `covid-forecast/handler.R` contains the actual R code implementing the function logic. You'll see an example for that below. The dependencies required by the handler need to be added to the `covid-forecast/DESCRIPTION` file. See how the dependencies specified in the `DESCRIPTION` file are installed [here](https://github.com/analythium/openfaas-rstats-templates#customize-your-function).
8282

83-
> See [worked examples](https://github.com/analythium/openfaas-rstats-examples) for different use cases. Read more about the [structure of the templates](template/README.md) if advanced tuning is required, e.g. by editing the `Dockerfile`, etc.
83+
> See [worked examples](https://github.com/analythium/openfaas-rstats-examples) for different use cases. Read more about the [structure of the templates](https://github.com/analythium/openfaas-rstats-templates/tree/master/template#r-rstats-templates-for-openfaas) if advanced tuning is required, e.g. by editing the `Dockerfile`, etc.
8484
8585
Add the forecast R package to the `covid-forecast/DESCRIPTION` file:
8686

@@ -147,7 +147,7 @@ The R script loads the forecast package, defines the `covid_forecast` function w
147147

148148
- `region`: a region slug value for the API endpoint in global data set (see [available values](https://hub.analythium.io/covid-19/api/v1/regions/)),
149149
- `cases`: one of `"confirmed"` or `"deaths"`,
150-
- `windows`: a positive integer giving the forecast horizon in days,
150+
- `window`: a positive integer giving the forecast horizon in days,
151151
- `last`: last day (`"YYYY-MM-DD"` date format) of the time series to consider.
152152

153153
The function gives the following output in R:
@@ -172,7 +172,7 @@ The result of the call is a list with six elements, all elements are vectors of
172172

173173
The following plot combines the historical daily case counts and the 30-day forecast for Canada. The point forecast is the white line, the 80% and 95% forecast intervals are the blue shaded areas. I made two forecasts, the first on December 1st, 2020, the second on February 18th, 2021:
174174

175-
![COVID-19 Canada](/images/2021-03-r/covid-canada-2021-02-18.png)
175+
![COVID-19 Canada](/images/2021-05-r/covid-canada-2021-02-18.png)
176176

177177
The last part of the script defines the Plumber endpoint `/` for a GET request. One of the nicest features of Plumber is that you can create a web API by [decorating the R source code](https://www.rplumber.io/articles/quickstart.html) with special `#*` comments. These annotations will tell Plumber how to handle the requests, what kind of parsers and formatters to use, etc. The current setup will treat the function arguments as URL parameters. The default content type for the response is JSON, thus we do not need to specify it.
178178

File renamed without changes.

0 commit comments

Comments
 (0)