Git Product home page Git Product logo

Comments (53)

oggioniale avatar oggioniale commented on June 16, 2024 1

yes for sure I can parse the code ... just to know

from relter.

micha-silver avatar micha-silver commented on June 16, 2024 1

Hi @oggioniale
Here are some ideas of packages that we might be able to remove:
leaflet (if we switch all map plots to tmap)
rgeos (probably not necessary)
lubridate (nice to have, but we might get by with base R)
tidyr and dplyr and dtplyr and magrittr ? - these could be consolidated
rworldmap and rnaturealearth. One should be enough
qrcode - How important is the produce_site_qrcode function? What is the purpose?
ggforce - Really required?

Best regards,
Micha

from relter.

oggioniale avatar oggioniale commented on June 16, 2024 1

Dear @micha-silver,
yes we working on the dev branch and we have a lot of changes in the package.
We still working to solve some issues at the moment.

from relter.

oggioniale avatar oggioniale commented on June 16, 2024 1

Hi @maelle, Happy New Year to you too.

Nothing at the moment.
We will need your support when we will reduce the number of packages imported.

I thinking … soon

from relter.

micha-silver avatar micha-silver commented on June 16, 2024 1

@maelle
Happy holiday to you as well

from relter.

maelle avatar maelle commented on June 16, 2024

Happy to help if needed!

from relter.

maelle avatar maelle commented on June 16, 2024

@oggioniale

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

Dear Maëlle, apologise for my late replay!
We working on re-structuring old functions and with a lot new functions.

In the next days we release the new version, also with the resolution of the error.

Thanks!!

from relter.

maelle avatar maelle commented on June 16, 2024

Thank you!

from relter.

maelle avatar maelle commented on June 16, 2024

Error I see in the vignette

siteGeneral <- ReLTER::get_site_info(
  deimsid = "https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe",
  category = "General"
)
#> Warning: Unknown or uninitialised column: `generalInfo.keywords`.
#> Error in `colnames<-`(`*tmp*`, value = c("keywordsLabel", "keywordsURI")): attempt to set 'colnames' on an object with less than two dimensions

Created on 2022-10-11 with reprex v2.0.2

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

I have updated to the last version all packages and I can't reproduce the error.

> ReLTER::get_site_info(
+     deimsid = "https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe",
+     category = "General"
+ )
# A tibble: 1 × 21
  title     uri   geoCo…¹ country geoEl…² geoEl…³ geoEl…⁴ geoEl…⁵ gener…⁶ gener…⁷ gener…⁸ gener…⁹ gener…˟ gener…˟ gener…˟ gener…˟ gener…˟ gener…˟ gener…˟ gener…˟ gener…˟
  <chr>     <chr> <chr>   <list>    <dbl>   <int>   <int> <chr>   <chr>   <chr>   <chr>     <int> <lgl>   <list>  <lgl>   <chr>   <chr>   <chr>   <lgl>   <lgl>   <list> 
1 Lago Mag… http… POINT … <chr>      194.     186    4633 msl     "Lake … Operat… https:…    1960 NA      <df>    NA      Lago M… IT08-0… Statio… NA      NA      <df>   
# … with abbreviated variable names ¹​geoCoord, ²​geoElev.avg, ³​geoElev.min, ⁴​geoElev.max, ⁵​geoElev.unit, ⁶​generalInfo.abstract, ⁷​generalInfo.status.label,
#   ⁸​generalInfo.status.uri, ⁹​generalInfo.yearEstablished, ˟​generalInfo.yearClosed, ˟​generalInfo.hierarchy.parent, ˟​generalInfo.hierarchy.children,
#   ˟​generalInfo.siteName, ˟​generalInfo.shortName, ˟​generalInfo.siteType, ˟​generalInfo.protectionLevel, ˟​generalInfo.landUse, ˟​generalInfo.images

from relter.

maelle avatar maelle commented on June 16, 2024

I still get the error, I added session info in case it is relevant. Does this function need authentication?

