grimbough / rhdf5

Package providing an interface between HDF5 and R
http://bioconductor.org/packages/rhdf5
61 stars 22 forks source link

Empty strings fail? #60

Closed muschellij2 closed 4 years ago

muschellij2 commented 4 years ago

Empty string gives bad value in a a list. This only started happening with new Bioc version.

library(rhdf5)
filepath = tempfile(fileext = ".h5")
name = "x"
hdr = list(descrip = "")
rhdf5::h5write(hdr, file = filepath, name = name)
#> Error in H5Tset_size(tid, size): HDF5. Invalid arguments to routine. Bad value.

Created on 2020-05-18 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.0 Patched (2020-05-13 r78451) #> os CentOS Linux 7 (Core) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz US/Eastern #> date 2020-05-18 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.0) #> backports 1.1.7 2020-05-13 [2] CRAN (R 4.0.0) #> callr 3.4.3 2020-03-28 [2] CRAN (R 4.0.0) #> cli 2.0.2 2020-02-28 [2] CRAN (R 4.0.0) #> colorout * 1.2-2 2020-05-18 [1] Github (jalvesaq/colorout@726d681) #> crayon 1.3.4 2017-09-16 [2] CRAN (R 4.0.0) #> desc 1.2.0 2018-05-01 [2] CRAN (R 4.0.0) #> devtools 2.3.0 2020-04-10 [2] CRAN (R 4.0.0) #> digest 0.6.25 2020-02-23 [2] CRAN (R 4.0.0) #> ellipsis 0.3.1 2020-05-15 [2] CRAN (R 4.0.0) #> evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.0) #> fansi 0.4.1 2020-01-08 [2] CRAN (R 4.0.0) #> fs 1.4.1 2020-04-04 [2] CRAN (R 4.0.0) #> glue 1.4.1 2020-05-13 [2] CRAN (R 4.0.0) #> highr 0.8 2019-03-20 [2] CRAN (R 4.0.0) #> htmltools 0.4.0 2019-10-04 [2] CRAN (R 4.0.0) #> knitr 1.28 2020-02-06 [2] CRAN (R 4.0.0) #> magrittr 1.5 2014-11-22 [2] CRAN (R 4.0.0) #> memoise 1.1.0 2017-04-21 [2] CRAN (R 4.0.0) #> pkgbuild 1.0.8 2020-05-07 [2] CRAN (R 4.0.0) #> pkgload 1.0.2 2018-10-29 [2] CRAN (R 4.0.0) #> prettyunits 1.1.1 2020-01-24 [2] CRAN (R 4.0.0) #> processx 3.4.2 2020-02-09 [2] CRAN (R 4.0.0) #> ps 1.3.3 2020-05-08 [2] CRAN (R 4.0.0) #> R6 2.4.1 2019-11-12 [2] CRAN (R 4.0.0) #> Rcpp 1.0.4.6 2020-04-09 [2] CRAN (R 4.0.0) #> remotes 2.1.1 2020-02-15 [2] CRAN (R 4.0.0) #> rhdf5 * 2.33.0 2020-04-27 [2] Bioconductor #> Rhdf5lib 1.11.0 2020-04-27 [2] Bioconductor #> rlang 0.4.6 2020-05-02 [2] CRAN (R 4.0.0) #> rmarkdown 2.1 2020-01-20 [1] CRAN (R 4.0.0) #> rprojroot 1.3-2 2018-01-03 [2] CRAN (R 4.0.0) #> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.0) #> stringi 1.4.6 2020-02-17 [2] CRAN (R 4.0.0) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 4.0.0) #> testthat 2.3.2 2020-03-02 [2] CRAN (R 4.0.0) #> usethis 1.6.1 2020-04-29 [2] CRAN (R 4.0.0) #> withr 2.2.0 2020-04-20 [2] CRAN (R 4.0.0) #> xfun 0.13 2020-04-13 [2] CRAN (R 4.0.0) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.0) #> #> [1] /users/jmuschel/R/4.0.x #> [2] /jhpce/shared/jhpce/core/conda/miniconda3-4.6.14/envs/svnR-4.0.x/R/4.0.x/lib64/R/site-library #> [3] /jhpce/shared/jhpce/core/conda/miniconda3-4.6.14/envs/svnR-4.0.x/R/4.0.x/lib64/R/library ```
grimbough commented 4 years ago

Thanks for the report, I'll look into it.

grimbough commented 4 years ago

Thanks again, this should be patched in version 2.33.4. It didn't only affect writing lists, but any character vector where the contents were all the empty string. I'll also patch the release version on Bioconductor since this is a bug.

library(rhdf5)
filepath = tempfile(fileext = ".h5")
rhdf5::h5write("", file = filepath, name = "X")
h5read(filepath, "X")
#> [1] ""

rhdf5::h5write(list(empty_char = ""), file = filepath, name = "Y")
h5read(filepath, "Y")
#> $empty_char
#> [1] ""

Let me know if you run into more issues.

muschellij2 commented 4 years ago

Was this patched on BioC release? Still seeing the same bug.

grimbough commented 4 years ago

Sorry, I should have left the issue open. Thank for reminding me, I wanted to wait a few day to make sure nothing downstream broke in devel before pushing this.

It is now in rhdf5 v 2.32.1, which should propagate in the next day.

Out of interest, what's the usecase for creating vectors with only empty strings?