├── earl2019slides.pdf ├── user2019slides.pdf ├── Dockerfile ├── train-model.R ├── install-packages.R ├── .gitignore ├── azure-pipelines.yml ├── LICENSE └── README.md /earl2019slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/revodavid/RMLops/HEAD/earl2019slides.pdf -------------------------------------------------------------------------------- /user2019slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/revodavid/RMLops/HEAD/user2019slides.pdf -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rocker/r-base:3.6.0 2 | 3 | RUN apt-get update -qq 4 | && install2.r --error \ 5 | --deps TRUE \ 6 | xgboost -------------------------------------------------------------------------------- /train-model.R: -------------------------------------------------------------------------------- 1 | ## toy model, using mtcars 2 | # mpg.reg <- lm(mpg ~ disp + hp + factor(cyl), data=mtcars) 3 | 4 | library(xgboost, lib.loc="library") 5 | 6 | data(agaricus.train, package='xgboost') 7 | 8 | train <- agaricus.train 9 | 10 | dtrain <- xgb.DMatrix(data = train$data, label = train$label) 11 | bst <- xgboost(data = dtrain, max_depth = 2, eta = 1, nthread = 2, nrounds = 2, 12 | objective = "binary:logistic", verbose = 2) 13 | 14 | saveRDS(bst, file="model.Rd") 15 | -------------------------------------------------------------------------------- /install-packages.R: -------------------------------------------------------------------------------- 1 | ## ensure user library exists, or else R will attempt to install to /usr/local/lib 2 | print(Sys.getenv("R_LIBS_USER")) 3 | print(getwd()) 4 | 5 | dir.create("library") 6 | 7 | #if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { 8 | # dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) } 9 | 10 | # ensure /usr/local/lib/R/site-library is writeable first 11 | #install.packages("xgboost", repos="https://cran.rstudio.com", lib="library") 12 | install.packages("xgboost", repos='https://mran.microsoft.com/snapshot/2019-09-20/', lib="library") 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # Example code in package build process 9 | *-Ex.R 10 | 11 | # Output files from R CMD build 12 | /*.tar.gz 13 | 14 | # Output files from R CMD check 15 | /*.Rcheck/ 16 | 17 | # RStudio files 18 | .Rproj.user/ 19 | 20 | # produced vignettes 21 | vignettes/*.html 22 | vignettes/*.pdf 23 | 24 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 25 | .httr-oauth 26 | 27 | # knitr and R markdown default cache directories 28 | /*_cache/ 29 | /cache/ 30 | 31 | # Temporary files created by R markdown 32 | *.utf8.md 33 | *.knit.md 34 | 35 | # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html 36 | rsconnect/ 37 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Starter pipeline 2 | # Start with a minimal pipeline that you can customize to build and deploy your code. 3 | # Add steps that build, run tests, deploy, and more: 4 | # https://aka.ms/yaml 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: 'ubuntu-16.04' 11 | 12 | container: 'rocker/r-ver:3.6.1' 13 | 14 | steps: 15 | - script: Rscript -e 'R.version' 16 | displayName: 'Confirm R version' 17 | 18 | - script: Rscript install-packages.R 19 | displayName: 'Install packages' 20 | 21 | - script: Rscript train-model.R 22 | displayName: 'Train model' 23 | 24 | - publish: $(System.DefaultWorkingDirectory)/model.Rd 25 | artifact: TrainedModel 26 | 27 | - script: | 28 | echo Add other tasks to build, test, and deploy your project. 29 | echo See https://aka.ms/yaml 30 | displayName: 'Run a multi-line script' 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 David Smith 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://dev.azure.com/davidsmi0786/davidsmiRtest/_apis/build/status/revodavid.RMLops?branchName=master)](https://dev.azure.com/davidsmi0786/davidsmiRtest/_build/latest?definitionId=1&branchName=master) 2 | 3 | # RMLops: A simple R example for Azure Pipelines 4 | 5 | This is the Github repository associated with this Azure Pipelines project: https://dev.azure.com/davidsmi0786/davidsmiRtest. It is intended as a simple example 6 | of using R with Azure Pipelines to use a CI/CD process to trigger training of a 7 | predictive model. 8 | 9 | You will need an Azure Subscription to replicate these examples. For new subscribers, [use this link for an Azure Account](https://azure.microsoft.com/free/?WT.mc_id=rmlops-github-davidsmi) that includes $200 of Azure services. 10 | 11 | ## Presentations 12 | 13 | Slides from the presentation [A DevOps process for deploying R to production](https://github.com/revodavid/RMLops/blob/master/earl2019slides.pdf) are available. Presented at the [EARL 2019 conference](http://www.earlconf.com/) in London, September 11 2019. 14 | 15 | Slides from the presentation [A DevOps process for deploying R to production](https://github.com/revodavid/RMLops/blob/master/user2019slides.pdf) are available. Presented at the [useR!2019 conference](http://www.user2019.fr/) in Toulouse, July 12 2019. A [video recording](https://youtu.be/o6sIB0MJyOs) of this presentation is available. 16 | 17 | ## Resources 18 | 19 | [Integrating the Data Science and App Development Cycles](https://aka.ms/AA5ib6c) (Medium), Francesca Lazzeri, Microsoft. 20 | 21 | [MLOps: Manage, deploy, and monitor models with Azure Machine Learning Service](https://aka.ms/mlopsdoc) (Microsoft Docs). 22 | 23 | [Train and deploy machine learning models with Azure Pipelines](https://aka.ms/azpipe) (Microsoft Docs). 24 | 25 | [Azure Machine Learning Service](https://aka.ms/amlsvc) (Microsoft Docs). 26 | 27 | --------------------------------------------------------------------------------