
    bi-                         d Z ddlZddlZddlmZmZmZmZ ddlZddl	m
Z
  ej                  d      Zdeeef   dd	d
efdZdeeeef      de
d
eee   ef   fdZy)z)Utilities for the XGBoost Dask interface.    N)AnyDictOptionalTuple   )Configz[xgboost.dask]local_paramworkerzdistributed.Workerreturnc                    t        |d      r|j                  j                  n|j                  }d}dD ]F  }| j                  |d      | j                  ||      |k7  s,t        j                  d       | |   } n |dk(  s||}|S )zIGet the number of threads from a worker and the user-supplied parameters.stateN)nthreadn_jobsz-Overriding `nthreads` defined in dask worker.r   )hasattrr   nthreadsgetLOGGERinfo)r	   r
   dwnt	n_threadsps        M/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/xgboost/dask/utils.pyget_n_threadsr      s     %,FG$<6<<  &//DI" ??1d#/KOOAt4LPT4TKKGH#AI	
 A~*	    dconfigcoll_cfgc                    dg}d}d}| 8| D ]2  }||vrt        d|       t        j                  d| dt               4 ni } | j	                  dd      }|'|j                  d      r|j                  d      r|d	d
 }|#	 t        j                  j                  |      \  }}|
t               }|j                  9|+|j                  |k7  rt        d| d|j                   d      |j                  }|j                  M|dk7  r<|:|j                  dk7  r+||j                  k7  rt        d| d|j                   d      |j                  }||fS # t         $ r Y w xY w)a  Get the tracker address from the optional user configuration.

    Parameters
    ----------
    dconfig :
        Dask global configuration.

    coll_cfg :
        Collective configuration.

    Returns
    -------
    The IP address along with the port number.

    scheduler_addressNr   zUnknown configuration: zeUse `coll_cfg` instead of the Dask global configuration store for the XGBoost tracker configuration: .[]   z\Conflicting host IP addresses from the dask configuration and the collective configuration: z v.s. zPConflicting ports from the dask configuration and the collective configuration: )
ValueErrorwarningswarnFutureWarningr   
startswithendswithdistributedcommget_address_host_portr   tracker_host_iptracker_port)r   r   valid_confighost_ipportks         r   get_address_from_userr3      s   & ((LGD 		A$ #:1#!>??MM??@cD 		 kk-t4Gw11#67;K;KC;P!B-	',,BB7KMGT 8+8#;#;w#F--4IVH<T<T;UUVX  **(AI %%*-----1F&9N9N8OqR  $$D=3  		s   "E 	EE)__doc__loggingr%   typingr   r   r   r   r*   
collectiver   	getLoggerr   strintr   r3    r   r   <module>r<      s    /   - -  			+	,tCH~ 7K PS Fd38n%F17F
8C=#Fr   