o
    ci                     @   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 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)AnyTYPE_CHECKING)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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                   sF   | d| _|jdd| _|   |   d| _t | _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   N)getr   copyr
   
set_devicemake_module_weights_seq_nor   metricssuper__init__)selfr
   kwargs	__class__ R/home/ubuntu/.local/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   1   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_metricsH   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   stopP   r   zRunner.stopc                 C   r   )z$Returns the device of this `Runner`.Nr   r   r   r   r   _deviceX   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__c   r   zRunner.__del__c                 C   r   )z0Converts structs to a framework-specific tensor.Nr   )r   structr   r   r   _convert_to_tensorg   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&   __classcell__r   r   r   r   r	      s*    


	r	   )	metaclass)r*   loggingtypingr   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    