siteGeneral <- ReLTER::get_site_info(
  deimsid = "https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe",
  category = "General"
)
#> Warning: Unknown or uninitialised column: `generalInfo.keywords`.
#> Error in `colnames<-`(`*tmp*`, value = c("keywordsLabel", "keywordsURI")): attempt to set 'colnames' on an object with less than two dimensions

Created on 2022-10-20 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22)
#>  os       Ubuntu 20.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US.utf8
#>  collate  en_US.utf8
#>  ctype    en_US.utf8
#>  tz       Europe/Paris
#>  date     2022-10-20
#>  pandoc   2.18 @ /usr/lib/rstudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  abind          1.4-5      2016-07-21 [1] RSPM
#>  ape            5.6-2      2022-03-02 [1] RSPM
#>  assertthat     0.2.1      2019-03-21 [1] RSPM (R 4.2.0)
#>  base64enc      0.1-3      2015-07-28 [1] RSPM (R 4.2.0)
#>  bold           1.2.0      2021-05-11 [1] RSPM
#>  class          7.3-20     2022-01-16 [2] CRAN (R 4.2.0)
#>  classInt       0.4-8      2022-09-29 [1] RSPM
#>  cli            3.4.1      2022-09-23 [1] RSPM
#>  codetools      0.2-18     2020-11-04 [2] CRAN (R 4.2.0)
#>  colorspace     2.0-3      2022-02-21 [1] RSPM (R 4.2.0)
#>  conditionz     0.1.0      2019-04-24 [1] RSPM
#>  crayon         1.5.2      2022-09-29 [1] RSPM
#>  crosstalk      1.2.0      2021-11-04 [1] RSPM
#>  crul           1.3        2022-09-03 [1] CRAN (R 4.2.0)
#>  curl           4.3.3      2022-10-06 [1] RSPM
#>  data.table     1.14.4     2022-10-17 [1] CRAN (R 4.2.0)
#>  DBI            1.1.3.9000 2022-06-20 [1] Github (r-dbi/DBI@5f632ae)
#>  dichromat      2.0-0.1    2022-05-02 [1] RSPM
#>  digest         0.6.30     2022-10-18 [1] RSPM
#>  dplyr          1.0.10     2022-09-01 [1] CRAN (R 4.2.0)
#>  dtplyr         1.2.2      2022-08-20 [1] RSPM
#>  e1071          1.7-11     2022-06-07 [1] RSPM
#>  evaluate       0.17       2022-10-07 [1] CRAN (R 4.2.0)
#>  extrafont      0.18       2022-04-12 [1] RSPM (R 4.2.0)
#>  extrafontdb    1.0        2012-06-11 [1] RSPM (R 4.2.0)
#>  fansi          1.0.3      2022-03-24 [1] RSPM (R 4.2.0)
#>  farver         2.1.1      2022-07-06 [1] CRAN (R 4.2.0)
#>  fastmap        1.1.0      2021-01-25 [1] RSPM (R 4.2.0)
#>  foreach        1.5.2      2022-02-02 [1] RSPM
#>  fs             1.5.2      2021-12-08 [1] RSPM (R 4.2.0)
#>  generics       0.1.3      2022-07-05 [1] RSPM
#>  ggforce        0.4.1      2022-10-04 [1] RSPM
#>  ggplot2        3.3.6      2022-05-03 [1] RSPM
#>  glue           1.6.2      2022-02-24 [1] RSPM (R 4.2.0)
#>  gridExtra      2.3        2017-09-09 [1] RSPM
#>  gtable         0.3.1      2022-09-01 [1] CRAN (R 4.2.0)
#>  highr          0.9        2021-04-16 [1] RSPM (R 4.2.0)
#>  htmltools      0.5.3.9000 2022-09-29 [1] Github (rstudio/htmltools@5fa01e7)
#>  htmlwidgets    1.5.4      2021-09-08 [1] RSPM (R 4.2.0)
#>  httpcode       0.3.0      2020-04-10 [1] RSPM (R 4.2.0)
#>  httr           1.4.4      2022-08-17 [1] RSPM
#>  iterators      1.0.14     2022-02-05 [1] RSPM
#>  jqr            1.2.3      2022-03-10 [1] RSPM
#>  jsonlite       1.8.2      2022-10-02 [1] CRAN (R 4.2.0)
#>  KernSmooth     2.23-20    2021-05-03 [2] CRAN (R 4.2.0)
#>  knitr          1.40       2022-08-24 [1] RSPM
#>  lattice        0.20-45    2021-09-22 [2] CRAN (R 4.2.0)
#>  lazyeval       0.2.2      2019-03-15 [1] RSPM (R 4.2.0)
#>  leafem         0.2.0      2022-04-16 [1] RSPM
#>  leaflet        2.1.1      2022-03-23 [1] RSPM
#>  leafsync       0.1.0      2019-03-05 [1] RSPM
#>  lifecycle      1.0.3      2022-10-07 [1] CRAN (R 4.2.0)
#>  lwgeom         0.2-9      2022-10-01 [1] CRAN (R 4.2.0)
#>  magrittr       2.0.3      2022-03-30 [1] RSPM (R 4.2.0)
#>  MASS           7.3-58.1   2022-08-03 [1] RSPM
#>  munsell        0.5.0      2018-06-12 [1] RSPM (R 4.2.0)
#>  nlme           3.1-160    2022-10-10 [1] CRAN (R 4.2.0)
#>  pillar         1.8.1      2022-08-19 [1] RSPM
#>  pkgconfig      2.0.3      2019-09-22 [1] RSPM (R 4.2.0)
#>  plyr           1.8.7      2022-03-24 [1] RSPM
#>  png            0.1-7      2013-12-03 [1] RSPM
#>  polyclip       1.10-0     2019-03-14 [1] RSPM
#>  proxy          0.4-27     2022-06-09 [1] RSPM
#>  purrr          0.3.5      2022-10-06 [1] CRAN (R 4.2.0)
#>  qrcode         0.1.4      2021-10-13 [1] RSPM
#>  R.cache        0.16.0     2022-07-21 [1] CRAN (R 4.2.0)
#>  R.methodsS3    1.8.2      2022-06-13 [1] RSPM
#>  R.oo           1.25.0     2022-06-12 [1] RSPM
#>  R.utils        2.12.0     2022-06-28 [1] RSPM
#>  R6             2.5.1      2021-08-19 [1] RSPM (R 4.2.0)
#>  raster         3.6-3      2022-09-18 [1] RSPM
#>  RColorBrewer   1.1-3      2022-04-03 [1] RSPM (R 4.2.0)
#>  Rcpp           1.0.9      2022-07-08 [1] RSPM (R 4.2.0)
#>  ReLTER         1.1.0      2022-10-20 [1] local
#>  reprex         2.0.2      2022-08-17 [1] RSPM
#>  reshape        0.8.9      2022-04-12 [1] RSPM
#>  rgeos          0.5-9      2021-12-15 [1] RSPM
#>  rlang          1.0.6      2022-09-24 [1] RSPM (R 4.2.0)
#>  rmarkdown      2.17       2022-10-07 [1] CRAN (R 4.2.0)
#>  rosm           0.2.6      2022-06-09 [1] RSPM
#>  rstudioapi     0.14       2022-08-22 [1] RSPM
#>  Rttf2pt1       1.3.11     2022-10-08 [1] CRAN (R 4.2.0)
#>  scales         1.2.1      2022-08-20 [1] RSPM
#>  sessioninfo    1.2.2      2021-12-06 [1] RSPM (R 4.2.0)
#>  sf             1.0-8      2022-07-14 [1] RSPM
#>  sp             1.5-0      2022-06-05 [1] RSPM
#>  stars          0.5-6      2022-07-21 [1] CRAN (R 4.2.0)
#>  stringi        1.7.8      2022-07-11 [1] RSPM (R 4.2.0)
#>  stringr        1.4.1      2022-08-20 [1] RSPM
#>  styler         1.7.0.9001 2022-05-31 [1] https://r-lib.r-universe.dev (R 4.2.0)
#>  taxize         0.9.100    2022-04-22 [1] RSPM
#>  terra          1.6-17     2022-09-10 [1] RSPM (R 4.2.0)
#>  tibble         3.1.8      2022-07-22 [1] CRAN (R 4.2.0)
#>  tidyselect     1.2.0      2022-10-10 [1] CRAN (R 4.2.0)
#>  tmap           3.3-3      2022-03-02 [1] RSPM
#>  tmaptools      3.1-1      2021-01-19 [1] RSPM
#>  tweenr         2.0.2      2022-09-06 [1] RSPM
#>  units          0.8-0      2022-02-05 [1] CRAN (R 4.2.0)
#>  utf8           1.2.2      2021-07-24 [1] RSPM (R 4.2.0)
#>  uuid           1.1-0      2022-04-19 [1] RSPM (R 4.2.0)
#>  vctrs          0.4.2      2022-09-29 [1] RSPM
#>  viridisLite    0.4.1      2022-08-22 [1] RSPM
#>  waffle         0.7.0      2017-01-07 [1] RSPM
#>  withr          2.5.0      2022-03-03 [1] RSPM (R 4.2.0)
#>  worrms         0.4.2      2020-07-08 [1] RSPM
#>  xfun           0.34       2022-10-18 [1] RSPM
#>  XML            3.99-0.11  2022-10-03 [1] RSPM
#>  xml2           1.3.3      2021-11-30 [1] RSPM (R 4.2.0)
#>  xslt           1.4.3      2021-05-05 [1] RSPM (R 4.2.0)
#>  yaml           2.3.6      2022-10-18 [1] RSPM
#>  zoo            1.8-11     2022-09-17 [1] RSPM
#> 
#>  [1] /home/maelle/R/x86_64-pc-linux-gnu-library/4.2
#>  [2] /opt/R/4.2.0/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

from relter.

maelle avatar maelle commented on June 16, 2024

You could pre-build the vignette https://ropensci.org/blog/2019/12/08/precompute-vignettes/ (and set a reminder for yourself in a release_bullets() function cf https://usethis.r-lib.org/reference/use_release_issue.html#ref-usage, example https://github.com/lucarraro/traudem/blob/2038f221d3197674b62dbb20da22fdb16991e15c/R/utils.R#L15)

But we should still find out why I can't run the code I suppose 😅

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

thanks!
Please let me know what is the content of the get_site_general() function?
Because the past version of this function contains the "keywordsLabel", "keywordsURI" as some column names of the output. Currently is:

get_site_general <- function(deimsid) {
  qo <- queries_jq[[get_deims_API_version()]]$site_general
  jj <- get_id(deimsid, qo$path)
  if (is.na(attr(jj, "status"))) {
    invisible(
      utils::capture.output(
        general <- dplyr::as_tibble(do_Q(qo$query, jj))
      )
    )
  } else {
    message("\n----\nThe requested page could not be found.
Please check again the DEIMS ID\n----\n")
    general <- NULL
  }
  general
}

And please can execute also ReLTER::get_deims_API_version() and ReLTER::get_deims_base_url(). The output should be:

> ReLTER::get_deims_API_version()
[1] "1.1"
> ReLTER::get_deims_base_url()
[1] "https://deims.org/"
> 

from relter.

maelle avatar maelle commented on June 16, 2024

Did you forget to push updates? These functions aren't exported (I'm using a clone of this repository)

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

