small pbar fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import multiprocessing
|
||||
import sys
|
||||
from collections.abc import Iterable, Iterator
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum, auto
|
||||
@@ -107,12 +106,8 @@ class PositionGetter:
|
||||
self.offset = offset
|
||||
self.busy_at = [False for _ in range(n)]
|
||||
|
||||
@property
|
||||
def max_pos(self) -> int:
|
||||
return max(self.busy_at)
|
||||
|
||||
def book(self) -> int:
|
||||
for pos, busy in enumerate(self.busy_at[: self.remaining]):
|
||||
for pos, busy in enumerate(self.busy_at):
|
||||
if not busy:
|
||||
self.busy_at[pos] = True
|
||||
self.remaining -= 1
|
||||
@@ -129,7 +124,7 @@ class MultibarThread(Thread):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
n_bars: int,
|
||||
n_tasks: int,
|
||||
n_show: int,
|
||||
queue: Queue,
|
||||
default_total: int | float | None = None,
|
||||
@@ -138,9 +133,9 @@ class MultibarThread(Thread):
|
||||
super().__init__()
|
||||
self.queue = queue
|
||||
|
||||
pos_getter = PositionGetter(n_bars, n_show, offset=1)
|
||||
pos_getter = PositionGetter(n_tasks, n_show, offset=1)
|
||||
|
||||
self.sub_pbars = [DelayedTqdm(pos_getter, total=default_total) for _ in range(n_bars)]
|
||||
self.sub_pbars = [DelayedTqdm(pos_getter, total=default_total) for _ in range(n_tasks)]
|
||||
self.main_pbar = tqdm(
|
||||
total=sum((bar.total or 0) for bar in self.sub_pbars),
|
||||
position=0,
|
||||
|
||||
Reference in New Issue
Block a user