Skip to content

Commit b0a62fa

Browse files
Merge branch 'release/0.4.0'
2 parents 469fb16 + 8452b3a commit b0a62fa

File tree

105 files changed

+1336
-380
lines changed

Some content is hidden

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

105 files changed

+1336
-380
lines changed

.Rbuildignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@ Rplots.pdf$
5858
^.ghi
5959
^.issues
6060
^last.dump*
61-
62-
vignettes/
63-
^.*.gif$
61+
^imgs
62+
^.*.bob$

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.local
55
inst/doc
66
.make/README.md.rsp
7+

.make/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ win-builder-devel: $(R_OUTDIR)/$(PKG_TARBALL)
423423
win-builder-release: $(R_OUTDIR)/$(PKG_TARBALL)
424424
curl -v -T $? ftp://anonymous@$(WIN_BUILDER)/R-release/
425425

426+
win-builder-oldrelease: $(R_OUTDIR)/$(PKG_TARBALL)
427+
curl -v -T $? ftp://anonymous@$(WIN_BUILDER)/R-oldrelease/
428+
426429
win-builder: win-builder-devel win-builder-release
427430

428431

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ matrix:
4343
- Rscript -e 'covr::codecov(quiet=FALSE)'
4444
env: NB='w/ covr' ## Just a label
4545

46+
r_github_packages:
47+
- HenrikBengtsson/progressr@develop
48+
4649
notifications:
4750
email:
4851
on_success: change

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: progressr
2-
Version: 0.3.0
2+
Version: 0.4.0
33
Title: A Unifying API for Progress Updates
4-
Description: A minimal, unifying API for scripts and packages to report progress updates. By design, it allows the developer to focus on what progress that should be reported on, without having to worry about how to present it. The end user has full control on how, where, and when to render these progress updates, e.g. in the terminal using 'utils::txtProgressBar()' or 'progress::progress_bar()', in a graphical user interface using 'utils::winProgressBar()', 'tcltk::tkProgressBar()' or 'shiny::withProgress()', via the speakers using 'beep::beepr()', or on a file system via the size of a file. Anyone can add additional, customized, progression handlers. The 'progressr' package uses R's condition framework for signaling progress updated. Because of this, progress can be reported from almost anywhere in R, e.g. from classical for and while loops, from map-reduce APIs like the 'lapply()' family of functions, 'purrr', 'plyr', and 'foreach'. It will also work with parallel processing via the 'future' framework, e.g. 'future.apply::future_lapply()', 'furrr::map()', and 'foreach' with 'doFuture'.
4+
Description: A minimal, unifying API for scripts and packages to report progress updates from anywhere including when using parallel processing. The package is designed such that the developer can to focus on what progress should be reported on without having to worry about how to present it. The end user has full control of how, where, and when to render these progress updates, e.g. in the terminal using 'utils::txtProgressBar()' or 'progress::progress_bar()', in a graphical user interface using 'utils::winProgressBar()', 'tcltk::tkProgressBar()' or 'shiny::withProgress()', via the speakers using 'beep::beepr()', or on a file system via the size of a file. Anyone can add additional, customized, progression handlers. The 'progressr' package uses R's condition framework for signaling progress updated. Because of this, progress can be reported from almost anywhere in R, e.g. from classical for and while loops, from map-reduce APIs like the 'lapply()' family of functions, 'purrr', 'plyr', and 'foreach'. It will also work with parallel processing via the 'future' framework, e.g. 'future.apply::future_lapply()', 'furrr::map()', and 'foreach' with 'doFuture'. The package is compatible with Shiny applications.
55
Authors@R: c(
66
person("Henrik", "Bengtsson", role=c("aut", "cre", "cph"),
77
email = "[email protected]"))
@@ -22,7 +22,10 @@ Suggests:
2222
future (>= 1.16.0),
2323
future.apply,
2424
furrr,
25-
shiny
25+
shiny,
26+
commonmark,
27+
tools
28+
VignetteBuilder: progressr
2629
URL: https://github.com/HenrikBengtsson/progressr
2730
BugReports: https://github.com/HenrikBengtsson/progressr/issues
2831
RoxygenNote: 7.0.2

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
include .make/Makefile
2+
3+
vignettes/progressr-intro.md: OVERVIEW.md vignettes/incl/clean.css
4+
sed -i '/%\\Vignette/!d' $@
5+
echo "<!-- DO NOT EDIT THIS FILE! Edit 'OVERVIEW.md' instead and then rebuild this file with 'make vigs' -->" >> $@
6+
cat $< >> $@
7+
8+
vigs: vignettes/progressr-intro.md

