Skip to content

do not duplicate verification warning message, if it already existed in @code #322

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

Closed
wants to merge 37 commits into from

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Aug 7, 2024

Fixes insightsengineering/teal#1286

Previously, a verification warning was prepended to the @code slot each time a get_code(teal_data()) was run. And if a warning already existed in the code, then it was duplicated.

x <- teal_data(iris = iris)
get_code(x)
> [1] "warning('Code was not verified for reproducibility.')"
x@code <- get_code(x)
get_code(x)
> [1] "warning('Code was not verified for reproducibility.')\nwarning('Code was not verified for reproducibility.')"

The @code slot gets overwritten for teal apps, when hashes are added to the code (and sometimes libraries)

stopifnot(rlang::hash(iris) == "34844aba7bde36f5a34f6d8e39803508")
stopifnot(rlang::hash(mtcars) == "d0487363db4e6cc64fdb740cb6617fc0")
iris_raw <- iris
mtcars_raw <- mtcars

and also during this operation the warning is added to the @code and then on another get_code() you see the warning appearing twice

image

So this PR prevents that and do not add warning again if it was already in the @code

x <- teal_data(iris = iris)
get_code(x)
> [1] "warning('Code was not verified for reproducibility.')"
x@code <- get_code(x)
get_code(x)
> [1] "warning('Code was not verified for reproducibility.')"
image

Tests

> devtools::test()
ℹ Testing teal.data| F W  S  OK | Context|          2 | cdisc_data|          6 | cdisc_join_keys|         17 | datanames|         23 | formatters_var_labels|      2  55 | get_code|         27 | join_key|         12 | join_keys-c|         57 | join_keys-extract|          2 | join_keys-names|         17 | join_keys-parents|          5 | join_keys-print|         23 | join_keys|         20 | teal_data|          8 | verify                                               

══ Results ═══════════════════════════════════════════════════════════
Duration: 3.1 s

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

[ FAIL 0 | WARN 0 | SKIP 2 | PASS 274 ]

m7pr and others added 30 commits January 18, 2024 11:54
Merge branch 'main' of https://github.com/insightsengineering/teal.data

# Conflicts:
#	tests/testthat/test-get_code.R
Update R/teal_data-datanames.R

Signed-off-by: Marcin <[email protected]>
add two tests for topological_sort
Co-authored-by: André Veríssimo <[email protected]>
Signed-off-by: Marcin <[email protected]>
…in_keys as they might refer to datanames that do not exist in env
@m7pr m7pr added the core label Aug 7, 2024
@m7pr m7pr changed the title do not duplicate verification warning message, if it already existed in @code slot do not duplicate verification warning message, if it already existed in @code Aug 7, 2024
@m7pr m7pr marked this pull request as draft August 7, 2024 12:08
@m7pr
Copy link
Contributor Author

m7pr commented Aug 7, 2024

Converting to draft, and making one more check

@m7pr m7pr marked this pull request as ready for review August 7, 2024 12:13
@m7pr m7pr mentioned this pull request Aug 7, 2024
63 tasks
@gogonzo gogonzo self-assigned this Aug 7, 2024
@m7pr
Copy link
Contributor Author

m7pr commented Aug 8, 2024

Base automatically changed from 669_insertUI@main to main August 12, 2024 11:34
@gogonzo gogonzo closed this Aug 12, 2024
@gogonzo gogonzo deleted the verify_message@669_insertUI@main branch August 12, 2024 11:39
@gogonzo
Copy link
Contributor

gogonzo commented Aug 12, 2024

fixed in the source of the problem

@github-actions github-actions bot locked and limited conversation to collaborators Aug 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: warning('Code was not verified for reproducibility.') shown twice in Show R Code
2 participants