Skip to content

[Feature Request]: Data verification doesn't evaluate code in all cases #375

Description

@llrs-roche

Feature description

Data validation doesn't execute code that is present on the object, failing to verify an object that is reproducible. If the data object is provided on the ... argument is also not found:

library("teal.data")
#> Loading required package: teal.code
packageVersion("teal.data")
#> [1] '0.7.0.9004'
packageVersion("teal.code")
#> [1] '0.6.1.9004'
data_empty <- teal_data()
data_populated <- teal_data(code = "D5 <- diag(5)")
data_populated # No object as documented
#> ✖ code unverified
#> <environment: 0x000001d15bc3ce10> 🔒 
#> Parent: <environment: package:teal.data>
verify(data_populated) # Verification fails even if code is present
#> Error: Code verification failed.
#> Object(s) created with code that do not exist in data_populated:
#>   • D5

# Code is executed but data not found
tdata2 <- teal_data(x1 = iris, code = "x2 <- x1")
tdata2
#> ✖ code unverified
#> <environment: 0x000001d158e4df80> 🔒 
#> Parent: <environment: package:teal.data> 
#> Bindings:
#> - x1: [data.frame]
verify(tdata2)
#> Error: object 'x1' not found 
#>  when evaluating qenv code:
#> x2 <- x1

Created on 2025-07-09 with reprex v2.1.1

I thought that objects supplied would be found by the verification process


Related to this, the only way to evaluate the code supplied on teal_data() is by data_populated_evaluated <- eval_code(data_populated, code = get_code(data_populated)) . Maybe in case of teal_data object and missing code argument it could get_code(object) and evaluate that?

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions