ropensci / EML

Ecological Metadata Language interface for R: synthesis and integration of heterogenous data
https://docs.ropensci.org/EML
Other
98 stars 33 forks source link

running set_attributes generates message " Error in readBin(4L, raw(0), 32768L) : can only read from a binary connection #277

Open christystarr opened 5 years ago

christystarr commented 5 years ago

I am not sure if this is a problem with the EML package or some other package but when I try to run set_attributes I get the message Error in readBin(4L, raw(0), 32768L) : can only read from a binary connection

I can not figure out what I am doing wrong.

cboettig commented 5 years ago

Hi @christystarr , thanks for the bug report! Can you please provide a minimal reproducible example to help us investigate? e.g. from the example in the README

library(EML)
attributes <- read.table(system.file("extdata/hf205_attributes.csv", package = "EML"))
factors <- read.table(system.file("extdata/hf205_factors.csv", package = "EML"))
attributeList <- 
  set_attributes(attributes, 
                 factors, 
                 col_classes = c("character", 
                                 "Date",
                                 "Date",
                                 "Date",
                                 "factor",
                                 "factor",
                                 "factor",
                                 "numeric"))

and I do not get that error. Providing sessionInfo() is also helpful for us in debugging to see differences in platform or version that may be responsible. e.g. here's what I see when I run sessionInfo():

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] EML_2.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       rstudioapi_0.10  knitr_1.22       xml2_1.2.0       magrittr_1.5     uuid_0.1-2      
 [7] tidyselect_0.2.5 R6_2.4.0         rlang_0.3.4      dplyr_0.8.0.1    tools_3.6.0      packrat_0.5.0   
[13] xfun_0.7         jqr_1.1.0        htmltools_0.3.6  digest_0.6.18    yaml_2.2.0       lazyeval_0.2.2  
[19] assertthat_0.2.1 jsonld_2.1       tibble_2.1.1     crayon_1.3.4     purrr_0.3.2      curl_3.3        
[25] emld_0.2.0       glue_1.3.1       evaluate_0.13    rmarkdown_1.12   V8_2.2           compiler_3.6.0  
[31] pillar_1.4.0     jsonlite_1.6     pkgconfig_2.0.2 
christystarr commented 5 years ago

Hello, Thanks for any help! It is within a larger program that converts excel table to eml (exceltoeml). I have debugged it down to this point below, where fact1 is the attributes if there are factors and meta1 is non-factors. The columns in these data frames are attributeName, attributeLabel, attributeDefinition, measurementScale,domain, storageType, and formatString.

The weird thing is that it worked last week. Then I loaded the new version of R and the associated packages, and now it does not work. Here is the code that gives that error message. Mainly the second half, since I don't have any factors.

if (dim(fact1)[1] > 0) { attributeList <- set_attributes(meta1,factors=fact1) } else { attributeList <- set_attributes(meta1) }

R version 3.5.2 (2018-12-20) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] pkgload_1.0.2 emld_0.2.0 dplyr_0.8.1 jqr_1.1.0 usethis_1.5.0 devtools_2.0.2 [7] processx_3.3.1 data.table_1.12.2 readr_1.3.1 tidyr_0.8.3 EML_2.0.0 XLConnect_0.2-15 [13] XLConnectJars_0.2-15 readxl_1.3.1 loaded via a namespace (and not attached): [1] tidyselect_0.2.5 xfun_0.7 remotes_2.0.4 purrr_0.3.2 rJava_0.9-11 testthat_2.1.1 V8_2.2 [8] vctrs_0.1.0 htmltools_0.3.6 yaml_2.2.0 utf8_1.1.4 rlang_0.3.4 pkgbuild_1.0.3 pillar_1.4.0 [15] glue_1.3.1 withr_2.1.2 sessioninfo_1.1.1 uuid_0.1-2 cellranger_1.1.0 evaluate_0.13 memoise_1.1.0 [22] knitr_1.22 callr_3.2.0 ps_1.3.0 curl_3.3 fansi_0.4.0 Rcpp_1.0.1 backports_1.1.4 [29] desc_1.2.0 jsonlite_1.6 fs_1.3.1 hms_0.4.2 digest_0.6.18 jsonld_2.1 rprojroot_1.3-2 [36] cli_1.1.0 tools_3.5.2 magrittr_1.5 lazyeval_0.2.2 tibble_2.1.1 crayon_1.3.4 pkgconfig_2.0.2 [43] zeallot_0.1.0 xml2_1.2.0 prettyunits_1.0.2 assertthat_0.2.1 rmarkdown_1.12 rstudioapi_0.10 R6_2.4.0 [50] compiler_3.5.2

 