I push all currently in the dev branch. May be is this the problem? Do you have clone main branch?

from relter.

maelle avatar maelle commented on June 16, 2024

yes I was using the main branch, and that is what the pkgdown building infrastructure uses.

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

Ahhh ok the error is about the function because I don't already done the PR from dev to main.

I think to solve all the issue (e.g. ERROR: dependency ‘SPARQL’ is not available for package ReLTER) in the dev branch and after merge this in the main.

Isn't that right?

from relter.

maelle avatar maelle commented on June 16, 2024

Now I also get the error about SPARQL. It has been archived on CRAN https://cran.r-project.org/web/packages/SPARQL/

However see https://discuss.ropensci.org/t/optional-suggests-dependency-that-has-been-archived-on-cran/3071

from relter.

maelle avatar maelle commented on June 16, 2024

I think to solve all the issue (e.g. ERROR: dependency ‘SPARQL’ is not available for package ReLTER) in the dev branch and after merge this in the main.

yes it makes sense!

from relter.

maelle avatar maelle commented on June 16, 2024

Regarding SPARQL you could also stop using it by making the API calls with httr2 or httr, example in https://github.com/lvaudor/glitter/blob/3fe7c9f90258a4ac9892f832a05da9e5b1d6e8e1/R/send_sparql.R#L34 (please tell me if you'd prefer me to make a PR, or have any question!)

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

