Fix Optuna n_jobs deprecation warning

This commit is contained in:
allegroai 2022-03-06 18:50:17 +02:00
parent 104308d660
commit 8a60a92fac

View File

@ -1,3 +1,4 @@
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from typing import Any, Optional, Sequence
@ -174,8 +175,9 @@ class OptimizerOptuna(SearchStrategy):
sleep_interval=int(self.pool_period_minutes * 60),
config_space=config_space,
)
self._study.optimize(
self._objective.objective, n_trials=self.total_max_jobs, n_jobs=self._num_concurrent_workers)
with ThreadPoolExecutor(max_workers=self._num_concurrent_workers) as executor:
for _ in range(self._num_concurrent_workers):
executor.submit(self._study.optimize, self._objective.objective, n_trials=self.total_max_jobs)
def stop(self):
# type: () -> ()