influxdbr icon indicating copy to clipboard operation
influxdbr copied to clipboard

The `validate` argument of `as_tibble()` is deprecated.

Open SchmoFl opened this issue 1 year ago • 8 comments

The validate argument of the as_tibble function has been deprecated since tibble version 2.0.0. Since version 3.2.0 the change is breaking. The validate argument is still explicitly used in the influxdbr::influx_query function, which therefore is throwing the following error when used with tibble verison 3.2.0 or higher: The validate argument of as_tibble() was deprecated in tibble 2.0.0 and is now defunct.

SchmoFl avatar Mar 28 '23 12:03 SchmoFl

@SchmoFl Wouldn't this be as simple as removing the validate argument in the as_tibble() call?

ComeMaes avatar Apr 07 '23 06:04 ComeMaes

I can confirm removing , validate = FALSE from line 82 of influxdb_json_parser.R fixes this problem.

I've figured out how to do this locally, but I don't know how to create a pull request. Maybe now is the time for me to learn...?

adamjbc avatar Apr 30 '23 10:04 adamjbc

Only removing , validate = FALSE does not seem to be enough. I installed the PR as follows:

devtools::install_github("dleutnant/influxdbr", ref = github_pull("81"))

When doing a query I get the following error now:

Error in purrr::map(): ℹ In index: 1. Caused by error in purrr::map(): ℹ In index: 1. ℹ With name: results. Caused by error in purrr::map_int(): ℹ In index: 1. Caused by error: ! Result must be length 1, not 0. Run rlang::last_trace() to see where the error occurred. With the following trace:

│ └─influxdbr::influx_query(...) │ └─... %>% purrr::map_if(result_is_empty, ~NULL) ├─purrr::map_if(., result_is_empty, ~NULL) │ └─purrr:::where_if(.x, .p) │ └─purrr:::map_(.x, .p, ..., .type = "logical", .purrr_error_call = .purrr_error_call) │ └─purrr:::vctrs_vec_compat(.x, .purrr_user_env) ├─purrr::flatten(.) └─purrr::map(., query_list_to_tibble, timestamp_format = timestamp_format) └─purrr:::map_("list", .x, .f, ..., .progress = .progress) ├─purrr:::with_indexed_errors(...) │ └─base::withCallingHandlers(...) ├─purrr:::call_with_cleanup(...) └─influxdbr (local) .f(.x[[i]], ...) └─purrr::map(...) └─purrr:::map_("list", .x, .f, ..., .progress = .progress) ├─purrr:::with_indexed_errors(...) │ └─base::withCallingHandlers(...) ├─purrr:::call_with_cleanup(...) └─influxdbr (local) .f(.x[[i]], ...) └─purrr::map_int(result$series_values, nrow) └─purrr:::map_("integer", .x, .f, ..., .progress = .progress) ├─purrr:::with_indexed_errors(...) │ └─base::withCallingHandlers(...) └─purrr:::call_with_cleanup(...)

oldirtybasti avatar May 17 '23 08:05 oldirtybasti

I think you still need the tibble::as_tibble(.) line in there, so it looks like this:

        purrr::map( ~ purrr::map_at(., .at = "time",
                                    ~ as.POSIXct(. / div, 
                                                 origin = "1970-1-1",
                                                 tz = "GMT")) %>%
                      tibble::as_tibble(.))

adamjbc avatar Jun 11 '23 09:06 adamjbc

I tried that, same error as above

oldirtybasti avatar Jun 12 '23 09:06 oldirtybasti

The same issue here in show_databases and influx_query

> show_databases(con = con)
Error:
! The `validate` argument of `as_tibble()` was deprecated in tibble 2.0.0 and is now defunct.
ℹ Please use the `.name_repair` argument instead.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/lifecycle_error_deprecated>
Error:
! The `validate` argument of `as_tibble()` was deprecated in tibble 2.0.0 and is now defunct.
ℹ Please use the `.name_repair` argument instead.
---
Backtrace:
     ▆
  1. ├─influxdbr::show_databases(con = con)
  2. │ ├─... %>% purrr::map_df(~ dplyr::select(., name))
  3. │ └─influxdbr::influx_query(...)
  4. │   └─... %>% purrr::map_if(result_is_empty, ~NULL)
  5. ├─purrr::map_df(., ~dplyr::select(., name))
  6. │ └─purrr::map(.x, .f, ...)
  7. │   └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
  8. │     └─purrr:::vctrs_vec_compat(.x, .purrr_user_env)
  9. ├─purrr::map_if(., result_is_empty, ~NULL)
 10. │ └─purrr:::where_if(.x, .p)
 11. │   └─purrr:::map_(.x, .p, ..., .type = "logical", .purrr_error_call = .purrr_error_call)
 12. │     └─purrr:::vctrs_vec_compat(.x, .purrr_user_env)
 13. ├─purrr::flatten(.)
 14. ├─purrr::map(., query_list_to_tibble, timestamp_format = timestamp_format)
 15. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 16. │   ├─purrr:::with_indexed_errors(...)
 17. │   │ └─base::withCallingHandlers(...)
 18. │   ├─purrr:::call_with_cleanup(...)
 19. │   └─influxdbr (local) .f(.x[[i]], ...)
 20. │     └─purrr::map(...)
 21. │       └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 22. │         ├─purrr:::with_indexed_errors(...)
 23. │         │ └─base::withCallingHandlers(...)
 24. │         ├─purrr:::call_with_cleanup(...)
 25. │         └─influxdbr (local) .f(.x[[i]], ...)
 26. │           └─... %>% ...
 27. ├─purrr::map(...)
 28. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 29. │   ├─purrr:::with_indexed_errors(...)
 30. │   │ └─base::withCallingHandlers(...)
 31. │   ├─purrr:::call_with_cleanup(...)
 32. │   └─influxdbr (local) .f(.x[[i]], ...)
 33. │     └─... %>% tibble::as_tibble(., validate = FALSE)
 34. ├─tibble::as_tibble(., validate = FALSE)
 35. └─tibble:::as_tibble.list(., validate = FALSE)
 36.   └─lifecycle::deprecate_stop(...)
 37.     └─lifecycle:::deprecate_stop0(msg)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.

Patrikios avatar Oct 06 '23 07:10 Patrikios

I think you still need the tibble::as_tibble(.) line in there, so it looks like this:

        purrr::map( ~ purrr::map_at(., .at = "time",
                                    ~ as.POSIXct(. / div, 
                                                 origin = "1970-1-1",
                                                 tz = "GMT")) %>%
                      tibble::as_tibble(.))

This definitely works.

The pull request #81 removes too much code! I have fixed it by cloning the repo, making the correct fix, and installing the package by using devtools::install('path/to/package') and it works.

adamjbc avatar May 09 '24 18:05 adamjbc

@adamjbc I've generated a pull request with your correction. Package is functioning as intended on R4.3.3. Utilize remotes::install_github("dleutnant/influxdbr", ref = remotes::github_pull(82))

jthom40 avatar Aug 09 '24 08:08 jthom40