NAMESPACE

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
S3method(print,progression)
44
S3method(print,progression_handler)
55
S3method(print,progressor)
6-
export(ascii_alert_handler)
7-
export(beepr_handler)
8-
export(debug_handler)
9-
export(filesize_handler)
6+
export(handler_ascii_alert)
7+
export(handler_beepr)
8+
export(handler_debug)
9+
export(handler_filesize)
10+
export(handler_newline)
11+
export(handler_notifier)
12+
export(handler_pbmcapply)
13+
export(handler_progress)
14+
export(handler_shiny)
15+
export(handler_tkprogressbar)
16+
export(handler_txtprogressbar)
17+
export(handler_winprogressbar)
1018
export(handlers)
1119
export(make_progression_handler)
12-
export(newline_handler)
13-
export(notifier_handler)
14-
export(pbmcapply_handler)
1520
export(progress)
1621
export(progress_aggregator)
17-
export(progress_handler)
1822
export(progress_progressr)
1923
export(progression)
2024
export(progressor)
21-
export(shiny_handler)
2225
export(slow_sum)
23-
export(tkprogressbar_handler)
24-
export(txtprogressbar_handler)
25-
export(winprogressbar_handler)
2626
export(withProgressShiny)
2727
export(with_progress)
2828
export(without_progress)

NEWS

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
Package: progressr
22
==================
33

4+
Version: 0.4.0 [2020-01-22]
5+
6+
SIGNIFICANT CHANGES:
7+
8+
* All progression handler function have been renamed from <name>_handler()
9+
to handler_<name>() to make it easier to use autocompletion on them.
10+
11+
412
Version: 0.3.0 [2020-01-20]
513

614
NEW FEATURES:
715

8-
* progressor() gained offset and slope arguments 'a' and 'b', and functional
9-
argument 'transform'.
16+
* progressor() gained arguments 'offset' and 'scale', and 'transform'.
1017

1118
* handlers() gained argument 'append' to make it easier to append handlers.
1219

OVERVIEW.md

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
![Life cycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)
1+
![Life cycle: experimental](imgs/lifecycle-experimental-orange.svg)
22

