autogen/test/tune/test_stop.py
Chi Wang 75e3454120
notebook test; spark warning message; reproducibility bug; sequential tuning stop condition (#869)
* notebook test

* add ipykernel, remove except

* only create dir if not empty

* Stop sequential tuning when result is None

* fix reproducibility of global search

* save gs seed

* use get to avoid KeyError

* test
2023-01-07 18:39:29 -08:00

26 lines
559 B
Python

from flaml import tune
n_trials = 0
def evaluate_config(config):
global n_trials
n_trials += 1
if n_trials >= 10:
return None
metric = (round(config["x"]) - 85000) ** 2 - config["x"] / config["y"]
return metric
def test_eval_stop():
analysis = tune.run(
evaluate_config,
config={
"x": tune.qloguniform(lower=1, upper=100000, q=1),
"y": tune.qlograndint(lower=2, upper=100000, q=2),
},
num_samples=100,
mode="max",
)
assert len(analysis.trials) == 10