Skip to content

Commit e3f3a30

Browse files
authored
Request patches (#8)
* Dependency update * let requests properly encode params * Break on too many errors * flake edits
1 parent a20ebec commit e3f3a30

File tree

2 files changed

+50
-43
lines changed

2 files changed

+50
-43
lines changed

isamples_export_client/export_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __init__(self, query: str,
6868
refresh_date: Optional[str] = None,
6969
session: Session = requests.session(),
7070
sleep_time: float = 5):
71+
self._max_errors = 3 # Max number of errors in retrieval loop
7172
self._query = query
7273
self._destination_directory = destination_directory
7374
self._jwt = jwt
@@ -130,8 +131,9 @@ def create(self) -> str:
130131
if self._refresh_date is not None:
131132
query = self._query_with_timestamp()
132133

133-
create_url = f"{self._export_server_url}create?q={query}&export_format={self._format}"
134-
response = self._rsession.get(create_url, headers=self._authentication_headers())
134+
params = {"q": query, "export_format": self._format}
135+
create_url = f"{self._export_server_url}create"
136+
response = self._rsession.get(create_url, headers=self._authentication_headers(), params=params)
135137
if _is_expected_response_code(response):
136138
json = response.json()
137139
return json.get("uuid")
@@ -312,6 +314,7 @@ def perform_full_download(self):
312314
tstarted = datetime.datetime.now()
313315
uuid = self.create()
314316
logging.info(f"Contacted the export service, created export job with uuid {uuid}")
317+
error_count = 0
315318
while True:
316319
try:
317320
status_json = self.status(uuid)
@@ -344,3 +347,7 @@ def perform_full_download(self):
344347
logging.error("An error occurred:", e)
345348
# Sleep for a short time before retrying after an error
346349
time.sleep(self._sleep_time)
350+
error_count += 1
351+
if error_count > self._max_errors:
352+
logging.error("Maximum number of errors exceeded (%s/%s).", error_count, self._max_errors)
353+
break

poetry.lock

Lines changed: 41 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)