Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix Result block don't get updated properly #432 #435

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ generate_server.result_field <- function(x, ...) {
res <- get_stack_result(
get_workspace_stack(inp)
)
# Handle the join block
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The join block was broken since we do this:

by_choices <- function(data, y) {
    intersect(colnames(data), colnames(y))
  }

and y is a reactive expression coming from the result field, which means it needs to be evaluated to get the correct result. I believe the best place to do this is here, in the server logic rather than in the code block code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't cause problems: y from "within the block" should not behave as reactive, but as regular R value. All of this should happen in value():

blockr/R/field-core.R

Lines 184 to 209 in 061ac78

value.result_field <- function(x, name = "value") {
stopifnot(identical(name, "value"))
field <- get_field_value(x, "value")
if (length(field) && field %in% list_workspace_stacks()) {
res <- get_stack_result(get_workspace_stack(field))
if (inherits(res, "reactive")) {
if (is.null(getDefaultReactiveDomain())) {
list()
} else {
res()
}
} else {
res
}
} else {
list()
}
}

So if this is still an open issue (is it?), the question is why the "reactive representation" slips through here.

Copy link
Collaborator Author

@DivadNojnarg DivadNojnarg Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. missed this part of the code. Debugging with a new_join_block shows we never enter the first if statement as list_workspace_stacks() always return character(0).
To reproduce:

serve_workspace(
  stack1 = new_stack(
    blockr.pharmaverseadam::new_adam_block("adae")
  ),
  stack2 = new_stack(blockr.pharmaverseadam::new_adam_block("adsl"), new_join_block(y = "stack1"))
)

if (is.reactive(res)) res <- res()

attr(res, "result_field_stack_name") <- inp

Expand Down
Loading