Skip to content

Commit

Permalink
publish datasets using workaround for now
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jul 1, 2019
1 parent fbd058b commit a1b4073
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions create_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dvconfig
import os
import time
import requests
base_url = dvconfig.base_url
api_token = dvconfig.api_token
paths = dvconfig.sample_data
Expand Down Expand Up @@ -45,6 +46,7 @@
resp = api.create_dataset(dataverse, json.dumps(metadata))
print(resp)
dataset_pid = resp.json()['data']['persistentId']
dataset_dbid = resp.json()['data']['id']
files_dir = path.replace(json_file, '') + 'files'
print(files_dir)
if not os.path.isdir(files_dir):
Expand All @@ -59,3 +61,9 @@
# This sleep is here to prevent the dataset from being permanently
# locked because a tabular file was uploaded first.
time.sleep(3)
# Sleep a little more to avoid org.postgresql.util.PSQLException: ERROR: deadlock detected
time.sleep(2)
print('Publishing dataset id ' + str(dataset_dbid))
# TODO: Switch to pyDataverse api.publish_dataset after this issue is fixed: https://github.com/AUSSDA/pyDataverse/issues/24
resp = requests.post(base_url + '/api/datasets/' + str(dataset_dbid) + '/actions/:publish?type=major&key=' + api_token)
print(resp)

0 comments on commit a1b4073

Please sign in to comment.