You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using pyDataverse 0.2.1 and I can't publish a dataset. I'm getting the following error:
Traceback (most recent call last):
File "create_and_publish_dataset.py", line 15, in <module>
resp = api.publish_dataset(dataset_pid, type='major')
File "/home/pdurbin/envs/dataverse-sample-data/lib/python3.6/site-packages/pyDataverse/api.py", line 727, in publish_dataset
query_str += '?persistentId={0}&type={1}'.format(identifier, type)
NameError: name 'identifier' is not defined
Something like this should fix it:
dhcp-10-250-190-90:pyDataverse pdurbin$ git diff src/pyDataverse/api.py
diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py
index 2bebc05..972e427 100644
--- a/src/pyDataverse/api.py
+++ b/src/pyDataverse/api.py
@@ -673,7 +673,7 @@ class Api(object):
print('Dataset {} created.'.format(identifier))
return resp
- def publish_dataset(self, pid, type='minor', auth=True):
+ def publish_dataset(self, identifier, type='minor', auth=True):
"""Publish dataset.
Publishes the dataset whose id is passed. If this is the first version
@@ -705,7 +705,7 @@ class Api(object):
Parameters
----------
- pid : string
+ identifier : string
Persistent identifier of the dataset (e.g.
``doi:10.11587/8H3N93``).
type : string
dhcp-10-250-190-90:pyDataverse pdurbin$
Here's the code I'm using to exercise the bug:
from pyDataverse.api import Api
import json
import dvconfig
base_url = dvconfig.base_url
api_token = dvconfig.api_token
api = Api(base_url, api_token)
print(api.status)
dataset_json = 'data/dataverses/open-source-at-harvard/datasets/open-source-at-harvard/open-source-at-harvard.json'
with open(dataset_json) as f:
metadata = json.load(f)
dataverse = ':root'
resp = api.create_dataset(dataverse, json.dumps(metadata))
print(resp.json())
dataset_pid = resp.json()['data']['persistentId']
resp = api.publish_dataset(dataset_pid, type='major')
print(resp.json())
I'm using pyDataverse 0.2.1 and I can't publish a dataset. I'm getting the following error:
Something like this should fix it:
Here's the code I'm using to exercise the bug:
The "dvconfig" stuff comes from https://github.com/IQSS/dataverse-sample-data
The text was updated successfully, but these errors were encountered: