DataONEorg / rdataone

R package for reading and writing data at DataONE data repositories
http://doi.org/10.5063/F1M61H5X
36 stars 19 forks source link

Last version and issue for data package upload #252

Closed yvanlebras closed 2 years ago

yvanlebras commented 4 years ago

Dear rdataone colleagues,

Trying to upload a data package to our metacat, and also testing on test.arcticdata.io, I have this error:

> packageId <- uploadDataPackage(d1c, dp, public = TRUE)
Error in if (node@APIversion >= "v2") { : argument is of length zero

Is there any issue regarding that ?

mbjones commented 4 years ago

@yvanlebras can you please provide the outout of devtools::sessionInfo() to help understand your deployment? Also, what version of Metacat are you using? A short reproducible example would help to debug, e.g., that creates both d1c and dp objects before calling uploadDataPackage. Thanks.

yvanlebras commented 4 years ago

Thank you Matt for your rapid answer. Hope all is doing well on your side!

SessionInfo() output:

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252   
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
[5] LC_TIME=French_France.1252    

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

other attached packages:
[1] EML_2.0.2      uuid_0.1-4     datapack_1.3.2 dataone_2.1.4 

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.0  xfun_0.14         remotes_2.1.1     purrr_0.3.4      
 [5] V8_3.1.0          vctrs_0.3.0       generics_0.0.2    testthat_2.3.2   
 [9] htmltools_0.4.0   usethis_1.6.1     hash_2.2.6.1      yaml_2.2.1       
[13] base64enc_0.1-3   XML_3.99-0.3      rlang_0.4.6       pkgbuild_1.0.8   
[17] pillar_1.4.4      glue_1.4.1        withr_2.2.0       sessioninfo_1.1.1
[21] lifecycle_0.2.0   plyr_1.8.6        stringr_1.4.0     devtools_2.1.0   
[25] evaluate_0.14     memoise_1.1.0     knitr_1.28        emld_0.4.0       
[29] callr_3.4.3       ps_1.3.3          curl_4.3          fansi_0.4.1      
[33] Rcpp_1.0.4.6      backports_1.1.7   desc_1.2.0        pkgload_1.1.0    
[37] redland_1.0.17-11 jsonlite_1.6.1    fs_1.4.1          digest_0.6.25    
[41] jsonld_2.2        stringi_1.4.6     processx_3.4.2    parsedate_1.2.0  
[45] dplyr_1.0.0       rprojroot_1.3-2   jqr_1.1.0         cli_2.0.2        
[49] tools_3.5.1       magrittr_1.5      lazyeval_0.2.2    tibble_3.0.1     
[53] crayon_1.3.4      pkgconfig_2.0.3   ellipsis_0.3.1    xml2_1.3.2       
[57] prettyunits_1.1.1 rmarkdown_2.2     assertthat_0.2.1  roxygen2_7.1.0   
[61] httr_1.4.1        rstudioapi_0.11   R6_2.4.1          compiler_3.5.1  

Here is the code I use (please don't be cruel ;) ):

install.packages("dataone")
library(datapack)
library(uuid)
library(dataone)
library(EML)

options(dataone_test_token = "MYMETACATTOKEN")
cn <- CNode("STAGING")
# cn <- CNode("PROD")
## the arcticdata mn to test if the issue is the same
# mn <- MNode("http://test.arcticdata.io/metacat/d1/mn/v2/")

## our previous test metacat were we already push DP
# mn <- MNode("http://openstack-192-168-100-101.genouest.org/metacat/d1/mn/v2/")
mn <- MNode("http://test.pndb.fr/metacat/d1/mn/v2")
d1c <- new("D1Client", cn, mn)
d1c <- D1Client("STAGING", mn)

## Data package initialization
dp <- new("DataPackage")

metadata_id <- generateIdentifier(mn, scheme = "uuid")
doc <- read_eml("~/1_PNDB/0_USe_cases/Marchand_EML/F330_data.xml")
doc$packageId <- metadata_id
doc$system <- mn@identifier
metadataObj <- new("DataObject",
                   id = metadata_id,
                   format ="eml://ecoinformatics.org/eml-2.1.1",
                   filename = "~/MYEML/F330_data.xml")
dp <- addMember(dp, metadataObj)
dp

eml_validate(doc)
d1c@mn@identifier <- mn@identifier
packageId <- uploadDataPackage(d1c, dp, public = TRUE)

Whishing you a good day. Thank you!

yvanlebras commented 4 years ago

Any information about an error on my side using the package or a transient issue with dataone API ?

amoeba commented 4 years ago

Hey @yvanlebras, apologies for the long delay in getting back to you on this. I see the cause of the issue but don't have a fix just yet. I'm looking now and will hopefully dig something up shortly.

yvanlebras commented 4 years ago

Thank you very much to come back to me ! No urgence, happy that you identify the cause of the issue, maybe from DataOne API ? Whishing you a nice day/night

amoeba commented 4 years ago

It looks like D1Client and uploadDataPackage (and other functions) expect your MNode to be Metacat instance registered with DataONE and, since yours isn't, we get a cryptic error. It's totally fine that your Metacat installation isn't registered.

For the time being, I think you can do the following:

mn <- MNode("http://test.pndb.fr/metacat/d1/mn/v2")
d1c <- D1Client("STAGING", mn)
d1c@mn <- mn # <- this is key

and try your upload then.

jeanetteclark commented 2 years ago

@amoeba do you think we should set a formal workaround for this or can I close this issue?

amoeba commented 2 years ago

My initial take was to stop the user from instantiating a D1Client instance using an MNode that isn't registered in the corresponding environment but that's actually a very common use case as unregistered nodes still use a DataONE environment to do auth. So I think we should just make it so this code actually sets the MNode instance the user has provided rather than fail silently:

mn <- MNode("http://test.pndb.fr/metacat/d1/mn/v2")
d1c <- D1Client("STAGING", mn)
jeanetteclark commented 2 years ago

turns out this had nothing to do with the MN being registered, and was just a missing signature from the method. I added the argument signature so you can initialize the D1Client this way now