Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset publishing error #24

Closed
pdurbin opened this issue Jun 28, 2019 · 3 comments
Closed

Dataset publishing error #24

pdurbin opened this issue Jun 28, 2019 · 3 comments
Assignees
Labels
pkg:api api related activities type:bug Something isn't working

Comments

@pdurbin
Copy link
Member

pdurbin commented Jun 28, 2019

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())

The "dvconfig" stuff comes from https://github.com/IQSS/dataverse-sample-data

@skasberger skasberger added pkg:api api related activities type:bug Something isn't working labels Jul 1, 2019
@skasberger skasberger self-assigned this Jul 1, 2019
@skasberger skasberger added this to the v0.2.2 milestone Jul 1, 2019
@skasberger
Copy link
Member

oh, the passed variable is not named identifier (its called ''dataset_pid`).
Will fix this in the next release.

Thanks for the bug report. Testing the publishing is a bit tricky. :)

pdurbin referenced this issue in IQSS/dataverse-sample-data Jul 1, 2019
@skasberger skasberger changed the title cannot publish dataset dataset publishing error Jul 2, 2019
@skasberger skasberger changed the title dataset publishing error Dataset publishing error Jul 2, 2019
@foobarbecue
Copy link

This hasn't been fixed yet? Yikes...

@skasberger
Copy link
Member

It is, but only in the develop branch.
try it through pip like this
pip3 install git+https://github.com/AUSSDA/pyDataverse.git@develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:api api related activities type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants