Skip to content

Commit

Permalink
Add request headers for API calls + bump version (#126)
Browse files Browse the repository at this point in the history
* Add request headers for API calls

* Fix linting error

* Add section for 0.7.1

Co-authored-by: Matthew Gopez <matthew.gopez@phac-aspc.gc.ca>
  • Loading branch information
mgopez and Matthew Gopez authored Jan 10, 2022
1 parent 821c49d commit 557f0f1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changes
=======

Beta 0.7.1
----------
Bug fixes:
* Added User-Agent, Accept-Encoding, and Connection headers to API requests which should fix intermittent 10054 errors.

Beta 0.7.0
----------
Changes:
Expand Down
2 changes: 1 addition & 1 deletion iridauploader/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION_NUMBER = "0.7.0"
VERSION_NUMBER = "0.7.1"
22 changes: 16 additions & 6 deletions iridauploader/api/api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
# 20 minute minimum timeout
TIMEOUT_MINIMUM = 1200

SESSION_HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.1.2222.33 Safari/537.36",
"Accept-Encoding": "*",
"Connection": "keep-alive"
}


class ApiCalls(object):

Expand Down Expand Up @@ -611,7 +617,8 @@ def send_project(self, project, clear_cache=True):
json_obj = json.dumps(project.get_uploadable_dict())
headers = {
"headers": {
"Content-Type": "application/json"
"Content-Type": "application/json",
**SESSION_HEADERS
}
}

Expand Down Expand Up @@ -653,7 +660,8 @@ def send_sample(self, sample, project_id):

headers = {
"headers": {
"Content-Type": "application/json"
"Content-Type": "application/json",
**SESSION_HEADERS
}
}

Expand Down Expand Up @@ -729,7 +737,7 @@ def send_sequence_files(self, sequence_file, sample_name, project_id, upload_id,
# Get the data encoder
data_pkg = self._get_sequence_data_pkg(sequence_file, upload_id)
# Generate headers from the data encoder
headers_pkg = {'Content-Type': data_pkg.content_type}
headers_pkg = {'Content-Type': data_pkg.content_type, **SESSION_HEADERS}

logging.debug("Sending files to [{}]".format(url))
logging.debug("headers: " + str(headers_pkg))
Expand Down Expand Up @@ -787,7 +795,7 @@ def send_metadata(self, metadata, sample_id):

json_obj = json.dumps(metadata.get_uploadable_dict())

headers_pkg = {'Content-Type': 'application/json'}
headers_pkg = {'Content-Type': 'application/json', **SESSION_HEADERS}

response = self._session.put(url, data=json_obj, headers=headers_pkg)

Expand Down Expand Up @@ -957,7 +965,8 @@ def create_seq_run(self, metadata, sequencing_run_type):

headers = {
"headers": {
"Content-Type": "application/json"
"Content-Type": "application/json",
**SESSION_HEADERS
}
}

Expand Down Expand Up @@ -1079,7 +1088,8 @@ def _set_seq_run_upload_status(self, identifier, status):
})
headers = {
"headers": {
"Content-Type": "application/json"
"Content-Type": "application/json",
**SESSION_HEADERS
}
}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name='iridauploader',
version='0.7.0',
version='0.7.1',
description='IRIDA uploader: upload NGS data to IRIDA system',
url='https://github.com/phac-nml/irida-uploader',
author='Jeffrey Thiessen',
Expand Down
2 changes: 1 addition & 1 deletion windows-installer.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Application]
name=IRIDA Uploader GUI
version=0.7.0
version=0.7.1
entry_point=iridauploader.gui.gui:main
icon=iridauploader/gui/images/icon.ico
# Uncomment this to have a console show alongside the application
Expand Down

0 comments on commit 557f0f1

Please sign in to comment.