Commit cd248275 authored by Enrique Garcia's avatar Enrique Garcia
Browse files

take out metadata root key and update the update_metadata method in agreement with this

parent 905e96bc
.pytest_cache
# Compiled files
__pycache__
# Packages/installer info
*.egg
*.eggs
*.egg-info
dist
build
# Mac OSX
.DS_Store
# Pycharm editor project files
.idea
\ No newline at end of file
......@@ -106,4 +106,4 @@ test_deploy_from_container:
- upload_new_deposit --token $SANDBOX_ZENODO_TOKEN --sandbox True --input-dir ./build
- upload_new_version_deposit -t $SANDBOX_ZENODO_TOKEN -s True -i ./build -id $ZENODO_PROJECT_ID
only:
- branches # testing/debugging
- master # testing/debugging
......@@ -22,7 +22,7 @@ setup(
description="REST API handler to manage the uploads and communication with Zenodo.",
install_requires=[
'requests',
'codemeta2zenodo_crosswalk @ git+https://gitlab.in2p3.fr/escape2020/wp3/codemeta2zenodo',
'codemeta2zenodo @ git+https://gitlab.in2p3.fr/escape2020/wp3/codemeta2zenodo',
],
packages=find_packages(),
scripts=['zenodoci/parse_last_release_git.sh'],
......
......@@ -107,7 +107,7 @@ def main():
# entry_info['metadata']['doi'] = doi # In the new version of the API the doi is updated automatically.
update_entry = zenodo.update_metadata_entry(
deposition_id,
data=entry_metadata
json_metadata=entry_metadata
)
if update_entry.status_code < 399:
......
......@@ -118,7 +118,7 @@ def main():
# update_entry_info['metadata']['doi'] = doi # In the new version of the API the doi is updated automatically.
update_entry = zenodo.update_metadata_entry(
new_deposition_id,
data=update_entry_metadata
json_metadata=update_entry_metadata
)
if update_entry.status_code < 399:
......
......@@ -109,7 +109,7 @@ class ZenodoAPI:
return upload.json()
def update_metadata_entry(self, entry_id, data):
def update_metadata_entry(self, entry_id, json_metadata):
"""
Update an entry resource. Data should be the entry information that will be shown when a deposition is visited
at the Zenodo site.
......@@ -118,7 +118,7 @@ class ZenodoAPI:
:param entry_id: str
deposition_id of the Zenodo entry
:param data: object
:param json_metadata: object
json object containing the metadata (compulsory fields) that are enclosed when a new entry is created.
:return: obj
......@@ -128,6 +128,8 @@ class ZenodoAPI:
headers = {"Content-Type": "application/json"}
parameters = {'access_token': self.access_token}
data = {"metadata": json_metadata}
return requests.put(url, data=json.dumps(data),
headers=headers, params=parameters)
......@@ -301,7 +303,8 @@ class ZenodoAPI:
with open(self.path_zenodo_metadata_file) as file:
metadata_entry = json.load(file)
update_metadata = self.update_metadata_entry(test_entry_id,
data=metadata_entry)
json_metadata=metadata_entry)
if update_metadata.status_code == 200:
print(" * Update metadata status OK !")
pprint.pprint(metadata_entry)
......@@ -312,6 +315,8 @@ class ZenodoAPI:
if erase_error.status_code != 204:
print(f" !! ERROR erasing dummy test entry. Please erase it manually at\n "
f"{self.zenodo_api_url[:-4]}/deposit")
else:
print(" - Done.\n")
sys.exit(-1)
# 4 - Test delete entry
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment