如何从模块外部禁用TQDM进度条。

发布于 2025-02-07 19:29:08 字数 136 浏览 1 评论 0原文

我正在使用神经先知模块以预测时间表。在使用它时,由于某些原因,我得到了进度条的音调。其中一些我能够禁用,但是TQDM产生的进度栏仍在来。该TQDM用于神经prophet模块内部,因此无法更改。前任。 disable = true,离开= false将行不通。

I am working with neural prophet module for timeseries forecasting. While using it I got tones of progress bars which I don't want due to some reasons. Some of them I was able to disable but the progress bar generated from tqdm is still coming. This tqdm is used inside neuralprophet module so can't change it. Ex. disable=True, leave=False will not work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2025-02-14 19:29:09

您可以用代码顶部的tqdm类覆盖tqdm class,它没有做任何事情...

import tqdm

def tqdm_replacement(iterable_object,*args,**kwargs):
    return iterable_object
tqdm_copy = tqdm.tqdm # store it if you want to use it later
tqdm.tqdm = tqdm_replacement

# import any other module you need after this line

然后作为示例(下一个代码可以在上述代码之后的任何位置),

from tqdm import tqdm

for i in tqdm(range(5)):
    print(i)

输出不包含进度栏,而且,如果您想在代码中使用进度栏,则可以自己使用tqdm_copy对象。
如果进度栏仍然存在,则还应该为TQDM内的其他迭代器做同样的操作。

请注意,如果您在导入使用它来保证它可以正常工作的任何模块之前,在将代码运行以禁用TQDM,最好是最好的。

you can overwrite the tqdm class in the top of your code with something that does nothing...

import tqdm

def tqdm_replacement(iterable_object,*args,**kwargs):
    return iterable_object
tqdm_copy = tqdm.tqdm # store it if you want to use it later
tqdm.tqdm = tqdm_replacement

# import any other module you need after this line

then as an example (this next code can be anywhere after the above code)

from tqdm import tqdm

for i in tqdm(range(5)):
    print(i)

the output contains no progress bar, and if you want to use a progress bar in your code then you can use the tqdm_copy object yourself.
you should also do the same for other iterators inside tqdm if the progress bar is still there.

note that it is best if you run the code to disable tqdm before you import any of the modules that use it to guarantee this will work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文