o
    $i                     @   s   d dl Z d dlZd dlmZmZ d dlmZ d dlmZ dZ	dZ
deeef deeef fd	d
Zdeeef deeef fddZdeeef deeef fddZdedefddZdedefddZdeeef deeef fddZdS )    N)AnyDict)get_ray_temp_dir)
cli_loggerz6The field {} is not supported for on-premise clusters.zlocal.cluster.nodeconfigreturnc                 C   sp   t | } dD ]}| |rt|}t| qti i di| d< t| d< d| d v r2t| } | S t	| } | S )z\
    Prepare local cluster config for ingestion by cluster launcher and
    autoscaler.
    )	head_nodeworker_nodesavailable_node_types)node_config	resourcesr
   head_node_typecoordinator_addressprovider)
copydeepcopygetunsupported_field_messageformatr   abortLOCAL_CLUSTER_NODE_TYPEprepare_coordinatorprepare_manual)r   fielderr_msg r   a/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/autoscaler/_private/local/config.pyprepare_local   s   




r   c                 C   sH   t | } d| vrtd | d t }| dd|d< | d |d< | S )Nmax_workersz[The field `max_workers` is required when using an automatically managed on-premise cluster.r
   min_workersr   )r   r   r   r   r   pop)r   	node_typer   r   r   r   %   s   
r   c              	   C   s
  t | } d| d vsd| d vrtd t| d d }| d t }| d| | d|}| d }||krLtd| d	| d
| d ||d< n||d< ||krltd| d	| d| d ||d< || d< n||d< ||k rtd| d| d| d | S )ah  Validates and sets defaults for configs of manually managed on-prem
    clusters.

    - Checks for presence of required `worker_ips` and `head_ips` fields.
    - Defaults min and max workers to the number of `worker_ips`.
    - Caps min and max workers at the number of `worker_ips`.
    - Writes min and max worker info into the single worker node type.
    
worker_ipsr   head_ipzbPlease supply a `head_ip` and list of `worker_ips`. Alternatively, supply a `coordinator_address`.r
   r   r   z%The value of `min_workers` supplied (z6) is greater than the number of available worker ips (z). Setting `min_workers=z`.z%The value of `max_workers` supplied (z). Setting `max_workers=z3) is less than the number of available worker ips (z). At most z. Ray worker nodes will connect to the cluster.)	r   r   r   r   lenr   
setdefaultr    warning)r   num_ipsr!   r   r   r   r   r   r   6   sR   
	

r   cluster_namec                 C      t jt d| S )Nzcluster-{}.lockospathjoinr   r   r(   r   r   r   get_lock_pathp      r/   c                 C   r)   )Nzcluster-{}.stater*   r.   r   r   r   get_state_patht   r0   r1   c                 C   s   | S )Nr   )r   r   r   r   bootstrap_localx   s   r2   )r   r+   typingr   r   ray._common.utilsr   "ray.autoscaler._private.cli_loggerr   r   r   strr   r   r   r/   r1   r2   r   r   r   r   <module>   s    """:&