o
    `۷i                     @   sd   d dl mZmZ d dlmZmZmZmZmZm	Z	 d dl
mZ G dd deZG dd dZe ZdS )	    )Enumauto)AnyCallableDictListOptionalUnion)
cli_loggerc                   @   sR   e Zd ZdZe Ze Ze Ze Ze Z	e Z
e Ze Ze Ze Ze ZdS )CreateClusterEventa  Events to track in ray.autoscaler.sdk.create_or_update_cluster.

    Attributes:
        up_started : Invoked at the beginning of create_or_update_cluster.
        ssh_keypair_downloaded : Invoked when the ssh keypair is downloaded.
        cluster_booting_started : Invoked when when the cluster booting starts.
        acquiring_new_head_node : Invoked before the head node is acquired.
        head_node_acquired : Invoked after the head node is acquired.
        ssh_control_acquired : Invoked when the node is being updated.
        run_initialization_cmd : Invoked before all initialization
            commands are called and again before each initialization command.
        run_setup_cmd : Invoked before all setup commands are
            called and again before each setup command.
        start_ray_runtime : Invoked before ray start commands are run.
        start_ray_runtime_completed : Invoked after ray start commands
            are run.
        cluster_booting_completed : Invoked after cluster booting
            is completed.
    N)__name__
__module____qualname____doc__r   
up_startedssh_keypair_downloadedcluster_booting_startedacquiring_new_head_nodehead_node_acquiredssh_control_acquiredrun_initialization_cmdrun_setup_cmdstart_ray_runtimestart_ray_runtime_completedcluster_booting_completed r   r   Z/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/autoscaler/_private/event_system.pyr      s    
r   c                	   @   sz   e Zd ZdZdd Zdedeeegdf e	eegdf  f fddZ
	dded	eeeef  fd
dZdefddZdS )_EventSystemzEvent system that handles storing and calling callbacks for events.

    Attributes:
        callback_map (Dict[str, List[Callable]]) : Stores list of callbacks
            for events when registered.
    c                 C   s
   i | _ d S Ncallback_map)selfr   r   r   __init__1   s   
z_EventSystem.__init__eventcallbackNc                 C   sN   |t j vrt| d | j|g t|t	ur"|g dS | dS )ag  Stores callback handler for event.

        Args:
            event: Event that callback should be called on. See
                CreateClusterEvent for details on the events available to be
                registered against.
            callback (Callable[[Dict], None]): Callable object that is invoked
                when specified event occurs.
        zA is not currently tracked, and this callback will not be invoked.N)
r   __members__valuesr
   warningr    
setdefaultextendtypelist)r!   r#   r$   r   r   r   add_callback_handler4   s   z!_EventSystem.add_callback_handler
event_datac                 C   s>   |du ri }||d< || j v r| j | D ]}|| qdS dS )a:  Executes all callbacks for event.

        Args:
            event: Event that is invoked. See CreateClusterEvent
                for details on the available events.
            event_data (Dict[str, Any]): Argument that is passed to each
                callable object stored for this particular event.
        N
event_namer   )r!   r#   r-   r$   r   r   r   execute_callbackL   s   

z_EventSystem.execute_callbackc                 C   s   || j v r| j |= dS dS )zClears stored callable objects for event.

        Args:
            event: Event that has callable objects stored in map.
                See CreateClusterEvent for details on the available events.
        Nr   )r!   r#   r   r   r   clear_callbacks_for_event_   s   
z&_EventSystem.clear_callbacks_for_eventr   )r   r   r   r   r"   strr	   r   r   r   r,   r   r   r   r/   r0   r   r   r   r   r   )   s    "

r   N)enumr   r   typingr   r   r   r   r   r	   "ray.autoscaler._private.cli_loggerr
   r   r   global_event_systemr   r   r   r   <module>   s     "
A