Skip to content

Commit 22f0f33

Browse files
author
Valerie Obenchain
committed
BiocParallelParam:
- change default for 'logdir' and 'resultdir' from character() to NA_character_ - consolidate show method git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/BiocParallel@103866 bc3139a8-67e5-0310-9ffc-ced21a209358
1 parent f3ad279 commit 22f0f33

13 files changed

+86
-80
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: BiocParallel
22
Type: Package
33
Title: Bioconductor facilities for parallel evaluation
4-
Version: 1.3.11
4+
Version: 1.3.12
55
Authors@R: c(
66
person("Bioconductor Package Maintainer",
77
email="[email protected]", role="cre"),

R/BatchJobsParam-class.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@
4848
show = function() {
4949
## TODO more output
5050
callSuper()
51-
cat(" bpisup:", bpisup(.self), "\n")
52-
cat(" bpprogressbar:", bpprogressbar(.self), "\n")
53-
cat("cleanup:", .self$cleanup, "\n")
51+
cat(" bpworkers:", bpworkers(.self),
52+
"; bpisup:", bpisup(.self), "\n", sep="")
53+
cat(" bpcatchErrors:", bpcatchErrors(.self),
54+
"; bpstopOnError:", bpstopOnError(.self), "\n", sep="")
55+
cat(" bpprogressbar:", bpprogressbar(.self), "\n", sep="")
56+
cat(" cleanup:", .self$cleanup, "\n", sep="")
5457
})
5558
)
5659

R/BiocParallelParam-class.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
},
2525
show = function() {
2626
cat("class:", class(.self), "\n")
27-
cat(" bpworkers:", bpworkers(.self), "\n")
28-
cat(" bptasks:", bptasks(.self), "\n")
29-
cat(" bpcatchErrors:", bpcatchErrors(.self), "\n")
30-
cat(" bpstopOnError:", bpstopOnError(.self), "\n")
3127
})
3228
)
3329

R/DoparParam-class.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
methods=list(
1414
show = function() {
1515
callSuper()
16+
cat(" bpworkers:", bpworkers(.self),
17+
"; bpisup:", bpisup(.self), "\n", sep="")
1618
})
1719
)
1820

R/MulticoreParam-class.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ multicoreWorkers <- function() {
2525

2626
MulticoreParam <- function(workers=multicoreWorkers(),
2727
tasks=0L, catch.errors=TRUE, stop.on.error=FALSE,
28-
progressbar=FALSE, log=FALSE, threshold="INFO", logdir=character(),
29-
resultdir=character(), ...)
28+
progressbar=FALSE, log=FALSE, threshold="INFO", logdir=NA_character_,
29+
resultdir=NA_character_, ...)
3030
{
3131
if (.Platform$OS.type == "windows")
3232
warning("MulticoreParam not supported on Windows. Using SerialParam().")

R/SerialParam-class.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
},
2222
show = function() {
2323
callSuper()
24-
cat("bplog:", bplog(.self), "\n")
25-
cat("bpthreshold:", names(bpthreshold(.self)), "\n")
24+
cat(" bplog:", bplog(.self),
25+
"; bpthreshold:", names(bpthreshold(.self)), "\n", sep="")
2626
})
2727
)
2828

R/SnowParam-class.R

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ setOldClass(c("NULLcluster", "cluster"))
4343
.controlled=TRUE,
4444
log=FALSE,
4545
threshold="INFO",
46-
logdir=character(),
47-
resultdir=character())
46+
logdir=NA_character_,
47+
resultdir=NA_character_)
4848
{
4949
initFields(.controlled=.controlled,
5050
log=log, threshold=threshold,
@@ -53,20 +53,24 @@ setOldClass(c("NULLcluster", "cluster"))
5353
},
5454
show = function() {
5555
callSuper()
56-
cat(" bpisup:", bpisup(.self), "\n")
57-
cat(" bplog:", bplog(.self), "\n")
58-
cat(" bpthreshold:", names(bpthreshold(.self)), "\n")
59-
cat(" bplogdir:", bplogdir(.self), "\n")
60-
cat(" bpresultdir:", bpresultdir(.self), "\n")
61-
cat(" bpprogressbar:", bpprogressbar(.self), "\n")
56+
cat(" bpworkers:", bpworkers(.self),
57+
"; bptasks:", bptasks(.self),
58+
"; bpisup:", bpisup(.self), "\n", sep="")
59+
cat(" bplog:", bplog(.self),
60+
"; bpthreshold:", names(bpthreshold(.self)),
61+
"; bplogdir:", bplogdir(.self),
62+
"; bpprogressbar:", bpprogressbar(.self), "\n", sep="")
63+
cat(" bpcatchErrors:", bpcatchErrors(.self),
64+
"; bpstopOnError:", bpstopOnError(.self), "\n", sep="")
65+
cat(" bpresultdir:", bpresultdir(.self), "\n", sep="")
6266
cat("cluster type:", .clusterargs$type, "\n")
6367
})
6468
)
6569

6670
SnowParam <- function(workers=snowWorkers(), type=c("SOCK", "MPI", "FORK"),
6771
tasks=0L, catch.errors=TRUE, stop.on.error=FALSE,
6872
progressbar=FALSE, log=FALSE, threshold="INFO",
69-
logdir=character(), resultdir=character(), ...)
73+
logdir=NA_character_, resultdir=NA_character_, ...)
7074
{
7175
type <- match.arg(type)
7276
if (!type %in% c("SOCK", "MPI", "FORK"))
@@ -100,11 +104,11 @@ SnowParam <- function(workers=snowWorkers(), type=c("SOCK", "MPI", "FORK"),
100104
msg <- c(msg, "'bplog(BPPARAM)' must be logical(1)")
101105

102106
dir <- bplogdir(object)
103-
if (length(dir) > 0L && !is(dir, "character"))
107+
if (length(dir) > 1L || !is(dir, "character"))
104108
msg <- c(msg, "'bplogdir(BPPARAM)' must be character(1)")
105109

106-
if (length(dir) > 0L && !bplog(object))
107-
msg <- c(msg, "'bplog(BPPARAM)' must be TRUE when 'logdir' is provided")
110+
if (!is.na(dir) && !bplog(object))
111+
msg <- c(msg, "'log' must be TRUE when 'logdir' is provided")
108112
msg
109113
}
110114

R/SnowParam-utils.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ bprunMPIslave <- function() {
179179
bpdynamicClusterApply <- function(cl, fun, n, argfun, BPPARAM, progress)
180180
{
181181
## result output
182-
if (length(resdir <- bpresultdir(BPPARAM)))
182+
if (!is.na(resdir <- bpresultdir(BPPARAM)))
183183
BatchJobs:::checkDir(resdir)
184184

185185
## log connection
186-
if (bplog(BPPARAM) && length(bplogdir(BPPARAM))) {
186+
if (bplog(BPPARAM) && !is.na(bplogdir(BPPARAM))) {
187187
con <- .bplogSetUp(bplogdir(BPPARAM))
188188
on.exit({
189189
sink(NULL, type = "message")
@@ -212,19 +212,20 @@ bpdynamicClusterApply <- function(cl, fun, n, argfun, BPPARAM, progress)
212212
if (bplog(BPPARAM))
213213
.bpwriteLog(con, d)
214214
## stop on error
215+
## FIXME: kill other workers
215216
if (bpstopOnError(BPPARAM) && !d$value$success) {
216217
warning(paste0("error in task ", d$value$tag))
217218
return(val)
218219
}
219220
j <- i + min(n, p)
220221
if (j <= n)
221222
submit(d$node, j)
222-
if (length(resdir))
223+
if (!is.na(resdir))
223224
save(value, file=paste0(resdir, "/TASK", d$value$tag, ".Rda"))
224225
}
225226
}
226227

227-
if (length(bpresultdir(BPPARAM)))
228+
if (!is.na(resdir))
228229
NULL
229230
else val
230231
}
@@ -277,11 +278,11 @@ bpdynamicClusterIterate <- function(cl, fun, ITER, REDUCE, init,
277278
stop("REDUCE must be provided when 'init' is given")
278279

279280
## result output
280-
if (length(resdir <- bpresultdir(BPPARAM)))
281+
if (!is.na(resdir <- bpresultdir(BPPARAM)))
281282
BatchJobs:::checkDir(resdir)
282283

283284
## log connection
284-
if (bplog(BPPARAM) && length(bplogdir(BPPARAM))) {
285+
if (bplog(BPPARAM) && !is.na(bplogdir(BPPARAM))) {
285286
con <- .bplogSetUp(bplogdir(BPPARAM))
286287
on.exit({
287288
sink(NULL, type = "message")
@@ -350,7 +351,7 @@ bpdynamicClusterIterate <- function(cl, fun, ITER, REDUCE, init,
350351
}
351352

352353
## results
353-
if (length(bpresultdir(BPPARAM))) {
354+
if (!is.na(resdir)) {
354355
NULL
355356
} else {
356357
if (missing(REDUCE))

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Possible TODO
1212
+ lazy DoparParam
1313
+ SnowParam support for setSeed, recursive, cleanup
1414
+ subset SnowParam
15-
+ elaborate SnowParam for SnowSocketParam, SnowForkParam, SnowMpiParam, ...
16-
+ MulticoreParam on Windows
1715

1816
DONE
1917
----
@@ -23,6 +21,8 @@ DONE
2321
+ Make functions generics
2422
+ parLapply-like function
2523
+ Short vignette
24+
+ elaborate SnowParam for SnowSocketParam, SnowForkParam, SnowMpiParam, ...
25+
+ MulticoreParam on Windows
2626

2727
github notes
2828
------------

man/BiocParallelParam-class.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@
146146
Gets or sets the parallel \code{bpbackend}. Not all back-ends can
147147
be retrieved; see \code{showMethods("backend")}.
148148
}
149+
\item{progressbar}{
150+
\code{logical(1)} Enable progress bar. Applicable to
151+
\code{BatchJobsParam}, \code{SnowParam} and \code{MulticoreParam} only.
152+
}
149153
}
150154
}
151155

0 commit comments

Comments
 (0)