dataverse-client-python icon indicating copy to clipboard operation
dataverse-client-python copied to clipboard

Failure to update dataset metadata?

Open keflavich opened this issue 10 years ago • 0 comments

I'm trying to bulk update metadata on a data set. update_metadata raises no errors, but it also doesn't change the underlying data set. I have manually confirmed that the data being sent are correct, and that no change to the dataset occurs in the web browser or in the python terminal. This is possibly an API bug, not a client bug, but I think this is the appropriate place to post it. Please let me know if I'm doing something completely wrong.

from dataverse import Connection
hostname = 'dataverse.harvard.edu'
api_token = 'redacted'
connection = Connection(hostname, api_token)
dataverse = connection.get_dataverse('APEX-CMZ-1mm')
info = dataverse.get_collection_info()
ds, = dataverse.get_datasets()

meta = ds.get_metadata()
fmeta = meta['files']
for item in fmeta:
    df = item['datafile']
    if df['name'][-5:] == '.apex':
        if 'description' in df:
            print df['name'], item['description']
        else:
            print df['name'], "no description"
        df['description'] = 'Raw Data'

# confirm that metadata is set - if it is not, this will raise an Exception because some files have no metadata at all
[x['datafile']['description'] for x in meta['files']]

ds.update_metadata(meta)

ds._metadata['draft'] == meta # evaluates to False

keflavich avatar Jun 06 '15 02:06 keflavich