Skip to content

Commit

Permalink
Merge pull request #178 from 4dn-dcic/ajs_fix_ecred_bug
Browse files Browse the repository at this point in the history
Ajs fix ecred bug
  • Loading branch information
aschroed authored Aug 19, 2024
2 parents d80a7db + cad104b commit 1799871
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Submit4DN
Change Log
----------


4.1.1
=====

* Bug fix for uploading extra_files via spreadsheet


4.1.0
=====

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Submit4DN"
version = "4.1.0"
version = "4.1.1"
description = "Utility package for submitting data to the 4DN Data Portal"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down
12 changes: 8 additions & 4 deletions wranglertools/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,10 @@ def update_item(verb, file_to_upload, post_json, filename_to_post, extrafiles, c
pp.Path(filename_to_post).unlink()
if extrafiles:
extcreds = e['@graph'][0].get('extra_file_creds')
if not extcreds:
time.sleep(5)
if not extcreds or (
datetime.datetime.strptime(extcreds.get('upload_credentials').get('Expiration'), "%Y-%m-%d %H:%M:%S%z")
.replace(tzinfo=None) < datetime.datetime.now()
):
extcreds = get_upload_creds(e['@graph'][0]['accession'], connection, extfilecreds=True)
for fformat, filepath in extrafiles.items():
try:
Expand Down Expand Up @@ -1434,10 +1436,12 @@ def user_workflow_reader(workbook, sheet, connection):

def get_upload_creds(file_id, connection, extfilecreds=False): # pragma: no cover
creds2return = 'upload_credentials'
url = f"{file_id}/upload/"
url = f"{file_id}/upload/?datastore=database"
if extfilecreds:
creds2return = 'extra_files_creds'
req = ff_utils.authorized_request(f"{connection.key.get('server')}/{url}", auth=ff_utils.get_authentication_with_server(connection.key)).json()
req = ff_utils.authorized_request(
f"{connection.key.get('server')}/{url}", auth=ff_utils.get_authentication_with_server(connection.key)
).json()
else:
req = ff_utils.post_metadata({}, url, key=connection.key)
return req['@graph'][0][creds2return]
Expand Down

0 comments on commit 1799871

Please sign in to comment.