Skip to content

Commit

Permalink
CRAN Version 1.1.0
Browse files Browse the repository at this point in the history
tabledap now retrus values as same type as in the dds
  • Loading branch information
rmendels committed Jan 12, 2024
1 parent 9662d98 commit 056b542
Show file tree
Hide file tree
Showing 64 changed files with 38,315 additions and 28 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/R-check.yml
@@ -0,0 +1,101 @@
on: [push, pull_request]

name: R-check

jobs:
R-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: 'release'}
- { os: macOS-latest, r: 'release'}
# - { os: macOS-latest, r: 'devel'}
- { os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
VCR_VERBOSE_ERRORS: true

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: install macOS system dependencies
if: runner.os == 'macOS'
continue-on-error: true
run: |
brew install pkg-config gdal udunits proj netcdf
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
gdal-bin \
libgdal-dev \
libproj-dev \
netcdf-bin
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran(c("rcmdcheck", "taxize"))
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

- name: Test coverage
if: matrix.config.os == 'ubuntu-18.04' && matrix.config.r == 'release'
run: |
Rscript -e 'remotes::install_cran("covr")' -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
@@ -1,3 +1,3 @@
Version: 1.0.4
Date: 2023-08-23 01:37:27 UTC
SHA: 5c8c7179d4e63b927a08e707d8bb1c8b6bd0c693
Version: 1.1.0
Date: 2024-01-12 17:22:06 UTC
SHA: 9662d98df70233be405dedcd27534c721b9136f5
14 changes: 8 additions & 6 deletions DESCRIPTION
Expand Up @@ -5,8 +5,8 @@ Description: General purpose R client for 'ERDDAP' servers. Includes
'datasets', and fetch 'datasets', in either 'csv' or 'netCDF' format.
'ERDDAP' information:
<https://upwell.pfeg.noaa.gov/erddap/information.html>.
Version: 1.0.4
Date: 2023-08-23
Version: 1.1.0
Date: 2024-1-12
License: MIT + file LICENSE
Authors@R: c(
person("Scott", "Chamberlain", role = "aut"),
Expand All @@ -23,16 +23,18 @@ Roxygen: list(markdown = TRUE)
Encoding: UTF-8
Language: en-US
Imports:
utils,
crul (>= 0.7.4),
dplyr (>= 0.5.0),
data.table (>= 1.12.0),
jsonlite (>= 1.6),
xml2 (>= 1.2.0),
digest,
hoardr (>= 0.5.2),
jsonlite (>= 1.6),
lubridate,
methods,
ncdf4 (>= 1.16),
tibble,
hoardr (>= 0.5.2)
utils,
xml2 (>= 1.2.0)
Suggests:
knitr,
rmarkdown
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
rerddap 1.1.0
=============
* 'tabledap()' responses now have the datatype given in the file .dds

rerddap 1.0.4
=============
* fixes problem with time bounds check and "last"
Expand Down
5 changes: 4 additions & 1 deletion R/ncdf_helpers.R
Expand Up @@ -12,7 +12,10 @@ ncdf4_get <- function(file){
for (i in seq_along(dims)) {
out[[dims[i]]] <- ncdf4::ncvar_get(nc, nc$dim[[dims[i]]])
}
out$time <- sapply(out$time, convert_time)
if ('time' %in% names(out)){
out$time <- sapply(out$time, convert_time)

}
vars <- names(nc$var)
outvars <- list()
for (i in seq_along(vars)) {
Expand Down
43 changes: 42 additions & 1 deletion R/table.R
Expand Up @@ -208,8 +208,27 @@ tabledap <- function(x, ..., fields=NULL, distinct=FALSE, orderby=NULL,
}
resp <- erd_tab_GET(url, dset = attr(x, "datasetid"), store, callopts)
loc <- if (store$store == "disk") resp else "memory"
temp_table <- read_table(resp)
# change response type
dds_url <- sub('csv', 'dds', url)
# strip off constraints
amp_location <- regexpr("&", dds_url)
if (amp_location[1] > 0) {
dds_url <- substr(dds_url, 1, amp_location[1] - 1)
}
dds <- try(suppressWarnings(utils::read.table(dds_url)), silent = TRUE)
# if (class(dds) == 'try-error') {
if (methods::is(dds, 'try-error')) {
print('failed to get variable datatype information')
print('will leave units unchanged')
} else{
temp_table <- set_units(temp_table, dds)
}


structure(
read_table(resp),
#read_table(resp),
temp_table,
class = c("tabledap", "data.frame"),
datasetid = attr(x, "datasetid"),
path = loc,
Expand Down Expand Up @@ -262,3 +281,25 @@ makevar <- function(x, y){
NULL
}
}

set_units <- function(temp_t, dds) {
for (i in seq(3, (nrow(dds) - 2))) {
var_type <- dds[i, 1]
var_name <- dds[i, 2]
var_name <- substr(var_name, 1, nchar(var_name)-1)
if (var_name == 'time') {
# make certain lubridate can convert time
temp_time <- suppressWarnings(lubridate::as_datetime(temp_t$time))
if (!any(is.na(temp_time))) {
temp_t$time <- temp_time
}
} else {
if (grepl('Float', var_type)) {
temp_t[[var_name]] <- as.numeric(temp_t[[var_name]])
} else if(grepl('Int', var_type)) {
temp_t[[var_name]] <- as.integer(temp_t[[var_name]])
}
}
}
return(temp_t)
}
4 changes: 2 additions & 2 deletions cran-comments.md
@@ -1,6 +1,6 @@
## Test environments

* local macOS install, R 4.3.1
* local macOS install, R 4.3.2
* rhub (devtools::check_rhub())
* macOS Builder (devtools::check_mac_release())
* win-builder (devel and release - devtools::check_win_*())
Expand All @@ -15,7 +15,7 @@ OK from all checks

---

This version fixes problems with the time bounds checks and "last"
'tabledap()' responses now have the datatype given in the file .dds

Thanks!
Roy Mendelssohn
60 changes: 60 additions & 0 deletions man/rerddap-package.Rd

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

Binary file not shown.

0 comments on commit 056b542

Please sign in to comment.