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

Add verbose argument in check_variables and check_ct_data #74

Open
yurovska opened this issue Nov 14, 2024 · 0 comments
Open

Add verbose argument in check_variables and check_ct_data #74

yurovska opened this issue Nov 14, 2024 · 0 comments

Comments

@yurovska
Copy link

yurovska commented Nov 14, 2024

During development of ADaM programs, when not all variables existing in the specs have been derived yet, it is so annoying that check_variables function fails with error and stops execution. Same for ongoing work. Someone adds a new variables to the specs and ADaM program no longer works. What's the point to fail with error just because there is one variable not derived? Shouldn't it be a warning?

Same for check_ct_data. We're far away from eSub and do not want to clean up our specs now by adding all CTs etc. We'll do it when ADaM is final. Until then we'd like to see a warning, not an error.

Our temporary solution is to add the following in .Rprofile:

# Suppress errors in ADaM programs coming from {metatools} functions ----

setHook(
  packageEvent("metatools", "onLoad"),
  function(...) {
    check_variables_original <- metatools::check_variables
    environment(check_variables_original) <- asNamespace("metatools")
    
    assignInNamespace(
      "check_variables",
      function(...) {
        tryCatch(
          check_variables_original(...),
          error = function(e) {
            warning(e$message)
          }
        )
      },
      ns = "metatools"
    )
    
    check_ct_data_original <- metatools::check_ct_data
    environment(check_ct_data_original) <- asNamespace("metatools")
    
    assignInNamespace(
      "check_ct_data",
      function(...) {
        tryCatch(
          check_ct_data_original(...),
          error = function(e) {
            warning(e$message)
          }
        )
      },
      ns = "metatools"
    )
  }
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant