ó
    tñ:i»  ã                   ó‚   • S r SSKrSSKrSSKrSSKJrJr  SSKJrJ	r	J
r
  SSKJrJrJrJr  S\S\4S	 jr " S
 S5      rg)zTracker for XGBoost collective.é    N)ÚIntEnumÚunique)ÚDictÚOptionalÚUnioné   )Ú_LIBÚ_check_callÚ_deprecate_positional_argsÚmake_jcargsÚaddrÚreturnc                 ó<   • [         R                  " U S5      S   S   $ )z Get network family from address.Nr   )ÚsocketÚgetaddrinfo)r   s    ÚR/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/xgboost/tracker.pyÚ
get_familyr      s   € ä×Ò˜d DÓ)¨!Ñ,¨QÑ/Ð/ó    c                   óÖ   • \ rS rSrSr\ " S S\5      5       r\ SSSS.S\	S	\
\   S
\	S\S\	SS4S jjj5       rSS jrSS jrSS jrSS\
\	   SS4S jjrS\\\\\	4   4   4S jrSrg)ÚRabitTrackeré   aÁ  Tracker for the collective used in XGBoost, acting as a coordinator between
workers.

Parameters
----------

n_workers:

    The total number of workers in the communication group.

host_ip:

    The IP address of the tracker node. XGBoost can try to guess one by probing with
    sockets. But it's best to explicitly pass an address.

port:

    The port this tracker should listen to. XGBoost can query an available port from
    the OS, this configuration is useful for restricted network environments.

sortby:

    How to sort the workers for rank assignment. The default is host, but users can
    set the `DMLC_TASK_ID` via arguments of :py:meth:`~xgboost.collective.init` and
    obtain deterministic rank assignment through sorting by task name. Available
    options are:

      - host
      - task

timeout :

    Timeout for constructing (bootstrap) and shutting down the communication group,
    doesn't apply to communication when the group is up and running.

    The timeout value should take the time of data loading and pre-processing into
    account, due to potential lazy execution. By default the Tracker doesn't have
    any timeout to avoid pre-mature aborting.

    The :py:meth:`.wait_for` method has a different timeout parameter that can stop
    the tracker even if the tracker is still being used. A value error is raised
    when timeout is reached.

Examples
--------

.. code-block:: python

    from xgboost.tracker import RabitTracker
    from xgboost import collective as coll

    tracker = RabitTracker(host_ip="127.0.0.1", n_workers=2)
    tracker.start()

    with coll.CommunicatorContext(**tracker.worker_args()):
        ret = coll.broadcast("msg", 0)
        assert str(ret) == "msg"

c                   ó   • \ rS rSrSrSrSrg)ÚRabitTracker._SortByéN   r   r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚHOSTÚTASKÚ__static_attributes__r   r   r   Ú_SortByr   N   s   † àˆØ‹r   r#   r   Úhost)ÚsortbyÚtimeoutÚ	n_workersÚhost_ipÚportr%   r&   r   Nc          
      ón  • [         R                  " 5       nUS;  a  [        S5      eUb  [        U5        [	        UUUSUS:X  a  U R
                  R                  OU R
                  R                  [        U5      S9n[        [        R                  " U[         R                  " U5      5      5        X`l        g )N)r$   Útaskz-Expecting either 'host' or 'task' for sortby.Úrabitr$   )r$   r'   r)   Údmlc_communicatorr%   r&   )ÚctypesÚc_void_pÚ
ValueErrorr   r   r#   r    r!   Úintr
   r	   ÚXGTrackerCreateÚbyrefÚhandle)Úselfr'   r(   r)   r%   r&   r4   Úargss           r   Ú__init__ÚRabitTracker.__init__S   s•   € ô —’Ó"ˆØÐ)Ó)ÜÐLÓMÐMØÑÜ�wÔÜØØØØ%Ø(.°&Ó(8�4—<‘<×$Ò$¸d¿l¹l×>OÑ>OÜ˜“Lñ
ˆô 	”D×(Ò(¨¬v¯|ª|¸FÓ/CÓDÔEØ�r   c                 ó‚   • [        U S5      (       a.  U R                  nU ?[        [        R                  " U5      5        gg)zInternal function for testing.r4   N)Úhasattrr4   r
   r	   ÚXGTrackerFree)r5   r4   s     r   ÚfreeÚRabitTracker.freen   s5   € ä�4˜×"Ñ"Ø—[‘[ˆFØ�Üœ×*Ò*¨6Ó2Õ3ð #r   c                 ó$   • U R                  5         g ©N)r<   ©r5   s    r   Ú__del__ÚRabitTracker.__del__u   s   € Ø�	‰	�r   c                 óh   • [        [        R                  " U R                  [	        5       5      5        g)zœStart the tracker. Once started, the client still need to call the
:py:meth:`wait_for` method in order to wait for it to finish (think of it as a
thread).

N)r
   r	   ÚXGTrackerRunr4   r   r@   s    r   ÚstartÚRabitTracker.startx   s   € ô 	”D×%Ò% d§k¡k´;³=ÓAÕBr   c           	      óf   • [        [        R                  " U R                  [	        US95      5        g)zÖWait for the tracker to finish all the work and shutdown. When timeout is
reached, a value error is raised. By default we don't have timeout since we
don't know how long it takes for the model to finish training.

)r&   N)r
   r	   ÚXGTrackerWaitForr4   r   )r5   r&   s     r   Úwait_forÚRabitTracker.wait_for€   s"   € ô 	”D×)Ò)¨$¯+©+´{È7Ñ7SÓTÕUr   c                 ó
  • [         R                  " 5       n[        [        R                  " U R
                  [         R                  " U5      5      5        UR                  c   e[        R                  " UR                  5      nU$ )zGet arguments for workers.)
r.   Úc_char_pr
   r	   ÚXGTrackerWorkerArgsr4   r3   ÚvalueÚjsonÚloads)r5   Úc_envÚenvs      r   Úworker_argsÚRabitTracker.worker_argsˆ   sW   € ä—’Ó!ˆÜ”D×,Ò,¨T¯[©[¼&¿,º,ÀuÓ:MÓNÔOØ�{‰{Ñ&Ð&Ð&Ü�jŠj˜Ÿ™Ó%ˆØˆ
r   )r4   )r   )r   Nr?   )r   r   r   r   Ú__doc__r   r   r#   r   r1   r   Ústrr7   r<   rA   rE   rI   r   r   rS   r"   r   r   r   r   r      sÏ   † ñ:ðx ô�'ó ó ðð  ð
 ð	ð Øòàðð ˜#‘ðð ð	ð ðð ðð 
õó  ðô44ôôCñV ¨¡ð V¸õ Vð˜T # u¨S°#¨X¡Ð"6Ñ7÷ r   r   )rU   r.   rO   r   Úenumr   r   Útypingr   r   r   Úcorer	   r
   r   r   rV   r1   r   r   r   r   r   Ú<module>rZ      s?   ðÙ %ã Û Û ß  ß (Ñ (ç LÓ Lð0�Sð 0˜Sô 0÷
}ò }r   