easystats icon indicating copy to clipboard operation
easystats copied to clipboard

Suppress (or attend to) warnings and messages in examples

Open IndrajeetPatil opened this issue 2 years ago • 11 comments

Follow-up on https://github.com/easystats/easystats/issues/338

The check-all-examples workflow should pass.

You can work on this issue either when #338 is resolved for the repo(s) you are maintaining, or work on both issues at the same time.

Preamble

Same as https://github.com/easystats/easystats/issues/338

Examples

Same as https://github.com/easystats/easystats/issues/338

Progress tracker

  • [x] insight
  • [ ] modelbased
  • [ ] bayestestR
  • [x] effectsize
  • [x] parameters
  • [x] performance
  • [x] correlation
  • [x] report
  • [ ] see
  • [x] datawizard
  • [x] easystats

IndrajeetPatil avatar Jan 07 '23 04:01 IndrajeetPatil

@IndrajeetPatil Why would this pass but suddenly fail when R-CMD-check-strict was created?

https://github.com/easystats/effectsize/actions/workflows/check-all-examples.yaml

mattansb avatar Jan 09 '23 06:01 mattansb

@mattansb It has actually nothing to do with the new strict check.

Previously, the “check all examples” workflow was checking only that all examples run. Now, it additionally checks that examples don’t produce warnings. That’s what the current issue is about.

IndrajeetPatil avatar Jan 09 '23 07:01 IndrajeetPatil

Ahhhhh ok. Thanks!

mattansb avatar Jan 09 '23 07:01 mattansb

@IndrajeetPatil Is it possible to ignore some warnings (without using suppressWarnings() since we still want to show them to users)? In the following example, a warning is expected and I think it's useful to show the users the potential warnings:

https://github.com/easystats/datawizard/actions/runs/3918766334/jobs/6699343379

library(datawizard)

test <- data.frame(
  a = c("iso", 2, 5),
  b = c("year", 3, 6),
  c = c(NA, 5, 7)
)
test
#>     a    b  c
#> 1 iso year NA
#> 2   2    3  5
#> 3   5    6  7
row_to_colnames(test)
#> Warning: Some values of row 1 were NAs. The corresponding column names are
#>   prefixed with `x`.
#>   iso year x1
#> 2   2    3  5
#> 3   5    6  7

etiennebacher avatar Jan 16 '23 12:01 etiennebacher

Hmm, I am wondering if it's really necessary to show an example that is going to generate a warning.

Typically, the help page examples will expose the functionality but not the edge cases users might run into, which is where they are likely to see warnings and errors. Does that make sense?

That said, if you do want to retain that example, maybe just set verbose = FALSE?

IndrajeetPatil avatar Jan 16 '23 12:01 IndrajeetPatil

Right, it doesn't bring much to show warnings in the example, I'll change the example

etiennebacher avatar Jan 16 '23 18:01 etiennebacher

In examples I often see that we load the current package, but I've never seen that anywhere else before. Why do we do that? Should I remove those instances?

rempsyc avatar Jan 17 '23 17:01 rempsyc

Yeah, I have also noticed this. It's definitely not necessary, but I don't feel strongly either way.

I think you can let them be for now. We do have a number of other, more immediate issues to resolve that we can prioritize.

IndrajeetPatil avatar Jan 17 '23 17:01 IndrajeetPatil

In examples I often see that we load the current package, but I've never seen that anywhere else before. Why do we do that? Should I remove those instances?

Due to lazyness, I copy/paste examples into an R file, and then I don't need to load the related library manually.

strengejacke avatar Jan 17 '23 20:01 strengejacke

No more warnings in examples for report

rempsyc avatar Jan 18 '23 17:01 rempsyc

Some examples have warnings (and therefore this check fails) because of the environment problem due to insight:

Could not recover model data from environment. Please make sure your data is available in your workspace. Trying to retrieve data from the model frame now.

This only happens in devtools::run_examples(), not when I run them manually. Should we ignore them? Users shouldn't see these warnings and it might confuse them to add a data <<- data in the examples (if this fixes the issue)

etiennebacher avatar Mar 31 '23 06:03 etiennebacher