Skip to content

collect_extracts() for workflow_set #156

@jrosell

Description

@jrosell

I noticed that workflowsets does not appear to have a method for collecting extracts and it has a method for collecting notes #135.

class(results)
[1] "workflow_set" "tbl_df" "tbl" "data.frame"
collect_extracts(results)
Error in collect_extracts():
! No collect_extracts() exists for a <workflow_set/tbl_df/tbl/data.frame> object.
Run rlang::last_trace() to see where the error occurred.

It would be handy to have collect_extracts implemented so that you can get elapsed time or other information extracted.

Here one example using partials if you want to reuse the code for mulitple collect_*

my_collect_custom <- function(wflow_set_results, fn){
  wflow_set_rsl <- wflow_set_results %>%
    dplyr::select(wflow_id, result)
  
  distinct_list_of_workflows <- wflow_set_rsl %>%
    dplyr::select(wflow_id) %>%
    distinct() %>%
    pull(wflow_id)
  
  collect_fn_helper <- function(x){
    wflow_set_rsl %>%
          filter(wflow_id == x) %>%
          pull(result) %>%
          pluck(1) %>%
          fn()
  }
  list_dfs <- map_dfr(
    set_names(distinct_list_of_workflows),
    collect_fn_helper,
    .id = "workflow_id")
  
  list_dfs
}

my_collect_extracts <- purrr::partial(my_collect_custom, fn = collect_extracts)
my_collect_extracts(results)

my_collect_notes <- purrr::partial(my_collect_custom, fn = collect_notes)
my_collect_notes(results)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions