o
    $i                     @   sf   d dl Z d dlmZ d dlmZmZ edededefddZ	edefdd	Z
eG d
d dZdS )    N)DeveloperAPI	PublicAPIcls
serializerdeserializerc                C   s    t jjj }|| || dS )a  Use the given serializer to serialize instances of type ``cls``,
    and use the deserializer to deserialize the serialized object.

    Args:
        cls: A Python class/type.
        serializer: A function that converts an instances of
            type ``cls`` into a serializable object (e.g. python dict
            of basic objects).
        deserializer: A function that constructs the
            instance of type ``cls`` from the serialized object.
            This function itself must be serializable.
    N)ray_privateworkerglobal_workerget_serialization_context _register_cloudpickle_serializer)r   r   r   context r   S/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/util/serialization.pyregister_serializer   s   r   c                 C   s   t jjj }||  dS )zDeregister the serializer associated with the type ``cls``.
    There is no effect if the serializer is unavailable.

    Args:
        cls: A Python class/type.
    N)r   r   r	   r
   r   _unregister_cloudpickle_reducer)r   r   r   r   r   deregister_serializer   s   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )StandaloneSerializationContextc                 C   s   |t jj|< d S NpickleCloudPicklerdispatch)selfr   reducerr   r   r   _register_cloudpickle_reducer*   s   z<StandaloneSerializationContext._register_cloudpickle_reducerc                 C   s   t jj|d  d S r   )r   r   r   pop)r   r   r   r   r   r   -   s   z>StandaloneSerializationContext._unregister_cloudpickle_reducerc                    s    fdd}|t jj|< d S )Nc                    s    | ffS r   r   )objcustom_deserializercustom_serializerr   r   _CloudPicklerReducer3   s   z]StandaloneSerializationContext._register_cloudpickle_serializer.<locals>._CloudPicklerReducerr   )r   r   r    r   r!   r   r   r   r   0   s   z?StandaloneSerializationContext._register_cloudpickle_serializerN)__name__
__module____qualname__r   r   r   r   r   r   r   r   $   s    r   )r   ray.cloudpicklecloudpickler   ray.util.annotationsr   r   typecallabler   r   r   r   r   r   r   <module>   s    