Skip to contents

Orchestrates multiple Tool objects over shared directories.

Typical use: filter_files() (optional), tidy(), write(); run() chains all three.

Public fields

name

(character(1))
Name of workflow.

path

(character(n))
Path(s) to workflow results.

metapkg

(character(n))
Package name(s) used for metadata version reporting.

written_files

(tibble(n))
Tibble of files written from self$write().

s3sync_exclude

(character(n))
Trailing --exclude globs for get_s3sync_patterns(), carving files back out of the schema-derived includes. Subclasses override this.

Methods


Method new()

Create a new Workflow object.

Usage

Workflow$new(name, path, tools, metapkg = "nemo")

Arguments

name

(character(1))
Name of workflow.

path

(character(n))
Path(s) to workflow results.

tools

(list(n))
Named list of Tool subclasses that compose a Workflow. List names serve as aliases and need not match each tool's own $name field.

metapkg

(character(n))
Package name(s) used for metadata version reporting.

Returns

(R6::R6Class())
R6 object.


Method print()

Print details about the Workflow.

Usage

Workflow$print(...)

Arguments

...

(ignored).

Returns

(R6::R6Class())
R6 object invisibly.


Method get_tools()

Get the list of Tool objects in this Workflow.

Usage

Workflow$get_tools()

Returns

(list(n))
Named list of instantiated Tool objects.


Method get_globs()

Get S3 sync globs for all Tools, derived from their schema patterns.

Usage

Workflow$get_globs()

Returns

(tibble())
Bound get_globs() tibbles from all Tools (tool, name, glob).


Method get_s3sync_patterns()

Build the aws s3 sync patterns: exclude everything, include the schema globs, then s3sync_exclude, then the extra exclude and include globs (filters are last-match-wins, so an extra include wins over any exclude).

Usage

Workflow$get_s3sync_patterns(include = NULL, exclude = NULL)

Arguments

include

(character(n))
Extra globs to include.

exclude

(character(n))
Extra globs to exclude.

Returns

(tibble())
Tibble with inex ("in"/"ex") and pat columns, as expected by s3sync().


Method filter_files()

Filter files in given workflow directory.

Usage

Workflow$filter_files(include = NULL, exclude = NULL)

Arguments

include

(character(n))
tool_parser names to include (e.g. "tool1_table1").

exclude

(character(n))
tool_parser names to exclude (e.g. "tool1_table6").

Returns

(R6::R6Class())
R6 object invisibly.


Method list_files()

List files matching the tools' patterns.

Usage

Workflow$list_files()

Returns

(tibble())
Bound files tibbles from all Tools, with a leading tool column.


Method tidy()

Tidy Workflow files.

Usage

Workflow$tidy(keep_raw = FALSE)

Arguments

keep_raw

(logical(1))
Should the raw parsed tibbles be kept in the final output?

Returns

(R6::R6Class())
R6 object invisibly.


Method write()

Write tidy tibbles.

Usage

Workflow$write(
  output_dir = ".",
  format = "tsv",
  input_id = NULL,
  output_id = NULL,
  prefix_include = FALSE,
  dbconn = NULL,
  write_metadata = TRUE
)

Arguments

output_dir

(character(1))
Directory path to output tidy files.

format

(character(1))
Format of output.

input_id

(character(1))
Input ID to use for the dataset (e.g. run123).

output_id

(character(1))
Output ID to use for the dataset (e.g. out1).

prefix_include

(logical(1))
If TRUE, prepend an input_prefix column to each tidy table.

dbconn

(DBIConnection)
Database connection object (see DBI::dbConnect).

write_metadata

(logical(1))
If TRUE (default), write a metadata.parquet file alongside the tidy outputs. Set to FALSE to suppress.

Returns

(R6::R6Class())
R6 object invisibly.


Method run()

Filter, tidy, and write files in one step. A no-op if already written; if already tidied, writes the in-memory tables via write() instead of re-parsing.

Usage

Workflow$run(
  output_dir = ".",
  format = "tsv",
  input_id = NULL,
  output_id = NULL,
  prefix_include = FALSE,
  dbconn = NULL,
  write_metadata = TRUE,
  include = NULL,
  exclude = NULL
)

Arguments

output_dir

(character(1))
Directory path to output tidy files.

format

(character(1))
Format of output.

input_id

(character(1))
Input ID to use for the dataset (e.g. run123).

output_id

(character(1))
Output ID to use for the dataset (e.g. out1).

prefix_include

(logical(1))
If TRUE, prepend an input_prefix column to each tidy table.

dbconn

(DBIConnection)
Database connection object (see DBI::dbConnect).

write_metadata

(logical(1))
If TRUE (default), write a metadata.parquet file. Set to FALSE to suppress.

include

(character(n))
tool_parser names to include (e.g. "tool1_table1").

