Is there a way to deal with variable sized iterables?
还没有人认领这个 Issue。
评估
调研方向
首先定位 progress_bar 的实现以及 issue 中描述的 self.total = len(gen) if total is None else total 这一行。重现提供的 Timer 示例,然后确定应如何表示大小可变的 iterable 或基于时间的迭代;当进度条能够处理该用例而不假定固定长度时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
The problem is this line:
self.total = len(gen) if total is None else total
That is executed at the beginning. But len(gen) might change throughout the iteration, but progress_bar just assumes it keeps still.
What I really want is to use a timer (so "train for 1 hour" instead of "train for so and so epochs").
import time
class Timer:
def __init__(self, num_seconds):
self.num_seconds = num_seconds
self.i = None
def __len__(self):
if self.i is None: return 1
eps = 1e-7
t = time.time() - self.start
progress = t/num_seconds
return int((num_seconds*self.i)/(progress+eps)) # estimated size. Changes constantly.
def __iter__(self):
self.start = time.time()
self.i, t = 0, 0.0
while t <= self.num_seconds:
t = time.time() - self.start
self.i += 1
yield None
With this class, if you write
for t in Timer(3.0):
# do stuff
it runs for 3 seconds. But it doesn't work with the progress_bar :(
- 主要语言
- Jupyter Notebook
- 星标
- 1.1k
- 派生
- 103
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AnswerDotAI/fastprogress 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 38/100
AnswerDotAI/fastprogress#124 ·
-
难度 4/5 3-5 天 新手友好度 30/100
AnswerDotAI/fastprogress#121 · 2 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 48/100
AnswerDotAI/fastprogress#117 · 4 条评论 · 12 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
AnswerDotAI/fastprogress#111 ·
-
难度 3/5 1-2 天 新手友好度 35/100
AnswerDotAI/fastprogress#107 ·
查看 AnswerDotAI/fastprogress 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
zerocracy/judges-action#2729 ·
维护者通常 8 天内回复
-
agent/scanner bug hive/hosted-available-lke648397-260827-5n31
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
dependencies feature github_actions good first issue
难度 2/5 1-3 小时 新手友好度 62/100
wemake-services/wemake-django-template#3149 ·
维护者通常 1 天内回复
-
`Processing lsp` never exits and leaves orphaned processes可能已有人在做 @overcast302 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
processing/processing4#1578 · 1 条评论 ·
-
autoInject recall silently drops memory injection on long / non-Latin prompts (HTTP 400 Query too long)可能已有人在做 @Epsilon006 今天认领。 未关闭integration:coding-agents
难度 2/5 1-3 小时 新手友好度 72/100
vectorize-io/hindsight#5476 · 1 条评论 ·
维护者通常 1 天内回复