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

[Feature Request]: Implement names argument in get_code to subset code for specific objects. #210

Closed
3 tasks done
gogonzo opened this issue Sep 26, 2024 · 1 comment · Fixed by insightsengineering/teal.data#343, insightsengineering/teal#1388 or #214
Assignees

Comments

@gogonzo
Copy link
Contributor

gogonzo commented Sep 26, 2024

Feature description

technically, it means to move teal.data:::get_code_dependencies to teal.code.
We also need to deprecate teal.data::get_code method and just use the get_code method from teal.code.


Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@donyunardi
Copy link
Contributor

donyunardi commented Oct 3, 2024

We can only move forward with this once we completed insightsengineering/teal.data#333

Acceptance Criteria

  • Move teal.data:::get_code_dependency to teal.code
  • Deprecate teal.data::get_code method
  • Review teal framework that's using teal.data::get_code and use teal.code::get_code
  • Perform tests to ensure everything is working

@m7pr m7pr self-assigned this Oct 16, 2024
m7pr added a commit that referenced this issue Oct 22, 2024
BLOCKED by 
- insightsengineering/teal.data#340

Closes 
- #210 

Companion to 
- insightsengineering/teal.data#343 
- insightsengineering/teal#1388

# Description

Brings `names` parameter to `get_code` so that you can limit returned
code to specific objects (and the lines that create those objects).
`get_code_dependency` was moved from `teal.data`

# Tested with

``` r
library(teal.code)

# EVAL CODE
q <- qenv()
q <- eval_code(q, code = c("a <- 1", "b <- 2"))
q@code
#> [1] "a <- 1\nb <- 2"
get_code(q, names = "a")
#> [1] "a <- 1"

# WITHIN
q <- qenv()
q <- within(q, {a <- 1; b <- 2})
q@code
#> [1] "a <- 1\nb <- 2"
get_code(q, names = "a")
#> [1] "a <- 1"

# OLD TEAL.DATA
t <- teal.data::teal_data(a = 5, code = c("a <- 1", "b <- 2"))
t@code
#> [1] "a <- 1\nb <- 2"
teal.data::get_code(t, datanames = 'a')
#> Warning in .local(object, deparse, ...): get_code(datanames) was deprecated in
#> teal.data 0.6.1, use get_code(names) instead.
#> [1] "a <- 1"
```

<sup>Created on 2024-10-16 with [reprex
v2.1.1](https://reprex.tidyverse.org)</sup>

# Local tests

```r
> devtools::test()
ℹ Testing teal.code
✔ | F W  S  OK | Context
✔ |         12 | qenv_concat                                                 
✔ |          8 | qenv_constructor                                            
✔ |         26 | qenv_eval_code                                              
✔ |      2  60 | qenv_get_code [1.1s]                                        
✔ |         10 | qenv_get_var                                                
✔ |          7 | qenv_get_warnings                                           
✔ |         40 | qenv_join                                                   
✔ |         14 | qenv_within                                                 
✔ |         12 | utils                                                       

══ Results ══════════════════════════════════════════════════════════════════
Duration: 2.2 s

── Skipped tests (2) ────────────────────────────────────────────────────────
• This is not urgent and can be ommitted with @linksto tag. (1):
  test-qenv_get_code.R:526:3
• We will not resolve this, as this requires code evaluation. (1):
  test-qenv_get_code.R:318:3

[ FAIL 0 | WARN 0 | SKIP 2 | PASS 189 ]
````

# Local R CMD CHECK

```r
── R CMD check results ──────────────────────────────────── teal.code 0.5.0.9010 ────
Duration: 33.5s

❯ checking for future file timestamps ... NOTE
  unable to verify current time

0 errors ✔ | 0 warnings ✔ | 1 note ✖

R CMD check succeeded
```

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
m7pr added a commit to insightsengineering/teal.data that referenced this issue Oct 22, 2024
Part of 
- insightsengineering/teal.code#210

Companion to
- insightsengineering/teal#1388
- insightsengineering/teal.code#214

# Description

Deprecates the usage of `datanames` parameter in
`teal.data::get_code(datanames)` in favour of
`teal.code::get_code(names)`.

VBUMP package version locally to something greater than `0.6.1` during
testing.

``` r
library(teal.data)
#> Loading required package: teal.code
tdata1 <- within(teal_data(), {a <- 1; b <- 2})
get_code(tdata1)
#> [1] "a <- 1\nb <- 2"
get_code(tdata1, datanames = "a")
#> Warning: The `datanames` argument of `get_code()` is deprecated as of teal.data 0.6.1.
#> ℹ Please use the `names` argument of `teal.code::get_code()` instead.
#> ℹ The deprecated feature was likely used in the teal.data package.
#>   Please report the issue at
#>   <https://github.com/insightsengineering/teal.data/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> [1] "a <- 1"
```

<sup>Created on 2024-10-17 with [reprex
v2.1.1](https://reprex.tidyverse.org)</sup>

---------

Signed-off-by: Marcin <[email protected]>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pawel Rucki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment