diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5e361fd4..4ec5cc4b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,13 @@ Submit4DN Change Log ---------- + +4.1.1 +===== + +* Bug fix for uploading extra_files via spreadsheet + + 4.1.0 ===== diff --git a/pyproject.toml b/pyproject.toml index 5a9bd7cb..5584491f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT" diff --git a/wranglertools/import_data.py b/wranglertools/import_data.py index a92e8b95..2848dbc7 100755 --- a/wranglertools/import_data.py +++ b/wranglertools/import_data.py @@ -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: @@ -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]