Skip to content

Commit

Permalink
Azure ML SDK for R
Browse files Browse the repository at this point in the history
  • Loading branch information
heemanshusuri committed Oct 9, 2019
0 parents commit b56a832
Show file tree
Hide file tree
Showing 321 changed files with 37,601 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .azure-pipelines/azure-pipelines.yml
@@ -0,0 +1,76 @@
trigger:
- master

pool:
vmImage: 'ubuntu-16.04'

container: ninhu/r-sdk-build:latest

variables:
- name: TEST_LOCATION
value: eastus2
- name: TEST_RESOURCE_GROUP
value: static_resources_r_sdk
- name: TEST_SUBSCRIPTION_ID
value: 4faaaf21-663f-4391-96fd-47197c630979
- name: TEST_WORKSPACE_NAME
value: r_sdk_workspace
- name: TEST_BUILD_NUMBER
value: $(Build.BuildNumber)

steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
Rscript './.azure-pipelines/scripts/validate_copyright_header.R' 'R'
displayName: 'Validate copyright header'

- task: Bash@3
inputs:
targetType: 'inline'
script: |
pip install --user azureml-sdk
R -e 'dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE);
.libPaths(Sys.getenv("R_LIBS_USER"));
# build and install R sdk
devtools::install_deps(upgrade = FALSE);
package_location <- devtools::build();
install.packages(package_location, repos = NULL)'
displayName: 'Build and Install SDK'

- task: Bash@3
inputs:
targetType: 'inline'
script: |
Rscript './.azure-pipelines/scripts/check_code_style.R' 'R'
displayName: 'Check code style'

- task: Bash@3
inputs:
targetType: 'inline'
script: |
R -e 'library("rcmdcheck");
check_results <- rcmdcheck(".", args = c("--no-manual", "--no-tests"));
stopifnot(length(check_results$errors) == 0);
stopifnot(length(check_results$warnings) == 0)'
displayName: 'Check package build'

- task: AzureCLI@1
inputs:
azureSubscription: 'Project Vienna Build Tests (4faaaf21-663f-4391-96fd-47197c630979)'
scriptLocation: inlineScript
inlineScript: |
python -c "from azureml._base_sdk_common.common import perform_interactive_login; perform_interactive_login(username='$servicePrincipalId', password='$servicePrincipalKey', service_principal=True, tenant='$tenantId')"
R -e '# needed to load all non exported packages for testing
devtools::load_all();
options(testthat.output_file = "TEST-ALL.xml");
testthat::test_dir("tests/testthat", reporter = "junit")'
addSpnToEnvironment: true
displayName: 'Run R SDK Tests'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/TEST-*.xml'
failTaskOnFailedTests: true
25 changes: 25 additions & 0 deletions .azure-pipelines/docker/Dockerfile
@@ -0,0 +1,25 @@
FROM ubuntu:16.04

USER root:root
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV DEBIAN_FRONTEND noninteractive

# Miniconda
ENV MINICONDA_VERSION 4.5.11
ENV PATH /opt/miniconda/bin:$PATH
RUN apt-get update && apt-get install -y bzip2 wget git libxrender1 && \
wget -qO /tmp/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh && \
bash /tmp/miniconda.sh -bf -p /opt/miniconda && \
conda clean -ay && \
rm -rf /opt/miniconda/pkgs && \
rm /tmp/miniconda.sh && \
find / -type d -name __pycache__ | xargs rm -rf

RUN conda install -c r -y r-essentials r-devtools r-testthat r-reticulate && conda clean -ay && \
pip install azureml-defaults

# Azure CLI
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# Install R packages from CRAN
RUN R -e 'install.packages(c("roxygen2", "pkgdown", "rcmdcheck", "fs", "lintr"), repos = "http://cran.us.r-project.org")'
32 changes: 32 additions & 0 deletions .azure-pipelines/scripts/check_code_style.R
@@ -0,0 +1,32 @@
#!/usr/bin/env
args <- commandArgs(trailingOnly = TRUE)
if (length(args) == 0) {
stop("Please provide the directory path", call.=FALSE)
}

library("lintr")

