New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerize R package build #5182
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
source(".utils.R") | ||
|
||
# Increase the timeout length for `utils::download.file` because the default value (60 seconds) | ||
# could be too short to download large packages such as h2o. | ||
options(timeout=300) | ||
# Install dependencies required for the submission check. | ||
devtools::install_deps(".", dependencies = TRUE) | ||
# Bundle up the package into a .tar.gz file. This file will be submitted to CRAN. | ||
package_path <- devtools::build(".", path = ".") | ||
# Run the submission check against the built package. | ||
devtools::check_built( | ||
path = normalizePath(package_path), | ||
remote = should_enable_cran_incoming_checks(), | ||
error_on = "note", | ||
args = c("--no-tests", "--as-cran"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ Reference_Manual_mlflow.md | |
*.Rcheck/ | ||
depends.Rds | ||
R-version | ||
*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
source("../.utils.R") | ||
|
||
parent_dir <- dir("../", full.names = TRUE) | ||
package <- parent_dir[grepl("mlflow_", parent_dir)] | ||
|
||
library(reticulate) | ||
use_condaenv(mlflow:::mlflow_conda_env_name()) | ||
|
||
# Disable CRAN incoming feasibility check within a week after the latest release because it fails. | ||
# | ||
# Relevant code: | ||
# https://github.com/wch/r-source/blob/4561aea946a75425ddcc8869cdb129ed5e27af97/src/library/tools/R/QC.R#L8005-L8008 | ||
install.packages(c("xml2", "rvest")) | ||
library(xml2) | ||
library(rvest) | ||
|
||
url <- "https://cran.r-project.org/web/packages/mlflow/index.html" | ||
html <- read_html(url) | ||
xpath <- '//td[text()="Published:"]/following-sibling::td[1]/text()' | ||
published_date <- as.Date(html_text(html_nodes(html, xpath=xpath))) | ||
today <- Sys.Date() | ||
days_since_last_release <- difftime(today, published_date, units="days") | ||
remote <- as.numeric(days_since_last_release) > 7 | ||
|
||
devtools::check_built(path = package, remote = remote, error_on = "note", args = "--no-tests") | ||
devtools::check_built( | ||
path = package, | ||
remote = should_enable_cran_incoming_checks(), | ||
error_on = "note", | ||
args = "--no-tests" | ||
) | ||
source("testthat.R") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# This script defines utility functions only used during development. | ||
|
||
should_enable_cran_incoming_checks <- function() { | ||
# The CRAN incoming feasibility check performs a package recency check (this is undocumented) | ||
# that examines the number of days since the last release and raises a NOTE if it's < 7. | ||
# Relevant code: | ||
# https://github.com/wch/r-source/blob/4561aea946a75425ddcc8869cdb129ed5e27af97/src/library/tools/R/QC.R#L8005-L8008 | ||
# This check needs to be disabled for a week after releasing a new version. | ||
desc_url <- url("https://cran.r-project.org/web/packages/mlflow/DESCRIPTION") | ||
field <- "Date/Publication" | ||
desc <- read.dcf(desc_url, fields = c(field)) | ||
close(desc_url) | ||
publication_date <- as.Date(unname(desc[1, field])) | ||
today <- Sys.Date() | ||
days_since_last_release <- as.numeric(difftime(today, publication_date, units="days")) | ||
days_since_last_release > 7 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM rocker/r-ver:4.1.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
RUN apt-get update -y | ||
RUN apt-get install pandoc -y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
RUN Rscript -e 'install.packages("devtools", dependencies = TRUE)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
docker build -f Dockerfile.build -t r-build-package . | ||
docker run --rm --workdir /app -v $(pwd):/app r-build-package Rscript -e 'source(".build-package.R", echo = TRUE)' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step takes about 5 minutes, which I think is acceptable:
https://github.com/mlflow/mlflow/runs/4577625774?check_suite_focus=true#step:16:1