Skip to content

Commit

Permalink
Try #1382
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Nov 21, 2024
1 parent 7acd224 commit 79bab3b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Description: Pipeline tools coordinate the pieces of computationally
The methodology in this package
borrows from GNU 'Make' (2015, ISBN:978-9881443519)
and 'drake' (2018, <doi:10.21105/joss.00550>).
Version: 1.9.0.9000
Version: 1.9.0.9001
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# targets 1.9.0.9000 (development)
# targets 1.9.0.9001 (development)

## Bug fixes

* Allow branch references to contain multi-element `path` vectors with cloud metadata (#1382).

# targets 1.9.0

Expand Down
19 changes: 17 additions & 2 deletions tests/aws/test-branching.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,32 @@ tar_test("dynamic branch references have complete path info", {
)
)
)
# From
# https://github.com/wjschne/spiro/blob/ \
# 87f73ec37ceb0a7a9d09856ada8ae28d587a2ebd/R/spirograph.R
# Adapted under the CC0 1.0 Universal license:
# https://github.com/wjschne/spiro/blob/ \
# 87f73ec37ceb0a7a9d09856ada8ae28d587a2ebd/LICENSE.md
spirograph_points <- function(fixed_radius, cycling_radius) {
t <- seq(1, 30 * pi, length.out = 1e4)
diff <- (fixed_radius - cycling_radius)
ratio <- diff / cycling_radius
x <- diff * cos(t) + cos(t * ratio)
y <- diff * sin(t) - sin(t * ratio)
tibble(x = x, y = y, fixed_radius = fixed_radius, cycling_radius = cycling_radius)
tibble(
x = x,
y = y,
fixed_radius = fixed_radius,
cycling_radius = cycling_radius
)
}
plot_spirographs <- function(points) {
label <- "fixed_radius = %s, cycling_radius = %s"
points$parameters <- sprintf(label, points$fixed_radius, points$cycling_radius)
points$parameters <- sprintf(
label,
points$fixed_radius,
points$cycling_radius
)
ggplot(points) +
geom_point(aes(x = x, y = y, color = parameters), size = 0.1) +
facet_wrap(~parameters) +
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-class_pipeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ tar_test("managing lightweight references to targets in pipelines", {
branch <- pipeline_get_target(local$pipeline, branch_name)
reference <- pipeline$targets[[bud_name]]
expect_equal(reference_parent(reference), "data")
expect_equal(reference_path(reference), NA_character_)
expect_equal(reference_stage(reference), NA_character_)
expect_equal(reference_hash(reference), NA_character_)
expect_equal(reference_path(reference), NULL)
expect_equal(reference_stage(reference), NULL)
expect_equal(reference_hash(reference), NULL)
reference <- pipeline$targets[[branch_name]]
expect_equal(reference_parent(reference), "map")
expect_equal(reference_path(reference), branch$file$path)
Expand All @@ -327,9 +327,9 @@ tar_test("managing lightweight references to targets in pipelines", {
pipeline_unload_loaded(local$pipeline)
reference <- pipeline$targets[[bud_name]]
expect_equal(reference_parent(reference), "data")
expect_equal(reference_path(reference), NA_character_)
expect_equal(reference_stage(reference), NA_character_)
expect_equal(reference_hash(reference), NA_character_)
expect_equal(reference_path(reference), NULL)
expect_equal(reference_stage(reference), NULL)
expect_equal(reference_hash(reference), NULL)
reference <- pipeline$targets[[branch_name]]
expect_equal(reference_parent(reference), "map")
expect_equal(reference_path(reference), branch$file$path)
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-class_reference.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
tar_test("reference with only parent", {
out <- reference_init(parent = "my_parent")
out <- reference_new(parent = "my_parent")
expect_equal(reference_parent(out), "my_parent")
expect_equal(reference_path(out), NULL)
expect_equal(reference_stage(out), NULL)
expect_equal(reference_hash(out), NULL)
})

tar_test("reference with parent and path but no other fields", {
out <- reference_init(parent = "my_parent", path = "my_path")
out <- reference_new(parent = "my_parent", path = "my_path")
expect_equal(reference_parent(out), "my_parent")
expect_equal(reference_path(out), "my_path")
expect_equal(reference_stage(out), NULL)
expect_equal(reference_hash(out), NULL)
})

tar_test("reference with parent and hash but no other fields", {
out <- reference_init(parent = "my_parent", hash = "my_hash")
out <- reference_new(parent = "my_parent", hash = "my_hash")
expect_equal(reference_parent(out), "my_parent")
expect_equal(reference_path(out), NA_character_)
expect_equal(reference_stage(out), NA_character_)
expect_equal(reference_path(out), NULL)
expect_equal(reference_stage(out), NULL)
expect_equal(reference_hash(out), "my_hash")
})

tar_test("reference with all fields", {
out <- reference_init(
out <- reference_new(
parent = "my_parent",
path = "my_path",
stage = "my_stage",
Expand Down Expand Up @@ -62,9 +62,9 @@ tar_test("reference_produce_target() and its inverse", {
bud_reference <- target_produce_reference(bud)
branch_reference <- target_produce_reference(branch)
expect_equal(reference_parent(bud_reference), "data")
expect_equal(reference_path(bud_reference), NA_character_)
expect_equal(reference_stage(bud_reference), NA_character_)
expect_equal(reference_hash(bud_reference), NA_character_)
expect_equal(reference_path(bud_reference), NULL)
expect_equal(reference_stage(bud_reference), NULL)
expect_equal(reference_hash(bud_reference), NULL)
expect_equal(reference_parent(branch_reference), "map")
expect_equal(reference_path(branch_reference), branch$file$path)
expect_equal(reference_stage(branch_reference), branch$file$stage)
Expand Down

0 comments on commit 79bab3b

Please sign in to comment.