Skip to content

Commit

Permalink
update stage meta class - wait logic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
saurbhc committed Nov 14, 2023
1 parent 0f25d56 commit 38decdc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions darwin/future/meta/objects/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,21 @@ def check_all_items_complete(
max_attempts (int, optional): Max number of attempts. Defaults to 5.
wait_time (float, optional): Wait time between attempts. Defaults to 0.5.
"""
completed = []
for attempt in range(1, wait_max_attempts + 1):
# check if all items are complete
for item_id in item_ids:
for item_id in item_ids[:]:
if get_item(self.client, slug, item_id).processing_status != "complete":
# if not complete, wait and try again with the in-complete items
time.sleep(wait_time * attempt)
item_ids = [i for i in item_ids if i not in completed]
break
completed.append(item_id)
item_ids.remove(item_id)
else:
# if all items are complete, return.
return True
# if not complete, wait
time.sleep(wait_time * attempt)
else:
# if max attempts reached, raise error
raise MaxRetriesError(
f"Max attempts reached. {len(completed)} items completed out of {len(item_ids)} items."
f"Max attempts reached. {len(item_ids)} items pending completion check."
)

def move_attached_files_to_stage(
Expand Down

0 comments on commit 38decdc

Please sign in to comment.