MCPcopy
hub / github.com/hyperopt/hyperopt / test_trial_attachments

Function test_trial_attachments

hyperopt/tests/integration/test_mongoexp.py:418–447  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

416
417
418def test_trial_attachments():
419
420 exp_key = "A"
421 with TempMongo() as tm:
422 mj = tm.mongo_jobs("foo")
423 trials = MongoTrials(tm.connection_string("foo"), exp_key=exp_key)
424
425 space = hp.uniform("x", -10, 10)
426 max_evals = 3
427 fmin_thread = threading.Thread(
428 target=fmin_thread_fn, args=(space, trials, max_evals)
429 )
430 fmin_thread.start()
431
432 mw = MongoWorker(mj=mj, logfilename=None, workdir="mongoexp_test_dir")
433 n_jobs = max_evals
434 while n_jobs:
435 try:
436 mw.run_one("hostname", 10.0, erase_created_workdir=True)
437 print("worker: ran job")
438 except Exception as exc:
439 print(f"worker: encountered error : {str(exc)}")
440 traceback.print_exc()
441 n_jobs -= 1
442 fmin_thread.join()
443 all_trials = MongoTrials(tm.connection_string("foo"))
444
445 assert len(all_trials) == max_evals
446 assert trials.count_by_state_synced(JOB_STATE_DONE) == max_evals
447 assert trials.count_by_state_unsynced(JOB_STATE_DONE) == max_evals
448
449
450class FakeOptions:

Callers

nothing calls this directly

Calls 8

run_oneMethod · 0.95
MongoTrialsClass · 0.90
MongoWorkerClass · 0.90
TempMongoClass · 0.85
mongo_jobsMethod · 0.80
connection_stringMethod · 0.80
count_by_state_syncedMethod · 0.80

Tested by

no test coverage detected