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

220 detect default side effects #230

Merged
merged 14 commits into from
Dec 22, 2023
Merged

220 detect default side effects #230

merged 14 commits into from
Dec 22, 2023

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Dec 18, 2023

Close #220

We introduced a list of functions that are treated as default side effects having impact on all objects. Those will be always returned with get_code. Currently the list contains of library, require and data. I wonder if this should be a parameter to get_code so that this list can be extended and adjusted by future users?

@m7pr m7pr added the core label Dec 18, 2023
@m7pr m7pr requested a review from gogonzo December 18, 2023 12:54
Copy link
Contributor

github-actions bot commented Dec 18, 2023

badge

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  -------------------
R/cdisc_data.R                       1       1  0.00%    37
R/default_cdisc_join_keys.R         11      11  0.00%    17-35
R/deprecated.R                      69      69  0.00%    16-350
R/dummy_function.R                   5       5  0.00%    16-23
R/formatters_var_labels.R           47      47  0.00%    28-149
R/join_key.R                        31       0  100.00%
R/join_keys-c.R                     26       0  100.00%
R/join_keys-extract.R              122       0  100.00%
R/join_keys-names.R                 15       0  100.00%
R/join_keys-parents.R               28       1  96.43%   28
R/join_keys-print.R                 46       0  100.00%
R/join_keys-utils.R                 87       2  97.70%   127, 130
R/join_keys.R                       21       0  100.00%
R/teal_data-class.R                 25       1  96.00%   70
R/teal_data-datanames.R             10       0  100.00%
R/teal_data-get_code.R              15       1  93.33%   55
R/teal_data-show.R                   4       4  0.00%    13-18
R/teal_data.R                       22       9  59.09%   32, 41-47, 50
R/testhat-helpers.R                 26       0  100.00%
R/topological_sort.R                32       0  100.00%
R/utils-get_code_dependency.R      104       1  99.04%   43
R/utils.R                           14       0  100.00%
R/verify.R                          42      11  73.81%   68, 98-102, 105-109
R/zzz.R                             10      10  0.00%    4-16
TOTAL                              813     173  78.72%

Diff against main

Filename                         Stmts    Miss  Cover
-----------------------------  -------  ------  -------
R/utils-get_code_dependency.R      +16       0  +0.17%
TOTAL                              +16       0  +0.43%

Results for commit: 2e19f52

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Dec 18, 2023

Unit Test Performance Difference

Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
get_code 👶 $+0.01$ get_call_data_call_is_returned_when_data_name_is_provided_as_character
get_code 👶 $+0.01$ get_call_returns_data_call_for_a_datanames_specified_asis
get_code 👶 $+0.01$ library_and_require_are_always_returned

Results for commit 0134fb8

♻️ This comment has been updated with latest results.

@chlebowa
Copy link
Contributor

Objection to data.
data(miniACC, package = "MultiAssayExperiment") # @linksto miniACC
but
data(airway, package = "cond") # @linksto airway

Copy link
Contributor

github-actions bot commented Dec 18, 2023

Unit Tests Summary

    1 files    14 suites   2s ⏱️
166 tests 164 ✔️ 2 💤 0
249 runs  247 ✔️ 2 💤 0

Results for commit 2e19f52.

♻️ This comment has been updated with latest results.

@m7pr
Copy link
Contributor Author

m7pr commented Dec 18, 2023 via email

@chlebowa
Copy link
Contributor

Let's try to think of something else before we add arguments for everything.

@m7pr
Copy link
Contributor Author

m7pr commented Dec 18, 2023 via email

@chlebowa
Copy link
Contributor

If a person has to manage what function calls are "automatically" included, they might as well manually tag them.

A reasonable exception is the search path, that one has to be reproduced.

@m7pr
Copy link
Contributor Author

m7pr commented Dec 19, 2023

Hey, so far I'm only automatically extracting library and require calls.
I also extended data() function detection that is extracted only for respective objects. See a new test that I added.

@gogonzo
Copy link
Contributor

gogonzo commented Dec 21, 2023

You mean library calls detection should be handled by functions from insightsengineering/teal#950 ?

Yes but in general I'm looking to resolve library calls problem. In get_rcode_header we add all attached packages to the code so the problem is not in teal_data object. If we add all attached libraries in get_rcode_header than adding any library() call in teal_data is redundant. Also, adding libarary calls to eval_code doesn't really reproduce session as there are other packages often attached outside of the eval_code call. I don't have any strong opinion how it should be done. It is not a problem of this PR so let's not continue a discussion here but rather in insightsengineering/teal#950

@m7pr
Copy link
Contributor Author

m7pr commented Dec 21, 2023

ALrighty, let's move there for the conversation about library() simplification. And for this feature, do you think we're good to approve and merge?

Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

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

Looks good functional-wise. Please apply tests suggestions and add lifecycle::experimental label to the get_call(datanames). We are finishing developing this package at this moment. It goes to CRAN soon 💪

tests/testthat/test-get_code.R Show resolved Hide resolved
tests/testthat/test-get_code.R Outdated Show resolved Hide resolved
@m7pr m7pr requested review from gogonzo and chlebowa December 21, 2023 13:49
Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com>
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
@m7pr
Copy link
Contributor Author

m7pr commented Dec 21, 2023

Thanks for the review. Badge was added and test were simplified

@m7pr m7pr merged commit 4ab5520 into main Dec 22, 2023
23 checks passed
@m7pr m7pr deleted the 220_return_libraries@main branch December 22, 2023 07:27
m7pr added a commit that referenced this pull request Dec 22, 2023
**Merge after**
#230
Closes #233 

Added one more text for future improvement, where we are not able to
handle `x` parameter passed to `assign` function as `variable`.

Such specs for `assign` are handled

```r
  code <- c(
    "a <- 1",
    "assign('b', 5)",
    "assign(value = 7, x = 'c')",
    "b <- b + 2",
    "c <- b"
  )
```

and below is not (yet!)

```r
  code <- c(
    "z <- 'a'",
    "assign(x = z, 5)",
    "b <- a"
  )
```

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] get_code should return side-effect line always.
3 participants