
    -ji                    @   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  \(       a  S SKrS S	KJr  S S
KJr  O\" S5      r\" S5      r\" S5      r\R(                  " \5      rSr S         SS jjr\	" S5      SSSS.         SS jj5       rg)    )annotations)ThreadPoolExecutor)TYPE_CHECKING)logging)experimental_func)_LazyImport)BaseStorageN)servicer)api_pb2_grpcgrpczoptuna.storages._grpc.servicerz1optuna.storages._grpc.auto_generated.api_pb2_grpcz%Y-%m-%d %H:%M:%S.%fc                    [         R                  " U=(       d	    [        SS95      n[        R                  " [
        R                  " U 5      U5        UR                  U SU 35        U$ )N
   )max_workers:)r   serverr   r   $add_StorageServiceServicer_to_servergrpc_servicerOptunaStorageProxyServiceadd_insecure_portstoragehostportthread_poolr   s        V/home/james-whalen/.local/lib/python3.13/site-packages/optuna/storages/_grpc/server.pymake_serverr      s[     [[J(:r(JKF55//8& vQtf-.M    z4.2.0	localhosti2  )r   r   r   c                   [        XX#5      nUR                  5         [        R                  SU SU 35        [        R                  S5        UR	                  5         g)a  Run a gRPC server for the given storage URL, host, and port.

Example:

    Run this server with the following way:

    .. code::

        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 :class:`~optuna.storages.GrpcStorageProxy` for
    the client usage. Please use :func:`~optuna.storages.get_storage` instead of
    :class:`~optuna.storages.RDBStorage` since ``RDBStorage`` by itself does not use cache in
    process and it may cause significant slowdown.

Args:
    storage: A storage object to proxy.
    host: Hostname to listen on.
    port: Port to listen on.
    thread_pool:
        Thread pool to use for the server. If :obj:`None`, a default thread pool
        with 10 workers will be used.

.. warning::

    Currently, gRPC storage proxy does not support the
    :class:`~optuna.storages.JournalStorage`. This issue is tracked in
    https://github.com/optuna/optuna/issues/6084. Please use
    :class:`~optuna.storages.RDBStorage` instead.
zServer started at r   zListening...N)r   start_loggerinfowait_for_terminationr   s        r   run_grpc_proxy_serverr$   &   sL    T :F
LLNLL%dV1TF34LL 
!r   )N)
r   r	   r   strr   intr   ThreadPoolExecutor | Nonereturnzgrpc.Server)
r   r	   r   r%   r   r&   r   r'   r(   None)
__future__r   concurrent.futuresr   typingr   optunar   optuna._experimentalr   optuna._importsr   optuna.storagesr	   r   optuna.storages._grpcr
   r   $optuna.storages._grpc.auto_generatedr   
get_logger__name__r!   DATETIME_FORMATr   r$    r   r   <module>r7      s    " 1    2 ' ' ?AvD @AMRSL 

X
&( Z^ #+.=V 7 -1-"-" -" 	-"
 +-" 
-" -"r   