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

Ajs fix ecred bug #178

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>"]
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
Loading