You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DESCRIPTION
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
Package: progressr
2
-
Version: 0.1.4
2
+
Version: 0.1.5
3
3
Title: A Unifying API for Progress Updates
4
4
Description: A minimal API for reporting progress updates upstream. 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.
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.
4
4
@@ -26,7 +26,7 @@ Assume that we have a function `slow_sum()` for adding up the values in a vector
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:
109
109
110
-
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,
111
110
```r
112
111
library(progressr)
112
+
113
+
xs<-1:5
114
+
y_truth<- lapply(xs, slow_sqrt)
115
+
113
116
with_progress({
114
-
y<-plyr::l_ply(1:5, function(x, ...) {
115
-
Sys.sleep(1)
117
+
p<- progressor(along=xs)
118
+
y<- lapply(xs, function(x) {
119
+
p(sprintf("x=%g", x))
120
+
Sys.sleep(0.1)
116
121
sqrt(x)
117
-
}, .progress="progressr")
122
+
})
123
+
})
124
+
125
+
library(foreach)
126
+
with_progress({
127
+
p<- progressor(along=xs)
128
+
y<- foreach(x=xs) %do% {
129
+
p(sprintf("x=%g", x))
130
+
Sys.sleep(0.1)
131
+
sqrt(x)
132
+
}
133
+
})
134
+
135
+
library(purrr)
136
+
with_progress({
137
+
p<- progressor(along=xs)
138
+
y<- map(xs, function(x) {
139
+
p(sprintf("x=%g", x))
140
+
Sys.sleep(0.1)
141
+
sqrt(x)
142
+
})
118
143
})
119
-
## |===================== | 40%
120
144
```
121
145
122
146
123
-
### The future framework
147
+
### Parallel processing and progress updates
148
+
149
+
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]**.
150
+
151
+
152
+
#### future_lapply() - parallel lapply()
124
153
125
-
The **[future]** framework has built-in support for the kind of progression updates produced by the **progressr** package. 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:
154
+
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:
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:
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
+
248
+
146
249
147
250
## Roadmap
148
251
@@ -201,3 +304,7 @@ To debug progress updates, use:
0 commit comments