Skip to content

Commit

Permalink
viz pbar
Browse files Browse the repository at this point in the history
  • Loading branch information
soldni committed May 24, 2024
1 parent e42f9fc commit be6c984
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/dolma/core/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def _run_all(

with PoolWithDebug(processes=num_processes, debug=self.debug) as pool:
pbar_queue: QueueType = (manager := get_manager(pool)).Queue()
(pbar := self.PROGRESS_BAR_CLS(pbar_queue)).start()
(pbar := self.PROGRESS_BAR_CLS(pbar_queue, thread=True)).start()

process_single_fn = partial(self.process_single, queue=pbar_queue)
results = []
Expand Down
7 changes: 4 additions & 3 deletions python/dolma/core/progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, queue: QueueType, min_step: int = 1, min_time: float = 1e-1,
"""
self._logger = get_logger(self.__class__.__name__, "warn")
self._queue = queue
self._last_update_delta_time = 0
self._last_update_time = 0
self._last_update_delta_step = 0

self._update_every_seconds = min_time
Expand Down Expand Up @@ -196,6 +196,7 @@ def _update(self):

# reset the steps
self._last_update_delta_step = 0
self._last_update_time = time.time()

# reset the steps
for k in self.fields():
Expand All @@ -208,6 +209,7 @@ def update(self):
if self._update_every_steps > self._last_update_delta_step:
return

time_before_update = self._last_update_time
self._update()

# check if we wanna update frequency based on steps
Expand All @@ -216,8 +218,7 @@ def update(self):
return

# check if we wanna update frequency based on time
self._last_update_delta_time = -(time.time() - self._last_update_delta_time)
if self._last_update_delta_time < self._update_every_seconds:
if (self._last_update_time - time_before_update) < self._update_every_seconds:
self._update_every_steps *= 2
return

Expand Down

0 comments on commit be6c984

Please sign in to comment.