Skip to content

Commit d92492f

Browse files
atrisovicpdurbin
andcommitted
add check_dataset_lock
Co-authored-by: Philip Durbin <[email protected]>
1 parent a93f9d5 commit d92492f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

dataverse.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ def parse_arguments():
2222
args = parser.parse_args()
2323
return args
2424

25+
26+
def check_dataset_lock(dataset_dbid):
27+
query_str = '/datasets/' + str(dataset_dbid) + '/locks'
28+
params = {}
29+
resp = api.get_request(query_str, params=params, auth=True)
30+
locks = resp.json()['data']
31+
if (locks):
32+
print('Lock found for dataset id ' + str(dataset_dbid) + '... sleeping...')
33+
time.sleep(2)
34+
check_dataset_lock(dataset_dbid)
35+
36+
2537
if __name__ == '__main__':
2638
args = parse_arguments()
2739
dataverse_server = args.server.strip("/")
@@ -61,7 +73,8 @@ def parse_arguments():
6173
})
6274
resp = api.upload_datafile(
6375
args.doi, join(root,f), df.json())
64-
sleep(0.05) # give some time to upload
76+
check_dataset_lock(
77+
resp['data']['files'][0]['dataFile']['id'])
6578

6679
# publish updated dataset
6780

0 commit comments

Comments
 (0)