Skip to content

Nested with_progress() #56

Open
Open

Description

@HenrikBengtsson

Add support for nested with_progress() calls where it's only the outer layer (or?) that ends up presenting progress.

Activity

  1. HenrikBengtsson commented on Jan 20, 2020

    @HenrikBengtsson
    CollaboratorAuthor

    Clarification: The below example produces two rounds of progress bars. It would be neat if nested with_progress() could be detected and automatically "merged" such that all progress updates from an inner with_progress() are relayed up to the parent with_progress() environment. This way we could end up getting a single progress bar with 2 * 5 = 10 steps, instead of two with 5 steps each.

    library(progressr)
    handlers("progress")
    
    xs <- list(a = 1:5, b = 1:5)
    
    ys <- list()
    
    with_progress({
      p <- progressor(along = xs, scale = 5.0)
      for (kk in seq_along(xs)) {
        x <- xs[[kk]]
        with_progress({
          ys[[kk]] <- slow_sum(x)
        })
      }
    })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions