
    &`ijV                         d dl Z d dlZd dlZd dlmZmZmZ d dlmc m	Z	 d dl
mZ d dlmZ  e j        e          Z G d d          ZdS )    N)DictListOptional)ResourceIsolationConfig)get_ray_client_dependency_errorc            l       v   e Zd ZdZddddddddddddddddddddddddej        ej        ddddddej        ej        ej	        ddddddddddddddddddddf7de
e         de
e         de
e         de
e         d	e
eeef                  d
e
eeef                  de
e         de
e         de
e         de
ee                  de
e         dede
e         de
e         de
e         de
e         de
e         de
ee                  de
e         de
e         de
ee                  de
e         de
e         de
e         de
e         de
e         de
e         d e
e         d!e
e         d"e
e         d#e
e         d$e
e         d%e
e         d&e
e         d'e
e         d(e
e         d)e
e         d*e
e         d+e
e         d,e
e         d-e
e         d.ed/e
eeef                  d0e
e         d1e
e         d2e
e         d3e
e         d4e
eeef                  d5e
e         d6e
e         d7e
e         d8e
e         d9e
e         fjd:Zd; Zd< Zd= Zd> Zd? ZdS )@	RayParamsa  A class used to store the parameters used by Ray.

    Attributes:
        redis_address: The address of the Redis server to connect to. If
            this address is not provided, then this command will start Redis, a
            raylet, a plasma store, a plasma manager, and some workers.
            It will also kill these processes when Python exits.
        redis_port: The port that the primary Redis shard should listen
            to. If None, then it will fall back to
            ray._private.ray_constants.DEFAULT_PORT, or a random port if the default is
            not available.
        redis_shard_ports: A list of the ports to use for the non-primary Redis
            shards. If None, then it will fall back to the ports right after
            redis_port, or random ports if those are not available.
        num_cpus: Number of CPUs to configure the raylet with.
        num_gpus: Number of GPUs to configure the raylet with.
        resources: A dictionary mapping the name of a resource to the quantity
            of that resource available.
        labels: The key-value labels of the node.
        memory: Total available memory for workers requesting memory.
        object_store_memory: The amount of memory (in bytes) to start the
            object store with.
        object_manager_port int: The port to use for the object manager.
        node_manager_port: The port to use for the node manager.
        gcs_server_port: The port to use for the GCS server.
        node_ip_address: The IP address of the node that we are on.
        min_worker_port: The lowest port number that workers will bind
            on. If not set or set to 0, random ports will be chosen.
        max_worker_port: The highest port number that workers will bind
            on. If set, min_worker_port must also be set.
        worker_port_list: An explicit list of ports to be used for
            workers (comma-separated). Overrides min_worker_port and
            max_worker_port.
        ray_client_server_port: The port number the ray client server
            will bind on. If not set, the ray client server will not
            be started.
        redirect_output: True if stdout and stderr for non-worker
            processes should be redirected to files and false otherwise.
        external_addresses: The address of external Redis server to
            connect to, in format of "ip1:port1,ip2:port2,...".  If this
            address is provided, then ray won't start Redis instances in the
            head node but use external Redis server(s) instead.
        num_redis_shards: The number of Redis shards to start in addition to
            the primary Redis shard.
        redis_max_clients: If provided, attempt to configure Redis with this
            maxclients number.
        redis_username: Prevents external clients without the username
            from connecting to Redis if provided.
        redis_password: Prevents external clients without the password
            from connecting to Redis if provided.
        plasma_directory: A directory where the Plasma memory mapped files will
            be created.
        object_spilling_directory: The path to spill objects to. The same path will
            be used as the object store fallback directory as well.
        worker_path: The path of the source code that will be run by the
            worker.
        setup_worker_path: The path of the Python file that will set up
            the environment for the worker process.
        huge_pages: Boolean flag indicating whether to start the Object
            Store with hugetlbfs support. Requires plasma_directory.
        include_dashboard: Boolean flag indicating whether to start the web
            UI, which displays the status of the Ray cluster. If this value is
            None, then the UI will be started if the relevant dependencies are
            present.
        dashboard_host: The host to bind the web UI server to. Can either be
            localhost (127.0.0.1) or 0.0.0.0 (available from all interfaces).
            By default, this is set to localhost to prevent access from
            external machines.
        dashboard_port: The port to bind the dashboard server to.
            Defaults to 8265.
        dashboard_agent_listen_port: The port for dashboard agents to listen on
            for HTTP requests.
            Defaults to 52365.
        runtime_env_agent_port: The port at which the runtime env agent
            listens to for HTTP.
            Defaults to random available port.
        plasma_store_socket_name: If provided, it specifies the socket
            name used by the plasma store.
        raylet_socket_name: If provided, it specifies the socket path
            used by the raylet process.
        temp_dir: If provided, it will specify the root temporary
            directory for the Ray process. Must be an absolute path.
        runtime_env_dir_name: If provided, specifies the directory that
            will be created in the session dir to hold runtime_env files.
        include_log_monitor: If True, then start a log monitor to
            monitor the log files for all processes on this node and push their
            contents to Redis.
        autoscaling_config: path to autoscaling config file.
        metrics_agent_port: The port to bind metrics agent.
        metrics_export_port: The port at which metrics are exposed
            through a Prometheus endpoint.
        no_monitor: If True, the ray autoscaler monitor for this cluster
            will not be started.
        _system_config: Configuration for overriding RayConfig
            defaults. Used to set system configuration and for experimental Ray
            core feature flags.
        enable_object_reconstruction: Enable plasma reconstruction on
            failure.
        ray_debugger_external: If true, make the Ray debugger for a
            worker available externally to the node it is running on. This will
            bind on 0.0.0.0 instead of localhost.
        env_vars: Override environment variables for the raylet.
        session_name: The current Ray session name.
        webui: The url of the UI.
        cluster_id: The cluster ID in hex string.
        resource_isolation_config: settings for cgroupv2 based isolation of ray
            system processes (defaults to no isolation if config not provided)
    Nr   Fredis_addressgcs_addressnum_cpusnum_gpus	resourceslabelsmemoryobject_store_memory
redis_portredis_shard_portsobject_manager_portnode_manager_portgcs_server_portnode_ip_address	node_namemin_worker_portmax_worker_portworker_port_listray_client_server_portredirect_outputexternal_addressesnum_redis_shardsredis_max_clientsredis_usernameredis_passwordplasma_directoryobject_spilling_directoryworker_pathsetup_worker_path
huge_pagesinclude_dashboarddashboard_hostdashboard_portdashboard_agent_listen_portruntime_env_agent_portplasma_store_socket_nameraylet_socket_nametemp_dirruntime_env_dir_nameinclude_log_monitorautoscaling_configray_debugger_external_system_configenable_object_reconstructionmetrics_agent_portmetrics_export_port
no_monitorenv_varssession_namewebui
cluster_idnode_idresource_isolation_configc8                    || _         || _        || _        || _        || _        || _        || _        |	| _        |
| _        || _	        || _
        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        | | _        |!| _        |"| _         |#| _!        |$| _"        |%| _#        |&| _$        |'| _%        |(ptL          j'        | _(        |)| _)        |*| _*        |.| _+        |/| _,        |0| _-        |1| _.        |+| _/        |2| _0        |3| _1        |4| _2        |,pi | _3        |-| _4        || _5        | 6                                 |5| _7        |6| _8        |7| _9        | j9        stu          d          | _9        |-r:| j3        tw                      | _3        ty          | j3                   d| j3        d<   d S d S )NF)enable_resource_isolationTlineage_pinning_enabled)=r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   driver_moder   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   ray_constantsDEFAULT_RUNTIME_ENV_DIR_NAMEr0   r1   r2   r6   r7   tracing_startup_hookr8   r3   r9   r:   r;   r4   _enable_object_reconstructionr   _check_usager<   r=   r>   r   dictprint)8selfr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rB   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   rE   r8   r9   r:   r;   r<   r=   r>   s8                                                           j/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/_private/parameter.py__init__zRayParams.__init__{   sI   x +&  #6 "$!2#6 !2..".. 0&<#&."4 0!2,, 0)B&&!2$!2,,+F(&<#(@%"4  NM$N 	! $7 "4"4#6 $8!$%:" (
,2-I*$)B&- 	-D*/. . .D*
 ( 	B"*&*ff#$%&&&=AD 9:::	B 	B    c                     |D ];}t          | |          rt          | |||                    *t          d|           |                                  dS )zUpdate the settings according to the keyword arguments.

        Args:
            kwargs: The keyword arguments to set corresponding fields.
        z'Invalid RayParams parameter in update: N)hasattrsetattr
ValueErrorrG   rJ   kwargsargs      rK   updatezRayParams.update   sp      	R 	RCtS!! Rc6#;//// !P3!P!PQQQrM   c                     |D ]K}t          | |          r(t          | |          t          | |||                    :t          d|           |                                  dS )zUpdate the settings when the target fields are None.

        Args:
            kwargs: The keyword arguments to set corresponding fields.
        Nz1Invalid RayParams parameter in update_if_absent: )rO   getattrrP   rQ   rG   rR   s      rK   update_if_absentzRayParams.update_if_absent  s      	 	CtS!! 4%%-D#vc{333 MMM   	rM   c                 @   d } || j                    || j                   || j                   || j                   || j                   || j                   || j                   || j                   || j                   || j	                  d
}| j
        }|g }||d<   | j        B| j        5| j        .t          t          | j        | j        dz                       |d<   n-g |d<   n'd | j                            d          D             |d<   t#                      | _        |                                D ]Y\  }}|D ]Q}|| j        v r,t)          d	| d
| d|                     |           d          | j                            |           RZdS )z}Update the pre-selected port information

        Returns:
            The dictionary mapping of component -> ports.
        c                     | | dk    rg S | gS )Nr    )ports    rK   	wrap_portz5RayParams.update_pre_selected_port.<locals>.wrap_port%  s    |tqyy	vrM   )
gcsobject_managernode_manager
gcs_serverclient_server	dashboarddashboard_agent_grpcdashboard_agent_httpruntime_env_agentmetrics_exportNredis_shards   worker_portsc                 ,    g | ]}t          |          S r[   )int).0r\   s     rK   
<listcomp>z6RayParams.update_pre_selected_port.<locals>.<listcomp>F  s+     2 2 2"D		2 2 2rM   ,zRay component z  is trying to use a port number z5 that is used by other components.
Port information: zZ
If you allocate ports, please make sure the same port is not used by multiple components.)r   r   r   r   r   r*   r6   r+   r,   r7   r   r   r   r   listrangesplitsetreserved_portsitemsrQ   _format_portsadd)rJ   r]   pre_selected_portsr   comp	port_listr\   s          rK   update_pre_selected_portz"RayParams.update_pre_selected_port  s6   	 	 	 9T_--'i(@AA%Id&<==#)D$899&Yt'BCC"4#677$-Id.E$F$F$-Id.N$O$O!*4+F!G!G'i(@AA
 
 !2$ "->>* (#/D4H4T59$.0Dq0HII6 6">22
 68">222 2&*&;&A&A#&F&F2 2 2~.
 "ee17799 
	. 
	.OD)! 	. 	.4...$> > >)-> >-1-?-?@R-S-S> > >   #''----	.
	. 
	.rM   c                      j         q j                             d          D ]V}	 t          |          }n%# t          $ r}t          d|           d d }~ww xY w|dk     s|dk    rt          d|           Wt          j                            dd          r j         j        d _        d _         j        0 j        dk    r% j        dk     s j        dk    rt          d	           j        e j        t          d
           j        dk    rD j        dk     s j        dk    rt          d           j         j        k    rt          d           j	        Bt                      t          d           j	        dk     s j	        dk    rt          d           j        % j        dk     s j        dk    rt          d           j        y fd}d j        vsJ  |dd                      d j        vsJ  |dd                      d j        vsJ  |dd                      d j        vsJ  |dd                       j        t          d           j        3t          j                             j                  st          d           j        t	          j        d          rd}	 t'          j         j                                                                      t'          j        t	          j        d                                                               n# t          $ r d}Y nw xY w|rt          d          d S d S d S )Nro   z=worker_port_list must be a comma-separated list of integers: i   i  z?Ports in worker_port_list must be between 1024 and 65535. Got: RAY_USE_RANDOM_PORTSFr   z?min_worker_port must be 0 or an integer between 1024 and 65535.z<If max_worker_port is set, min_worker_port must also be set.z?max_worker_port must be 0 or an integer between 1024 and 65535.z4max_worker_port must be higher than min_worker_port.zRay Client requires pip package `ray[client]`. If you installed the minimal Ray (e.g. `pip install ray`), please reinstall by executing `pip install ray[client]`.zAray_client_server_port must be an integer between 1024 and 65535.zAruntime_env_agent_port must be an integer between 1024 and 65535.c                 r    j          d|  dt          j         d| d|                    dd           d|  dS )	Nz -> `zJ` cannot be a custom resource because it is one of the default resources (z). Use `z)` instead. For example, use `ray start --_-z(=1` instead of `ray start --resources={'z': 1}`)r   rC   DEFAULT_RESOURCESreplace)resourcealternativerJ   s     rK   build_errorz+RayParams._check_usage.<locals>.build_error  s    ~ C CH C C%7C C (C C %,,S#66	C C
 2:C C CrM   CPUr   GPUr   r   r   z+The redirect_output argument is deprecated.z'temp_dir must be absolute path or None.VIRTUAL_ENVTz7temp_dir must not be child directory of virtualenv root)r   rr   rl   rQ   osenvirongetr   r   r   r   r,   r   r   DeprecationWarningr/   pathisabsgetenvpathlibPathresolverelative_to)rJ   port_strr\   er   is_relatives   `     rK   rG   zRayParams._check_usageX  sP    , 177<<   x==DD!      $1-.1 1      $;;$,,$?8<? ?   #/ :>>0%88 	)#+0D0L'($'($+#q(($t++t/Ce/K/K U   +#+ R   %**'$..$2F2N2N$*   )T-AAA$N   &2.00< O   +d22.66 .   &2+d22.66 .  
 >%     ...E:0N0N......E:0N0N...4>111;;x3R3R111(>>>%'<A A>>> +$%RSSS=$RW]]4=-I-I$FGGG=$=)A)A$K$L//WYY [bi.F.F!G!G!O!O!Q!QRRRR $ $ $#$   M   %$$$ s(   6
A AA<A4L1 1M ?M c                    |                                 }|                                D ]\  }}t          |          dk    r|d         ||<   $t          |          dk    rd||<   =|dk    rb|d         }|t          |          dz
           }t          |          dk     rt          |          }nd| d| }t          |           d| ||<   |S )	zDFormat the pre-selected ports information to be more human-readable.ri   r   randomrj   2   zfrom z to z ports )copyru   lenstr)rJ   rx   portsry   rz   min_portmax_portport_range_strs           rK   rv   zRayParams._format_ports  s    "''))${{}} 	I 	IOD)9~~""'ldY1$$&d''$Q<$S^^a%78y>>B&&%(^^NN%EX%E%E8%E%EN!$YHHHHdrM   )__name__
__module____qualname____doc__rC   REDIS_DEFAULT_USERNAMEREDIS_DEFAULT_PASSWORDDEFAULT_DASHBOARD_IPDEFAULT_DASHBOARD_PORT#DEFAULT_DASHBOARD_AGENT_LISTEN_PORTr   r   rl   r   floatr   boolr   rL   rU   rX   r{   rG   rv   r[   rM   rK   r	   r	      s       k k^ (,%)"&"&04+/"&/3$(15-1!")-)-#')-)-0404*.26*.+/(5(L(5(L*.37%)+/%*,0(5(J)6)M =0426,0"&.2-1,0&+377<,0-1!%*-1&*#$(!%GKuBB BB}BB c]BB 3-	BB
 3-BB De,-BB c3h(BB BB &e_BB SMBB $DI.BB &c]BB BB "#BB "#BB  C=!BB" "##BB$ "#%BB& #49-'BB( !))BB, "$-BB. %T#Y//BB0 #3-1BB2 $C=3BB4 !5BB6 !7BB8 #3-9BB: $,C=;BB< c]=BB> $C=?BB@ TNABBB $D>CBBD !EBBF !GBBH &.&
IBBN !)OBBP #+3-QBBR %SMSBBT 3-UBBV 'smWBBX &c]YBBZ %SM[BB\  $]BB^ !c3h0_BB` '/tnaBBb %SMcBBd &c]eBBh TNiBBj 4S>*kBBl smmBBn }oBBp SMqBBr #sBBt $,,C#DuBB BB BB BBH    "8. 8. 8.tn n n`    rM   r	   )loggingr   r   typingr   r   r   ray._private.ray_constants_privaterC   &ray._private.resource_isolation_configr   ray._private.utilsr   	getLoggerr   loggerr	   r[   rM   rK   <module>r      s     				  ' ' ' ' ' ' ' ' ' ' 2 2 2 2 2 2 2 2 2 J J J J J J > > > > > >		8	$	$M M M M M M M M M MrM   