Skip to content

Commit b772240

Browse files
authored
Merge pull request #798 from runarmod/fix-tqdm-total
Fix: show tqdm total iteration count
2 parents d7a4bb5 + 184a300 commit b772240

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

marker/processors/llm/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ def rewrite_blocks(self, document: Document):
156156
return
157157

158158
pbar = tqdm(
159-
desc=f"{self.__class__.__name__} running", disable=self.disable_tqdm
159+
total=total_blocks,
160+
desc=f"{self.__class__.__name__} running",
161+
disable=self.disable_tqdm
160162
)
161163
with ThreadPoolExecutor(max_workers=self.max_concurrency) as executor:
162164
for future in as_completed(

marker/processors/llm/llm_mathblock.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def rewrite_blocks(self, document: Document):
142142
return
143143

144144
pbar = tqdm(
145-
desc=f"{self.__class__.__name__} running", disable=self.disable_tqdm
145+
total=total_blocks,
146+
desc=f"{self.__class__.__name__} running",
147+
disable=self.disable_tqdm
146148
)
147149
with ThreadPoolExecutor(max_workers=self.max_concurrency) as executor:
148150
for future in as_completed(

marker/processors/llm/llm_table_merge.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ def rewrite_blocks(self, document: Document):
158158
if self.no_merge_tables_across_pages:
159159
logger.info("Skipping table merging across pages due to --no_merge_tables_across_pages flag")
160160
return
161-
162-
pbar = tqdm(desc=f"{self.__class__.__name__} running", disable=self.disable_tqdm)
161+
163162
table_runs = []
164163
table_run = []
165164
prev_block = None
@@ -221,6 +220,17 @@ def rewrite_blocks(self, document: Document):
221220
if table_run:
222221
table_runs.append(table_run)
223222

223+
# Don't show progress if there is nothing to process
224+
total_table_runs = len(table_runs)
225+
if total_table_runs == 0:
226+
return
227+
228+
pbar = tqdm(
229+
total=total_table_runs,
230+
desc=f"{self.__class__.__name__} running",
231+
disable=self.disable_tqdm,
232+
)
233+
224234
with ThreadPoolExecutor(max_workers=self.max_concurrency) as executor:
225235
for future in as_completed([
226236
executor.submit(self.process_rewriting, document, blocks)

0 commit comments

Comments
 (0)