boldigger3 2.2.0__tar.gz → 2.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boldigger3
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: A python package to query different databases of boldsystems.org v5!
5
5
  Home-page: https://github.com/DominikBuchner/BOLDigger3
6
6
  Author: Dominik Buchner
@@ -150,7 +150,7 @@ def build_url_params(database: int, operating_mode: int) -> tuple:
150
150
  """Function that generates a base URL and the params for the POST request to the ID engine.
151
151
 
152
152
  Args:
153
- database (int): Between 1 and 7 referring to the database, see readme for details.
153
+ database (int): Between 1 and 8 referring to the database, see readme for details.
154
154
  operating_mode (int): Between 1 and 3 referring to the operating mode, see readme for details
155
155
 
156
156
  Returns:
@@ -211,7 +211,7 @@ def build_download_queue(fasta_dict: dict, database: int, operating_mode: int) -
211
211
  base_url, params = build_url_params(database, operating_mode)
212
212
 
213
213
  # determine the query size from the params
214
- query_size_dict = {0.94: 1000, 0.9: 200, 0.75: 100}
214
+ query_size_dict = {0.94: 100, 0.9: 20, 0.75: 10}
215
215
  query_size = query_size_dict[params["mi"]]
216
216
 
217
217
  # split the fasta dict in query sized chunks
@@ -262,6 +262,7 @@ def build_post_request(BoldIdRequest: object) -> object:
262
262
 
263
263
  # generate the files to send via the id engine
264
264
  files = {"fasta_file": ("submitted.fas", data, "text/plain")}
265
+ backoff_time = 0
265
266
 
266
267
  while True:
267
268
  try:
@@ -275,14 +276,23 @@ def build_post_request(BoldIdRequest: object) -> object:
275
276
 
276
277
  # fetch the result
277
278
  result = json.loads(response.text)
279
+ if "detail" in result.keys():
280
+ tqdm.write(
281
+ f"{datetime.datetime.now().strftime('%H:%M:%S')}: Limit reached. Waiting."
282
+ )
283
+ # wait for the backoff time
284
+ backoff_time += 30
285
+ time.sleep(backoff_time)
286
+ continue
278
287
  break
279
- except (JSONDecodeError, ReadTimeout):
288
+ except (JSONDecodeError, ReadTimeout, KeyError):
280
289
  # user output
281
290
  tqdm.write(
282
- f"{datetime.datetime.now().strftime('%H:%M:%S')}: Building the request failed. Waiting 60 seconds for repeat."
291
+ f"{datetime.datetime.now().strftime('%H:%M:%S')}: Building the request failed. Waiting."
283
292
  )
284
- # wait 60 seconds
285
- time.sleep(60)
293
+ backoff_time += 30
294
+ # wait for the backoff_time
295
+ time.sleep(backoff_time)
286
296
 
287
297
  result_url = f"https://id.boldsystems.org/submission/results/{result['sub_id']}"
288
298
 
@@ -446,7 +456,7 @@ def download_json(
446
456
  now = datetime.datetime.now()
447
457
  # check the timestamp of the key, if it is older than 10 minutes, pop it from the active
448
458
  # queue to fetch it in a later run
449
- if now - active_queue[key].timestamp > datetime.timedelta(minutes=15):
459
+ if now - active_queue[key].timestamp > datetime.timedelta(minutes=30):
450
460
  tqdm.write(
451
461
  f"{datetime.datetime.now().strftime('%H:%M:%S')}: Request ID {key} has timed out. Will be requeued."
452
462
  )
@@ -612,21 +622,26 @@ def main(fasta_path: str, database: int, operating_mode: int) -> None:
612
622
  if download_queue["waiting"] or download_queue["active"]:
613
623
  # as long as there are not 4 active requests in the download queue
614
624
  # move on request from the waiting queue to the active queue
615
- if len(download_queue["active"]) < 4 and download_queue["waiting"]:
625
+ if len(download_queue["active"]) < 10 and download_queue["waiting"]:
616
626
  # retrieve one request from the waiting queue
617
627
  request_id, current_request_object = download_queue[
618
628
  "waiting"
619
629
  ].popitem(last=False)
630
+
631
+ # add this request to the active queue
632
+ download_queue["active"][request_id] = build_post_request(
633
+ current_request_object
634
+ )
635
+
620
636
  tqdm.write(
621
637
  "{}: Request ID {} has been moved to the active downloads.".format(
622
638
  datetime.datetime.now().strftime("%H:%M:%S"),
623
639
  request_id,
624
640
  )
625
641
  )
626
- # add this request to the active queue
627
- download_queue["active"][request_id] = build_post_request(
628
- current_request_object
629
- )
642
+
643
+ # wait for 10 seconds until sending the next request
644
+ time.sleep(30)
630
645
  # check if any of the active queue objects has finished and can be saved and removed
631
646
  else:
632
647
  # check if any of the active downloads has been finished
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boldigger3
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: A python package to query different databases of boldsystems.org v5!
5
5
  Home-page: https://github.com/DominikBuchner/BOLDigger3
6
6
  Author: Dominik Buchner
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="boldigger3",
8
- version="2.2.0",
8
+ version="2.3.0",
9
9
  author="Dominik Buchner",
10
10
  author_email="dominik.buchner@uni-due.de",
11
11
  description="A python package to query different databases of boldsystems.org v5!",
File without changes
File without changes
File without changes