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

Move dplyr to Suggests #246

Merged
merged 7 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ License: MIT + file LICENSE
URL: https://pkgs.rstudio.com/connectapi/, https://github.com/rstudio/connectapi
BugReports: https://github.com/rstudio/connectapi/issues
Imports:
dplyr,
fs,
glue,
httr,
Expand All @@ -41,6 +40,7 @@ Suggests:
crayon,
dbplyr,
devtools,
dplyr,
flexdashboard,
ggplot2,
gridExtra,
Expand Down
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ S3method("[[",connect_tag_tree)
S3method(api_build,op_base_connect)
S3method(api_build,op_head)
S3method(as.data.frame,tbl_connect)
S3method(collect,tbl_connect)
S3method(connect_vars,op_base)
S3method(connect_vars,op_single)
S3method(connect_vars,tbl_connect)
Expand Down Expand Up @@ -37,7 +36,6 @@ export(bundle_dir)
export(bundle_path)
export(bundle_static)
export(cache_apps)
export(collect)
export(connect)
export(content_add_group)
export(content_add_user)
Expand Down Expand Up @@ -135,7 +133,6 @@ export(user_guid_from_username)
export(users_create_remote)
export(variant_render)
export(verify_content_name)
importFrom(dplyr,collect)
importFrom(lifecycle,deprecate_warn)
importFrom(magrittr,"%>%")
importFrom(rlang,"%||%")
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## Breaking changes

- All previously deprecated functions are now removed.
- The functions `Connect$download_bundle()` and
`Connect$bundle_delete()` have been removed. Use `Content$bundle_download()`
and `Content$bundle_delete()` instead.
- All previously deprecated functions are now removed.
- dplyr is no longer a required dependency. If you use `tbl_connect()`,
you will need to install dplyr and dbplyr explicitly. (#246)

## Enhancements and fixes

- The package is now tested against many versions of Connect, back to 1.8.8.2 (May 2021).
There are now fewer warnings about version mismatches: you should only see a warning if your Connect server is older than that. (#244)
Expand All @@ -15,6 +19,7 @@
than removing the tag entirely. (#194)
- Fix issue with `NULL` or `length 1` job outputs ([#193](https://github.com/rstudio/connectapi/issues/193))


# connectapi 0.1.3.1

- Fix generated documentation HTML for CRAN submission
Expand Down
5 changes: 5 additions & 0 deletions R/connectapi.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ utils::globalVariables(
)

current_connect_version <- "2024.03.0"

.onLoad <- function(...) {
vctrs::s3_register("dplyr::collect", "tbl_connect")
invisible()
}
23 changes: 12 additions & 11 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,16 @@ content_list_with_permissions <- function(src, ..., .p = NULL) {
content_list <- get_content(src, .p = .p)

message("Getting permission list")
pb <- progress::progress_bar$new(total = nrow(content_list), format = "[:bar] :percent :eta")
updated_list <- content_list %>% dplyr::mutate(
permission = purrr::map(guid, function(.x) .get_content_permission_with_progress(src, .x, pb))
pb <- progress::progress_bar$new(
total = nrow(content_list),
format = "[:bar] :percent :eta"
)
content_list[["permission"]] <- purrr::map(
content_list$guid,
function(.x) .get_content_permission_with_progress(src, .x, pb)
)

return(updated_list)
content_list
}

#' Content List
Expand Down Expand Up @@ -367,13 +371,10 @@ content_list_by_tag <- function(src, tag) {
#' @export
content_list_guid_has_access <- function(content_list, guid) {
warn_experimental("content_list_filter_by_guid")
filtered <- content_list %>% dplyr::filter(
access_type == "all" |
access_type == "logged_in" |
owner_guid == {{ guid }} |
purrr::map_lgl(permission, ~ {{ guid }} %in% .x$principal_guid)
)
return(filtered)
rows_keep <- content_list$access_type %in% c("all", "logged_in") |
content_list$owner_guid == guid |
purrr::map_lgl(content_list$permission, ~ guid %in% .x$principal_guid)
content_list[rows_keep, ]
}

#' Get usage information for deployed shiny applications
Expand Down
8 changes: 5 additions & 3 deletions R/lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ tbl_connect <- function(src, from = c("users", "groups", "content", "usage_shiny
dplyr::make_tbl(c("connect", "lazy"), src = src, ops = ops)
}

#' @importFrom dplyr collect
#' @export
# This will be registered in .onLoad if dplyr is available
collect.tbl_connect <- function(x, ..., n = Inf) {
api_build(op = x[["ops"]], con = x[["src"]], n = n)
}
Expand Down Expand Up @@ -96,7 +95,10 @@ print.tbl_connect <- function(x, ..., n = NULL) {

#' @export
as.data.frame.tbl_connect <- function(x, row.names = NULL, optional = NULL, ..., n = Inf) {
as.data.frame(collect(x, n = n))
# We don't need to check if dplyr is available here
# because you won't have a tbl_connect without first
# checking for dplyr.
as.data.frame(dplyr::collect(x, n = n))
nealrichardson marked this conversation as resolved.
Show resolved Hide resolved
}

op_base_connect <- function(x, vars) {
Expand Down
4 changes: 2 additions & 2 deletions R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ tag_tree <- function(.x) {

parse_tags_tbl <- function(x) {
parsed_tags <- purrr::map_dfr(x, ~ {
out <- dplyr::tibble(
out <- tibble::tibble(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can later, but is it worth doing the hacky add the class on without also requiring tibble?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, tibble is used heavily throughout, they're the main thing that the API wrappers return. Can make an issue to evaluate.

id = as.character(.x$id),
name = .x$name,
created_time = .x$created_time,
Expand All @@ -445,7 +445,7 @@ parse_tags_tbl <- function(x) {

if (length(.x$children) > 0) {
child <- parse_tags_tbl(.x$children)
out <- dplyr::bind_rows(out, child)
out <- rbind(out, child)
}

return(out)
Expand Down
10 changes: 0 additions & 10 deletions R/utils-collect.R

This file was deleted.

9 changes: 0 additions & 9 deletions man/collect.Rd

This file was deleted.

2 changes: 2 additions & 0 deletions tests/integrated/test-lazy.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testthat::skip_if_not_installed("dbplyr")

# should connect with env vars
test_conn_1 <- connect(prefix = "TEST_1")
test_conn_2 <- connect(prefix = "TEST_2")
Expand Down
Loading