exclude

(character(n))
tool_parser names to exclude (e.g. "tool1_table6").

Returns

(R6::R6Class())
R6 object invisibly.


Method get_schemas_raw()

Get raw schemas for all Tools.

Usage

Workflow$get_schemas_raw()

Returns

(tibble())
Bound schemas_raw tibbles from all Tools, with a leading tool column.


Method get_schemas_tidy()

Get tidy schemas for all Tools.

Usage

Workflow$get_schemas_tidy()

Returns

(tibble())
Bound tidy schema tibbles from all Tools, with a leading tool column.


Method get_tbls()

Get tidy tibbles for all Tools.

Usage

Workflow$get_tbls()

Returns

(tibble())
Bound tbls tibbles from all Tools, with a leading tool column. When tidy(keep_raw = TRUE) was used, each tool's tibble also contains a raw list-column.


Method get_metadata()

Get metadata for the workflow run.

Usage

Workflow$get_metadata(input_id, output_id, output_dir, pkgs = NULL)

Arguments

input_id

(character(1))
Input ID to use for the dataset (e.g. run123).

output_id

(character(1))
Output ID to use for the dataset (e.g. out1).

output_dir

(character(1))
Output directory.

pkgs

(character(n))
Which R packages to extract versions for.

Returns

(tibble())
Single-row tibble with columns input_id, output_id, input_dirs, output_dir, pkg_versions, and files.

Examples

fs::path(tempdir(), letters[1:5]) |>
  fs::file_temp_push() |>
  fs::dir_create()