check_code_style <- function(directory) {
files <- list.files(directory)
for (filename in files) {
if (filename == "package.R"){
next
}

file <- file.path(".", "R", filename)

style_issues <- lintr::lint(file, linters = with_defaults(
line_length_linter = line_length_linter(240L),
object_length_linter = object_length_linter(40L)
)
)

if (length(style_issues) != 0) {
print(file)
print(style_issues)
stop("Code quality failed.")
}
}
}

check_code_style(directory = args[1])
25 changes: 25 additions & 0 deletions .azure-pipelines/scripts/validate_copyright_header.R
@@ -0,0 +1,25 @@
#!/usr/bin/env
args <- commandArgs(trailingOnly = TRUE)
if (length(args) == 0) {
stop("Please provide the directory path", call.=FALSE)
}

validate_copyright_header <- function(directory) {
copyright_header <- c("# Copyright(c) Microsoft Corporation.",
"# Licensed under the MIT license.")
files <- list.files(directory)
for (filename in files) {
file <- file.path(".", "R", filename)
file_handle <- file(file, open="r")
lines <- readLines(file_handle)

assertthat::assert_that(length(lines) >= length(copyright_header))

for (i in 1:length(copyright_header)) {
assertthat::assert_that(lines[[i]] == copyright_header[[i]])
}
}
}


validate_copyright_header(directory = args[1])
53 changes: 53 additions & 0 deletions .azure-pipelines/update-docs.yml
@@ -0,0 +1,53 @@
trigger:
batch: true
branches:
include:
- master

# no PR builds
pr: none

pool:
vmImage: 'ubuntu-16.04'

container: ninhu/r-sdk-build:latest

steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
git config --global user.email "$(GITHUB_USER_EMAIL)"
git config --global user.name "$(GITHUB_USER_NAME)"
branch_ref=$(Build.SourceBranch)
echo BranchRef=$branch_ref
branch_name="${branch_ref/"refs/heads/"}"
echo BranchName=$branch_name
echo GIT CHECKOUT
git checkout $branch_name
echo GIT STATUS
git status
echo UPDATE DOCS
R -e 'dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE);
.libPaths(Sys.getenv("R_LIBS_USER"));
devtools::install_deps(upgrade = FALSE);
unlink("man", recursive=TRUE, force=TRUE);
roxygen2::roxygenise();
unlink("docs", recursive=TRUE, force=TRUE);
pkgdown::build_site();'
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to generate documents!! Exiting..."
exit $retVal
fi
echo GIT ADD
git add man/* docs/* DESCRIPTION NAMESPACE
echo GIT COMMIT
git commit -m "Update R SDK docs via Build $(Build.BuildNumber) [skip ci]"
echo GIT STATUS
git status
echo GIT PUSH
git push https://$(GITHUB_AUTH_TOKEN)@github.com/Azure/azureml-sdk-for-r.git
echo GIT STATUS
git status
displayName: 'Update Docs'
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,23 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
9 changes: 9 additions & 0 deletions CODE_OF_CONDUCT.md
@@ -0,0 +1,9 @@
# Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,14 @@
# Contributing

This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
30 changes: 30 additions & 0 deletions DESCRIPTION
@@ -0,0 +1,30 @@
Package: azureml
Type: Package
Title: R interface to AzureML SDK
Version: 0.4.0
Authors@R: c(
person("Himanshu", "Chandola", email = "Himanshu.Chandola@microsoft.com", role = c("aut")),
person("Billy", "Hu", email = "ninhu@microsoft.com", role = c("aut", "cre")),
person("Heemanshu", "Suri", email = "Heemanshu.Suri@microsoft.com", role = c("aut")),
person("Diondra", "Peck", email = "Diondra.Peck@microsoft.com", role = c("aut")),
person("Microsoft", role = c("cph", "fnd"))
)
URL: https://github.com/azure/azureml-sdk-for-r
BugReports: https://github.com/azure/azureml-sdk-for-r/issues
Description: Provides an R interface to the AzureML Service.
Encoding: UTF-8
License: MIT
RoxygenNote: 6.1.1
Depends:
R (>= 3.5.0)
Imports:
reticulate (>= 1.12),
R6 (>= 2.4.0),
plyr (>= 1.8),
DT,
parsedate,
rstudioapi (>= 0.7)
Suggests: rmarkdown,
knitr,
testthat
VignetteBuilder: knitr
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

0 comments on commit b56a832

Please sign in to comment.