o
    bi/                     @   sv   d dl Z d dlZd dlmZmZmZ d dlmZmZ d dl	m
Z d dlmZ d dlmZ e eZG dd deZdS )	    N)NodeUpdaterTAG_RAY_NODE_STATUSSTATUS_UP_TO_DATE)	with_envswith_head_node_ip)NodeProvider)AutoscalingConfig)Instancec                   @   s@   e Zd ZdZefdededdfddZded	e	ddfd
dZ
dS )RayInstallerzP
    RayInstaller is responsible for installing ray on the target instance.
    providerconfigreturnNc                 C   s   || _ || _|| _d S )N)	_provider_config_process_runner)selfr   r   process_runner r   d/home/ubuntu/.local/lib/python3.10/site-packages/ray/autoscaler/v2/instance_manager/ray_installer.py__init__   s   
zRayInstaller.__init__instancehead_node_ipc           	      C   s  | j |j}| j  }| j |j}td|j d | j |j}t	di d|jd| j 
dd| jd| j 
dd| j 
dd	| j 
d	d
t| j |j|dt||dt|||j|j|dd| j jd| j jddd| j 
dd| j 
d| j 
ddddd|d| j |jd| j |jd| j}|  | j|j}|ttkrtd|t dS ) z
        Install ray on the target instance synchronously.
        TODO:(rickyx): This runs in another thread, and errors are silently
        ignored. We should propagate the error to the main thread.
        z5Creating new (spawn_updater) updater thread for node .node_idprovider_configr   auth_configauthcluster_namefile_mountsinitialization_commandssetup_commandsray_start_commands)RAY_HEAD_IPRAY_CLOUD_INSTANCE_IDRAY_NODE_TYPE_NAMERAY_CLOUD_INSTANCE_TYPE_NAMEruntime_hashfile_mounts_contents_hashis_head_nodeFcluster_synced_filesrsync_optionsrsync_excludersync_filter)r+   r,   use_internal_ipTdocker_confignode_resourcesnode_labelsr   z0Ray installation failed with unexpected status: Nr   )r   get_worker_setup_commandsinstance_typeget_worker_start_ray_commandsget_docker_configloggerinfocloud_instance_idget_provider_instance_typer   
get_configr   r   get_initialization_commandsr   r&   r'   get_node_resourcesget_node_labelsr   run	node_tagsgetr   r   	Exception)	r   r   r   r    r!   r.   provider_instance_type_nameupdatertagsr   r   r   install_ray    s   



"#$%&(zRayInstaller.install_ray)__name__
__module____qualname____doc__
subprocessNodeProviderV1r   r   r	   strrD   r   r   r   r   r
      s    

r
   )loggingrI   ray.autoscaler._private.updaterr   r   r   ray.autoscaler._private.utilr   r   ray.autoscaler.node_providerr   rJ   )ray.autoscaler.v2.instance_manager.configr   'ray.core.generated.instance_manager_pb2r	   	getLoggerrE   r5   objectr
   r   r   r   r   <module>   s    
