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

Extend validate_has_data to accept vector input #962

Merged
merged 10 commits into from
Nov 20, 2023
Merged

Conversation

vedhav
Copy link
Contributor

@vedhav vedhav commented Nov 10, 2023

Copy link
Contributor

github-actions bot commented Nov 10, 2023

badge

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  -------------------------------------------------------------------------------------------------------------------------------
R/dummy_functions.R                 92      50  45.65%   9-71
R/get_rcode_utils.R                 46       1  97.83%   49
R/include_css_js.R                  24       0  100.00%
R/init.R                            79      25  68.35%   143, 168-189, 221-223, 225-227, 229-230
R/landing_popup_module.R            25      25  0.00%    61-87
R/module_filter_manager.R          107      29  72.90%   62-70, 79-84, 228, 233-246
R/module_nested_tabs.R             176      14  92.05%   72, 119, 138-145, 163, 216, 238, 271
R/module_snapshot_manager.R        209     157  24.88%   87-99, 127-136, 140-152, 154-161, 168-182, 186-188, 190-195, 198-208, 211-227, 236-251, 265-288, 291-302, 305-311, 325, 346-369
R/module_tabs_with_filters.R        73       2  97.26%   95, 140
R/module_teal_with_splash.R        119      11  90.76%   73, 83-91, 122
R/module_teal.R                    141       8  94.33%   68, 71, 158-159, 165, 195, 203-204
R/modules_debugging.R               18      18  0.00%    25-44
R/modules.R                        143      26  81.82%   119, 132, 226-229, 243-248, 259-263, 378-421
R/reporter_previewer_module.R       18       2  88.89%   26, 30
R/show_rcode_modal.R                20      20  0.00%    16-37
R/tdata.R                           39       1  97.44%   158
R/teal_data_module.R                 6       0  100.00%
R/teal_reporter.R                   60       5  91.67%   65, 116-117, 120, 137
R/teal_slices-store.R               25       0  100.00%
R/teal_slices.R                     59      12  79.66%   135-148
R/utils.R                          110      27  75.45%   113-140
R/validate_inputs.R                 32       0  100.00%
R/validations.R                     58      37  36.21%   109-371
R/zzz.R                             11       7  36.36%   3-14
TOTAL                             1690     477  71.78%

Diff against main

Filename           Stmts    Miss  Cover
---------------  -------  ------  -------
R/validations.R       -2       0  -2.13%
TOTAL                 -2       0  -0.03%

Results for commit: 9542b13

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Nov 10, 2023

Unit Tests Summary

    1 files    18 suites   11s ⏱️
195 tests 195 ✔️ 0 💤 0
369 runs  369 ✔️ 0 💤 0

Results for commit 9542b13.

♻️ This comment has been updated with latest results.

@vedhav vedhav added bug Something isn't working core labels Nov 10, 2023
Copy link
Contributor

@chlebowa chlebowa left a comment

Choose a reason for hiding this comment

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

I disagree with the applied solution.
validate_has_data is a function specialized to deal with datasets, i.e. data.frames.
There is nothing wrong with the function, it was only used incorrectly by the module developer who passed a vector.

I think it is better to assert argument type here and fix the offending call (calls?) by adding drop = FALSE. If a vector is passed by accident (as is clearly the case) the app should fail immediately and the bug should be caught in the console by the app developer, not in the app by a user.

Also, the changes to the documentation do not reflect changes to the functionality, and the changes to the code are more of a hack than an adjustment.

@vedhav
Copy link
Contributor Author

vedhav commented Nov 16, 2023

Thanks @chlebowa reverted the changes and now it only has an assert to check for data.frame so it fails.
Only teal.modules.general had two places that could potentially return vectors to this function so created a PR for that teal.modules.general PR #601

Other places that use this function were teal.modules.clinical, teal.goshawk, and teal.osprey but they were passing a data.frame or subsetting multiple columns so this was not possible to occur.

Copy link
Contributor

