-
-
Notifications
You must be signed in to change notification settings - Fork 30
Provide support for hot reloading in Dash for R #127
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
Conversation
This reverts commit 4db6184.
add more trace
🔧 fix the ci
points to dashr debug
fixed in 9979346 |
fixed in da30cb2 |
Co-Authored-By: alexcjohnson <[email protected]>
fixed in 79a4996 |
@alexcjohnson I think this one is ready to go 🚢 . I also added in documentation for |
cb02497
to
df4c737
Compare
R/dash.R
Outdated
router$add_route(route, "dashR-endpoints") | ||
server$attach(router) | ||
|
||
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.
🙄
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.
fixed in aa1ad07
R/dash.R
Outdated
self$server$port <- getServerParam(as.integer(port), "numeric", 8050) | ||
|
||
dev_tools_ui <- getServerParam(dev_tools_ui, "logical", NULL) | ||
dev_tools_props_check <- getServerParam(dev_tools_props_check, "logical", NULL) |
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.
Do you need an as.logical
here (and all the "logical"
items), for the getenv
case? In fact, perhaps getServerParam
could be written to do this coercion, at least if you start with a string?
This looks like a good solution to me - one kind of funny thing is users can provide all the run_server
args as strings - app$run_server(port="1234")
as well as app$run_server(port=1234)
- but a nice side effect is we won't accept run_server
args that don't end up with the correct type.
BTW it would be cleaner to set debug
first, then use that as the default for some of these other args - rather than needing the confusing is.null(x) && debug || isTRUE(x)
clauses.
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.
Good point. I'll make that change, you're right that the handling for logicals-as-strings is missing this critical detail.
As for the confusing clauses, following up on our offline conversation, will use debug
as their default since it is always TRUE
or FALSE
.
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.
fixed in 6131677
R/dash.R
Outdated
if (is.null(dev_tools_ui) && debug || isTRUE(dev_tools_ui)) { | ||
self$config$ui <- TRUE | ||
getServerParam <- function(value, type, default) { | ||
if (!is.null(value) && toupper(value) %in% c("TRUE", "FALSE")) |
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.
if (!is.null(value) && toupper(value) %in% c("TRUE", "FALSE")) | |
if (type == "logical" && !is.null(value) && toupper(value) %in% c("TRUE", "FALSE")) |
Maybe also add a clause
if (type == "numeric")
value <- as.numeric(value)
for the hot reload intervals; as.integer
probably has to stay where it is since that doesn't appear to map onto a type...
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 can verify that an integer is of mode numeric
and storage mode integer
, typeof
is probably a better approach but mode
and storage.mode
are other options:
> foo <- 1L
> mode(foo)
[1] "numeric"
> storage.mode(foo)
[1] "integer"
The col_info
function I wrote a while back attempts to present a summary with all the type/mode information I generally want for vectors and data.frames:
https://github.com/rpkyle/cscmisc/blob/master/R/col_info.R
e.g.
> cscmisc::col_info(foo)
mode class storage.mode is.factor
foo numeric integer integer FALSE
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.
fixed in ba7c015
@alexcjohnson As a follow-up to our offline conversation, I've tried to make handling of (what ought to be) numeric dev tools parameters a bit more robust in 2e8b90c. |
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.
🔥 💃 🔥
6b81790
to
24c254a
Compare
* Provide support for no_update in Dash for R (#111) * Use dev_tools_prune_errors instead of pruned_errors (#113) * Better handling for user-defined error conditions in debug mode (#116) * Provide support for multiple outputs (#119) * Provide support for hot reloading in Dash for R (#127) * Implement support for clientside callbacks in Dash for R (#130) * Add line number context to stack traces when srcrefs are available (#133) * Update dash-renderer to 1.2.2 and fix dev tools UI display of stack traces (#137) * Support for meta tags in Dash for R (#142) * Fixes for hot reloading interval handling and refreshing apps within viewer pane (#148) * Support for asynchronous loading/compression in Dash for R (#157) * Support returning asset URLs via public method within Dash class (#160) * Minor fix for get_asset_url + docs, add url_base_pathname (#161)
This PR proposes to support frontend and backend hot reloading in Dash for R, in a manner analogous to that currently provided in Dash for Python (plotly/dash#66, plotly/dash#362, plotly/dash-renderer#73).
The primary modifications required include
Dash
objectassets
folder, but also within the app directory root itselfdev_tools_silence_routes_logging
parameter, as in Dash for Pythonhard_reload
is set (e.g. if non-CSS assets or the app itself is modified), and runningsource
to reload the app code✨ It also proposes a new (logical)
viewer
parameter, which can be used to load Dash apps within RStudio for a more pleasant development experience. This feature requires specifying127.0.0.1
orlocalhost
for thehost
parameter; this is a restriction imposed by RStudio's API.https://www.rdocumentation.org/packages/rstudioapi/versions/0.10/topics/viewer
Additional work is required:
dev_tools_hot_reload_watch_interval
; this is used to control how frequentlywalk_assets_directory
is invoked.CHANGELOG.md
fordev
branchCloses #125.
@alexcjohnson @StalkComrade