| >

cboettig commented 5 years ago

@christystarr Thanks for sessionInfo(), this confirms you are working on the latest version. Yes, the new version is not the same as the old version and some things may break after you upgraded; sorry.

Yes, I understand that your error probably comes from a larger script, unfortunately that's not something we can debug. Please provide code which I can copy-paste into R to reproduce the error. This may require creating a smaller example set of attributes by removing complexity from your code. Please see https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for a quick overview of this! Without it we really can't be much help.

scelmendorf commented 4 years ago

FWIW I can recreate this error when I have a typo setting my eml_db options (and yes I have solved my own problems but just in case others haven't and stumble across this and/or you want to make a more informative error message for invalid eml_db options)

library(EML)
attributes <- read.table(system.file("extdata/hf205_attributes.csv", package = "EML"))
factors <- read.table(system.file("extdata/hf205_factors.csv", package = "EML"))

#works fine
attributeList <- 
  set_attributes(attributes, 
                 factors, 
                 col_classes = c("character", 
                                 "Date",
                                 "Date",
                                 "Date",
                                 "factor",
                                 "factor",
                                 "factor",
                                 "numeric"))

#also works find if I change to another version of eml
options(emld_db = "eml-2.1.1")
attributeList <- 
  set_attributes(attributes, 
                 factors, 
                 col_classes = c("character", 
                                 "Date",
                                 "Date",
                                 "Date",
                                 "factor",
                                 "factor",
                                 "factor",
                                 "numeric"))

options("emld_db" = "eml-2.2.0")
attributeList <- 
  set_attributes(attributes, 
                 factors, 
                 col_classes = c("character", 
                                 "Date",
                                 "Date",
                                 "Date",
                                 "factor",
                                 "factor",
                                 "factor",
                                 "numeric"))

#generates readBin error when you make a typo in your eml version
options("emld_db" = "a typo")
attributeList <- 
  set_attributes(attributes, 
                 factors, 
                 col_classes = c("character", 
                                 "Date",
                                 "Date",
                                 "Date",
                                 "factor",
                                 "factor",
                                 "factor",
                                 "numeric"))
amoeba commented 4 years ago

That's perfect, thanks @scelmendorf, makes this straightforward to track down.

@cboettig: (1) I think a more helpful error message should be produced higher up the call stack and (2) we should probably keep iterating on the API for changing/setting the EML version (something like emld::eml_version since we can't do any input validation on an options call. Thoughts?

christystarr commented 4 years ago

Hello! I had that error a while back. I no longer work at that job or have the same computer. This was so long ago that I kind of forget (although I recall being annoyed at the time about the error). Sorry I can't be of more help.

Christy

On Mon, Jun 22, 2020 at 2:36 PM Bryce Mecum notifications@github.com wrote:

That's perfect, thanks @scelmendorf https://github.com/scelmendorf, makes this straightforward to track down.

@cboettig https://github.com/cboettig: (1) I think a more helpful error message should be produced higher up the call stack and (2) we should probably keep iterating on the API for changing/setting the EML version (something like emld::eml_version since we can't do any input validation on an options call. Thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ropensci/EML/issues/277#issuecomment-647756640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIN6SRJRQ5JMUZ5WHWD2SKLRX66FRANCNFSM4HODUYYA .