github-actions bot commented Nov 16, 2023

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
teal_data_module 💀 $0.02$ $-0.02$ $-3$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
init 💀 $0.06$ $-0.06$ init_data_accepts_teal_data_module
init 👶 $+0.04$ init_data_throws_an_error_with_input_other_than_TealData_teal_data_and_ddl
init 💀 $0.03$ $-0.03$ init_data_throws_an_error_with_input_other_than_TealData_teal_data_and_list_ui_server_
init 👶 $+0.58$ init_filter_accepts_named_list_or_teal_slices_
init 💀 $0.52$ $-0.52$ init_filter_accepts_teal_slices_
init 💀 $0.05$ $-0.05$ init_throws_when_data_has_no_datanames
init 💀 $0.05$ $-0.05$ init_throws_when_incompatible_filter_s_datanames
init 💀 $0.05$ $-0.05$ init_throws_when_incompatible_module_s_datanames
module_teal 👶 $+0.04$ srv_teal_fails_when_raw_data_is_not_reactive
module_teal 💀 $0.03$ $-0.03$ srv_teal_fails_when_teal_data_rv_is_not_reactive
module_teal 👶 $+0.03$ srv_teal_initialized_data_list_structure_reflects_modules
module_teal 💀 $0.03$ $-0.03$ srv_teal_initialized_datasets_reactive_list_reflects_modules_structure
module_teal 👶 $+0.05$ srv_teal_initializes_the_data_when_raw_data_changes
module_teal 💀 $0.05$ $-0.05$ srv_teal_when_teal_data_rv_changes_datasets_reactive_is_initialized_as_list_of_FilteredData
module_teal_with_splash 👶 $+0.03$ srv_teal_with_splash_creates_reactiveVal_returning_teal_data
module_teal_with_splash 💀 $0.02$ $-0.02$ srv_teal_with_splash_data_accepts_a_teal_data_module
module_teal_with_splash 💀 $0.02$ $-0.02$ srv_teal_with_splash_passes_teal_data_to_reactive
module_teal_with_splash 💀 $0.02$ $-0.02$ srv_teal_with_splash_teal_data_rv_evaluates_the_server_of_teal_data_module
module_teal_with_splash 💀 $0.03$ $-0.03$ srv_teal_with_splash_teal_data_rv_validate_returns_teal_data_if_incompatible_filter_s_datanames
module_teal_with_splash 💀 $0.03$ $-0.03$ srv_teal_with_splash_teal_data_rv_validate_throws_then_qenv.error_occurs
module_teal_with_splash 💀 $0.04$ $-0.04$ srv_teal_with_splash_teal_data_rv_validate_throws_when_incompatible_module_s_datanames
module_teal_with_splash 💀 $0.02$ $-0.02$ srv_teal_with_splash_teal_data_rv_validate_throws_when_teal_data_module_doesn_t_return_teal_data
module_teal_with_splash 💀 $0.02$ $-0.02$ srv_teal_with_splash_teal_data_rv_validate_throws_when_teal_data_module_returns_error
module_teal_with_splash 💀 $0.04$ $-0.04$ srv_teal_with_splash_throws_when_datanames_are_empty
module_teal_with_splash 💀 $0.02$ $-0.02$ srv_teal_with_splash_throws_when_teal_data_module_doesn_t_return_reactive
teal_data_module 💀 $0.01$ $-0.01$ teal_data_module_returns_teal_data_module
teal_data_module 💀 $0.01$ $-0.01$ teal_data_module_throws_when_server_has_other_formals_than_id_only
teal_data_module 💀 $0.01$ $-0.01$ teal_data_module_throws_when_ui_has_other_formals_than_id_only

Results for commit 827755e

♻️ This comment has been updated with latest results.

R/validations.R Outdated Show resolved Hide resolved
Co-authored-by: Aleksander Chlebowski <[email protected]>
Signed-off-by: Vedha Viyash <[email protected]>
R/validations.R Outdated Show resolved Hide resolved
Co-authored-by: Aleksander Chlebowski <[email protected]>
Signed-off-by: Vedha Viyash <[email protected]>
Copy link
Contributor

@chlebowa chlebowa left a comment

Choose a reason for hiding this comment

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

👍

@vedhav vedhav merged commit fcca8ec into main Nov 20, 2023
23 checks passed
@vedhav vedhav deleted the 961-validate-vectors-too branch November 20, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: tm_outliers module - not able to use categorical_var
2 participants