Skip to content

Commit

Permalink
ci: run all examples on CI + de-export send_sparql() (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle authored Oct 5, 2023
1 parent c624013 commit cc626c1
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 115 deletions.
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ jobs:

- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-manual", "--as-cran", "--run-dontrun")'
upload-snapshots: true
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, run_dont_run = TRUE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scheduled-R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-manual", "--as-cran", "--run-dontrun")'
upload-snapshots: true
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Suggests:
httpuv,
knitr,
rmarkdown,
testthat (>= 3.0.0),
testthat (>= 3.1.10.9000),
withr
Config/Needs/website:
DT,
Expand All @@ -54,4 +54,5 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3

Remotes:
r-lib/testthat
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export(get_label)
export(get_thing)
export(get_triple)
export(is.spq)
export(send_sparql)
export(spq)
export(spq_add)
export(spq_arrange)
Expand Down
33 changes: 3 additions & 30 deletions R/send_sparql.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
#' Send SPARQL query to endpoint and get tibble as a result
#' @param query_string a string corresponding to a SPARQL query
#' @param endpoint a string or url corresponding to a SPARQL endpoint. Defaults to "Wikidata"
#' @param user_agent `r lifecycle::badge('deprecated')` a string indicating the user agent to send with the query.
#' @param max_tries,max_seconds `r lifecycle::badge('deprecated')` Cap the maximal number of
#' attemps with `max_tries` or the total elapsed time from the first request with `max_seconds`.
#' @param timeout `r lifecycle::badge('deprecated')` maximum number of seconds to wait (`httr2::req_timeout()`).
#' @param request_type `r lifecycle::badge('deprecated')` a string indicating how the query should be sent: in the
#' URL (`url`, default, most common) or as a body form (`body-form`).
#' @param dry_run Boolean indicating whether to return the output of `httr2::req_dry_run()`
#' rather than of `httr2::req_perform()`. Useful for debugging.
#' @inheritParams spq_init
#' @examples
#' \dontrun{
#' query_string = spq_init() %>%
#' spq_add("?city wdt:P31/wdt:P279* wd:Q486972") %>%
#' spq_label(city) %>%
#' spq_mutate(coords = wdt::P625(city),
#' .within_distance=list(center=c(long=4.84,lat=45.76),
#' radius=5)) %>%
#' spq_assemble()
#' send_sparql(query_string, endpoint = "https://query.wikidata.org/")
#' }
#' @section Request control:
#'
#' Control the way the query is performed via the `control_request`
#' argument of `spq_init()`.
#' This way you can create a basic spq object with all the correct options
#' corresponding to the SPARQL service you are using, and then use it as
#' the basis of all your subsequent glitter pipelines.
#'
#'
#' @export
#' @inheritParams spq_perform
#' @noRd

send_sparql = function(query_string,
endpoint = NULL,
user_agent = lifecycle::deprecated(),
Expand Down
20 changes: 18 additions & 2 deletions R/spq_perform.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
#' @param endpoint `r lifecycle::badge('deprecated')` a string or url corresponding to a SPARQL endpoint. Defaults to "Wikidata"
#' @param replace_prefixes Boolean indicating whether to replace used prefixes in the results table,
#' for instance making, for instance "http://www.wikidata.org/entity/" "wd:".
#' @inheritParams send_sparql
#' @param endpoint a string or url corresponding to a SPARQL endpoint. Defaults to "Wikidata"
#' @param user_agent `r lifecycle::badge('deprecated')` a string indicating the user agent to send with the query.
#' @param max_tries,max_seconds `r lifecycle::badge('deprecated')` Cap the maximal number of
#' attemps with `max_tries` or the total elapsed time from the first request with `max_seconds`.
#' @param timeout `r lifecycle::badge('deprecated')` maximum number of seconds to wait (`httr2::req_timeout()`).
#' @param request_type `r lifecycle::badge('deprecated')` a string indicating how the query should be sent: in the
#' URL (`url`, default, most common) or as a body form (`body-form`).
#' @param dry_run Boolean indicating whether to return the output of `httr2::req_dry_run()`
#' rather than of `httr2::req_perform()`. Useful for debugging.
#' @return A query object
#' @export
#' @examples
Expand All @@ -16,7 +24,15 @@
#' spq_perform()
#' }
#'
#' @inheritSection send_sparql Request control
#' @section Request control:
#'
#' Control the way the query is performed via the `control_request`
#' argument of `spq_init()`.
#' This way you can create a basic spq object with all the correct options
#' corresponding to the SPARQL service you are using, and then use it as
#' the basis of all your subsequent glitter pipelines.
#'
#'
spq_perform = function(.query,
endpoint = lifecycle::deprecated(),
user_agent = lifecycle::deprecated(),
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ reference:
- title: "Debugging"
- contents:
- spq_assemble
- send_sparql
- title: "Wikidata"
- contents:
- get_description
Expand Down
1 change: 1 addition & 0 deletions glitter.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --run-dontrun
PackageRoxygenize: rd,collate,namespace
63 changes: 0 additions & 63 deletions man/send_sparql.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/spq_perform.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tests/testthat/_snaps/spq_assemble.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

Code
spq_init() %>% spq_filter(lang(itemTitleLOOKTYPO) == "en") %>% spq_assemble()
Error <rlang_error>
Can't filter on undefined variables: ?itemTitleLOOKTYPO
Condition
Error in `spq_assemble()`:
! Can't filter on undefined variables: ?itemTitleLOOKTYPO
i You haven't mentioned them in any triple, VALUES, mutate.

# spq_assemble() called from printing isn't strict
Expand Down
25 changes: 15 additions & 10 deletions tests/testthat/_snaps/spq_control_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,42 @@

Code
spq_control_request(timeout = "ahahah")
Error <rlang_error>
Must provide an integer as `timeout`.
Condition
Error in `spq_control_request()`:
! Must provide an integer as `timeout`.
i You provided a "character".

---

Code
spq_control_request(max_tries = "ahahah")
Error <rlang_error>
Must provide an integer as `max_tries`.
Condition
Error in `spq_control_request()`:
! Must provide an integer as `max_tries`.
i You provided a "character".

---

Code
spq_control_request(max_seconds = "ahahah")
Error <rlang_error>
Must provide an integer as `max_seconds`.
Condition
Error in `spq_control_request()`:
! Must provide an integer as `max_seconds`.
i You provided a "character".

---

Code
spq_control_request(request_type = "ahahah")
Error <rlang_error>
`request_type` must be one of "url" or "body-form", not "ahahah".
Condition
Error in `spq_control_request()`:
! `request_type` must be one of "url" or "body-form", not "ahahah".

---

Code
spq_control_request(user_agent = 42)
Error <rlang_error>
Must provide a character as `user_agent`.
Condition
Error in `spq_control_request()`:
! Must provide a character as `user_agent`.

5 changes: 3 additions & 2 deletions tests/testthat/_snaps/spq_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

Code
spq_init(request_control = list(max_tries = 1L))
Error <rlang_error>
`request_control` must be created by `spq_control_request()`.
Condition
Error in `spq_init()`:
! `request_control` must be created by `spq_control_request()`.

0 comments on commit cc626c1

Please sign in to comment.