
    &`i&                     Z   d dl Z d dl mZmZ d dlmZmZmZmZ d dlZ	d dl
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d	ed
edefdZdeegee         f         de	j         j!        fdZ"de	j         j!        deeeeef                  fdZ#de	j         j!        defdZ$de	j         j!        defdZ%deegef         de	j         j!        fdZ&deeeeef                  dedeeeeef                  fdZ'dee(         deeeeef                  dede)dee(         f
dZ*dS )    N)asdictfields)	AwaitableCallableListTuplerest_response)HTTPStatusCode)DEFAULT_LIMITDEFAULT_RPC_TIMEOUTRAY_MAX_LIMIT_FROM_API_SERVERListApiOptionsListApiResponsePredicateTypeStateSchemaSummaryApiOptionsSummaryApiResponseSupportedFilterTypefilter_fields)DataSourceUnavailable)convert_string_to_typestatus_codeerror_messageresultc                 $    t          d| ||dd|S )NF)r   messager   convert_google_style r	   )r   r   r   kwargss       q/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/dashboard/state_api_utils.pydo_replyr"      s6      "	 
       list_api_fnreqc                   K   	  | t          |                     d {V }t          t          j        dt	          |                    S # t
          $ r3}t          t          j        t          |          d           cY d }~S d }~wt          $ r3}t          t          j	        t          |          d           cY d }~S d }~ww xY wN)option )r   r   r   )
options_from_reqr"   r   OKr   
ValueErrorBAD_REQUESTstrr   INTERNAL_ERROR)r$   r%   r   es       r!   handle_list_apir1   &   s     
"{*:3*?*?@@@@@@@@@&)&>>
 
 
 	

  
 
 
&2a&&
 
 
 	
 	
 	
 	
 	
 	

 ! 
 
 
&5a&&
 
 
 	
 	
 	
 	
 	
 	

s0   AA 
C(B>CC(B?9C?Creturnc                 P   | j                             dg           }| j                             dg           }| j                             dg           }t          |          t          |          k    sJ g }t          |||          D ]\  }}}|                    |||f           |S )Nfilter_keysfilter_predicatesfilter_values)querygetalllenzipappend)r%   r4   r5   r6   filterskey	predicatevals           r!   _get_filters_from_reqr@   ?   s     )""="55K	(()<bAAI$$_b99M{s=111111G";0A=QQ . .YY,----Nr#   c           	      2   t          | j                            d          | j                            d          nt                    }|t          k    rt          d| d| dt           d          t          | j                            dd                    }t          |           }t          | j                            d	d
          t                    }t          | j                            dd          t                    }t          |||||          S )z1Obtain `ListApiOptions` from the aiohttp request.limitNzGiven limit z# exceeds the supported Given limit z exceeds the supported limit zg. Use a lower limit, or set the `RAY_MAX_LIMIT_FROM_API_SERVER` environment variable to a larger value.timeout   detailFexclude_driverT)rB   rC   r<   rE   rF   )
intr7   getr   r   r,   r@   r   boolr   )r%   rB   rC   r<   rE   rF   s         r!   r*   r*   L   s$   "%)--"8"8"D	g- E ,,,W5 W W W W2W W W
 
 	
 #)--	2..//G#C((G#CIMM(E$B$BDIIF+CIMM:JD,Q,QSWXXN%   r#   c                     t          | j                            dt                              }t	          |           }| j                            dd           }t          |||          S )NrC   
summary_by)rC   r<   rK   )rG   r7   rH   r   r@   r   )r%   rC   r<   rK   s       r!   summary_options_from_reqrL   h   sW    #)--	+>??@@G#C((G|T22JWg*UUUUr#   
summary_fnc                    K    | t          |                     d {V }t          t          j        dt	          |                    S r'   )rL   r"   r   r+   r   )rM   r%   r   s      r!   handle_summary_apirO   o   s^       :%=c%B%BCCCCCCCCCF"%f~~   r#   filterschemac                 (   g }t          j        |          rd t          |          D             }n|                                }| D ]I\  }}}||v r%||         }	 t	          ||           t	          ||          rn|t
          u s|dk    r>	 t          |t
                    }n# t          $ r t          d| d| d| d          w xY w|t          u s|dk    r>	 t          |t                    }n# t          $ r t          d| d| d| d	          w xY w|t          u s|d
k    rA	 t          |t                    }n;# t          $ r t          d| d| d| d| d	          w xY wn# t          $ r Y nw xY w|                    |||f           K|S )a  Convert the given filter's type to SupportedFilterType.

    This method is necessary because click can only accept a single type
    for its tuple (which is string in this case).

    Args:
        filter: A list of filter which is a tuple of (key, val).
        schema: The state schema. It is used to infer the type of the column for filter.

    Returns:
        A new list of filters with correct types that match the schema.
    c                 (    i | ]}|j         |j        S r   )nametype).0fields     r!   
<dictcomp>z(convert_filters_type.<locals>.<dictcomp>   s    EEEU%*ejEEEr#   integerzInvalid filter `--filter  zD` for a int type column. Please provide an integer filter `--filter z [int]`numberzF` for a float type column. Please provide an integer filter `--filter z	 [float]`booleanz6` for a boolean type column. Please provide `--filter z& [True|true|1]` for True or `--filter z [False|false|0]` for False.)dataclassesis_dataclassr   schema_dict
isinstancerG   r   r,   floatrI   	TypeErrorr;   )rP   rQ   
new_filtercolr>   r?   column_types          r!   convert_filters_typerf   {   s     J'' &EEfVnnEEE##%%% ,1 ,1Y&== +K(3,,, c;// ! C'';)+C+C4S#>>%   (6 6 6c 6 6),6 6 6   !E))[H-D-D
4!  &   (8 8 8c 8 8),8 8 8   !D((K9,D,D4S$??%   (K K Kc K K),K K *-K K K   -E;     N 	3	3/0000s6   E(B##$CC00$D'D=='E$(
E54E5datar<   state_dataclassrE   c                 r   t          ||          }g }| D ] }d}|D ]\  }}}	|                                }
|                                }||
vrt          d| d|
           ||vrd}n|dk    rt	          |	t
                    rMt	          ||         t
                    r2||                                         |	                                k    }n4t	          |	t
                    r;t	          ||         t                    r ||         t          |	t                    k    }nt	          |	t
                    r;t	          ||         t                    r ||         t          |	t                    k    }n||         |	k    }n|dk    rnt	          |	t
                    rLt	          ||         t
                    r1||                                         |	                                k    }n ||         |	k    }nt          d| d          |s n|r$|	                    t          |||                     "|S )	a  Return the filtered data given filters.

    Args:
        data: A list of state data.
        filters: A list of KV tuple to filter data (key, val). The data is filtered
            if data[key] != val.
        state_dataclass: The state schema.

    Returns:
        A list of filtered state data in dictionary. Each state data's
        unnecessary columns are filtered by the given state_dataclass schema.
    TzThe given filter column un    is not supported. Enter filters with –-filter key=value or –-filter key!=value Supported filter columns: F=z!=zUnsupported filter predicate z' is given. Available predicates: =, !=.)rf   filterable_columnslowerr,   r`   r.   rI   r   rG   r;   r   )rg   r<   rh   rE   r   datummatchfilter_columnfilter_predicatefilter_valuerk   s              r!   	do_filterrr      s   $ #7O<<GF 4I 4I=D /	 /	9M+\!0!C!C!E!E)//11M$666 F} F F 2DF F   E))!S((lC00 AZ-(#6 6 A "-06688L<N<N<P<PPEEc22 Az-($8 8 A "-04J$d5 5 EE  c22 Az-(#8 8 A "-04J$c5 5 EE "-0L@EE!T))lC00 AZ-(#6 6 A "-06688L<N<N<P<PPEE!-0L@EE 34D 3 3 3  
    	IMM-GGHHHMr#   )+r]   r   r   typingr   r   r   r   aiohttp.webaiohttpray.dashboard.optional_utilsr
   ray.dashboard.utilsr   ray.util.state.commonr   r   r   r   r   r   r   r   r   r   r   ray.util.state.exceptionr   ray.util.state.utilr   r.   r"   webRequestr1   r@   r*   rL   rO   rf   dictrI   rr   r   r#   r!   <module>r~      s       & & & & & & & & 3 3 3 3 3 3 3 3 3 3 3 3     6 6 6 6 6 6 . . . . . .                          ; : : : : : 6 6 6 6 6 6		03	=L	 	 	 	
>*Io,FFG
		
 
 
 
2
		
	%]$77
89
 
 
 
'+- .    8V'+"5 V:K V V V V	+,.@@A				 	 	 	CsM+>>?@CC 
%]$77
89C C C CLI
t*I%],??@AI !I 	I
 
$ZI I I I I Ir#   