do you have some suggestion about this error?

from relter.

maelle avatar maelle commented on June 16, 2024

We're both too fast answering 😂

So I think the best would be to remove the dependency on SPARQL by using httr2 or httr see #62 (comment)

from relter.

maelle avatar maelle commented on June 16, 2024

In that package I'm giving as an example we had removed the SPARQL dependency, reasoning in lvaudor/glitter#19

from relter.

maelle avatar maelle commented on June 16, 2024

(httr might be a better choice since ReLTER already imports it, unless you switch everything to httr2 🤪 )

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

Yes httr is already imported.

But before to remove SPARQL and use httr, can you tell me how to use httr in this case (get_sensor_observed_properties() function):

library(SPARQL)

ireaEndpoint <- "http://fuseki1.get-it.it/directory/query"
ireaQuery <- paste0(
  "PREFIX owl: <http://www.w3.org/2002/07/owl#>
       PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
       PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
       PREFIX qudt: <http://qudt.org/schema/qudt/>
       SELECT ?c ?l ?code ?s
        WHERE {
          SERVICE <http://vocab.nerc.ac.uk/sparql/sparql> {
            ?c rdf:type skos:Concept .
            <http://vocab.nerc.ac.uk/collection/P06/current/> skos:member ?c .
            OPTIONAL {
              ?c skos:altLabel ?l .
              ?c owl:sameAs ?s .
            }
            FILTER(?l = 'degC')
            FILTER(REGEX(STR(?s), 'qudt'))
          }
          SERVICE <https://www.qudt.org/fuseki/qudt/query> {
  	        ?s qudt:udunitsCode ?code
          }
        }
      ORDER BY ASC(?l)
      LIMIT 1"
)
qudtUOM <- SPARQL::SPARQL(
  url = ireaEndpoint,
  query = ireaQuery,
  curl_args = list(.encoding = "UTF-8")
)
qudtUOM

I want understand because I am a fan of sparql queries. 🤪

from relter.

maelle avatar maelle commented on June 16, 2024

Here's a reprex with both httr2 and httr solutions (I haven't checked the encoding, but it might help as a starting point)

ireaEndpoint <- "http://fuseki1.get-it.it/directory/query"
ireaQuery <- paste0(
  "PREFIX owl: <http://www.w3.org/2002/07/owl#>
       PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
       PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
       PREFIX qudt: <http://qudt.org/schema/qudt/>
       SELECT ?c ?l ?code ?s
        WHERE {
          SERVICE <http://vocab.nerc.ac.uk/sparql/sparql> {
            ?c rdf:type skos:Concept .
            <http://vocab.nerc.ac.uk/collection/P06/current/> skos:member ?c .
            OPTIONAL {
              ?c skos:altLabel ?l .
              ?c owl:sameAs ?s .
            }
            FILTER(?l = 'degC')
            FILTER(REGEX(STR(?s), 'qudt'))
          }
          SERVICE <https://www.qudt.org/fuseki/qudt/query> {
            ?s qudt:udunitsCode ?code
          }
        }
      ORDER BY ASC(?l)
      LIMIT 1"
)

library("magrittr")
resp <- httr2::request(ireaEndpoint) %>%
    httr2::req_url_query(query = ireaQuery) %>%
    httr2::req_method("POST") %>%
    httr2::req_headers(Accept = "application/sparql-results+json") %>%
    httr2::req_user_agent("ReLTER dev") %>%
    httr2::req_retry(max_tries = 3, max_seconds = 120) %>%
    httr2::req_perform()
