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

uploadDataPackage should support 'common' objects #251

Closed gothub closed 4 years ago

gothub commented 4 years ago

A typical DataONE use case is to have the same data object in multiple packages.

It should be possible to download a package using getDataPackage(), add a package member for a pid that already exists in DataONE (in another package, for example), and upload the package using uploadDataPackage(). In this case, uploadDataPackage() should not try to upload the 'common' data object to DataONE again, and should include this new package member in the resource map.

ranicrab commented 4 years ago

It would be great to get this implemented - we share species and site tables across multiple datasets and currently do not have a way to upload these datasets in R unless we create different identifiers for the same table; we would prefer not to do that if possible!

gothub commented 4 years ago

Existing DataONE objects can now be included into new DataPackages. The workflow to use is:

d1c <- D1Client("STAGING2", "urn:node:mnTestKNB") dp <- new("DataPackage")

Read in and create a metadata object that describes science data

emlFile <- system.file("extdata/strix-pacific-northwest.xml", package="dataone") metadataObj <- new("DataObject", format="eml://ecoinformatics.org/eml-2.1.1", filename=emlFile) dp <- addMember(dp, metadataObj)

Create a new DataObject from a local file

progFile <- system.file("extdata/filterObs.R", package="dataone") progObj <- new("DataObject", format="application/R", filename=progFile, mediaType="text/x-rsrc") dp <- addMember(dp, progObj, metadataObj)

Reuse and existing DataONE object

OwlNightj.csv

sourceObj <- getDataObject(d1c, id="urn:uuid:4dc4a896-31c2-4185-b1d7-ebb37f3f9cd6", lazyLoad=T, limit="1GB", quiet=F); dp <- addMember(dp, sourceObj, metadataObj)

Upload the data package to DataONE

pkgId <- uploadDataPackage(d1c, dp, public=TRUE, quiet=FALSE)



A minor fix was made to `uploadDataPackage` that prevented downloaded items to be used. This fix was made in commit ce5f02c4a0a05fb1ea18800a8823f47a36f8491b