Skip to content

Commit

Permalink
Fix a bug, need to fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Nov 10, 2024
1 parent 81bcac0 commit 484703c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion R/class_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ builder_unmarshal_subpipeline <- function(target) {
pipeline_unmarshal_values(target$subpipeline)
}
patterns <- fltr(
names(subpipeline$targets),
pipeline_get_names(subpipeline),
~inherits(pipeline_get_target(subpipeline, .x), "tar_pattern")
)
map(
Expand Down
25 changes: 19 additions & 6 deletions R/class_pipeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pipeline_initialize_references_children <- function(
}

pipeline_get_names <- function(pipeline) {
names(pipeline$targets)
names(.subset2(pipeline, "targets"))
}

pipeline_get_priorities <- function(pipeline) {
Expand Down Expand Up @@ -109,8 +109,11 @@ pipeline_reset_deployment <- function(pipeline, name) {
}

pipeline_exists_target <- function(pipeline, name) {
envir <- pipeline$targets %|||% tar_empty_envir
exists(x = name, envir = envir, inherits = FALSE)
envir <- .subset2(pipeline, "targets")
if (is.null(envir)) {
envir <- tar_empty_envir
}
!is.null(.subset2(envir, name))
}

pipeline_exists_import <- function(pipeline, name) {
Expand All @@ -127,7 +130,10 @@ pipeline_targets_only_edges <- function(edges) {
}

pipeline_upstream_edges <- function(pipeline, targets_only = TRUE) {
edge_list <- map(pipeline$targets, ~target_upstream_edges(.x))
edge_list <- map(
pipeline_get_names(pipeline),
~target_upstream_edges(pipeline_get_target(pipeline, .x))
)
from <- map(edge_list, ~.x$from)
to <- map(edge_list, ~.x$to)
from <- unlist(from, recursive = FALSE, use.names = FALSE)
Expand Down Expand Up @@ -233,7 +239,11 @@ pipeline_prune_targets <- function(pipeline, names) {
graph <- pipeline_produce_igraph(pipeline, targets_only = TRUE)
keep <- upstream_vertices(graph = graph, from = names)
discard <- setdiff(pipeline_get_names(pipeline), keep)
remove(list = discard, envir = pipeline$targets, inherits = FALSE)
remove(
list = discard,
envir = .subset2(pipeline, "targets"),
inherits = FALSE
)
}

pipeline_prune_shortcut <- function(pipeline, names, shortcut) {
Expand Down Expand Up @@ -298,7 +308,10 @@ pipeline_validate_dag <- function(igraph) {
}

pipeline_validate_conflicts <- function(pipeline) {
conflicts <- intersect(names(pipeline$imports), names(pipeline$targets))
conflicts <- intersect(
names(.subset2(pipeline, "imports")),
pipeline_get_names(pipeline)
)
msg <- paste0(
"Targets and globals must have unique names. ",
"Ignoring global objects that conflict with target names: ",
Expand Down
7 changes: 6 additions & 1 deletion R/tar_described_as.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ tar_described_as_inner <- function(
described_as_quosure,
tidyselect
) {
descriptions <- unlist(map(pipeline$targets, ~.x$settings$description))
descriptions <- unlist(
map(
pipeline_get_names(pipeline),
~pipeline_get_target(pipeline, .x)$settings$description
)
)
chosen <- tar_tidyselect_eval(described_as_quosure, unique(descriptions))
sort(unique(names(descriptions[descriptions %in% chosen])))
}

0 comments on commit 484703c

Please sign in to comment.