cthoyt / zenodo-client

A tool for automated uploading and version management of scientific data to Zenodo
MIT License
25 stars 5 forks source link

Failing when update becase new version doesnt have metadata.version #31

Closed daviddavo closed 8 months ago

daviddavo commented 8 months ago

I don't know why, but new version drafts don't have a version field, so it fails

Traceback (most recent call last):
  File "/home/davo/Documents/GRASIA/dao-scripts/.direnv/python-3.11/bin/dao-utils-upload-dw", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/davo/Documents/GRASIA/dao-scripts/src/utils/uploadDataWarehouse.py", line 137, in main
    archiveToZenodo(tmpdir, args.zenodo_max_retries)
  File "/home/davo/Documents/GRASIA/dao-scripts/src/utils/uploadDataWarehouse.py", line 75, in archiveToZenodo
    uploadToZenodo([zpath / 'archive.zip'])
  File "/home/davo/Documents/GRASIA/dao-scripts/src/utils/uploadDataWarehouse.py", line 55, in uploadToZenodo
    z.update(ZENODO_DEPOSITION_ID, paths)
  File "/home/davo/Documents/GRASIA/dao-scripts/.direnv/python-3.11/lib/python3.11/site-packages/zenodo_client/api.py", line 182, in update
    new_deposition_data["metadata"]["version"] = _prepare_new_version(new_deposition_data["metadata"]["version"])
                                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'version'
daviddavo commented 8 months ago

Furthermore, it seems that now update accepts just the metadata field. The response is giving me lots of "Unknown field" error messages.

This can be fixed like this:

res = requests.put(
    f"{self.depositions_base}/{new_deposition_id}",
    json={"metadata": new_deposition_data["metadata"]},
    params={"access_token": self.access_token},
)

To fix the version thing, I guess you will have to use get_latest_record

daviddavo commented 8 months ago

I WAS USING A WRONG RECORD NUMBER!! Sorry...