httr2::resp_check_status(resp)
httr2::resp_body_json(resp)
#> $head
#> $head$vars
#> $head$vars[[1]]
#> [1] "c"
#> 
#> $head$vars[[2]]
#> [1] "l"
#> 
#> $head$vars[[3]]
#> [1] "code"
#> 
#> $head$vars[[4]]
#> [1] "s"
#> 
#> 
#> 
#> $results
#> $results$bindings
#> $results$bindings[[1]]
#> $results$bindings[[1]]$c
#> $results$bindings[[1]]$c$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$c$value
#> [1] "http://vocab.nerc.ac.uk/collection/P06/current/UPAA/"
#> 
#> 
#> $results$bindings[[1]]$l
#> $results$bindings[[1]]$l$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$l$value
#> [1] "degC"
#> 
#> 
#> $results$bindings[[1]]$code
#> $results$bindings[[1]]$code$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$code$value
#> [1] "°C"
#> 
#> 
#> $results$bindings[[1]]$s
#> $results$bindings[[1]]$s$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$s$value
#> [1] "http://qudt.org/vocab/unit/DEG_C"

qudtUOM <- httr::GET(
  url = ireaEndpoint,
  query = list(query = ireaQuery)
)
httr::parsed_content(qudtUOM)
#> text_content() deprecated. Use content(x, as = 'parsed')
#> $head
#> $head$vars
#> $head$vars[[1]]
#> [1] "c"
#> 
#> $head$vars[[2]]
#> [1] "l"
#> 
#> $head$vars[[3]]
#> [1] "code"
#> 
#> $head$vars[[4]]
#> [1] "s"
#> 
#> 
#> 
#> $results
#> $results$bindings
#> $results$bindings[[1]]
#> $results$bindings[[1]]$c
#> $results$bindings[[1]]$c$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$c$value
#> [1] "http://vocab.nerc.ac.uk/collection/P06/current/UPAA/"
#> 
#> 
#> $results$bindings[[1]]$l
#> $results$bindings[[1]]$l$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$l$value
#> [1] "degC"
#> 
#> 
#> $results$bindings[[1]]$code
#> $results$bindings[[1]]$code$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$code$value
#> [1] "°C"
#> 
#> 
#> $results$bindings[[1]]$s
#> $results$bindings[[1]]$s$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$s$value
#> [1] "http://qudt.org/vocab/unit/DEG_C"

Created on 2022-10-20 with reprex v2.0.2

from relter.

maelle avatar maelle commented on June 16, 2024

(as a side note you might be interested in https://github.com/lvaudor/glitter since you like SPARQL queries 😉)

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

(as a side note you might be interested in https://github.com/lvaudor/glitter since you like SPARQL queries 😉)

(I had seen this package, but didn't have time to look at it. Better than httr or httr2?)

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

Here's a reprex with both httr2 and httr solutions (I haven't checked the encoding, but it might help as a starting point)

ireaEndpoint <- "http://fuseki1.get-it.it/directory/query"
ireaQuery <- paste0(
  "PREFIX owl: <http://www.w3.org/2002/07/owl#>
       PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
       PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
       PREFIX qudt: <http://qudt.org/schema/qudt/>
       SELECT ?c ?l ?code ?s
        WHERE {
          SERVICE <http://vocab.nerc.ac.uk/sparql/sparql> {
            ?c rdf:type skos:Concept .
            <http://vocab.nerc.ac.uk/collection/P06/current/> skos:member ?c .
            OPTIONAL {
              ?c skos:altLabel ?l .
              ?c owl:sameAs ?s .
            }
            FILTER(?l = 'degC')
            FILTER(REGEX(STR(?s), 'qudt'))
          }
          SERVICE <https://www.qudt.org/fuseki/qudt/query> {
            ?s qudt:udunitsCode ?code
          }
        }
      ORDER BY ASC(?l)
      LIMIT 1"
)

library("magrittr")
resp <- httr2::request(ireaEndpoint) %>%
    httr2::req_url_query(query = ireaQuery) %>%
    httr2::req_method("POST") %>%
    httr2::req_headers(Accept = "application/sparql-results+json") %>%
    httr2::req_user_agent("ReLTER dev") %>%
    httr2::req_retry(max_tries = 3, max_seconds = 120) %>%
    httr2::req_perform()
