o
    `۷i                     @   s   d dl Z d dlZd dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZmZ er.d dlmZ eeZG dd dee jd	ZdS )
    N)TYPE_CHECKINGAnyUnion)FaultAwareApply)MetricsLogger)
DeviceType
TensorType)AlgorithmConfigc                       s   e Zd Zd fddZejdd Zejdd Zejd	efd
dZ	ejd	efddZ
ejdddZeejd	eedf fddZejdddZejdddZejd	efddZ  ZS )Runnerconfigr	   c                   sN   | d| _|jdd| _|   |   d| _t|jdd| _	t
   dS )zInitializes a `Runner` instance.

        Args:
            config: The `AlgorithmConfig` to use to setup this `Runner`.
            **kwargs: Forward compatibility `kwargs`.
        worker_indexF)copy_frozenr   )stats_cls_lookuprootN)getr   copyr   
set_devicemake_module_weights_seq_nor   r   metricssuper__init__)selfr   kwargs	__class__ T/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/rllib/utils/runners/runner.pyr      s   zRunner.__init__c                 C      dS )aD  Checks that self.__init__() has been completed properly.

        Useful in case an `Runner` is run as @ray.remote (Actor) and the owner
        would like to make sure the Ray Actor has been properly initialized.

        Raises:
            AssertionError: If the `Runner` Actor has NOT been properly initialized.
        Nr   r   r   r   r   assert_healthy(       zRunner.assert_healthyc                 C   r   )a*  Creates the `RLModule` for this `Runner` and assigns it to `self.module`.

        Note that users should be able to change the `Runner`'s config (e.g. change
        `self.config.rl_module_spec`) and then call this method to create a new `RLModule`
        with the updated configuration.
        Nr   r   r   r   r   r   3   s   zRunner.make_modulereturnc                 K   r   )zRuns the `Runner`.

        The exact logic of this method could have very different forms.

        Args:
            **kwargs: Forward compatibility kwargs.

        Returns:
            Anything.
        Nr   )r   r   r   r   r   run=   r!   z
Runner.runc                 C   r   )z|Returns metrics (in any form) of the logic run in this `Runner`.

        Returns:
            Metrics of any form.
        Nr   r   r   r   r   get_metricsJ   r!   zRunner.get_metricsNc                 C   r   )zReleases all resources used by this `Runner`.

        For example, when using a `gym.Env` in this `Runner`, you should make sure
        that its `close()` method is called.
        Nr   r   r   r   r   stopR   r!   zRunner.stopc                 C   r   )zHReturns the device of this `Runner`. None if framework is not supported.Nr   r   r   r   r   _deviceZ   s   zRunner._devicec                 C   r   )z"Sets the device for this `Runner`.Nr   r   r   r   r   r   `   s   zRunner.set_devicec                 C   r   )z:If this Actor is deleted, clears all resources used by it.Nr   r   r   r   r   __del__e   r!   zRunner.__del__c                 C   r   )z0Converts structs to a framework-specific tensor.Nr   )r   structr   r   r   _convert_to_tensori   r!   zRunner._convert_to_tensor)r   r	   )r"   N)__name__
__module____qualname__r   abcabstractmethodr    r   r   r#   r$   r%   propertyr   r   r&   r   r'   r   r)   __classcell__r   r   r   r   r
      s*    


	r
   )	metaclass)r-   loggingtypingr   r   r   ray.rllib.utils.actor_managerr   &ray.rllib.utils.metrics.metrics_loggerr   ray.rllib.utils.typingr   r   %ray.rllib.algorithms.algorithm_configr	   	getLoggerr*   loggerABCMetar
   r   r   r   r   <module>   s    
