Skip to content

Commit 965a039

Browse files
README: Add gif
1 parent 1fcae01 commit 965a039

File tree

5 files changed

+56
-20
lines changed

5 files changed

+56
-20
lines changed

OVERVIEW.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
![Lifecycle:maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)
1+
![Life cycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.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

5+
6+
<img src="incl/three_in_chinese.gif" alt="Three strokes writing three in Chinese" style="float: right; margin-right: 1ex; margin-left: 1ex;"/>
7+
58
Design motto:
69

710
> The developer is responsible for providing progress updates but it's only the end user who decides if, when, and how progress should be presented. No exceptions will be allowed.
811
12+
913
## Two Minimal APIs
1014

1115
| Developer's API | End-user's API |
@@ -15,6 +19,7 @@ Design motto:
1519
| | `options(progressr.*=...)` |
1620

1721

22+
1823
## A simple example
1924

2025
Assume that we have a function `slow_sum()` for adding up the values in a vector. It is so slow, that we like to provide progress updates to whoever might be interested in it. With the **progressr** package, this can be done as:
@@ -59,7 +64,7 @@ To get progress updates, we can call it as:
5964

6065
## Customizing how progress is reported
6166

62-
The default is to present progress via `utils::txtProgressBar()`, which is available on all R installations. To change the default, to, say, `progress_bar()` by the **[progress]** package, set the following R option(\*):
67+
The default is to present progress via `utils::txtProgressBar()`, which is available on all R installations. To change the default, to, say, `progress_bar()` by the **[progress]** package, set:
6368

6469
```r
6570
handlers("progress")
@@ -70,6 +75,9 @@ This progress handler will present itself as:
7075
[==================>---------------------------] 40% Added 4
7176
```
7277

78+
To set the default progress handler(s) in all your R sessions, call `progressr::handlers(...)` in your <code>~/.Rprofile</code> file. An alternative, which avoids loading the **progressr** package if never used, is to set `options(progressr.handlers = progress_handler)`.
79+
80+
7381

7482
### Auditory progress updates
7583

@@ -114,7 +122,7 @@ with_progress({
114122

115123
### The future framework
116124

117-
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:
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:
118126

119127
```r
120128
library(future.apply)
@@ -162,7 +170,7 @@ When using the **progressr** package, progression updates are communicated via R
162170

163171
![](vignettes/figures/slow_sum.svg)
164172

165-
_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 choosen._
173+
_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._
166174

167175

168176
### Debugging
@@ -186,10 +194,6 @@ To debug progress updates, use:
186194
[13:33:50.776] (1.033s => +0.001s) shutdown: 10/10 (+0) '' {clear=TRUE, enabled=TRUE, status=ok}
187195
```
188196

189-
<small>
190-
(*) To set the default progress handler in all your R sessions, set this option in your <code>~/.Rprofile</code> file.
191-
</small>
192-
193197

194198

195199
[progressr]: https://github.com/HenrikBengtsson/progressr/

R/options.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,24 @@
6262
#'
6363
#'
6464
#' @seealso
65-
#' To set \R options when \R starts (even before the \pkg{progressr} package is loaded), see the \link[base]{Startup} help page. The \href{https://cran.r-project.org/package=startup}{\pkg{startup}} package provides a friendly mechanism for configurating \R's startup process.
65+
#' To set \R options when \R starts (even before the \pkg{progressr} package is loaded), see the \link[base]{Startup} help page. The \href{https://cran.r-project.org/package=startup}{\pkg{startup}} package provides a friendly mechanism for configuring \R at startup.
6666
#'
6767
#' @aliases
68+
#' progressr.clear
6869
#' progressr.debug
70+
#' progressr.delay
71+
#' progressr.delay_stdout progressr.delay_conditions
72+
#' progressr.enable progressr.enable_after
73+
#' progressr.interval
74+
#' progressr.intrusiveness
75+
#' progressr.intrusiveness.auditory
76+
#' progressr.intrusiveness.debug
77+
#' progressr.intrusiveness.file
78+
#' progressr.intrusiveness.gui
79+
#' progressr.intrusiveness.notifier
80+
#' progressr.intrusiveness.terminal
6981
#' progressr.handlers
70-
#' progressr.clear
82+
#' progressr.times
7183
#'
7284
#' @keywords internal
7385
#' @name progressr.options

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# progressr: A Unifying API for Progress Updates
22

3-
![Lifecycle:maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)
3+
![Life cycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)
44

55
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.
66

7+
8+
<img src="incl/three_in_chinese.gif" alt="Three strokes writing three in Chinese" style="float: right; margin-right: 1ex; margin-left: 1ex;"/>
9+
710
Design motto:
811

912
> The developer is responsible for providing progress updates but it's only the end user who decides if, when, and how progress should be presented. No exceptions will be allowed.
1013
14+
1115
## Two Minimal APIs
1216

1317
| Developer's API | End-user's API |
@@ -17,6 +21,7 @@ Design motto:
1721
| | `options(progressr.*=...)` |
1822

1923

24+
2025
## A simple example
2126

2227
Assume that we have a function `slow_sum()` for adding up the values in a vector. It is so slow, that we like to provide progress updates to whoever might be interested in it. With the **progressr** package, this can be done as:
@@ -61,7 +66,7 @@ To get progress updates, we can call it as:
6166

6267
## Customizing how progress is reported
6368

64-
The default is to present progress via `utils::txtProgressBar()`, which is available on all R installations. To change the default, to, say, `progress_bar()` by the **[progress]** package, set the following R option(\*):
69+
The default is to present progress via `utils::txtProgressBar()`, which is available on all R installations. To change the default, to, say, `progress_bar()` by the **[progress]** package, set:
6570

6671
```r
6772
handlers("progress")
@@ -72,6 +77,9 @@ This progress handler will present itself as:
7277
[==================>---------------------------] 40% Added 4
7378
```
7479

80+
To set the default progress handler(s) in all your R sessions, call `progressr::handlers(...)` in your <code>~/.Rprofile</code> file. An alternative, which avoids loading the **progressr** package if never used, is to set `options(progressr.handlers = progress_handler)`.
81+
82+
7583

7684
### Auditory progress updates
7785

@@ -116,7 +124,7 @@ with_progress({
116124

117125
### The future framework
118126

119-
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:
127+
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:
120128

121129
```r
122130
library(future.apply)
@@ -164,7 +172,7 @@ When using the **progressr** package, progression updates are communicated via R
164172

165173
![](vignettes/figures/slow_sum.svg)
166174

167-
_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 choosen._
175+
_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._
168176

169177

170178
### Debugging
@@ -188,10 +196,6 @@ To debug progress updates, use:
188196
[13:33:50.776] (1.033s => +0.001s) shutdown: 10/10 (+0) '' {clear=TRUE, enabled=TRUE, status=ok}
189197
```
190198

191-
<small>
192-
(*) To set the default progress handler in all your R sessions, set this option in your <code>~/.Rprofile</code> file.
193-
</small>
194-
195199

196200

197201
[progressr]: https://github.com/HenrikBengtsson/progressr/

inst/WORDLIST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ HenrikBengtsson
77
https
88
macOS
99
NL
10+
parallelize
1011
plyr
1112
Plyr
1213
POSIXct
@@ -16,4 +17,5 @@ progressor
1617
Progressor
1718
roadmap
1819
Roadmap
20+
Rprofile
1921
substyle

man/progressr.options.Rd

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)