Skip to content

Commit 6ae0194

Browse files
committed
PR-7501 counting granules and exit condition for prepare loop
1 parent e46bd3d commit 6ae0194

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

ctorm/ctorm/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class CtormConfig:
2424
source_buckets: list
2525
granules_sqs_queue_url: str
2626

27+
# This is the number of granules that will be prepared for test.
28+
granule_goal: int = 2000000
29+
2730
@classmethod
2831
def from_file(
2932
cls,

ctorm/ctorm/prepare.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ class CtormPrepare:
6363

6464
def __init__(self, cfg: CtormConfig):
6565
self.cfg = cfg
66+
self.total_granules = 0
6667

6768
def prepare(self):
68-
goal = 50
69-
while goal > 0: # TODO: replace with while true and an exit condition
69+
while self.total_granules < self.cfg.granule_goal:
7070
# This is the loop that creates a SQS message from multiple objects.
7171
sqs_msg = CtormSqsMessage(self.cfg)
7272
for b in self.cfg.source_buckets:
@@ -86,10 +86,10 @@ def prepare(self):
8686
file = self.process_ummg(ummg, b)
8787
if file:
8888
sqs_msg.add_file(file)
89-
goal -= 1
89+
self.total_granules += 1
9090
b.next_cont_token = page.get("NextContinuationToken")
9191

92-
log.debug("goal: %d", goal)
92+
log.debug("tot granules: %d/%d", self.total_granules, self.cfg.granule_goal)
9393
log.debug("sqs_msg size: %d", len(sqs_msg.to_json()))
9494
log.debug("sqs_msg size OK?: %d", sqs_msg.check_message_size())
9595
if sqs_msg.check_message_size():

0 commit comments

Comments
 (0)