Skip to content

Commit a3e99c4

Browse files
Merge branch 'release/0.2.0'
2 parents e74be88 + 4d95052 commit a3e99c4

Some content is hidden

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

52 files changed

+572
-173
lines changed

CONDUCT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [https://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: https://contributor-covenant.org
74+
[version]: https://contributor-covenant.org/version/1/4/

DESCRIPTION

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: progressr
2-
Version: 0.1.5
2+
Version: 0.2.0
33
Title: A Unifying API for Progress Updates
44
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.
55
Authors@R: c(
@@ -13,18 +13,18 @@ Suggests:
1313
graphics,
1414
tcltk,
1515
beepr,
16-
notifier,
1716
pbmcapply,
1817
plyr,
1918
progress,
20-
future,
19+
future (>= 1.15.1),
2120
doFuture,
2221
future.apply,
2322
furrr,
24-
shiny
23+
shiny,
24+
notifier
2525
Remotes:
2626
gaborcsardi/notifier@d92b1b6
2727
URL: https://github.com/HenrikBengtsson/progressr
2828
BugReports: https://github.com/HenrikBengtsson/progressr/issues
29-
RoxygenNote: 6.1.1
29+
RoxygenNote: 7.0.2
3030
Roxygen: list(markdown = TRUE)

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export(slow_sum)
2323
export(tkprogressbar_handler)
2424
export(txtprogressbar_handler)
2525
export(winprogressbar_handler)
26-
export(withProgress2)
26+
export(withProgressShiny)
2727
export(with_progress)
2828
export(without_progress)
2929
importFrom(digest,digest)

NEWS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Package: progressr
22
==================
33

4+
Version: 0.2.0 [2020-01-04]
5+
6+
SIGNIFICANT CHANGES:
7+
8+
* Renamed withProgress2() to withProgressShiny().
9+
10+
NEW FEATURES:
11+
12+
* handlers() gained argument 'default' specifying a progression handler to
13+
be returned if none is set.
14+
15+
416
Version: 0.1.5 [2019-10-26]
517

618
NEW FEATURES:

R/handlers.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#' is produces and the missing handlers is ignored. If `"ignore"`, the
1111
#' missing handlers is ignored.
1212
#'
13+
#' @param default The default progression calling handler to use if none
14+
#' are set.
15+
#'
1316
#' @return (invisibly) the previous list of progression handlers set.
1417
#' If no arguments are specified, then the current set of progression
1518
#' handlers is returned.
@@ -21,11 +24,11 @@
2124
#' @example incl/handlers.R
2225
#'
2326
#' @export
24-
handlers <- function(..., on_missing = c("error", "warning", "ignore")) {
27+
handlers <- function(..., on_missing = c("error", "warning", "ignore"), default = txtprogressbar_handler) {
2528
args <- list(...)
2629

2730
## Get the current set of progression handlers?
28-
if (length(args) == 0L) return(getOption("progressr.handlers"))
31+
if (length(args) == 0L) return(getOption("progressr.handlers", default))
2932

3033
on_missing <- match.arg(on_missing)
3134

R/progression_handler.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@
2929
#' @param clear (logical) If TRUE, any output, typically visual, produced
3030
#' by a reporter will be cleared/removed upon completion, if possible.
3131
#'
32+
#' @param target (character vector) Specifies where progression updates are
33+
#' rendered.
34+
#'
3235
#' @return A function of class `progression_handler` that takes a
3336
#' [progression] condition as its first and only argument.
3437
#'
3538
#' @seealso
3639
#' [base::withCallingHandlers()].
3740
#'
3841
#' @export
39-
make_progression_handler <- function(name, reporter = list(), handler = NULL, enable = getOption("progressr.enable", interactive()), enable_after = getOption("progressr.enable_after", 0.0), times = getOption("progressr.times", +Inf), interval = getOption("progressr.interval", 0.0), intrusiveness = 1.0, clear = getOption("progressr.clear", TRUE)) {
42+
make_progression_handler <- function(name, reporter = list(), handler = NULL, enable = getOption("progressr.enable", interactive()), enable_after = getOption("progressr.enable_after", 0.0), times = getOption("progressr.times", +Inf), interval = getOption("progressr.interval", 0.0), intrusiveness = 1.0, clear = getOption("progressr.clear", TRUE), target = "terminal") {
4043
if (!enable) times <- 0
4144
name <- as.character(name)
4245
stop_if_not(length(name) == 1L, !is.na(name), nzchar(name))
@@ -50,7 +53,8 @@ make_progression_handler <- function(name, reporter = list(), handler = NULL, en
5053
times >= 0)
5154
stop_if_not(length(interval) == 1L, is.numeric(interval),
5255
!is.na(interval), interval >= 0)
53-
56+
stop_if_not(is.character(target))
57+
5458
## Disable progress updates?
5559
if (times == 0 || is.infinite(interval) || is.infinite(intrusiveness)) {
5660
handler <- function(p) NULL
@@ -101,7 +105,8 @@ make_progression_handler <- function(name, reporter = list(), handler = NULL, en
101105
interval = interval,
102106
enable_after = enable_after,
103107
auto_finish = auto_finish,
104-
clear = clear
108+
clear = clear,
109+
target = target
105110
)
106111

107112
state <- list(
@@ -327,7 +332,7 @@ make_progression_handler <- function(name, reporter = list(), handler = NULL, en
327332
class(handler) <- c(sprintf("%s_progression_handler", name),
328333
"progression_handler", "calling_handler",
329334
class(handler))
330-
335+
331336
handler
332337
}
333338

@@ -348,6 +353,7 @@ print.progression_handler <- function(x, ...) {
348353
s <- c(s, sprintf(" - intrusiveness: %g", env$intrusiveness))
349354
s <- c(s, sprintf(" - auto_finish: %s", env$auto_finish))
350355
s <- c(s, sprintf(" - clear: %s", env$clear))
356+
s <- c(s, sprintf(" - target: %s", paste(sQuote(env$target), collapse = ", ")))
351357
s <- c(s, sprintf(" - milestones: %s", hpaste(env$milestones %||% "<NULL>")))
352358
s <- c(s, sprintf(" - owner: %s", hpaste(env$owner %||% "<NULL>")))
353359

R/progression_handlers.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' @example incl/ascii_alert_handler.R
1515
#'
1616
#' @export
17-
ascii_alert_handler <- function(symbol = "\a", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.auditory", 5.0), ...) {
17+
ascii_alert_handler <- 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, ...) {
@@ -44,7 +44,7 @@ ascii_alert_handler <- function(symbol = "\a", file = stderr(), intrusiveness =
4444
#'
4545
#' @importFrom utils file_test flush.console txtProgressBar setTxtProgressBar
4646
#' @export
47-
txtprogressbar_handler <- function(style = 3L, file = stderr(), intrusiveness = getOption("progressr.intrusiveness.terminal", 1), ...) {
47+
txtprogressbar_handler <- function(style = 3L, file = stderr(), intrusiveness = getOption("progressr.intrusiveness.terminal", 1), target = "terminal", ...) {
4848
reporter <- local({
4949
## Import functions
5050
eraseTxtProgressBar <- function(pb) {
@@ -123,7 +123,7 @@ txtprogressbar_handler <- function(style = 3L, file = stderr(), intrusiveness =
123123
#' @example incl/tkprogressbar_handler.R
124124
#'
125125
#' @export
126-
tkprogressbar_handler <- function(intrusiveness = getOption("progressr.intrusiveness.gui", 1), ...) {
126+
tkprogressbar_handler <- function(intrusiveness = getOption("progressr.intrusiveness.gui", 1), target = "terminal", ...) {
127127
## Used for package testing purposes only when we want to perform
128128
## everything except the last part where the backend is called
129129
if (!is_fake("tkprogressbar_handler")) {
@@ -190,7 +190,7 @@ tkprogressbar_handler <- function(intrusiveness = getOption("progressr.intrusive
190190
#' @param \ldots Additional arguments passed to [make_progression_handler()].
191191
#'
192192
#' @export
193-
winprogressbar_handler <- function(intrusiveness = getOption("progressr.intrusiveness.gui", 1), ...) {
193+
winprogressbar_handler <- function(intrusiveness = getOption("progressr.intrusiveness.gui", 1), target = "gui", ...) {
194194
## Used for package testing purposes only when we want to perform
195195
## everything except the last part where the backend is called
196196
if (!is_fake("winprogressbar_handler")) {
@@ -268,7 +268,7 @@ winprogressbar_handler <- function(intrusiveness = getOption("progressr.intrusiv
268268
#'
269269
#' @importFrom utils file_test flush.console txtProgressBar setTxtProgressBar
270270
#' @export
271-
pbmcapply_handler <- function(substyle = 3L, style = "ETA", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.terminal", 1), ...) {
271+
pbmcapply_handler <- function(substyle = 3L, style = "ETA", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.terminal", 1), target = "terminal", ...) {
272272
if (!is_fake("pbmcapply_handler")) {
273273
progressBar <- pbmcapply::progressBar
274274
eraseTxtProgressBar <- function(pb) {
@@ -366,7 +366,7 @@ pbmcapply_handler <- function(substyle = 3L, style = "ETA", file = stderr(), int
366366
#' @example incl/progress_handler.R
367367
#'
368368
#' @export
369-
progress_handler <- function(format = "[:bar] :percent :message", show_after = 0.0, intrusiveness = getOption("progressr.intrusiveness.terminal", 1), ...) {
369+
progress_handler <- function(format = "[:bar] :percent :message", show_after = 0.0, intrusiveness = getOption("progressr.intrusiveness.terminal", 1), target = "terminal", ...) {
370370
if (!is_fake("progress_handler")) {
371371
progress_bar <- progress::progress_bar
372372
} else {
@@ -440,7 +440,7 @@ progress_handler <- function(format = "[:bar] :percent :message", show_after = 0
440440
#' @example incl/beepr_handler.R
441441
#'
442442
#' @export
443-
beepr_handler <- function(initiate = 2L, update = 10L, finish = 11L, intrusiveness = getOption("progressr.intrusiveness.auditory", 5.0), ...) {
443+
beepr_handler <- function(initiate = 2L, update = 10L, finish = 11L, intrusiveness = getOption("progressr.intrusiveness.auditory", 5.0), target = "audio", ...) {
444444
## Used for package testing purposes only when we want to perform
445445
## everything except the last part where the backend is called
446446
if (!is_fake("beepr_handler")) {
@@ -491,7 +491,7 @@ beepr_handler <- function(initiate = 2L, update = 10L, finish = 11L, intrusiven
491491
#' @example incl/notifier_handler.R
492492
#'
493493
#' @export
494-
notifier_handler <- function(intrusiveness = getOption("progressr.intrusiveness.notifier", 10), ...) {
494+
notifier_handler <- function(intrusiveness = getOption("progressr.intrusiveness.notifier", 10), target = "gui", ...) {
495495
## Used for package testing purposes only when we want to perform
496496
## everything except the last part where the backend is called
497497
if (!is_fake("notifier_handler")) {
@@ -548,7 +548,7 @@ notifier_handler <- function(intrusiveness = getOption("progressr.intrusiveness.
548548
#' @example incl/debug_handler.R
549549
#'
550550
#' @export
551-
debug_handler <- function(interval = getOption("progressr.interval", 0), intrusiveness = getOption("progressr.intrusiveness.debug", 0), ...) {
551+
debug_handler <- function(interval = getOption("progressr.interval", 0), intrusiveness = getOption("progressr.intrusiveness.debug", 0), target = "terminal", ...) {
552552
reporter <- local({
553553
t_init <- NULL
554554

@@ -599,7 +599,7 @@ debug_handler <- function(interval = getOption("progressr.interval", 0), intrusi
599599
#' @param \ldots Additional arguments passed to [make_progression_handler()].
600600
#'
601601
#' @export
602-
newline_handler <- function(symbol = "\n", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.debug", 0), ...) {
602+
newline_handler <- function(symbol = "\n", file = stderr(), intrusiveness = getOption("progressr.intrusiveness.debug", 0), target = "terminal", ...) {
603603
reporter <- local({
604604
list(
605605
initiate = function(...) cat(file = file, symbol),
@@ -630,7 +630,7 @@ newline_handler <- function(symbol = "\n", file = stderr(), intrusiveness = getO
630630
#'
631631
#' @importFrom utils file_test
632632
#' @export
633-
filesize_handler <- function(file = "default.progress", intrusiveness = getOption("progressr.intrusiveness.file", 5), ...) {
633+
filesize_handler <- function(file = "default.progress", intrusiveness = getOption("progressr.intrusiveness.file", 5), target = "file", ...) {
634634
reporter <- local({
635635
set_file_size <- function(config, state, progression) {
636636
ratio <- state$step / config$max_steps
@@ -696,7 +696,7 @@ filesize_handler <- function(file = "default.progress", intrusiveness = getOptio
696696
#' }}
697697
#'
698698
#' @export
699-
shiny_handler <- function(intrusiveness = getOption("progressr.intrusiveness.gui", 1), ...) {
699+
shiny_handler <- function(intrusiveness = getOption("progressr.intrusiveness.gui", 1), target = "gui", ...) {
700700
reporter <- local({
701701
list(
702702
update = function(config, state, progression, ...) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#'
77
#' @return The value of `[shiny::withProgress]`.
88
#'
9-
#' @example incl/shiny-withProgress.R
9+
#' @example incl/withProgressShiny.R
1010
#'
1111
#' @export
12-
withProgress2 <- function(expr, ..., env = parent.frame(), quoted = FALSE, handlers = c(shiny = shiny_handler, getOption("progressr.handlers"))) {
12+
withProgressShiny <- function(expr, ..., env = parent.frame(), quoted = FALSE, handlers = c(shiny = shiny_handler, progressr::handlers(default = NULL))) {
1313
if (!quoted) expr <- substitute(expr)
1414
expr <- bquote(progressr::with_progress({.(expr)}, handlers = .(handlers)))
1515
res <- withVisible(shiny::withProgress(expr, ..., env = env, quoted = TRUE))

R/with_progress.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @example incl/with_progress.R
2626
#'
2727
#' @export
28-
with_progress <- function(expr, handlers = getOption("progressr.handlers", txtprogressbar_handler), cleanup = TRUE, delay_stdout = getOption("progressr.delay_stdout", interactive()), delay_conditions = getOption("progressr.delay_conditions", if (interactive()) c("condition") else character(0L)), interval = NULL, enable = NULL) {
28+
with_progress <- function(expr, handlers = progressr::handlers(), cleanup = TRUE, delay_stdout = getOption("progressr.delay_stdout", interactive()), delay_conditions = getOption("progressr.delay_conditions", if (interactive()) c("condition") else character(0L)), interval = NULL, enable = NULL) {
2929
stop_if_not(is.logical(cleanup), length(cleanup) == 1L, !is.na(cleanup))
3030

3131
## FIXME: With zero handlers, progression conditions will be

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,5 +339,5 @@ Contributing to this package is easy. Just send a [pull request](https://help.g
339339
| Resource: | GitHub | Travis CI | AppVeyor |
340340
| ------------- | ------------------- | --------------- | ---------------- |
341341
| _Platforms:_ | _Multiple_ | _Linux & macOS_ | _Windows_ |
342-
| R CMD check | | <a href="https://travis-ci.org/HenrikBengtsson/progressr"><img src="https://travis-ci.org/HenrikBengtsson/progressr.svg" alt="Build status"></a> | |
342+
| R CMD check | | <a href="https://travis-ci.org/HenrikBengtsson/progressr"><img src="https://travis-ci.org/HenrikBengtsson/progressr.svg" alt="Build status"></a> | <a href="https://ci.appveyor.com/project/HenrikBengtsson/progressr"><img src="https://ci.appveyor.com/api/projects/status/github/HenrikBengtsson/progressr?svg=true" alt="Build status"></a> |
343343
| Test coverage | | <a href="https://codecov.io/gh/HenrikBengtsson/progressr"><img src="https://codecov.io/gh/HenrikBengtsson/progressr/branch/develop/graph/badge.svg" alt="Coverage Status"/></a> | |

0 commit comments

Comments
 (0)