Skip to content

Commit 011a30b

Browse files
Mention warning(..., immediate.=TRUE) and 'interval' for handlers
1 parent 2099cb0 commit 011a30b

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

OVERVIEW.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ handlers(list(
123123
))
124124
```
125125

126-
With this construct, we can make adjustments to the default behavior of these progress handlers. For example, we can configure the `width` and the `complete` arguments of `progress::progress_bar$new()` and changing the `finish` sound of the **beepr** handler as:
126+
With this construct, we can make adjustments to the default behavior of these progress handlers. For example, we can configure the `width` and the `complete` arguments of `progress::progress_bar$new()`, and tell **beepr** to use a different `finish` sound and generate sounds at most every two seconds by setting:
127127

128128
```r
129129
handlers(list(
130130
handler_progress(width = 40, complete = "+"),
131-
handler_beepr(finish = 9)
131+
handler_beepr(finish = 9, interval = 2.0)
132132
))
133133
```
134134

@@ -199,6 +199,8 @@ Calculating the square root of 2
199199
This works because `with_progress()` will briefly buffer any output internally and only release it when the next progress update is received just before the progress is re-rendered in the terminal. This is why you see a two second delay when running the above example. Note that, if we use progress handlers that do not output to the terminal, such as `handlers("beepr")`, then output does not have to be buffered and will appear immediately.
200200

201201

202+
_Comment_: When signaling a warning using `warning(msg, immediate. = TRUE)` the message is immediately outputted to the standard-error stream. However, this is not possible to emulate when warnings are intercepted using calling handlers, which are used by `with_progress()`. This is a limitation of R that cannot be worked around. Because of this, the above call will behave the same as `warning(msg)` - that is, all warnings will be buffered by R internally and released only when all computations are done.
203+
202204

203205
## Support for progressr elsewhere
204206

@@ -390,6 +392,7 @@ with_progress({
390392
sqrt(x)
391393
}, .parallel = TRUE)
392394
})
395+
## [=================>-----------------------------] 40% x=2
393396
```
394397

395398
_Note:_ Although **progressr** implements support for using `.progress = "progressr"` with **plyr**, unfortunately, this will _not_ work when using `.parallel = TRUE`. This is because **plyr** resets `.progress` to the default `"none"` internally regardless how we set `.progress`. See <https://github.com/HenrikBengtsson/progressr/issues/70> for details and a hack that works around this limitation.

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ handlers(list(
125125
))
126126
```
127127

128-
With this construct, we can make adjustments to the default behavior of these progress handlers. For example, we can configure the `width` and the `complete` arguments of `progress::progress_bar$new()` and changing the `finish` sound of the **beepr** handler as:
128+
With this construct, we can make adjustments to the default behavior of these progress handlers. For example, we can configure the `width` and the `complete` arguments of `progress::progress_bar$new()`, and tell **beepr** to use a different `finish` sound and generate sounds at most every two seconds by setting:
129129

130130
```r
131131
handlers(list(
132132
handler_progress(width = 40, complete = "+"),
133-
handler_beepr(finish = 9)
133+
handler_beepr(finish = 9, interval = 2.0)
134134
))
135135
```
136136

@@ -201,6 +201,8 @@ Calculating the square root of 2
201201
This works because `with_progress()` will briefly buffer any output internally and only release it when the next progress update is received just before the progress is re-rendered in the terminal. This is why you see a two second delay when running the above example. Note that, if we use progress handlers that do not output to the terminal, such as `handlers("beepr")`, then output does not have to be buffered and will appear immediately.
202202

203203

204+
_Comment_: When signaling a warning using `warning(msg, immediate. = TRUE)` the message is immediately outputted to the standard-error stream. However, this is not possible to emulate when warnings are intercepted using calling handlers, which are used by `with_progress()`. This is a limitation of R that cannot be worked around. Because of this, the above call will behave the same as `warning(msg)` - that is, all warnings will be buffered by R internally and released only when all computations are done.
205+
204206

205207
## Support for progressr elsewhere
206208

@@ -392,6 +394,7 @@ with_progress({
392394
sqrt(x)
393395
}, .parallel = TRUE)
394396
})
397+
## [=================>-----------------------------] 40% x=2
395398
```
396399

397400
_Note:_ Although **progressr** implements support for using `.progress = "progressr"` with **plyr**, unfortunately, this will _not_ work when using `.parallel = TRUE`. This is because **plyr** resets `.progress` to the default `"none"` internally regardless how we set `.progress`. See <https://github.com/HenrikBengtsson/progressr/issues/70> for details and a hack that works around this limitation.

vignettes/progressr-intro.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ handlers(list(
132132
))
133133
```
134134

135-
With this construct, we can make adjustments to the default behavior of these progress handlers. For example, we can configure the `width` and the `complete` arguments of `progress::progress_bar$new()` and changing the `finish` sound of the **beepr** handler as:
135+
With this construct, we can make adjustments to the default behavior of these progress handlers. For example, we can configure the `width` and the `complete` arguments of `progress::progress_bar$new()`, and tell **beepr** to use a different `finish` sound and generate sounds at most every two seconds by setting:
136136

137137
```r
138138
handlers(list(
139139
handler_progress(width = 40, complete = "+"),
140-
handler_beepr(finish = 9)
140+
handler_beepr(finish = 9, interval = 2.0)
141141
))
142142
```
143143

@@ -208,6 +208,8 @@ Calculating the square root of 2
208208
This works because `with_progress()` will briefly buffer any output internally and only release it when the next progress update is received just before the progress is re-rendered in the terminal. This is why you see a two second delay when running the above example. Note that, if we use progress handlers that do not output to the terminal, such as `handlers("beepr")`, then output does not have to be buffered and will appear immediately.
209209

210210

211+
_Comment_: When signaling a warning using `warning(msg, immediate. = TRUE)` the message is immediately outputted to the standard-error stream. However, this is not possible to emulate when warnings are intercepted using calling handlers, which are used by `with_progress()`. This is a limitation of R that cannot be worked around. Because of this, the above call will behave the same as `warning(msg)` - that is, all warnings will be buffered by R internally and released only when all computations are done.
212+
211213

212214
## Support for progressr elsewhere
213215

@@ -399,6 +401,7 @@ with_progress({
399401
sqrt(x)
400402
}, .parallel = TRUE)
401403
})
404+
## [=================>-----------------------------] 40% x=2
402405
```
403406

404407
_Note:_ Although **progressr** implements support for using `.progress = "progressr"` with **plyr**, unfortunately, this will _not_ work when using `.parallel = TRUE`. This is because **plyr** resets `.progress` to the default `"none"` internally regardless how we set `.progress`. See <https://github.com/HenrikBengtsson/progressr/issues/70> for details and a hack that works around this limitation.

0 commit comments

Comments
 (0)