-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
189 - Add Pattern Matching Callbacks for Dash R #228
Conversation
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.
Nice work! This feature required some serious work to get right, definitely not one of the simpler improvements to the framework in R, but definitely one of the most valuable.
The majority of my comments relate to DRYing up the code a bit, but there are some spots where the code is a little hard to follow without comments. In particular, we should probably review setCallbackContext
since this function has gotten a lot more complex and I'm not completely sure what's happening in a few spots.
On the testing side of things, we'll definitely want to add a couple unit tests to ensure errors are thrown, and at least a basic integration test to confirm that a simple app using a pattern matching callback (like the to-do list example) works as expected. Really excited to see the arrival of this feature in R, one of the cooler improvements to Dash in quite a while.
👏 🏆 👏
R/dash.R
Outdated
if ("id.index" %in% names(unlist(input_element))) { | ||
unlisted_input <- unlist(input_element) |
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.
We could 🌴 this up a little by moving the unlist(input_element)
outside of the if
.
If what we're mostly interested in is names(unlisted_input)
, we could actually assign that instead, and use it where needed below.
Just an observation, but I think this may be a circumstance where using a for
loop and a conditional causes a lot of housekeeping that could avoided by retaining the original list
structure. For example, here:
values <- unname(unlisted_input[names(unlisted_input) == "value" | names(unlisted_input) == "value.index"])
we have to call names
twice, even though we already extracted the names above
On the other hand, had we left it as a list
, we could instead try
values <- unlist(input_list[c("value", "value.index")], use.names=FALSE)
which I think would give us what we want in a slightly easier-to-read/easier-to-follow way. I haven't tried it (and input_list
is so compact it hardly matters), but I suspect this might be a bit more efficient for large lists as well.
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'm a bit hesitant to change this part for a couple of reasons. For a normal callback, request$body$inputs
is already a named list, and unlisting that would make handling regular callbacks more complicated as we then have to append a list of lists to callback_args
for default callbacks.
In the case of pattern matching callbacks, each input_element
is a list of lists. By unlisting it we can access each of the wildcard inputs. I tried to use a vector to subset as you suggested, but while it works for some scenarios, on the initial call of the PMC we run into a subscript out of bounds error, and it might overcomplicate it to account for another condition. We'll also have to deal with NA
values that can come up if the input doesn't have a value.index
.
I'll try to figure out a way to simplify it and improve readability, but I think unlisting with a for loop
in this case would have to be a necessary evil.
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.
OK, trust your judgment (since I do as well). Though one remark I'd make is that the out of bounds error may be related to the current default values for callback inputs, which is list(NULL)
. In that case, we could probably just ensure these values are handled properly, but don't worry about this for now.
We can always revisit the implementation later if we have an epiphany about making it a little more concise, for the moment it looks OK as-is.
R/utils.R
Outdated
setCallbackContext <- function(callback_elements) { | ||
states <- lapply(callback_elements$states, function(x) { | ||
setNames(x$value, paste(x$id, x$property, sep=".")) | ||
}) | ||
# Set state elements for this callback | ||
|
||
if (length(callback_elements$state[[1]]) == 0) { | ||
states <- sapply(callback_elements$state, function(x) { | ||
setNames(list(x$value), paste(x$id, x$property, sep=".")) | ||
}) | ||
} else if (is.character(callback_elements$state[[1]][[1]])) { | ||
states <- sapply(callback_elements$state, function(x) { | ||
setNames(list(x$value), paste(x$id, x$property, sep=".")) | ||
}) | ||
} else { | ||
states <- sapply(callback_elements$state, function(x) { | ||
states_vector <- unlist(x) | ||
setNames(list(states_vector[names(states_vector) == "value" | names(states_vector) == "value.index"]), | ||
paste(as.character(jsonlite::toJSON(x[[1]])), x$property, sep=".")) | ||
}) | ||
} | ||
|
||
splitIdProp <- function(x) unlist(strsplit(x, split = "[.]")) | ||
|
||
triggered <- lapply(callback_elements$changedPropIds, | ||
function(x) { | ||
input_id <- splitIdProp(x)[1] | ||
prop <- splitIdProp(x)[2] | ||
|
||
id_match <- vapply(callback_elements$inputs, function(x) x$id %in% input_id, logical(1)) | ||
prop_match <- vapply(callback_elements$inputs, function(x) x$property %in% prop, logical(1)) | ||
|
||
value <- sapply(callback_elements$inputs[id_match & prop_match], `[[`, "value") | ||
|
||
list(`prop_id` = x, `value` = value) | ||
|
||
# The following conditionals check whether the callback is a pattern-matching callback and if it has been triggered. | ||
if (startsWith(input_id, "{")){ | ||
id_match <- vapply(callback_elements$inputs, function(x) { | ||
x <- unlist(x) | ||
any(x[names(x) == "id.index"] %in% jsonlite::fromJSON(input_id)[[1]]) | ||
}, logical(1))[[1]] | ||
} else { | ||
id_match <- vapply(callback_elements$inputs, function(x) x$id %in% input_id, logical(1)) | ||
} | ||
|
||
if (startsWith(input_id, "{")){ | ||
prop_match <- vapply(callback_elements$inputs, function(x) { | ||
x <- unlist(x) | ||
any(x[names(x) == "property"] %in% prop) | ||
}, logical(1))[[1]] | ||
} else { | ||
prop_match <- vapply(callback_elements$inputs, function(x) x$property %in% prop, logical(1)) | ||
} | ||
|
||
if (startsWith(input_id, "{")){ | ||
if (length(callback_elements$inputs) == 1) { | ||
value <- sapply(callback_elements$inputs[id_match & prop_match], `[[`, "value") | ||
} else { | ||
value <- sapply(callback_elements$inputs[id_match & prop_match][[1]], `[[`, "value") | ||
} | ||
} else { | ||
value <- sapply(callback_elements$inputs[id_match & prop_match], `[[`, "value") | ||
} | ||
|
||
if (startsWith(input_id, "{")){ | ||
return(list(`prop_id` = x, `value` = value)) | ||
} else { | ||
return(list(`prop_id` = x, `value` = value)) | ||
} | ||
} | ||
) | ||
|
||
inputs <- sapply(callback_elements$inputs, function(x) { | ||
setNames(list(x$value), paste(x$id, x$property, sep=".")) | ||
}) | ||
) | ||
if (length(callback_elements$inputs[[1]]) == 0) { | ||
inputs <- sapply(callback_elements$inputs, function(x) { | ||
setNames(list(x$value), paste(x$id, x$property, sep=".")) | ||
}) | ||
} else if (is.character(callback_elements$inputs[[1]][[1]])) { | ||
inputs <- sapply(callback_elements$inputs, function(x) { | ||
setNames(list(x$value), paste(x$id, x$property, sep=".")) | ||
}) | ||
} else if (length(callback_elements$inputs[[1]]) > 1) { | ||
inputs <- sapply(callback_elements$inputs, function(x) { | ||
inputs_vector <- unlist(x) | ||
setNames(list(inputs_vector[names(inputs_vector) == "value" | names(inputs_vector) == "value.index"]), paste(as.character(jsonlite::toJSON(x$id)), x$property, sep=".")) | ||
}) | ||
} else { | ||
inputs <- sapply(callback_elements$inputs, function(x) { | ||
inputs_vector <- unlist(x) | ||
setNames(list(inputs_vector[names(inputs_vector) == "value" | names(inputs_vector) == "value.index"]), paste(as.character(jsonlite::toJSON(x[[1]]$id)), x[[1]]$property, sep=".")) | ||
}) | ||
} |
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 suspect we could DRY this function up a bit as well. I was hoping to ask you about this block:
if (startsWith(input_id, "{")){
return(list(`prop_id` = x, `value` = value))
} else {
return(list(`prop_id` = x, `value` = value))
}
Is it just me or did we end up with some 🍝 in one of those two branches? I kept staring at it thinking I must have missed something. 🤔
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 suspect we could DRY this function up a bit as well. I was hoping to ask you about this block:
As discussed offline, we're going to see if it's possible to DRY up the first part of the function, and see if there's a cleaner way to handle the pattern matching callbacks case within setCallbackContext
:
} else if (length(callback_elements$inputs[[1]]) > 1) {
inputs <- sapply(callback_elements$inputs, function(x) {
inputs_vector <- unlist(x)
setNames(list(inputs_vector[names(inputs_vector) == "value" | names(inputs_vector) == "value.index"]), paste(as.character(jsonlite::toJSON(x$id)), x$property, sep="."))
})
} else {
inputs <- sapply(callback_elements$inputs, function(x) {
inputs_vector <- unlist(x)
setNames(list(inputs_vector[names(inputs_vector) == "value" | names(inputs_vector) == "value.index"]), paste(as.character(jsonlite::toJSON(x[[1]]$id)), x[[1]]$property, sep="."))
})
}
wildcards_test.R
Outdated
@@ -0,0 +1,147 @@ | |||
# Simple Example with 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.
Nice sample app! As far as tests go, I imagine we might want to consider
- unit tests in
tests/testthat
(for throwing errors when callbacks are misspecified, afterapp$callback
is invoked, but beforeapp$run_server()
is used) - a simple integration test to check functionality at adding/removing elements (like with Alex's to-do list app)
- at least some of the checks we implemented in https://github.com/plotly/dash/blob/master/tests/integration/devtools/test_callback_validation.py, we should probably ensure we error out on the same items in R as we do in Python (and maybe provide the same messages when possible)
Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com>
Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com>
Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com>
Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com>
@HammadTheOne In addition to Alex's comments, do we currently handle/store In Python, it looks like these are stored via Flask's application context; I believe in Fiery the analog is assigning these values via ( |
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.
💃 Fantastic, that's all from me!
💃 🚀 |
* New feature: callback graph improvements and timing (#224) * New feature: support user-defined server routes and redirects (#225) * Enable setting script and stylesheet attributes (#226) * New feature: Pattern-Matching Callbacks (#228) * Authenticate on pulls from Docker Hub (#231) * Fixed a bug in the usage of glue (#233) * Update dash-renderer to v1.8.2 (#234) Co-authored-by: HammadTheOne <hammadkhan@plotly.com>
* contribute test script * remove version updating in DESCRIPTION * fix EOL Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Add support for user-defined server routes (#225) * Provide support for script and stylesheet attributes (#226) * Authenticate on pulls from Docker Hub (#231) * Add support for callback graph improvements and timing (#224) * Update CHANGELOG.md * 189 - Add Pattern Matching Callbacks for Dash R (#228) * Testing initial implementation * More testing * Callback Context Updates * Updating callback context logic * Fixing callback returns * Adding callback args conditional * Cleanup and additional changes to callback value conditionals * Comment cleanup * Added PMC callback validation, removed unnecessary code * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Added build to gitignore * Updated dependencies.R * Update boilerplate docs and add wildcard symbols * Drying up validation code and applying symbol logic * Update test to use symbols * Cleaned up code and added allsmaller test example * Cleaning up redundant code * Update FUNDING.yml * Updated callback_args logic and example * Adding basic unittests, updated validation * Fixed response for MATCH callbacks * Added integration test and updated examples for docs * Added additional integration test * Formatting and cleanup * update docs * Update to-do app * Add comments to examples * Change empy vector to character type. Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update boilerplate text. Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/testthat/test-wildcards.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Removed triple colon syntax * Use seq_along and remove unnecessary unittest * Update CHANGELOG.md * Update CHANGELOG.md * Add support for arbitrary and sorted keys * Whitespace deleted * Added integration tests * Fixing test output * Fixing flakiness * Update test_pattern_matching.py * Update test_pattern_matching.py * Updating boilerplate text and test with generalized keys * Minor test fixes Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Nicolas Kruchten <nicolas@plot.ly> Co-authored-by: rpkyle <ryan@plotly.com> * Fixing Null error with glue::glue interpolation (#233) * Fixing NULL error with glue interpolation * Update utils.R * Update utils.R * Update CHANGELOG.md * Update dash-renderer to v1.8.2 (#234) * bump dash-renderer to v1.8.2 * Update CHANGELOG.md * add note about update to dash-renderer * Fixing flaky test * bump package version to v0.8.0 * Update R/dash.R Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/testthat/test-wildcards.R Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update DESCRIPTION Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * add PMC example * update documentation * update CHANGELOG release date * 🔨 PMC docs refactor * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * add import of glue * add glue to imports.R * fix line length issue * Fix setCallbackContext for wildcard and ordinary inputs (#237) * Update setCallbackContext * Adding graphs test * Slight fix * bump version and update CHANGELOG * Less flaky test Co-authored-by: rpkyle <ryan@plotly.com> * bump dependency versions * update CHANGELOG * update dash-renderer to v1.8.3 * update CHANGELOG * Favicon fix (#240) * Adding default favicon * Removing redundant codeblock * Added default favicon * Minor fix to requests prefix * Update CHANGELOG.md Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Added simple test * Fixed typo * Fixed typo Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Remove context reference from CircleCI (#241) * Dash R Core Package Unification (#243) * Initialize npm and gulpfile in repo * Adding directory structure * Initial implementation of unification script * Minor grep fixes * Fixed DESCRIPTION imports * Added updated dash-table deps * Regex for version numbers * Cut import entries from NAMESPACE * Remove && include(dashr) * Removing gulp-asset artifacts and rebuilding complete package * Removing unnecessary files * fix: remove html, core pkgs from tests * fix: update script tags unit test * Revert R6 import * Add temporary collate * Update README examples * Scrubbing imports * More import scrubbing * Package development updates * Update gitignore and namespace * Updated gulpfile jobs * Updated all dependencies * Added templates for namespace/internal exports * Update internal, namespace, and gulpfile cleanup * Fix dependency sourcing * Linting * Adding job for asset retrieval and deletion * Minor src change * Added error handling * Fixing favicon bug * chore: use shallow clone Co-authored-by: Ryan Patrick Kyle <ryan@plotly.com> * Added deprecation warning if dcc, html, or table packages are attached (#249) * Added deprecation warning * Update R/dash.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update `highlight.js` dependency for dash-table (#262) * Updating gulpfile * Updating dependencies for dash components * Updated highlight.js dependency source * Add Dash 2 layout syntax wrappers and html tags (#265) * Added add_meta helper * Add helper functions and export pipe * Adding in tags wrapper * Updating ci config * Updated CHANGELOG * Updated circleci to include rust package manager (cargo). * Removed dashr command in circleci config. * Updating changelog * added basic test * Cleaning up Dash 2 references and duplication * Updated documentation * Allow conditional UI * Add meta tag check * More cleanup * Last bit of cleanup Co-authored-by: Steve Sperandeo <steve.sperandeo@gmail.com> * Fix suppress_callback_exceptions config (#268) * Add config key * Fixing CI * Simplified callback syntax and addtional utility functions (#270) * Tag updates * Added RStudio dash snippet * Added simple_table * Added flexible callbacks * Documentation and NAMESPACE updates * Updated DESCRIPTION * Adding unittests * Adding context tags to tests * Updated CHANGELOG * Update monorepo and rebuild package (#271) * Updating gulpfile and package.json * More package.json and linting updates * Adding in simplified callback updates/tests * Import fixes * Updating package.json * Gulpfile script changes * Gulpfile updates * Rebuilding package with monorepo updates * Re-running test * Updating unittest * Updating test dependencies * Updating DESCRIPTION and .Rbuildignore forchecks * Updating function descriptions and NAMESPACE imports * Fixed examples and updated docs * Updating version * Remove references to dash namespace within package * Update testthat and remove deprecated context calls * Removed fixup_metadata.R * Removing more dash namespace references * Concatenating component function files * Updating checks * Merging components into package R files * Fixing check * More package cleanup * testthat 3.0.0 * Rebuilding package * Fixed conditional for multiple outputs * Fix no_update test * Fixing callback_instrumentation test * Fixing unit test * Added DBC to Dash R package (#273) * Adding dbc to dashR namespace * updated gitignore * Adding dbc docs and updating gulpfile * Updating test with dbc * Moved misc tests and added dbc snapshot * Fixing test * fixing id * Fixed export and test * Reverting sorted prop order * Checks updates * Re-running test Co-authored-by: Ryan Patrick Kyle <ryan@plot.ly> Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Nicolas Kruchten <nicolas@plot.ly> Co-authored-by: rpkyle <ryan@plotly.com> Co-authored-by: Steve Sperandeo <steve.sperandeo@gmail.com>
* contribute test script * remove version updating in DESCRIPTION * fix EOL Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Add support for user-defined server routes (#225) * Provide support for script and stylesheet attributes (#226) * Authenticate on pulls from Docker Hub (#231) * Add support for callback graph improvements and timing (#224) * Update CHANGELOG.md * 189 - Add Pattern Matching Callbacks for Dash R (#228) * Testing initial implementation * More testing * Callback Context Updates * Updating callback context logic * Fixing callback returns * Adding callback args conditional * Cleanup and additional changes to callback value conditionals * Comment cleanup * Added PMC callback validation, removed unnecessary code * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Added build to gitignore * Updated dependencies.R * Update boilerplate docs and add wildcard symbols * Drying up validation code and applying symbol logic * Update test to use symbols * Cleaned up code and added allsmaller test example * Cleaning up redundant code * Update FUNDING.yml * Updated callback_args logic and example * Adding basic unittests, updated validation * Fixed response for MATCH callbacks * Added integration test and updated examples for docs * Added additional integration test * Formatting and cleanup * update docs * Update to-do app * Add comments to examples * Change empy vector to character type. Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update boilerplate text. Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/testthat/test-wildcards.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Removed triple colon syntax * Use seq_along and remove unnecessary unittest * Update CHANGELOG.md * Update CHANGELOG.md * Add support for arbitrary and sorted keys * Whitespace deleted * Added integration tests * Fixing test output * Fixing flakiness * Update test_pattern_matching.py * Update test_pattern_matching.py * Updating boilerplate text and test with generalized keys * Minor test fixes Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Nicolas Kruchten <nicolas@plot.ly> Co-authored-by: rpkyle <ryan@plotly.com> * Fixing Null error with glue::glue interpolation (#233) * Fixing NULL error with glue interpolation * Update utils.R * Update utils.R * Update CHANGELOG.md * Update dash-renderer to v1.8.2 (#234) * bump dash-renderer to v1.8.2 * Update CHANGELOG.md * add note about update to dash-renderer * Fixing flaky test * bump package version to v0.8.0 * Update R/dash.R Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/testthat/test-wildcards.R Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update DESCRIPTION Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * add PMC example * update documentation * update CHANGELOG release date * 🔨 PMC docs refactor * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * add import of glue * add glue to imports.R * fix line length issue * Fix setCallbackContext for wildcard and ordinary inputs (#237) * Update setCallbackContext * Adding graphs test * Slight fix * bump version and update CHANGELOG * Less flaky test Co-authored-by: rpkyle <ryan@plotly.com> * bump dependency versions * update CHANGELOG * update dash-renderer to v1.8.3 * update CHANGELOG * Favicon fix (#240) * Adding default favicon * Removing redundant codeblock * Added default favicon * Minor fix to requests prefix * Update CHANGELOG.md Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Added simple test * Fixed typo * Fixed typo Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Remove context reference from CircleCI (#241) * Dash R Core Package Unification (#243) * Initialize npm and gulpfile in repo * Adding directory structure * Initial implementation of unification script * Minor grep fixes * Fixed DESCRIPTION imports * Added updated dash-table deps * Regex for version numbers * Cut import entries from NAMESPACE * Remove && include(dashr) * Removing gulp-asset artifacts and rebuilding complete package * Removing unnecessary files * fix: remove html, core pkgs from tests * fix: update script tags unit test * Revert R6 import * Add temporary collate * Update README examples * Scrubbing imports * More import scrubbing * Package development updates * Update gitignore and namespace * Updated gulpfile jobs * Updated all dependencies * Added templates for namespace/internal exports * Update internal, namespace, and gulpfile cleanup * Fix dependency sourcing * Linting * Adding job for asset retrieval and deletion * Minor src change * Added error handling * Fixing favicon bug * chore: use shallow clone Co-authored-by: Ryan Patrick Kyle <ryan@plotly.com> * Added deprecation warning if dcc, html, or table packages are attached (#249) * Added deprecation warning * Update R/dash.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update `highlight.js` dependency for dash-table (#262) * Updating gulpfile * Updating dependencies for dash components * Updated highlight.js dependency source * Add Dash 2 layout syntax wrappers and html tags (#265) * Added add_meta helper * Add helper functions and export pipe * Adding in tags wrapper * Updating ci config * Updated CHANGELOG * Updated circleci to include rust package manager (cargo). * Removed dashr command in circleci config. * Updating changelog * added basic test * Cleaning up Dash 2 references and duplication * Updated documentation * Allow conditional UI * Add meta tag check * More cleanup * Last bit of cleanup Co-authored-by: Steve Sperandeo <steve.sperandeo@gmail.com> * Fix suppress_callback_exceptions config (#268) * Add config key * Fixing CI * Simplified callback syntax and addtional utility functions (#270) * Tag updates * Added RStudio dash snippet * Added simple_table * Added flexible callbacks * Documentation and NAMESPACE updates * Updated DESCRIPTION * Adding unittests * Adding context tags to tests * Updated CHANGELOG * Update monorepo and rebuild package (#271) * Updating gulpfile and package.json * More package.json and linting updates * Adding in simplified callback updates/tests * Import fixes * Updating package.json * Gulpfile script changes * Gulpfile updates * Rebuilding package with monorepo updates * Re-running test * Updating unittest * Updating test dependencies * Updating DESCRIPTION and .Rbuildignore forchecks * Updating function descriptions and NAMESPACE imports * Fixed examples and updated docs * Updating version * Remove references to dash namespace within package * Update testthat and remove deprecated context calls * Removed fixup_metadata.R * Removing more dash namespace references * Concatenating component function files * Updating checks * Merging components into package R files * Fixing check * More package cleanup * testthat 3.0.0 * Rebuilding package * Fixed conditional for multiple outputs * Fix no_update test * Fixing callback_instrumentation test * Fixing unit test * Added DBC to Dash R package (#273) * Adding dbc to dashR namespace * updated gitignore * Adding dbc docs and updating gulpfile * Updating test with dbc * Moved misc tests and added dbc snapshot * Fixing test * fixing id * Fixed export and test * Reverting sorted prop order * Checks updates * Re-running test * Remove html exports and update tags (#274) * Updating tags and html exports * Re-running tests * Updating tag generation * Re-running tests * Updating tests to use new html list syntax * Adjusting tests * Re-run tests again * Updating tests * Wrapping up test fixes * Percy test Co-authored-by: Ryan Patrick Kyle <ryan@plot.ly> Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Nicolas Kruchten <nicolas@plot.ly> Co-authored-by: rpkyle <ryan@plotly.com> Co-authored-by: Steve Sperandeo <steve.sperandeo@gmail.com>
* contribute test script * remove version updating in DESCRIPTION * fix EOL Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Add support for user-defined server routes (#225) * Provide support for script and stylesheet attributes (#226) * Authenticate on pulls from Docker Hub (#231) * Add support for callback graph improvements and timing (#224) * Update CHANGELOG.md * 189 - Add Pattern Matching Callbacks for Dash R (#228) * Testing initial implementation * More testing * Callback Context Updates * Updating callback context logic * Fixing callback returns * Adding callback args conditional * Cleanup and additional changes to callback value conditionals * Comment cleanup * Added PMC callback validation, removed unnecessary code * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update R/dependencies.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Added build to gitignore * Updated dependencies.R * Update boilerplate docs and add wildcard symbols * Drying up validation code and applying symbol logic * Update test to use symbols * Cleaned up code and added allsmaller test example * Cleaning up redundant code * Update FUNDING.yml * Updated callback_args logic and example * Adding basic unittests, updated validation * Fixed response for MATCH callbacks * Added integration test and updated examples for docs * Added additional integration test * Formatting and cleanup * update docs * Update to-do app * Add comments to examples * Change empy vector to character type. Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update boilerplate text. Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update tests/testthat/test-wildcards.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update wildcards_test.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Removed triple colon syntax * Use seq_along and remove unnecessary unittest * Update CHANGELOG.md * Update CHANGELOG.md * Add support for arbitrary and sorted keys * Whitespace deleted * Added integration tests * Fixing test output * Fixing flakiness * Update test_pattern_matching.py * Update test_pattern_matching.py * Updating boilerplate text and test with generalized keys * Minor test fixes Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Nicolas Kruchten <nicolas@plot.ly> Co-authored-by: rpkyle <ryan@plotly.com> * Fixing Null error with glue::glue interpolation (#233) * Fixing NULL error with glue interpolation * Update utils.R * Update utils.R * Update CHANGELOG.md * Update dash-renderer to v1.8.2 (#234) * bump dash-renderer to v1.8.2 * Update CHANGELOG.md * add note about update to dash-renderer * Fixing flaky test * bump package version to v0.8.0 * Update R/dash.R Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/testthat/test-wildcards.R Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update DESCRIPTION Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * add PMC example * update documentation * update CHANGELOG release date * 🔨 PMC docs refactor * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * Update tests/integration/callbacks/test_pattern_matching.py Co-authored-by: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> * add import of glue * add glue to imports.R * fix line length issue * Fix setCallbackContext for wildcard and ordinary inputs (#237) * Update setCallbackContext * Adding graphs test * Slight fix * bump version and update CHANGELOG * Less flaky test Co-authored-by: rpkyle <ryan@plotly.com> * bump dependency versions * update CHANGELOG * update dash-renderer to v1.8.3 * update CHANGELOG * Favicon fix (#240) * Adding default favicon * Removing redundant codeblock * Added default favicon * Minor fix to requests prefix * Update CHANGELOG.md Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Added simple test * Fixed typo * Fixed typo Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Remove context reference from CircleCI (#241) * Dash R Core Package Unification (#243) * Initialize npm and gulpfile in repo * Adding directory structure * Initial implementation of unification script * Minor grep fixes * Fixed DESCRIPTION imports * Added updated dash-table deps * Regex for version numbers * Cut import entries from NAMESPACE * Remove && include(dashr) * Removing gulp-asset artifacts and rebuilding complete package * Removing unnecessary files * fix: remove html, core pkgs from tests * fix: update script tags unit test * Revert R6 import * Add temporary collate * Update README examples * Scrubbing imports * More import scrubbing * Package development updates * Update gitignore and namespace * Updated gulpfile jobs * Updated all dependencies * Added templates for namespace/internal exports * Update internal, namespace, and gulpfile cleanup * Fix dependency sourcing * Linting * Adding job for asset retrieval and deletion * Minor src change * Added error handling * Fixing favicon bug * chore: use shallow clone Co-authored-by: Ryan Patrick Kyle <ryan@plotly.com> * Added deprecation warning if dcc, html, or table packages are attached (#249) * Added deprecation warning * Update R/dash.R Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> * Update `highlight.js` dependency for dash-table (#262) * Updating gulpfile * Updating dependencies for dash components * Updated highlight.js dependency source * Add Dash 2 layout syntax wrappers and html tags (#265) * Added add_meta helper * Add helper functions and export pipe * Adding in tags wrapper * Updating ci config * Updated CHANGELOG * Updated circleci to include rust package manager (cargo). * Removed dashr command in circleci config. * Updating changelog * added basic test * Cleaning up Dash 2 references and duplication * Updated documentation * Allow conditional UI * Add meta tag check * More cleanup * Last bit of cleanup Co-authored-by: Steve Sperandeo <steve.sperandeo@gmail.com> * Fix suppress_callback_exceptions config (#268) * Add config key * Fixing CI * Simplified callback syntax and addtional utility functions (#270) * Tag updates * Added RStudio dash snippet * Added simple_table * Added flexible callbacks * Documentation and NAMESPACE updates * Updated DESCRIPTION * Adding unittests * Adding context tags to tests * Updated CHANGELOG * Update monorepo and rebuild package (#271) * Updating gulpfile and package.json * More package.json and linting updates * Adding in simplified callback updates/tests * Import fixes * Updating package.json * Gulpfile script changes * Gulpfile updates * Rebuilding package with monorepo updates * Re-running test * Updating unittest * Updating test dependencies * Updating DESCRIPTION and .Rbuildignore forchecks * Updating function descriptions and NAMESPACE imports * Fixed examples and updated docs * Updating version * Remove references to dash namespace within package * Update testthat and remove deprecated context calls * Removed fixup_metadata.R * Removing more dash namespace references * Concatenating component function files * Updating checks * Merging components into package R files * Fixing check * More package cleanup * testthat 3.0.0 * Rebuilding package * Fixed conditional for multiple outputs * Fix no_update test * Fixing callback_instrumentation test * Fixing unit test * Added DBC to Dash R package (#273) * Adding dbc to dashR namespace * updated gitignore * Adding dbc docs and updating gulpfile * Updating test with dbc * Moved misc tests and added dbc snapshot * Fixing test * fixing id * Fixed export and test * Reverting sorted prop order * Checks updates * Re-running test * Remove html exports and update tags (#274) * Updating tags and html exports * Re-running tests * Updating tag generation * Re-running tests * Updating tests to use new html list syntax * Adjusting tests * Re-run tests again * Updating tests * Wrapping up test fixes * Percy test * CRAN submission updates * Fix callback outputs with short ID's (#280) * CRAN submission updates * Callback output ID validation fixes * Updating duplicate callbacks test * Security updates * Update R/utils.R Co-authored-by: Dean Attali <dean@attalitech.com> * Updating error message Co-authored-by: Dean Attali <dean@attalitech.com> * Updating README link Co-authored-by: Ryan Patrick Kyle <ryan@plot.ly> Co-authored-by: Ryan Patrick Kyle <rpkyle@users.noreply.github.com> Co-authored-by: Nicolas Kruchten <nicolas@plot.ly> Co-authored-by: rpkyle <ryan@plotly.com> Co-authored-by: Steve Sperandeo <steve.sperandeo@gmail.com> Co-authored-by: Dean Attali <dean@attalitech.com>
This PR adds front-end support in Dash for R for parsing and passing through Pattern Matching ID's and values into callback arguments, similar to plotly/dash#1103. It involves changes to the route handler for callbacks in Dash for R, callback context updates to correctly identify triggered component ID's and values, and dependency changes to allow input, output, and state id's to be passed as lists.
An example of PMC for Dash R in action:
This PR is still a work in progress, standard unit tests and callback validation have to be added before it is merged.
wildcards_test.R
- Placeholder for easier local testing.Closes #189