33
The **[progressr]** package provides a minimal API for reporting progress updates in [R](https://www.r-project.org/). The design is to separate the representation of progress updates from how they are presented. What type of progress to signal is controlled by the developer. How these progress updates are rendered is controlled by the end user. For instance, some users may prefer visual feedback such as a horizontal progress bar in the terminal, whereas others may prefer auditory feedback.
44

55

6-
<img src="incl/three_in_chinese.gif" alt="Three strokes writing three in Chinese" style="float: right; margin-right: 1ex; margin-left: 1ex;"/>
6+
<img src="imgs/three_in_chinese.gif" alt="Three strokes writing three in Chinese" style="float: right; margin-right: 1ex; margin-left: 1ex;"/>
77

88
Design motto:
99

@@ -105,13 +105,15 @@ handlers("txtprogressbar", "beepr")
105105

106106
## Support for progressr elsewhere
107107

108-
Note that progression updates by **progressr** is designed to work out of the box for any _sequential_ iterator framework in R. Here is an set of examples for the most common ones:
108+
Note that progression updates by **progressr** is designed to work out of the box for any _sequential_ iterator framework in R. Below is an set of examples for the most common ones.
109+
110+
111+
### Base R Apply Functions
109112

110113
```r
111114
library(progressr)
112115

113116
xs <- 1:5
114-
y_truth <- lapply(xs, slow_sqrt)
115117

116118
with_progress({
117119
p <- progressor(along = xs)
@@ -121,8 +123,17 @@ with_progress({
121123
sqrt(x)
122124
})
123125
})
126+
# |===================== | 40%
127+
```
128+
129+
### The foreach package
124130

131+
```r
125132
library(foreach)
133+
library(progressr)
134+
135+
xs <- 1:5
136+
126137
with_progress({
127138
p <- progressor(along = xs)
128139
y <- foreach(x = xs) %do% {
@@ -131,8 +142,17 @@ with_progress({
131142
sqrt(x)
132143
}
133144
})
145+
# |===================== | 40%
146+
```
134147

148+
### The purrr package
149+
150+
```r
135151
library(purrr)
152+
library(progressr)
153+
154+
xs <- 1:5
155+
136156
with_progress({
137157
p <- progressor(along = xs)
138158
y <- map(xs, function(x) {
@@ -141,15 +161,34 @@ with_progress({
141161
sqrt(x)
142162
})
143163
})
164+
# |===================== | 40%
144165
```
145166

167+
### The plyr package
168+
169+
The functions in the [**plyr**](https://cran.r-project.org/package=plyr) package take argument `.progress`, which can be used to produce progress updates. To have them generate **progressr** 'progression' updates, use `.progress = "progressr"`. For example,
170+
```r
171+
library(plyr)
172+
library(progressr)
146173

147-
### Parallel processing and progress updates
174+
xs <- 1:5
175+
176+
with_progress({
177+
y <- llply(xs, function(x, ...) {
178+
Sys.sleep(0.1)
179+
sqrt(x)
180+
}, .progress = "progressr")
181+
})
182+
# |===================== | 40%
183+
```
184+
185+
186+
## Parallel processing and progress updates
148187

149188
The **[future]** framework, which provides a unified API for parallel and distributed processing in R, has built-in support for the kind of progression updates produced by the **progressr** package. This means that you can use it with for instance **[future.apply]**, **[furrr]**, and **[foreach]** with **[doFuture]**.
150189

151190

152-
#### future_lapply() - parallel lapply()
191+
### future_lapply() - parallel lapply()
153192

154193
Here is an example that uses `future_lapply()` of the **[future.apply]** package to parallelize on the local machine while at the same time signaling progression updates:
155194

@@ -174,7 +213,7 @@ with_progress({
174213
```
175214

176215

177-
#### foreach() with doFuture
216+
### foreach() with doFuture
178217

179218
Here is an example that uses `foreach()` of the **[foreach]** package to parallelize on the local machine (via **[doFuture]**) while at the same time signaling progression updates:
180219

@@ -200,7 +239,7 @@ with_progress({
200239
```
201240

202241

203-
#### future_map() - parallel purrr::map()
242+
### future_map() - parallel purrr::map()
204243

205244
```r
206245
library(furrr)
@@ -225,26 +264,7 @@ with_progress({
225264

226265
### The plyr package
227266

228-
The functions in the [**plyr**](https://cran.r-project.org/package=plyr) package take argument `.progress`, which can be used to produce progress updates. To have them generate **progressr** 'progression' updates, use `.progress = "progressr"`. For example,
229-
```r
230-
library(plyr)
231-
library(progressr)
232-
233-
xs <- 1:5
234-
235-
with_progress({
236-
y <- l_ply(xs, function(x, ...) {
237-
Sys.sleep(6.0-x)
238-
sqrt(x)
239-
}, .progress = "progressr")
240-
})
241-
## |===================== | 40%
242-
```
243-
244-
_Comment_: This also works when using `.parallel = TRUE` with a **[foreach]** parallel-backend such as **[doParallel]** or **[doFuture]** registered.
245-
246-
247-
267+
Unfortunately, when using `.parallel = TRUE`, the **plyr** package resets `.progress` to the default `"none"` internally regardless how we set `.progress`. This prevents **progressr** progression updates from being used with _parallel_ **plyr**. If it was not for this forced reset, using `doFuture::registerDoFuture()` with `.parallel = TRUE` and `.progress = "progressr"` would indeed have reported on progress updates also when **plyr** runs in parallel. See <https://github.com/HenrikBengtsson/progressr/issues/70> for a hack that works around this limitation.
248268

249269

250270
## Roadmap
@@ -271,7 +291,7 @@ When using the **progressr** package, progression updates are communicated via R
271291

272292

273293

274-
![](vignettes/figures/slow_sum.svg)
294+
![](imgs/slow_sum.svg)
275295

276296
_Figure: Sequence diagram illustrating how signaled progression conditions are captured by `with_progress()` and relayed to the two progression handlers 'progress' (a progress bar in the terminal) and 'beepr' (auditory) that the end user has chosen._
277297

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Auditory Progression Feedback
1+
#' Progression Handler: Progress Reported as ASCII BEL Symbols (Audio or Blink) in the Terminal
22
#'
33
#' A progression handler based on `cat("\a", file=stderr())`.
44
#'
@@ -11,10 +11,10 @@
1111
#'
1212
#' @param \ldots Additional arguments passed to [make_progression_handler()].
1313
#'
14-
#' @example incl/ascii_alert_handler.R
14+
#' @example incl/handler_ascii_alert.R
1515
#'
1616
#' @export
17-
ascii_alert_handler <- function(symbol = "\a", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.auditory", 5.0), target = c("terminal", "audio"), ...) {
17+
handler_ascii_alert <- function(symbol = "\a", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.auditory", 5.0), target = c("terminal", "audio"), ...) {
1818
reporter <- local({
1919
list(
2020
update = function(config, state, progression, ...) {

0 commit comments

Comments
 (0)