Skip to contents

Removes all output files generated by scripts in the pipeline, including intermediate files. This provides a complete clean of generated artifacts. The pipeline can be regenerated by running run() again.

Usage

clean(verbose = TRUE)

Arguments

verbose

Logical. If TRUE (default), prints progress messages to console.

Value

Character vector of file paths that were actually removed

Examples

# Copy sample project to temp directory
temp_dir <- tempfile()
dir.create(temp_dir)
sample_proj <- system.file("extdata", "sample-project", package = "bakepipe")
file.copy(sample_proj, temp_dir, recursive = TRUE)
#> [1] TRUE

# Change to the sample project directory
old_wd <- getwd()
setwd(file.path(temp_dir, "sample-project"))

# Run the pipeline first to create output files
run()
#> + script_02_summarize_r dispatched
#>  script_02_summarize_r completed [1ms, 266 B]
#> + input_csv dispatched
#>  input_csv completed [0ms, 14 B]
#> + script_01_process_r dispatched
#>  script_01_process_r completed [0ms, 204 B]
#> + output_01_process_r dispatched
#>  output_01_process_r completed [275ms, 36 B]
#> + output_02_summarize_r dispatched
#>  output_02_summarize_r completed [269ms, 22 B]
#>  ended pipeline [740ms, 5 completed, 0 skipped]
#> 

# Now clean up the generated files
removed_files <- clean()
#> ✓ removed 4 artifacts
print(removed_files)
#> [1] "processed.csv" "summary.csv"   "_targets.R"   

# Restore working directory and clean up
setwd(old_wd)
unlink(temp_dir, recursive = TRUE)