
    ch                        S SK Jr  S SKrS SKJr  S SKJrJrJrJ	r	  \(       a  S SK
Jr   " S S\5      rSS jr\	 " S	 S
\5      5       r " S S5      rg)    )annotationsN)abstractmethod)TYPE_CHECKING
NamedTupleProtocolruntime_checkable)Metricc                  L    \ rS rSr% SrS\S'   S\S'   S\S'   SS jrSS	 jrS
rg)	CacheStat   a1  Describes a single cache entry.

Properties
----------
category_name : str
    A human-readable name for the cache "category" that the entry belongs
    to - e.g. "st.memo", "session_state", etc.
cache_name : str
    A human-readable name for cache instance that the entry belongs to.
    For "st.memo" and other function decorator caches, this might be the
    name of the cached function. If the cache category doesn't have
    multiple separate cache instances, this can just be the empty string.
byte_length : int
    The entry's memory footprint in bytes.
strcategory_name
cache_nameintbyte_lengthc                T    SU R                    SU R                   SU R                   3$ )Nzcache_memory_bytes{cache_type="z	",cache="z"} r   r   r   selfs    jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\streamlit/runtime/stats.pyto_metric_strCacheStat.to_metric_str.   s0    1$2D2D1EYtN__cdhdtdtcuvv    c                6   UR                   R                  5       nSUl        U R                  Ul        UR                   R                  5       nSUl        U R
                  Ul        UR                  R                  5       nU R                  UR                  l	        g)z-Fill an OpenMetrics `Metric` protobuf object.
cache_typecacheN)
labelsaddnamer   valuer   metric_pointsr   gauge_value	int_value)r   metriclabelmetric_points       r   marshall_metric_protoCacheStat.marshall_metric_proto1   st    !!#!
((!!#
oo++//1-1-=-=  *r    N)returnr   )r$   MetricProtor*   None)	__name__
__module____qualname____firstlineno____doc____annotations__r   r'   __static_attributes__r)   r   r   r   r      s%      Ow>r   r   c                    SS jn/ n[        XS9n[        R                  " X1S9nU H2  u  u  pVnUR                  [	        UU[        S U 5       5      S95        M4     U$ )zOGroup a list of CacheStats by category_name and cache_name and sum byte_length.c                2    U R                   U R                  4$ N)r   r   )individual_stats    r   key_function!group_stats.<locals>.key_functionB   s    ,,o.H.HHHr   )keyc              3  8   #    U  H  oR                   v   M     g 7fr6   )r   ).0items     r   	<genexpr>group_stats.<locals>.<genexpr>O   s     P=OT 0 0=Os   r   )r7   r   r*   ztuple[str, str])sorted	itertoolsgroupbyappendr   sum)statsr8   resultsorted_statsgrouped_statsr   r   single_group_statss           r   group_statsrJ   ?   sm    I !F%2L%%lEM;H7#%7+%P=OPP	
 <I Mr   c                  (    \ rS rSr\SS j5       rSrg)CacheStatsProviderU   c                    [         er6   )NotImplementedErrorr   s    r   	get_statsCacheStatsProvider.get_statsW   s    !!r   r)   Nr*   list[CacheStat])r-   r.   r/   r0   r   rP   r3   r)   r   r   rL   rL   U   s    " "r   rL   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
StatsManager\   c                    / U l         g r6   _cache_stats_providersr   s    r   __init__StatsManager.__init__]   s
    @B#r   c                :    U R                   R                  U5        g)zvRegister a CacheStatsProvider with the manager.
This function is not thread-safe. Call it immediately after
creation.
N)rY   rC   )r   providers     r   register_providerStatsManager.register_provider`   s    
 	##**84r   c                n    / nU R                    H"  nUR                  UR                  5       5        M$     U$ )zAReturn a list containing all stats from each registered provider.)rY   extendrP   )r   	all_statsr]   s      r   rP   StatsManager.get_statsg   s6    %'	33HX//12 4 r   rX   N)r*   r,   )r]   rL   r*   r,   rR   )r-   r.   r/   r0   rZ   r^   rP   r3   r)   r   r   rU   rU   \   s    C5r   rU   )rE   rS   r*   rS   )
__future__r   rA   abcr   typingr   r   r   r   *streamlit.proto.openmetrics_data_model_pb2r	   r+   r   rJ   rL   rU   r)   r   r   <module>rh      sS    #   I IP#>
 #>L, " " " r   