httr2::resp_check_status(resp)
httr2::resp_body_json(resp)
#> $head
#> $head$vars
#> $head$vars[[1]]
#> [1] "c"
#> 
#> $head$vars[[2]]
#> [1] "l"
#> 
#> $head$vars[[3]]
#> [1] "code"
#> 
#> $head$vars[[4]]
#> [1] "s"
#> 
#> 
#> 
#> $results
#> $results$bindings
#> $results$bindings[[1]]
#> $results$bindings[[1]]$c
#> $results$bindings[[1]]$c$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$c$value
#> [1] "http://vocab.nerc.ac.uk/collection/P06/current/UPAA/"
#> 
#> 
#> $results$bindings[[1]]$l
#> $results$bindings[[1]]$l$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$l$value
#> [1] "degC"
#> 
#> 
#> $results$bindings[[1]]$code
#> $results$bindings[[1]]$code$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$code$value
#> [1] "°C"
#> 
#> 
#> $results$bindings[[1]]$s
#> $results$bindings[[1]]$s$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$s$value
#> [1] "http://qudt.org/vocab/unit/DEG_C"

qudtUOM <- httr::GET(
  url = ireaEndpoint,
  query = list(query = ireaQuery)
)
httr::parsed_content(qudtUOM)
#> text_content() deprecated. Use content(x, as = 'parsed')
#> $head
#> $head$vars
#> $head$vars[[1]]
#> [1] "c"
#> 
#> $head$vars[[2]]
#> [1] "l"
#> 
#> $head$vars[[3]]
#> [1] "code"
#> 
#> $head$vars[[4]]
#> [1] "s"
#> 
#> 
#> 
#> $results
#> $results$bindings
#> $results$bindings[[1]]
#> $results$bindings[[1]]$c
#> $results$bindings[[1]]$c$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$c$value
#> [1] "http://vocab.nerc.ac.uk/collection/P06/current/UPAA/"
#> 
#> 
#> $results$bindings[[1]]$l
#> $results$bindings[[1]]$l$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$l$value
#> [1] "degC"
#> 
#> 
#> $results$bindings[[1]]$code
#> $results$bindings[[1]]$code$type
#> [1] "literal"
#> 
#> $results$bindings[[1]]$code$value
#> [1] "°C"
#> 
#> 
#> $results$bindings[[1]]$s
#> $results$bindings[[1]]$s$type
#> [1] "uri"
#> 
#> $results$bindings[[1]]$s$value
#> [1] "http://qudt.org/vocab/unit/DEG_C"

Created on 2022-10-20 with reprex v2.0.2

sounds very good!!

... and could be possible also obtain a tibble as qudtUOM?

from relter.

maelle avatar maelle commented on June 16, 2024