path <- system.file("extdata/tool1", package = "nemo")
tools <- list(tool1 = Tool1)
wf <- Workflow$new(name = "wf1", path = path, tools = tools)
(lf_all <- wf$list_files())
#> # A tibble: 11 × 10
#>    tool  tool_parser parser bname  size lastmodified        path  pattern prefix
#>    <chr> <chr>       <chr>  <chr> <fs:> <dttm>              <chr> <chr>   <chr> 
#>  1 tool1 tool1_tabl… table1 samp…   133 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  2 tool1 tool1_tabl… table2 samp…    70 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  3 tool1 tool1_tabl… table3 samp…    83 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  4 tool1 tool1_tabl… table4 samp…    52 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  5 tool1 tool1_tabl… table6 samp…   100 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  6 tool1 tool1_tabl… table2 samp…    47 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  7 tool1 tool1_tabl… table3 samp…    48 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  8 tool1 tool1_tabl… table4 samp…    34 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#>  9 tool1 tool1_tabl… table6 samp…    78 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 10 tool1 tool1_tabl… table1 samp…   113 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 11 tool1 tool1_tabl… table1 samp…    93 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> # ℹ 1 more variable: prefix_suffix <chr>
(globs <- wf$get_globs())
#> # A tibble: 6 × 3
#>   tool  name   glob              
#>   <chr> <chr>  <chr>             
#> 1 tool1 table1 *.tool1.table1.tsv
#> 2 tool1 table2 *.tool1.table2.tsv
#> 3 tool1 table3 *.tool1.table3.tsv
#> 4 tool1 table4 *.tool1.table4.tsv
#> 5 tool1 table6 *.tool1.table6.csv
#> 6 tool1 table7 *.tool1.table7.tsv
(s3sync_pats <- wf$get_s3sync_patterns())
#> # A tibble: 7 × 2
#>   inex  pat               
#>   <chr> <chr>             
#> 1 ex    *                 
#> 2 in    *.tool1.table1.tsv
#> 3 in    *.tool1.table2.tsv
#> 4 in    *.tool1.table3.tsv
#> 5 in    *.tool1.table4.tsv
#> 6 in    *.tool1.table6.csv
#> 7 in    *.tool1.table7.tsv
wf$filter_files(exclude = "tool1_table6")
wf$tidy()
(tbls <- wf$get_tbls())
#> # A tibble: 9 × 11
#>   tool  tool_parser  parser bname  size lastmodified        path  pattern prefix
#>   <chr> <chr>        <chr>  <chr> <fs:> <dttm>              <chr> <chr>   <chr> 
#> 1 tool1 tool1_table1 table1 samp…   133 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 2 tool1 tool1_table2 table2 samp…    70 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 3 tool1 tool1_table3 table3 samp…    83 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 4 tool1 tool1_table4 table4 samp…    52 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 5 tool1 tool1_table2 table2 samp…    47 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 6 tool1 tool1_table3 table3 samp…    48 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 7 tool1 tool1_table4 table4 samp…    34 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 8 tool1 tool1_table1 table1 samp…   113 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> 9 tool1 tool1_table1 table1 samp…    93 2026-11-09 07:10:24 /hom… "\\.to… sampl…
#> # ℹ 2 more variables: prefix_suffix <chr>, tidy <list>
(rs <- wf$get_schemas_raw())
#> # A tibble: 13 × 6
#>    tool  name   tbl_description                          version schema   parent
#>    <chr> <chr>  <chr>                                    <chr>   <list>   <chr> 
#>  1 tool1 table1 Table1 for tool1 (tsv: header present, … v1.2.3  <tibble> NA    
#>  2 tool1 table1 Table1 for tool1 (tsv: header present, … v4.5.6  <tibble> NA    
#>  3 tool1 table1 Table1 for tool1 (tsv: header present, … latest  <tibble> NA    
#>  4 tool1 table2 Table2 for tool1 (tsv: header present, … v1.0.0  <tibble> NA    
#>  5 tool1 table2 Table2 for tool1 (tsv: header present, … latest  <tibble> NA    
#>  6 tool1 table3 Table3 for tool1 (tsv-keyvalue: no head… v1.0.0  <tibble> NA    
#>  7 tool1 table3 Table3 for tool1 (tsv-keyvalue: no head… latest  <tibble> NA    
#>  8 tool1 table4 Table4 for tool1 (tsv-nohead: no header… v1.0.0  <tibble> NA    
#>  9 tool1 table4 Table4 for tool1 (tsv-nohead: no header… latest  <tibble> NA    
#> 10 tool1 table6 Table6 for tool1 (csv: header present, … v1.0.0  <tibble> NA    
#> 11 tool1 table6 Table6 for tool1 (csv: header present, … latest  <tibble> NA    
#> 12 tool1 table7 Table7 for tool1 (tsv: one wide row, sp… v1.0.0  <tibble> NA    
#> 13 tool1 table7 Table7 for tool1 (tsv: one wide row, sp… latest  <tibble> NA    
dir1 <- fs::file_temp(); dir2 <- fs::file_temp()
wf$write(output_dir = dir1, format = "parquet", input_id = "run1")
(lf1 <- list.files(dir1, pattern = "tool1.*parquet", full.names = TRUE))
#> [1] "/tmp/RtmpRY5ahT/c/sampleA_2_tool1_table1.parquet"
#> [2] "/tmp/RtmpRY5ahT/c/sampleA_2_tool1_table2.parquet"
#> [3] "/tmp/RtmpRY5ahT/c/sampleA_2_tool1_table3.parquet"
#> [4] "/tmp/RtmpRY5ahT/c/sampleA_2_tool1_table4.parquet"
#> [5] "/tmp/RtmpRY5ahT/c/sampleA_3_tool1_table1.parquet"
#> [6] "/tmp/RtmpRY5ahT/c/sampleA_tool1_table1.parquet"  
#> [7] "/tmp/RtmpRY5ahT/c/sampleA_tool1_table2.parquet"  
#> [8] "/tmp/RtmpRY5ahT/c/sampleA_tool1_table3.parquet"  
#> [9] "/tmp/RtmpRY5ahT/c/sampleA_tool1_table4.parquet"  
(meta <- wf$get_metadata(input_id = "run1", output_id = "out1", output_dir = dir1))
#> # A tibble: 1 × 6
#>   input_id output_id input_dirs output_dir        pkg_versions files       
#>   <chr>    <chr>     <list>     <fs::path>        <list>       <list>      
#> 1 run1     out1      <chr [1]>  /tmp/RtmpRY5ahT/c <df [1 × 2]> <df [9 × 4]>
wf2 <- Workflow$new(name = "wf2", path = path, tools = tools)
wf2$run(output_dir = dir2, format = "parquet", input_id = "run2")
(lf2 <- list.files(dir2, pattern = "tool1.*parquet", full.names = TRUE))
#>  [1] "/tmp/RtmpRY5ahT/d/sampleA_2_tool1_table1.parquet"
#>  [2] "/tmp/RtmpRY5ahT/d/sampleA_2_tool1_table2.parquet"
#>  [3] "/tmp/RtmpRY5ahT/d/sampleA_2_tool1_table3.parquet"
#>  [4] "/tmp/RtmpRY5ahT/d/sampleA_2_tool1_table4.parquet"
#>  [5] "/tmp/RtmpRY5ahT/d/sampleA_2_tool1_table6.parquet"
#>  [6] "/tmp/RtmpRY5ahT/d/sampleA_3_tool1_table1.parquet"
#>  [7] "/tmp/RtmpRY5ahT/d/sampleA_tool1_table1.parquet"  
#>  [8] "/tmp/RtmpRY5ahT/d/sampleA_tool1_table2.parquet"  
#>  [9] "/tmp/RtmpRY5ahT/d/sampleA_tool1_table3.parquet"  
#> [10] "/tmp/RtmpRY5ahT/d/sampleA_tool1_table4.parquet"  
#> [11] "/tmp/RtmpRY5ahT/d/sampleA_tool1_table6.parquet"