-
-
Notifications
You must be signed in to change notification settings - Fork 51
Fix module print method for nested decorator lists #1685
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
- Updated format.teal_module to recursively extract decorator labels from nested lists - Added tests for single, multiple, and nested decorator structures - Fixes issue where decorators in nested lists showed NULL instead of labels Co-authored-by: m7pr <133694481+m7pr@users.noreply.github.com>
…action - Added depth parameter with limit of 10 to prevent potential infinite recursion - Improved code safety based on code review feedback - All tests still pass Co-authored-by: m7pr <133694481+m7pr@users.noreply.github.com>
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Unit Tests Summary 1 files 29 suites 2m 20s ⏱️ Results for commit 7e94ee2. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit e9c5e64 ♻️ This comment has been updated with latest results. |
Code Coverage SummaryDiff against mainResults for commit: 7e94ee2 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
llrs-roche
left a comment
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.
Nicely tested with format()!
I miss some tests with a mix of decorators: one general and some others specific:
decorators = list(decorator0.
table = list(decorator1, decorator2),
plot = list(decorator3)
)
I see it works but see also my comment about having a tree structure to know which decorator is applied to each object.
llrs-roche
left a comment
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.
My local checks fail: [ FAIL 7 | WARN 0 | SKIP 0 | PASS 85 ] I'm not sure why, but it might be related to the [ opened that are not closed that are somehow misidentified.
One last comment, are the semicolons : not aligned on purpose? See the proposed changes
I think it is fine for the individual objects but wanted to check with you.
Possible alignment of semicolons:
| |- Server Arguments :
| |- Decorators :
| | |- Global Decorator
| | |- table: Decorator One, Decorator Two
| | L- plot : Decorator Three
| L- Transformators :
Now that I think of it a similar modification might be in order for Transformators.
Co-authored-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
|
That would be perfect, but I wasn't sure if the decorators as being less important (?) were worth to indent as the other sections. Not sure if people use this feature much and we dedicated enough time already ... I'll leave it up to you |
llrs-roche
left a comment
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 like the output when there are decorators and transformators.
I found format.teal_module quite complex (cyclocomp complexity of 46!).
Lines of codes to handle:
- Datasets: 430:436 -> 6
- properties: 438:447 ->9
- arguments: 449:560 -> 111
- decorators: 492:558 ->66
- transformators 562:588->26
Couldn't some code from transformators be reused on the arguments to handle decorators? Or extract some of these in a separate function? I think it would be great if we can make it simpler.
What should be the output when there are not transformators or decorators?
Testing without them they are printed but with no information: should the leaves not be printed, have NULL or something else? Maybe this was discussed and I missed it.
print(test_module)
|- Test Module with All Features
| |- Datasets: all
| |- Properties:
| | |- Bookmarkable: FALSE
| | L- Reportable: TRUE
| |- Arguments:
| | |- templates_ids (character)
| | L- templates (data.frame)
| | L- Decorators:
| |- Transformators: Test files check that something is present not how. I leave some minor comments about the code style and there is one on tests that I think applies to multiple tests.
llrs-roche
left a comment
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.
Looks great! The code is easier to follow now.
One last nitpick, some leaves seem to carry on some | that does not continue below. If possible it would be great to fix, if not it good enough now in my opinion.
| |- Transformators:
- | | L- Data Transformator
+ | L- Data Transformator
|- Bare Module (no decorators, no transformators)
| |- Datasets: all
| |- Properties:
| | |- Bookmarkable: FALSE
| | L- Reportable: FALSE
| |- Arguments:
- | | |- page_size (numeric)
- | | L- cache (logical)
+ | |- page_size (numeric)
+ | L- cache (logical)…com/insightsengineering/teal into copilot/improve-module-print-method
|
@llrs-roche I added the requested change
Lastly, I see 2 tests fail locally - one for teal.slice and one for teal.reporter hmm ── Failed tests ──────────────────────────────────────────────────────────────
Failure (test-teal_reporter.R:2:3): TealReportCard object can be initialized
Expected `TealReportCard$new()` to produce warnings.
Backtrace:
▆
1. └─lifecycle::expect_deprecated(TealReportCard$new()) at test-teal_reporter.R:2:3
2. └─testthat::expect_warning(...)
Error (test-teal_slices.R:192:3): c.teal_slices combines mapping of two equal slices objects but ignores adding duplicated one
Error in `teal.slice::teal_slices(..., exclude_varnames = exclude_varnames, include_varnames = include_varnames, count_type = count_type, allow_add = allow_add)`: Some teal_slice objects have the same id:
test1
Backtrace:
▆
1. ├─testthat::expect_identical(...) at test-teal_slices.R:192:3
2. │ └─testthat::quasi_label(enquo(object), label)
3. │ └─rlang::eval_bare(expr, quo_get_env(quo))
4. ├─base::c(tss1, tss2)
5. ├─teal:::c.teal_slices(tss1, tss2)
6. │ ├─base::do.call(...)
7. │ └─teal (local) `<fn>`(...)
8. │ ├─shiny::isolate(...) at teal/R/teal_slices.R:81:3
9. │ │ ├─shiny::..stacktraceoff..(...)
10. │ │ └─ctx$run(...)
11. │ │ ├─promises::with_promise_domain(...)
12. │ │ │ └─domain$wrapSync(expr)
13. │ │ ├─shiny::withReactiveDomain(...)
14. │ │ │ └─promises::with_promise_domain(...)
15. │ │ │ └─domain$wrapSync(expr)
16. │ │ │ └─base::force(expr)
17. │ │ ├─shiny::captureStackTraces(...)
18. │ │ │ └─promises::with_promise_domain(...)
19. │ │ │ └─domain$wrapSync(expr)
20. │ │ │ └─base::withCallingHandlers(expr, error = doCaptureStack)
21. │ │ └─env$runWith(self, func)
22. │ │ └─shiny (local) contextFunc()
23. │ │ └─shiny::..stacktraceon..(expr)
24. │ └─teal.slice::teal_slices(...) at teal/R/teal_slices.R:111:5
25. │ └─base::stop("Some teal_slice objects have the same id:\n", toString(unique(slices_id[duplicated(slices_id)])))
26. └─base::.handleSimpleError(...)
27. └─shiny (local) h(simpleError(msg, call))
[ FAIL 2 | WARN 0 | SKIP 51 | PASS 598 ] |
|
Thanks @m7pr! Merge as soon as the checks are green |









Pull Request
The module print method displayed
NULLfor decorators when structured as nested lists:Changes
R/modules.R: Added recursive helper informat.teal_module()to extract labels from nested decorator structures. Includes depth limit (10) to prevent infinite recursion.tests/testthat/test-modules.R: Added tests for single, flat list, nested list, and mixed decorator structures.Now correctly displays:
Decorators: decorator1, decorator2regardless of list nesting depth.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.