(I had seen this package, but didn't have time to look at it. Better than httr or httr2?)

It is not a replacement for them, it's a package (not stable yet) that should help write SPARQL queries (well in your case you already know, but that can also help people who read the code)

from relter.

maelle avatar maelle commented on June 16, 2024

and could be possible also obtain a tibble as qudtUOM?

not via httr/httr2, at least I don't think so? which means, you'd need to add parsing code 🤔

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

I have changed the code using httr2 with this commit a72e1ee

from relter.

maelle avatar maelle commented on June 16, 2024

Cool!

Is the number of Imports becoming too high? CRAN has a limit, and you'd get a NOTE. Maybe the other httr code can be switched to httr2?

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

currently the imported packages are 45. Is it more the limit of CRAN?

The httr code has been wrote by my colleague and I would like to wait for changes or suggestions from him.

from relter.

maelle avatar maelle commented on June 16, 2024

currently the imported packages are 45. Is it more the limit of CRAN?

oh yeah definitely, it's about 20 if I remember correctly.

from relter.

maelle avatar maelle commented on June 16, 2024

the limit is for packages listed in Imports, not Suggests

from relter.

maelle avatar maelle commented on June 16, 2024

source https://github.com/wch/r-source/blob/3f86cb4b1867deea8f7e236f533fbdc5fac2b82e/doc/manual/R-ints.texi#L4458

from relter.

maelle avatar maelle commented on June 16, 2024

and https://github.com/wch/r-source/blob/16191bfcf873d55c3944678d9dfbd416317da83e/src/library/tools/R/check.R#L6664

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

the limit is for packages listed in Imports, not Suggests

45 are only in the Imports. Suggests packages are only 7.

How can I actually know whether a package is imported or suggested? Just from the fact that it is used in a function? In that case, do I have to import it and not suggests it?

from relter.

maelle avatar maelle commented on June 16, 2024

imported = listed in Imports.

Now, a package has to be listed in Imports when you call it from your code.

I'd suggest reading https://r-pkgs.org/dependencies.html

To limit the number of dependencies, you might need to

  • replace some code using a custom package with code using base R. If you prefer the style of a custom package, you could define your own utility functions that have the same interface. For instance if you have calls to purrr::map() but which to remove the purrr dependency you could be inspired by https://github.com/r-lib/rlang/blob/main/R/compat-purrr.R (rlang licence is MIT)
  • replace API calls that are made by a custom specific package, with API calls done with httr(2) directly
  • make some functionality optional. in that case some packages could be listed in Suggests but you would need to use them "conditionally", for instance adding a call to rlang::check_installed("blop") before using the blop package.
  • split ReLTER in a set of related packages, with maybe an umbrella package that would install them all (like what the {tidyverse} package is for all the tidyverse packages). If you do that please tell me so we can think of how that can work in the rOpenSci organization and whether we need to update our policies as that would be a first.

from relter.

oggioniale avatar oggioniale commented on June 16, 2024

Hi @micha-silver
I think it is a very accurate analysis. Thank you!!!

We have to work in terms of consolidation.
I would now like to arrive at a new and final version with the new functions and then think about consolidation and harmonisation in the use of packages.

Someone have idea about the rarer in the actions (https://github.com/ropensci/ReLTER/actions/runs/3378798361)?
Because if we don't get past this step, I wouldn't dare make any more changes.

from relter.

micha-silver avatar micha-silver commented on June 16, 2024

Hi @oggioniale
I see the errors in the Ubuntu builds have to do with openssl. I think there have been some updates to that software lately. It might be that we are temporarily between versions. Maybe after a day or two, when the repositories get synchronized, those errors will go away.??
If I understand, we are working on the dev branch? Should I wait till the above errors are fixed before pushing any new changes?

from relter.

maelle avatar maelle commented on June 16, 2024

👋 @oggioniale @micha-silver is any help needed here?

from relter.

maelle avatar maelle commented on June 16, 2024

wave @oggioniale @micha-silver Happy New Year! Is any help needed?

from relter.

micha-silver avatar micha-silver commented on June 16, 2024

Hi @oggioniale
One idea came to my mind this week: We have a minimal R version 3.5. And we need to import magrittr just for the '%>%' pipe operator. If we up the minimum R version to 4.1, then we can change to the new built in '|>' operator, and drop the magrittr dependency.
But let's wait till after the workshop ;-)

from relter.

maelle avatar maelle commented on June 16, 2024

Hello @oggioniale @micha-silver, any update? 😸

from relter.

maelle avatar maelle commented on June 16, 2024

👋 @oggioniale @micha-silver

from relter.

maelle avatar maelle commented on June 16, 2024

wave @oggioniale @micha-silver

from relter.

maelle avatar maelle commented on June 16, 2024

👋 @oggioniale @micha-silver -- what's the current status? Any help needed?

from relter.

micha-silver avatar micha-silver commented on June 16, 2024

Hi @maelle
Thanks for your continued support.
We see that the {MODIStsp} package, one of our dependencies, was removed from CRAN, but is still hosted at ROpenSci. Can we leave it in {ReLTER} as a dependency ?

from relter.

maelle avatar maelle commented on June 16, 2024

yes! if you submit ReLTER to CRAN you'll need to put it in Suggests though, see https://discuss.ropensci.org/t/optional-suggests-dependency-that-has-been-archived-on-cran/3071/6

from relter.

maelle avatar maelle commented on June 16, 2024

any update? any help needed? 😸

from relter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.