optuna.storages.run_grpc_proxy_server

optuna.storages.run_grpc_proxy_server(storage, *, host='localhost', port=13000, thread_pool=None)[source]

Run a gRPC server for the given storage URL, host, and port.

Example

Run this server with the following way:

from optuna.storages import run_grpc_proxy_server
from optuna.storages import get_storage

storage = get_storage("mysql+pymysql://<user>:<pass>@<host>/<dbname>[?<options>]")
run_grpc_proxy_server(storage, host="localhost", port=13000)

Please refer to the client class GrpcStorageProxy for the client usage. Please use get_storage() instead of RDBStorage since RDBStorage by itself does not use cache in process and it may cause significant slowdown.

Parameters:
  • storage (BaseStorage) – A storage object to proxy.

  • host (str) – Hostname to listen on.

  • port (int) – Port to listen on.

  • thread_pool (ThreadPoolExecutor | None) – Thread pool to use for the server. If None, a default thread pool with 10 workers will be used.

Return type:

None

Note

Added in v4.2.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v4.2.0.