-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix: task returned from content_render
missing task_id
#339
Conversation
R/deploy.R
Outdated
@@ -580,7 +580,7 @@ poll_task <- function(task, wait = 1, callback = message) { | |||
code <- -1 | |||
first <- 0 | |||
while (!finished) { | |||
task_data <- con$task(task$get_task()$task_id, wait = wait, first = first) | |||
task_data <- con$task(task$task$task_id, wait = wait, first = first) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't technically need this change right? get_task()
just yields self$task
. (Not opposed to ripping out the unnecessary getters, but that seems better done in a separate refactor PR where you did them all.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, I don't technically need it; happy to revert if you think it's bad to change it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, for things like this which are easily greppable, no need to do it piecemeal.
R/content.R
Outdated
@@ -1007,6 +1007,9 @@ content_render <- function(content, variant_key = NULL) { | |||
target_variant <- get_variant(content, variant_key) | |||
} | |||
render_task <- target_variant$render() | |||
# Tasks returned from variant render endpoint look different from those | |||
# returned by deploy. | |||
render_task$task_id <- render_task$id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this same logic in the Task initialize
method: https://github.com/rstudio/connectapi/blob/main/R/deploy.R#L67-L69
Why doesn't that handle this for you already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, because of course VariantTask
doesn't inherit from Task
:/
I think the better fix would be to push this adapting into the VariantTask
init method. Even better would be to look to fix the inheritance of all of these apparent (but not actual) Task subclasses, but that could be a followup--I'm not trying to derail a bugfix by tempting you into refactoring all the things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah lol. But good point, I'll put it into VariantTask
and rip out the other place that also does it.
I don't think ContentTask
needs it because I don't think there are any content APIs that return this form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick and crisp fix!
Intent
Fix
poll_task
for tasks returned bycontent_render
.Fixes #338
Approach
The
POST variants/{variant_id}/render
endpoint returns an object that is shaped differently from the task returned by thedeploy
task, with the task ID namedid
and nottask_id
. Thus, when creating aVariantTask
object, we need to rename the parameter.I believe this was working in an initial draft of this functionality, but was changed in a subsequent PR that altered the return type for the function.
I added an integration test to verify
content_render
and the task it returns.Checklist
NEWS.md
(referencing the connected issue if necessary)?devtools::document()
?