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

Implement support for asynchronous loading in Dash for R #157

Merged
merged 30 commits into from
Dec 22, 2019
Merged

Conversation

rpkyle
Copy link
Contributor

@rpkyle rpkyle commented Dec 13, 2019

This PR proposes to provide performance enhancements previously offered in plotly/dash#899. Briefly, it will implement the following:

  • support for an eager_loading flag to permit automatic loading of components, as before
  • selective loading of Dash components based on eager_loading and async or dynamic attributes for dependencies, which will optionally prevent serving of script tags in the index for certain components (thereby allowing them to load on-demand)
  • fingerprinting and ETag support for caching resources
  • support for brotli, gzip and deflate compression of text resources

Closes #134.

@rpkyle rpkyle self-assigned this Dec 15, 2019
# need assert that async and dynamic are not both present
if (
(!is.null(resource$dynamic) && (resource$dynamic == FALSE)) ||
(eager_loading==TRUE && !is.null(resource$async) && (resource$async %in% c("eager", TRUE)))
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet Dec 19, 2019

Choose a reason for hiding this comment

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

Nonblocking.

Since the async/dynamic values are generated (as opposed to the Python values, that are hard-coded, maybe it's not as important to guard for the case where both dynamic and async are defined. Still nice to have.

We could avoid the if(true) -> false cases and rewrite the whole func as:

return (!is.null(resource$dynamic) || !is.null(resource$async)) && 
    (is.null(resource$dynamic) || resource$dynamic == TRUE) && 
    (eager_loading == FALSE || is.null(resource$async) || !(resource$async %in% c("eager", TRUE))

# RStudio
tryBrotli <- request$accepts_encoding('br')
if (tryBrotli == "br") {
response$body <- brotli::brotli_compress(charToRaw(response$body),
Copy link
Contributor

Choose a reason for hiding this comment

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

🥔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🍠

extension)
}

checkFingerprint <- function(path) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nonblocking. I was a bit confused about the fingerprint check for a few minutes because I did not see anything to handle / paths like in the Python impl, but it's being handled in the caller and only the filename portion of the path is passed here. Maybe renaming path to filename for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the path is passed here -- hence the subsequent call to basename, which extracts the filename from the complete path if provided. I think I'll leave path as-is, though the earlier call to checkFingerprint could be written with path instead of filename to avoid confusion.

Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet left a comment

Choose a reason for hiding this comment

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

Two nonblocking comments. lgtm

@rpkyle rpkyle merged commit e852995 into dev Dec 22, 2019
@rpkyle rpkyle deleted the 134-async branch December 22, 2019 02:08
@rpkyle rpkyle mentioned this pull request Jan 3, 2020
rpkyle added a commit that referenced this pull request Jan 4, 2020
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants