tqdm progressbar breaks with MongoTrials
Author: tom-programmingCreated Jul 23, 2019Updated Jul 24, 2026
Hello,
I noticed that the progressbar when using MongoTrials is almost useless as it advances at one iteration a second regardless of the actual progress and then it makes as much (pseudo)iterations as it takes to complete the task.
MWE:
hyperop_mongo.py
from hyperopt import fmin, tpe, hp, Trials
from hyperopt.mongoexp import MongoTrials
import hyperopt_to_optim
trials = MongoTrials('mongo://localhost:1234/foo_db/jobs', exp_key='exp13')
best = fmin(hyperopt_to_optim.obj, hp.uniform('x', -2, 2), trials=trials, algo=tpe.suggest, max_evals=20)hyperopt_to_optim.py
import time
import math
def obj(x):
time.sleep(3)
return math.sin(x)output:
77it [01:17, 1.02s/it, best loss: -0.9947311913502885]
(instead of 20 iterations, also there might be another issue.. why does it take so much more than 60 seconds? )
to run you need to add the directory containing hyperopt_to_optim.py to PYTHONPATH for hyperopt-mongo-worker
Source: hyperopt/hyperopt