
    &`i\
                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZ	m
Z
 d dlmZ d dlZ	 d dlmZmZ n# e$ r	 d Zd	 ZY nw xY wd
 ZdS )    N)OrderedDict)Iterator)getitem)getquote)apply)fieldsis_dataclassc                     dS )NF xs    h/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/util/dask/common.pyr
   r
      s    u    c                     g S Nr   r   s    r   dataclass_fieldsr      s    	r   c                      g i t          j                    j        fdt          j                    j        t          fd| D             f<   fd}|fS )a  
    Extract Ray object refs from a set of potentially arbitrarily nested
    Python objects.

    Intended use is to find all Ray object references in a set of (possibly
    nested) Python objects, do something to them (get(), wait(), etc.), then
    repackage them into equivalent Python objects.

    Args:
        *args: One or more (potentially nested) Python objects that contain
            Ray object references.

    Returns:
        A 2-tuple of a flat list of all contained Ray object references, and a
        function that, when given the corresponding flat list of concrete
        values, will return a set of Python objects equivalent to that which
        was given in *args, but with all Ray object references replaced with
        their corresponding concrete values.
    c                     t           t          j                  rE                                 }t          t                    f|<                                   |S t          j                    j        }t           t                    rt          nt                     }|t          t          t          fv r|fd D             f}nq|t          t          fv r#|fd                                 D             f}n>t#                     r-t$          |dt           fdt'                     D             ff}n S ||<   |S )Nc                 &    g | ]} |          S r   r   .0i_unpacks     r   
<listcomp>z7unpack_object_refs.<locals>._unpack.<locals>.<listcomp>:   s!     : : : : : :r   c                 B    g | ]\  }} |           |          gS r   r   )r   kvr   s      r   r   z7unpack_object_refs.<locals>._unpack.<locals>.<listcomp><   s2     S S Sda''!**ggajj!9 S S Sr   r   c           	      Z    g | ]'}|j          t          |j                             g(S r   )namegetattr)r   fr   exprs     r   r   z7unpack_object_refs.<locals>._unpack.<locals>.<listcomp>D   sF        qv)>)>!?!?@  r   )
isinstanceray	ObjectRefhexr   lenappenduuiduuid4r   listtypetuplesetdictr   itemsr
   r   r   )r#   tokentyprepack_taskr   object_refsobject_refs_token
repack_dsks   `   r   r   z#unpack_object_refs.<locals>._unpack/   sc   dCM** 	HHJJE!(*;S=M=M NJut$$$L
  x00@ddd4jj4$$$ : : : :T : : :;KKT;''' S S S Sdjjll S S STKK$ 	    !1$!7!7  	KK K'
5r   c                 &    g | ]} |          S r   r   r   s     r   r   z&unpack_object_refs.<locals>.<listcomp>P   s!    888awwqzz888r   c                 p                                     }t          |           |<   t          |          S r   )copyr   get_sync)resultsdskr6   outr7   s     r   repackz"unpack_object_refs.<locals>.repackR   s3    oo!&wS!!!r   )r*   r+   r'   r.   )argsr?   r   r5   r6   r>   r7   s     @@@@@r   unpack_object_refsrA      s    ( KJ
(       @ *,,
C888848889JsO" " " " " " "
 r   )r*   collectionsr   collections.abcr   operatorr   	dask.corer   r;   r   
dask.utilsr   r%   dataclassesr	   r   r
   ImportErrorrA   r   r   r   <module>rI      s     # # # # # # $ $ $ $ $ $       , , , , , , , ,       



DDDDDDDDD         A A A A As   3 A A