jenkins - 如何让 tqdm 与 jenkins 配合良好?

标签 jenkins tqdm

tqdm进度条,但是当我在 jenkins 上使用它时,我不断收到一堆奇怪的工件,并且 stdout 中出现过多的膨胀(具体来说,[A 无处不在)。 tqdm 中是否有 secret 模式可以使其与 jenkins 很好地配合?无缝检测 Jenkins 等非交互式 shell 的奖励积分。这是我的典型输出:

label: 0it [00:00, ?it/s][A
[A
 16%|#6        | 5378/33302 [36:28<2:30:49,  3.09it/s]
[A
 16%|#6        | 5379/33302 [36:29<2:36:46,  2.97it/s]
[A
...

最佳答案

我会选择这样的东西:

from tqdm import tqdm
import os

# try this
for i in tqdm(..., disable=None):
    ...

# alternative if the above doesn't work
for i in tqdm(..., disable=os.environ.get("JENKINS_HOME")):
    ...

# or even...
for i in tqdm(..., disable=os.environ.get("JENKINS_HOME") is not None):
    ...

请注意,disable=None 应自动检查诸如 sys.stdout.isatty() 之类的内容。

不幸的是,对于 Jenkins 不支持 CR (\r)(tqdm 的基本要求),我们无能为力。

来自https://tqdm.github.io/ :

tqdm does not require any dependencies (not even curses!), just Python and an environment supporting carriage return \r and line feed \n control characters.

关于jenkins - 如何让 tqdm 与 jenkins 配合良好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46243363/

相关文章:

node.js - Docker Jenkins Pipeline 安装全局 NPM 包

Python:如何在嵌套循环中用下一个替换 tqdm 进度条?

java - 如何设置新的 Jenkins slave

jenkins - 如何使作业作为 "flyweight"作业执行

tqdm_notebook 描述被截断

jupyter-notebook - 无法显示类型为 HBox 的 Jupyter Widget;小部件 JavaScript 库丢失?

python - tqdm progressbar 和 zip 内置不能一起工作

python - 在线下载数据时如何使用python中的 `tqdm`显示进度?

Jenkins 中的 Maven 包装器

git - 如何通过 scm 更改触发 jenkins 管道作业?