Skip to content

Commit

Permalink
produce buds differently
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Nov 8, 2024
1 parent 19f4a7d commit 975a7f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions R/class_stem.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ stem_tar_assert_nonempty <- function(target) {
}
}

stem_produce_buds <- function(target) {
settings <- target$settings
names <- target_get_children(target)
map(seq_along(names), ~bud_new(names[.x], settings, .x))
stem_produce_bud <- function(target, name) {
junction <- .subset2(target, "junction")
index <- junction_extract_index(junction, name)
bud_new(name = name, settings = .subset2(target, "settings"), index = index)
}

stem_insert_buds <- function(target, pipeline) {
map(stem_produce_buds(target), pipeline_set_target, pipeline = pipeline)
map(
junction_splits(target$junction),
~pipeline_set_target(pipeline, stem_produce_bud(target, .x))
)
}

stem_ensure_buds <- function(target, pipeline, scheduler) {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-class_stem.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ tar_test("stem$update_junction() on a good stem", {
expect_true(all(grepl("abc_", out)))
})

tar_test("stem_produce_buds()", {
tar_test("stem produce buds", {
x <- target_init(name = "abc", expr = quote(letters))
tar_option_set(envir = baseenv())
target_run(x, tar_option_get("envir"), path_store_default())
pipeline <- pipeline_init(list(x))
stem_update_junction(x, pipeline)
children <- stem_produce_buds(x)
children <- map(target_get_children(x), ~stem_produce_bud(x, .x))
expect_true(is.list(children))
expect_length(children, length(letters))
for (index in seq_along(letters)) {
Expand Down

0 comments on commit 975a7f0

Please sign in to comment.