Skip to content

Commit 32088a7

Browse files
Merge branch 'release/0.9.0'
2 parents 1895d85 + 90d7ed8 commit 32088a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1057
-241
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#----------------------------
44
^.svn
55
^.git
6+
^.github
67
^.make
78
^INSTALL[.]md$
89
^OVERVIEW[.]md$
@@ -42,6 +43,7 @@ Rplots.pdf$
4243
^[.]devel
4344
^[.]test
4445
^[.]check
46+
^[.]local
4547
^.*[.]tar[.]gz$
4648

4749
#----------------------------
@@ -58,3 +60,4 @@ Rplots.pdf$
5860

5961
^.*\.Rproj$
6062
^\.Rproj\.user$
63+

.github/workflows/R-CMD-check.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
on: [push, pull_request]
2+
3+
name: R-CMD-check
4+
5+
jobs:
6+
R-CMD-check:
7+
runs-on: ${{ matrix.config.os }}
8+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
9+
if: "! contains(github.event.head_commit.message, '[ci skip]')"
10+
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
config:
15+
- { os: windows-latest, r: '3.5'}
16+
- { os: windows-latest, r: '3.6'}
17+
- { os: macOS-latest, r: '3.5'}
18+
- { os: macOS-latest, r: '3.6'}
19+
- { os: macOS-latest, r: 'devel'}
20+
- { os: ubuntu-16.04, r: '3.2', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
21+
- { os: ubuntu-16.04, r: '3.3', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
22+
- { os: ubuntu-16.04, r: '3.4', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
23+
- { os: ubuntu-16.04, r: '3.5', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
24+
- { os: ubuntu-16.04, r: '3.6', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
25+
26+
env:
27+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
28+
CRAN: ${{ matrix.config.cran }}
29+
30+
31+
steps:
32+
- uses: actions/checkout@v1
33+
34+
- uses: r-lib/actions/setup-r@master
35+
with:
36+
r-version: ${{ matrix.config.r }}
37+
38+
- uses: r-lib/actions/setup-pandoc@master
39+
40+
- name: Query dependencies
41+
run: Rscript -e "install.packages('remotes')" -e "saveRDS(remotes::dev_package_deps(dependencies = TRUE), 'depends.Rds', version = 2)"
42+
43+
- name: Cache R packages
44+
if: runner.os != 'Windows'
45+
uses: actions/cache@v1
46+
with:
47+
path: ${{ env.R_LIBS_USER }}
48+
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('depends.Rds') }}
49+
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-
50+
51+
- name: Install system dependencies
52+
if: runner.os == 'Linux'
53+
env:
54+
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
55+
run: |
56+
Rscript -e "remotes::install_github('r-hub/sysreqs')"
57+
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
58+
sudo -s eval "$sysreqs"
59+
60+
- name: Install dependencies
61+
run: |
62+
Rscript -e "library(remotes)" -e "update(readRDS('depends.Rds'))" -e "remotes::install_cran('rcmdcheck')"
63+
Rscript -e "install.packages('.', type = 'source', repos = NULL)"
64+
65+
- name: Check
66+
run: Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')"
67+
68+
- name: Upload check results
69+
if: failure()
70+
uses: actions/upload-artifact@master
71+
with:
72+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
73+
path: check
74+
75+
- name: Test coverage
76+
if: matrix.config.os == 'ubuntu-16.04' && matrix.config.r == '3.6-HIDE'
77+
run: |
78+
Rscript -e "install.packages('covr')" -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ matrix:
3333
- _R_CHECK_CONNECTIONS_LEFT_OPEN_=true
3434
- _R_CHECK_LENGTH_1_CONDITION_=true
3535
- _R_CHECK_LENGTH_1_LOGIC2_=true
36+
- _R_CLASS_MATRIX_ARRAY_=true
3637
- os: linux
3738
r: devel
3839
r_github_packages:
@@ -43,11 +44,21 @@ matrix:
4344
r: oldrel
4445
- os: osx
4546
r: release
47+
- os: linux
48+
r: release
49+
r_packages:
50+
- future.tests
51+
script:
52+
- R CMD build --no-build-vignettes --no-manual .
53+
- R CMD INSTALL *.tar.gz
54+
- Rscript -e future.tests::check --args --test-plan=future.batchtools::batchtools_local
55+
env: NB='w/ future.tests' ## Just a label
4656
- os: linux
4757
r: release
4858
r_packages:
4959
- covr
50-
r_check_args: --no-codoc --no-examples --no-tests --ignore-vignettes
60+
script:
61+
- R CMD build --no-build-vignettes --no-manual .
5162
after_success:
5263
- Rscript -e 'covr::codecov(quiet=FALSE)'
5364
env: NB='w/ covr' ## Just a label

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Package: future.batchtools
2-
Version: 0.8.1
2+
Version: 0.9.0
33
Depends:
44
R (>= 3.2.0),
55
future (>= 1.14.0)
66
Imports:
7-
batchtools (>= 0.9.11)
7+
batchtools (>= 0.9.11),
8+
utils
89
Suggests:
910
future.apply,
1011
listenv,
@@ -25,5 +26,5 @@ License: LGPL (>= 2.1)
2526
LazyLoad: TRUE
2627
URL: https://github.com/HenrikBengtsson/future.batchtools
2728
BugReports: https://github.com/HenrikBengtsson/future.batchtools/issues
28-
RoxygenNote: 6.1.1
29+
RoxygenNote: 7.1.0
2930
Roxygen: list(markdown = TRUE)

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export(status)
3030
importFrom(batchtools,batchExport)
3131
importFrom(batchtools,batchMap)
3232
importFrom(batchtools,clearRegistry)
33+
importFrom(batchtools,findConfFile)
3334
importFrom(batchtools,findTemplateFile)
3435
importFrom(batchtools,getErrorMessages)
3536
importFrom(batchtools,getLog)

NEWS

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
11
Package: future.batchtools
22
==========================
33

4+
Version: 0.9.0 [2020-04-14]
5+
6+
SIGNIFICANT CHANGES:
7+
8+
* The default number of workers on HPC environments is now 100. To revert
9+
to the previous default of +Inf, see below news entry.
10+
11+
NEW FEATURES:
12+
13+
* It is now possible to configure the default number of workers on the job
14+
queue of an HPC scheduler via either R option 'future.batchtools.workers'
15+
or environment variable 'R_FUTURE_BATCHTOOLS_WORKERS'.
16+
17+
* It is now possible to configure the batchtools registries that are used by
18+
batchtools futures via new argument 'registry' to plan(). This argument
19+
should be a named list of parameters recognized by the 'batchtools' package,
20+
e.g. plan(batchtools_sge, registry = list(...)). For notable example, see
21+
below news entries.
22+
23+
* The default working directory for batchtools futures is the current working
24+
directory of R _when_ the batchtools future is created. This corresponds to
25+
specifying plan(batchtools_nnn, registry = list(work.dir = NULL). Sometimes
26+
it is useful to use a explicit working directory that is guaranteed to be
27+
available on all workers on a shared file system, e.g. plan(batchtools_nnn,
28+
registry = list(work.dir = "~")).
29+
30+
* It is possible to control if and how batchtools should use file compressions
31+
for exported globals and results by specifying batchtools registry parameter
32+
'compress'. For example, to turn off file compression, use
33+
plan(batchtools_nnn, registry = list(compress = FALSE)).
34+
35+
* The default location of the '.future' folder can be controlled by R option
36+
'future.cache.path' or environment variable 'R_FUTURE_CACHE_PATH'.
37+
38+
* batchtools_custom() and BatchtoolsFuture gained argument 'conf.file'.
39+
Using plan(batchtools_custom) will now use any batchtools configuration
40+
file (an R script) found on the batchtools::findConfFile() search path.
41+
42+
DOCUMENTATION:
43+
44+
* Add help("future.batchtools.options") which descriptions R options and
45+
environment variables used specifically by the future.batchtools package.
46+
47+
448
Version: 0.8.1 [2019-09-30]
549

650
BUG FIXES:
@@ -20,7 +64,7 @@ NEW FEATURES:
2064
it because the job was running out of its allocated resources, then a
2165
BatchtoolsFutureError is produced which by default outputs the tail of the
2266
output logged by batchtools. The default number of lines displayed from
23-
the end is now increased to from six to 48 - a number which now can be set
67+
the end is now increased from six to 48 - a number which now can be set
2468
via option 'future.batchtools.expiration.tail'.
2569

2670
* Now a more informative error message is produced if a batchtools *.tmpl
@@ -151,14 +195,14 @@ NEW FEATURES:
151195

152196
BUG FIXES:
153197

154-
* Under plan(batchjobs_*), when being created futures would produce an error
198+
* Under plan(batchtools_*), when being created futures would produce an error
155199
on "all(is.finite(workers)) is not TRUE" due to an outdated sanity check.
156200

157201
SOFTWARE QUALITY:
158202

159203
* TESTS: Added test of future_lapply() for batchtools backends.
160204

161-
* TESTS: Added optional tests for batchjobs_* HPC schedulers listed in
205+
* TESTS: Added optional tests for batchtools_* HPC schedulers listed in
162206
environment variable 'R_FUTURE_TESTS_STRATEGIES'.
163207

164208
CODE REFACTORING:
@@ -184,7 +228,7 @@ Version: 0.2.0 [2017-02-23]
184228
GLOBALS:
185229

186230
* batchtools (>= 0.9.2) now supports exporting objects with any type of names
187-
(previously only possible if they mapped to to strictly valid filenames).
231+
(previously only possible if they mapped to strictly valid filenames).
188232
This allowed me to avoid lots of internal workaround code encoding and
189233
decoding globals.
190234

R/BatchtoolsFuture-class.R

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#' @param substitute Controls whether `expr` should be
99
#' `substitute()`:d or not.
1010
#'
11-
#' @param globals (optional) a logical, a character vector, a named list, or
12-
#' a [Globals][globals::Globals] object. If TRUE, globals are identified by code
11+
#' @param globals (optional) a logical, a character vector, a named list, or a
12+
#' [Globals][globals::Globals] object. If TRUE, globals are identified by code
1313
#' inspection based on `expr` and `tweak` searching from environment
1414
#' `envir`. If FALSE, no globals are used. If a character vector, then
1515
#' globals are identified by lookup based their names `globals` searching
@@ -19,23 +19,29 @@
1919
#' @param label (optional) Label of the future (where applicable, becomes the
2020
#' job name for most job schedulers).
2121
#'
22-
#' @param conf A batchtools configuration environment.
23-
#'
24-
#' @param cluster.functions A batchtools [ClusterFunctions][batchtools::ClusterFunctions]
25-
#' object.
26-
#'
27-
#' @param resources A named list passed to the batchtools template (available
28-
#' as variable `resources`).
22+
#' @param resources (optional) A named list passed to the batchtools template
23+
#' (available as variable `resources`).
2924
#'
3025
#' @param workers (optional) The maximum number of workers the batchtools
3126
#' backend may use at any time. Interactive and "local" backends can only
32-
#' process one future at the time, whereas HPC backends where futures are
33-
#' resolved via separate jobs on a scheduler, the default is to assume an
34-
#' infinite number of workers.
27+
#' process one future at the time (`workers = 1L`), whereas HPC backends,
28+
#' where futures are resolved via separate jobs on a scheduler, can have
29+
#' multiple workers. In the latter, the default is `workers = NULL`, which
30+
#' will resolve to `getOption("future.batchtools.workers")`. If that is not
31+
#' specified, the value of environment variable `R_FUTURE_BATCHTOOLS_WORKERS`
32+
#' will be used. If neither are specified, then the default is `100`.
3533
#'
3634
#' @param finalize If TRUE, any underlying registries are
3735
#' deleted when this object is garbage collected, otherwise not.
3836
#'
37+
#' @param conf.file (optional) A batchtools configuration file.
38+
#'
39+
#' @param cluster.functions (optional) A batchtools
40+
#' [ClusterFunctions][batchtools::ClusterFunctions] object.
41+
#'
42+
#' @param registry (optional) A named list of settings to control the setup
43+
#' of the batchtools registry.
44+
#'
3945
#' @param \ldots Additional arguments passed to [future::Future()].
4046
#'
4147
#' @return A BatchtoolsFuture object
@@ -47,18 +53,32 @@
4753
BatchtoolsFuture <- function(expr = NULL, envir = parent.frame(),
4854
substitute = TRUE,
4955
globals = TRUE, packages = NULL,
50-
label = NULL, cluster.functions = NULL,
51-
resources = list(), workers = NULL,
56+
label = NULL,
57+
resources = list(),
58+
workers = NULL,
5259
finalize = getOption("future.finalize", TRUE),
60+
conf.file = findConfFile(),
61+
cluster.functions = NULL,
62+
registry = list(),
5363
...) {
5464
if (substitute) expr <- substitute(expr)
5565

5666
if (!is.null(label)) label <- as.character(label)
5767

5868
if (!is.null(cluster.functions)) {
5969
stop_if_not(is.list(cluster.functions))
70+
stop_if_not(inherits(cluster.functions, "ClusterFunctions"))
71+
} else if (missing(conf.file)) {
72+
## BACKWARD COMPATILITY: Only when calling BatchtoolsFuture() directly
73+
cluster.functions <- makeClusterFunctionsInteractive(external = FALSE)
74+
} else {
75+
## If 'cluster.functions' is not specified, then 'conf.file' must
76+
## exist
77+
if (!file_test("-f", conf.file)) {
78+
stop("No such batchtools configuration file: ", sQuote(conf.file))
79+
}
6080
}
61-
81+
6282
if (is.function(workers)) workers <- workers()
6383
if (!is.null(workers)) {
6484
stop_if_not(length(workers) >= 1)
@@ -70,6 +90,11 @@ BatchtoolsFuture <- function(expr = NULL, envir = parent.frame(),
7090
}
7191
}
7292

93+
stop_if_not(is.list(registry))
94+
if (length(registry) > 0L) {
95+
stopifnot(!is.null(names(registry)), all(nzchar(names(registry))))
96+
}
97+
7398
stop_if_not(is.list(resources))
7499

75100
## Record globals
@@ -84,10 +109,12 @@ BatchtoolsFuture <- function(expr = NULL, envir = parent.frame(),
84109
future$packages <- unique(c(packages, gp$packages))
85110

86111
## Create batchtools registry
87-
reg <- temp_registry(label = future$label)
88-
if (!is.null(cluster.functions)) { ### FIXME
89-
reg$cluster.functions <- cluster.functions
90-
}
112+
reg <- temp_registry(
113+
label = future$label,
114+
conf.file = conf.file,
115+
cluster.functions = cluster.functions,
116+
config = registry
117+
)
91118
debug <- getOption("future.debug", FALSE)
92119
if (debug) mprint(reg)
93120

@@ -126,13 +153,15 @@ print.BatchtoolsFuture <- function(x, ...) {
126153
## Ask for status once
127154
status <- status(x)
128155
printf("batchtools status: %s\n", paste(sQuote(status), collapse = ", "))
129-
if ("error" %in% status) printf("Error: %s\n", loggedError(x))
156+
if ("error" %in% status) {
157+
printf("Error captured by batchtools: %s\n", loggedError(x))
158+
}
130159

131160
if (is_na(status)) {
132161
printf("batchtools %s: Not found (happens when finished and deleted)\n",
133162
class(reg))
134163
} else {
135-
printf("batchtools Registry:\n ")
164+
printf("batchtools Registry:\n")
136165
printf(" File dir exists: %s\n", file_test("-d", reg$file.dir))
137166
printf(" Work dir exists: %s\n", file_test("-d", reg$work.dir))
138167
try(print(reg))
@@ -504,8 +533,9 @@ await.BatchtoolsFuture <- function(future, cleanup = TRUE,
504533
}
505534
} else if ("error" %in% stat) {
506535
cleanup <- FALSE
507-
msg <- sprintf("BatchtoolsError in %s ('%s'): %s",
508-
class(future)[1], label, loggedError(future))
536+
msg <- sprintf(
537+
"BatchtoolsFutureError for %s ('%s') captured by batchtools: %s",
538+
class(future)[1], label, loggedError(future))
509539
stop(BatchtoolsFutureError(msg, future = future))
510540
} else if ("expired" %in% stat) {
511541
cleanup <- FALSE

0 commit comments

Comments
 (0)