Skip to contents

Creates an independent copy of the pipeline. Changes to the cloned pipeline do not affect the original pipeline, and vice versa.

Usage

pip_clone(x, name = NULL)

Arguments

x

A pipeflow pipeline object.

name

Optional name for the cloned pipeline. If NULL, the original name is used.

Value

A cloned pipeflow pipeline object.

Examples

p <- pip_new("original") |>
  pip_add("s1", \(x = 1) x) |>
  pip_add("s2", \(x = ~s1) x + 1)

# Clone produces a fully independent copy
cp <- pip_clone(p, name = "copy")
pip_add(cp, "s3", \(x = ~s2) x * 10)

# As a result, the clone has the new step ...
cp
#> <pipeflow> copy (3 steps)
#> -------------------------
#>    step params depends state
#> 1:   s1      x           new
#> 2:   s2      x      s1   new
#> 3:   s3      x      s2   new
#> -------------------------
#> <ready> last run: never

# ... while the original is left unchanged
p
#> <pipeflow> original (2 steps)
#> -----------------------------
#>    step params depends state
#> 1:   s1      x           new
#> 2:   s2      x      s1   new
#> -----------------------------
#> <ready> last run: never