
    Гh                         S r SSKrSSKJr  SSKJrJrJr  SSKJ	r	J
r
JrJr  SSKJr   " S S	\5      r\SSSS
SS.S\S\S\\   S\\   S\\   S\S\S\\\\4      4S jj5       rg)z4XGBoost Experimental Federated Learning related API.    N)Thread)AnyDictOptional   )_LIB_check_call_deprecate_positional_argsmake_jcargs)RabitTrackerc                   l    \ rS rSrSr\SSSSS.S\S\S\S	\\	   S
\\	   S\\	   S\SS4S jj5       r
Srg)FederatedTracker   a  Tracker for federated training.

Parameters
----------
n_workers :
    The number of federated workers.

port :
    The port to listen on.

secure :
    Whether this is a secure instance. If True, then the following arguments for SSL
    must be provided.

server_key_path :
    Path to the server private key file.

server_cert_path :
    Path to the server certificate file.

client_cert_path :
    Path to the client certificate file.

N,  )server_key_pathserver_cert_pathclient_cert_pathtimeout	n_workersportsecurer   r   r   r   returnc                    [         R                  " 5       n[        UUSUUUU[        U5      S9n	[	        [
        R                  " U	[         R                  " U5      5      5        Xl        g )N	federated)r   r   dmlc_communicatorfederated_securer   r   r   r   )	ctypesc_void_pr   intr	   r   XGTrackerCreatebyrefhandle)
selfr   r   r   r   r   r   r   r"   argss
             dC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\xgboost/federated.py__init__FederatedTracker.__init__%   s[     ")#+--L	
 	D((v||F/CDE    )r"   )__name__
__module____qualname____firstlineno____doc__r
   r   boolr   strr&   __static_attributes__ r(   r%   r   r      s    2   *.*.*. 
  "# #3- #3-  
  r(   r   Tr   )r   r   r   blockingr   r   r   r   r   r   r2   r   r   c          
      6   SU 0n[        S X#U4 5       5      n[        U UUUUUUS9n	U	R                  5         U(       a  U	R                  5         g[	        U	R                  S9n
SU
l        U
R                  5         UR                  U	R                  5       5        U$ )a`  See :py:class:`~xgboost.federated.FederatedTracker` for more info.

Parameters
----------
blocking :
    Block the server until the training is finished. If set to False, the function
    launches an additional thread and returns the worker arguments. The default is
    True and a higher level framework is responsible for setting worker parameters.

r   c              3   *   #    U  H	  nUS Lv   M     g 7f)Nr1   ).0paths     r%   	<genexpr>'run_federated_server.<locals>.<genexpr>V   s      ID 	DIs   )r   r   r   r   r   r   r   N)targetT)allr   startwait_forr   daemonupdateworker_args)r   r   r   r   r   r2   r   r$   r   trackerthreads              r%   run_federated_serverrB   @   s    * (3D $8HI F '))G MMO7++,FFM
LLNKK##%&Kr(   )r-   r   	threadingr   typingr   r   r   corer   r	   r
   r   r@   r   r   r   r/   r.   rB   r1   r(   r%   <module>rF      s    :   & & L L !2| 2j 
 &*&*&*,,
, c]	,
 sm, sm, , , d38n, ,r(   