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

Upgrade dbplyr generics #211

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 0 additions & 2 deletions .github/workflows/R-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CKANR_TEST_URL: ${{secrets.CKANR_TEST_URL}}
CKANR_TEST_BEHAVIOUR: ${{secrets.CKANR_TEST_BEHAVIOUR}}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
R_KEEP_PKG_SOURCE: yes
CKAN_VERSION: ${{ matrix.config.ckan-version }} # for docker compose up
Expand Down
18 changes: 10 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Title: Client for the Comprehensive Knowledge Archive Network ('CKAN') API
Description: Client for 'CKAN' API (<https://ckan.org/>). Includes interface
to 'CKAN' 'APIs' for search, list, show for packages, organizations, and
resources. In addition, provides an interface to the 'datastore' API.
Version: 0.7.0.9000
Version: 0.7.0.9001
Authors@R: c(
person("Scott", "Chamberlain",
role = c("aut"),
Expand All @@ -17,7 +17,7 @@ Authors@R: c(
comment = c(ORCID = "0000-0001-5180-0567")),
person("Florian", "Mayer",
role = "aut",
email="Florian.Mayer@dbca.wa.gov.au",
email="Florian.Mayer@dpc.wa.gov.au",
comment = c(ORCID = "0000-0003-4269-4242")),
person("Sharla", "Gelfand",
role = "aut"),
Expand All @@ -34,23 +34,25 @@ BugReports: https://github.com/ropensci/ckanr/issues
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
Depends: DBI (>= 0.3.1)
Depends:
DBI (>= 1.2.2),
R (>= 4.4.0)
Imports:
methods,
stats,
utils,
crul,
jsonlite (>= 0.9.17),
dplyr (>= 0.7.0),
dbplyr,
crul (>= 1.4.2),
jsonlite (>= 1.8.8),
dplyr (>= 1.1.4),
dbplyr (>= 2.5.0),
magrittr
Suggests:
sf,
readxl,
testthat,
xml2,
lazyeval
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
X-schema.org-keywords: database, open-data, ckan, api, data, dataset
X-schema.org-applicationCategory: Data Access
X-schema.org-isPartOf: "https://ropensci.org"
28 changes: 16 additions & 12 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ S3method(as.ckan_user,character)
S3method(as.ckan_user,ckan_user)
S3method(as.ckan_user,list)
S3method(db_begin,CKANConnection)
S3method(db_explain,CKANConnection)
S3method(db_desc,CKANConnection)
S3method(db_has_table,CKANConnection)
S3method(db_insert_into,CKANConnection)
S3method(db_query_fields,CKANConnection)
S3method(db_query_rows,CKANConnection)
S3method(format,src_ckan)
S3method(dbplyr_edition,CKANConnection)
S3method(format,CKANConnection)
S3method(print,ckan_group)
S3method(print,ckan_organization)
S3method(print,ckan_package)
Expand All @@ -36,9 +36,12 @@ S3method(print,ckan_resource)
S3method(print,ckan_tag)
S3method(print,ckan_user)
S3method(print,ckanr_settings)
S3method(sql_translate_env,CKANConnection)
S3method(sql_translate_env,src_ckan)
S3method(src_tbls,src_ckan)
S3method(sql_query_explain,CKANConnection)
S3method(sql_query_fields,CKANConnection)
S3method(sql_translation,CKANConnection)
S3method(sql_translation,src_ckan)
S3method(src_tbls,CKANConnection)
S3method(tbl,CKANConnection)
S3method(tbl,src_ckan)
export("%>%")
export(as.ckan_group)
Expand Down Expand Up @@ -133,23 +136,24 @@ importFrom(dbplyr,base_agg)
importFrom(dbplyr,base_scalar)
importFrom(dbplyr,base_win)
importFrom(dbplyr,build_sql)
importFrom(dbplyr,dbplyr_edition)
importFrom(dbplyr,sql)
importFrom(dbplyr,sql_prefix)
importFrom(dbplyr,sql_query_explain)
importFrom(dbplyr,sql_query_fields)
importFrom(dbplyr,sql_query_select)
importFrom(dbplyr,sql_query_wrap)
importFrom(dbplyr,sql_translation)
importFrom(dbplyr,sql_translator)
importFrom(dbplyr,sql_variant)
importFrom(dbplyr,src_sql)
importFrom(dbplyr,tbl_sql)
importFrom(dplyr,db_begin)
importFrom(dplyr,db_desc)
importFrom(dplyr,db_explain)
importFrom(dplyr,db_has_table)
importFrom(dplyr,db_insert_into)
importFrom(dplyr,db_list_tables)
importFrom(dplyr,db_query_fields)
importFrom(dplyr,db_query_rows)
importFrom(dplyr,sql)
importFrom(dplyr,sql_select)
importFrom(dplyr,sql_subquery)
importFrom(dplyr,sql_translate_env)
importFrom(dplyr,src_tbls)
importFrom(dplyr,tbl)
importFrom(jsonlite,fromJSON)
Expand Down
25 changes: 24 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# ckanr (development version)

ckanr 0.8.0
===========

### NEW FEATURES

* upgrades deprecated `dbplyr` generics (#187, @florianm)

Following [dbplyr's 2.0.0 backend API](https://dbplyr.tidyverse.org/articles/backend-2.html),
scripts using `ckanr`'s SQL `CKANConnection` must implement the following
changes:

* change `dplyr::sql_translate_env` to `dbplyr::sql_translation`
* change `dplyr::db_explain` to `dbplyr::sql_query_explain`
* change `dplyr::db_query_fields` to `dbplyr::sql_query_fields`
* change `dplyr::sql_subquery` to `dbplyr::sql_query_wrap`
* change `dplyr::sql_select` to `dbplyr::sql_query_select`
* all other generics are unchanged.
* updates dependencies (R, DBI, jsonlite, dplyr, dbplyr, RoxygenNote)

### MINOR IMPROVEMENTS

* update manpage author list (add SG, FA), author email (FM)

ckanr 0.7.0
===========

Expand Down Expand Up @@ -81,7 +104,7 @@ ckanr 0.3.0
* `package_show()` gains `key` parameter to pass an API key (#97)
* `package_search()` gains new parameters: `include_drafts`, `include_private`, `use_default_schema`, and `facet.mincount` (#107)
* function `fetch()` changed to `ckan_fetch()`
* gains function `organization_delet()` to delete an organization (#83)
* gains function `organization_delete()` to delete an organization (#83)
* gains function `ckan_version()` to get version info for a CKAN instance
* gains methods for creating a CKAN remote instance as a dplyr backend: gains `src_ckan()` and it's s3 methods `tbl` and `src_tbls`, `sql_translate_env`. in addition gains the S3 methods `db_begin`, `db_explain`, `db_has_table`, `db_insert_into`, `db_query_fields`, `db_query_rows`

Expand Down
6 changes: 4 additions & 2 deletions R/ckanr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@
#' @aliases ckanr
#' @docType package
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}
#' @author Florian Mayer \email{florian.wendelin.mayer@@gmail.com}
#' @author Florian Mayer \email{florian.wendelin.mayer+ckanr@@gmail.com}
#' @author Wush Wu
#' @author Imanuel Costigan \email{i.costigan@@me.com}
#' @author Sharla Gelfand
#' @author Francisco Alves \email{fjunior.alves.oliveira@@gmail.com}
#' @keywords package
NULL
"_PACKAGE"

#' Deprecated functions in \pkg{ckanr}
#'
Expand Down
102 changes: 64 additions & 38 deletions R/ckanr_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ assign("ckanr_proxy", NULL, envir = ckanr_settings_env)
#' @examples
#' ckanr_settings()
ckanr_settings <- function() {
ops <- list(url = Sys.getenv("CKANR_DEFAULT_URL", ""),
key = Sys.getenv("CKANR_DEFAULT_KEY", ""),
test_url = Sys.getenv("CKANR_TEST_URL", ""),
test_key = Sys.getenv("CKANR_TEST_KEY", ""),
test_did = Sys.getenv("CKANR_TEST_DID", ""),
test_rid = Sys.getenv("CKANR_TEST_RID", ""),
test_gid = Sys.getenv("CKANR_TEST_GID", ""),
test_oid = Sys.getenv("CKANR_TEST_OID", ""),
test_behaviour = Sys.getenv("CKANR_TEST_BEHAVIOUR", ""),
proxy = get("ckanr_proxy", ckanr_settings_env)
ops <- list(
url = Sys.getenv("CKANR_DEFAULT_URL", ""),
key = Sys.getenv("CKANR_DEFAULT_KEY", ""),
test_url = Sys.getenv("CKANR_TEST_URL", ""),
test_key = Sys.getenv("CKANR_TEST_KEY", ""),
test_did = Sys.getenv("CKANR_TEST_DID", ""),
test_rid = Sys.getenv("CKANR_TEST_RID", ""),
test_gid = Sys.getenv("CKANR_TEST_GID", ""),
test_oid = Sys.getenv("CKANR_TEST_OID", ""),
test_behaviour = Sys.getenv("CKANR_TEST_BEHAVIOUR", ""),
proxy = get("ckanr_proxy", ckanr_settings_env)
)
structure(ops, class = "ckanr_settings")
}
Expand Down Expand Up @@ -64,7 +65,12 @@ print.ckanr_settings <- function(x, ...) {
#' @export
#' @param url A CKAN URL (optional), default: https://data.ontario.ca
#' @param key A CKAN API key (optional, character)
#' @param test_url (optional, character) A valid CKAN URL for testing purposes
#' @param test_url (optional, character) A valid CKAN URL for testing purposes.
#' Default: "http://localhost:5000".
#' The default works with a local installation of CKAN via docker compose
#' running on port 5000, as well as for CI on GitHub.
#' This enables contributors to run the CI test suite on GitHub when submitting
#' a pull request.
#' @param test_key (optional, character) A valid CKAN API key privileged to
#' create datasets at `test_url`
#' @param test_did (optional, character) A valid CKAN dataset ID, existing at
Expand All @@ -76,7 +82,8 @@ print.ckanr_settings <- function(x, ...) {
#' `test_url`
#' @param test_behaviour (optional, character) Whether to fail ("FAIL") or skip
#' ("SKIP") writing tests in case of problems with the configured test CKAN.
#' @param proxy an object of class `request` from a call to
#' Default: "FAIL".
#' @param proxy an object of class `request` from a call to
#' [crul::proxy()]
#' @details
#' [ckanr_setup()] sets CKAN connection details. ckanr's functions
Expand Down Expand Up @@ -106,34 +113,35 @@ print.ckanr_settings <- function(x, ...) {
#' ckanr_setup(url = "https://data.ontario.ca/", key = "some-CKAN-API-key")
#'
#' # ckanR developers/testers can run:
#' ckanr_setup(url = "https://data.ontario.ca/", key = "some-CKAN-API-key",
#' test_url = "http://test-ckan.gov/",test_key = "test-ckan-API-key",
#' test_did = "test-ckan-dataset-id",test_rid = "test-ckan-resource-id",
#' test_gid = "test-group-name", test_oid = "test-organzation-name",
#' test_behaviour = "FAIL")
#' ckanr_setup(
#' url = "https://data.ontario.ca/", key = "some-CKAN-API-key",
#' test_url = "http://test-ckan.gov/", test_key = "test-ckan-API-key",
#' test_did = "test-ckan-dataset-id", test_rid = "test-ckan-resource-id",
#' test_gid = "test-group-name", test_oid = "test-organization-name",
#' test_behaviour = "FAIL"
#' )
#'
#' # Not specifying the default CKAN URL will reset the CKAN URL to its default
#' # "https://data.ontario.ca/":
#' ckanr_setup()
#'
#'
#' # set a proxy
#' ckanr_setup(proxy = crul::proxy("64.251.21.73:8080"))
#' ckanr_settings()
#' ## run without setting proxy to reset to no proxy
#' ckanr_setup()
#' ckanr_settings()
ckanr_setup <- function(
url = "https://data.ontario.ca/",
key = NULL,
test_url = NULL,
test_key = NULL,
test_did = NULL,
test_rid = NULL,
test_gid = NULL,
test_oid = NULL,
test_behaviour = NULL,
proxy = NULL) {

url = "https://data.ontario.ca/",
key = NULL,
test_url = NULL,
test_key = NULL,
test_did = NULL,
test_rid = NULL,
test_gid = NULL,
test_oid = NULL,
test_behaviour = NULL,
proxy = NULL) {
Sys.setenv("CKANR_DEFAULT_URL" = url)
if (!is.null(key)) Sys.setenv("CKANR_DEFAULT_KEY" = key)
if (!is.null(test_url)) Sys.setenv("CKANR_TEST_URL" = test_url)
Expand All @@ -151,36 +159,54 @@ ckanr_setup <- function(
#
#' @export
#' @rdname ckanr_settings
get_default_url <- function(){ Sys.getenv("CKANR_DEFAULT_URL") }
get_default_url <- function() {
Sys.getenv("CKANR_DEFAULT_URL")
}

#' @export
#' @rdname ckanr_settings
get_default_key <- function(){ Sys.getenv("CKANR_DEFAULT_KEY") }
get_default_key <- function() {
Sys.getenv("CKANR_DEFAULT_KEY")
}

#' @export
#' @rdname ckanr_settings
get_test_url <- function(){ Sys.getenv("CKANR_TEST_URL") }
get_test_url <- function() {
Sys.getenv("CKANR_TEST_URL", unset = "http://localhost:5000")
}

#' @export
#' @rdname ckanr_settings
get_test_key <- function(){ Sys.getenv("CKANR_TEST_KEY") }
get_test_key <- function() {
Sys.getenv("CKANR_TEST_KEY")
}

#' @export
#' @rdname ckanr_settings
get_test_did <- function(){ Sys.getenv("CKANR_TEST_DID") }
get_test_did <- function() {
Sys.getenv("CKANR_TEST_DID")
}

#' @export
#' @rdname ckanr_settings
get_test_rid <- function(){ Sys.getenv("CKANR_TEST_RID") }
get_test_rid <- function() {
Sys.getenv("CKANR_TEST_RID")
}

#' @export
#' @rdname ckanr_settings
get_test_gid <- function(){ Sys.getenv("CKANR_TEST_GID") }
get_test_gid <- function() {
Sys.getenv("CKANR_TEST_GID")
}

#' @export
#' @rdname ckanr_settings
get_test_oid <- function(){ Sys.getenv("CKANR_TEST_OID") }
get_test_oid <- function() {
Sys.getenv("CKANR_TEST_OID")
}

#' @export
#' @rdname ckanr_settings
get_test_behaviour <- function(){ Sys.getenv("CKANR_TEST_BEHAVIOUR") }
get_test_behaviour <- function() {
Sys.getenv("CKANR_TEST_BEHAVIOUR", unset = "FAIL")
}
2 changes: 1 addition & 1 deletion R/dbi.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ setMethod("dbGetException", "CKANConnection",

setMethod("dbGetInfo", "CKANConnection",
def = function(dbObj, ...) {
cat(sprintf("url: %s\n", dbObj@url))
cat(sprintf("CKAN URL: %s\n", dbObj@url))
}
)

Expand Down
Loading
Loading