
    LKi                        S SK r S SKJr  S SKrS SKrS SKJrJrJr  S SK	J
r
  S SKJrJrJr  S SKJr  S SKJr  S SKJrJr  S S	KJr  S S
KJrJrJrJr  S SKJr  S SKJ r J!r!J"r"  S SK#J$r$  S SK%r%\%RL                  " \'5      r( " S S\\5      r)g)    N) RetryOnRpcErrorClientInterceptor)ProducerConsumerConsumerCallbackFn)to_proto_submit)PushLogsRequestPullLogsRequest	LogRecord)LogServiceStub)OtelInterceptor)OperationRecordSeqId)System)OpenTelemetryClientOpenTelemetryGranularityadd_attributes_to_current_spantrace_method)override)SequenceOptionalcast)UUIDc                     ^  \ rS rSr% Sr\\S'   \\S'   \R                  \S'   \
\S'   \\S'   S\4U 4S	 jjr\" S
\R                  5      \S/U 4S jj5       5       r\" S\R                  5      \S/U 4S jj5       5       r\" S\R                  5      \S/U 4S jj5       5       r\" S\R                  5      \S\SS4S j5       5       r\" S\R                  5      \S\SS4S j5       5       r\" S\R                  5      \S\S\S\4S j5       5       r\" S\R                  5      \S\S\\   S\\   4S j5       5       r\" S\R                  5      \   S0S\S\S\\   S \\   S!\\   S\4S" jj5       5       r\" S#\R                  5      \S$\SS4S% j5       5       r\S\4S& j5       r \S\4S' j5       r!\"\S\4S( j5       5       r#S\S)\\   S\4S* jr$S\S+\S,\S\\%   4S- jr&S.r'U =r($ )1
LogService"   z 
Distributed Chroma Log Service
_log_service_stub_request_timeout_seconds_channel_log_service_url_log_service_portsystemc                   > UR                   R                  S5      U l        UR                   R                  S5      U l        UR                   R                  S5      U l        UR                  [
        5      U l        [        TU ]!  U5        g )Nchroma_logservice_hostchroma_logservice_port)chroma_logservice_request_timeout_seconds)	settingsrequirer   r    r   r   _opentelemetry_clientsuper__init__)selfr!   	__class__s     `/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/chromadb/logservice/logservice.pyr*   LogService.__init__-   sn     & 7 78P Q!'!8!89Q!R(.(?(?7)
% &,^^4G%H"     zLogService.startreturnNc                 2  > [         R                  " U R                   SU R                   35      U l        [        5       [        5       /n[         R                  " U R                  /UQ76 U l        [        U R                  5      U l	        [        TU ]-  5         g )N:)grpcinsecure_channelr   r    r   r   r   intercept_channelr   r   r)   start)r+   interceptorsr,   s     r-   r6   LogService.start6   s{     --$$%Qt'='=&>?
 ()+K+MN..t}}L|L!/!>r/   zLogService.stopc                 V   > U R                   R                  5         [        TU ]  5         g N)r   closer)   stopr+   r,   s    r-   r<   LogService.stopA   s     	r/   zLogService.reset_statec                 "   > [         TU ]  5         g r:   )r)   reset_stater=   s    r-   r@   LogService.reset_stateG   s     	r/   zLogService.delete_logcollection_idc                     [        S5      eNzNot implementedNotImplementedErrorr+   rB   s     r-   
delete_logLogService.delete_logL        ""344r/   zLogService.purge_logc                     [        S5      erD   rE   rG   s     r-   	purge_logLogService.purge_logQ   rJ   r/   zLogService.submit_embedding	embeddingc                 d    U R                   (       d  [        S5      eU R                  X/5      S   $ )NComponent not runningr   )_runningRuntimeErrorsubmit_embeddings)r+   rB   rN   s      r-   submit_embeddingLogService.submit_embeddingV   s/    
 }}677%%m[A!DDr/   zLogService.submit_embeddings
embeddingsc           	         [         R                  S[        U5       SU 35        [        S[        U5      05        U R                  (       d  [        S5      e[        U5      S:X  a  / $ / nU Vs/ s H  n[        U5      PM     nnUR                  U R                  U[        [        [           U5      5      5        U$ s  snf )NzSubmitting z" embeddings to log for collection records_countrP   r   )loggerinfolenr   rQ   rR   r   append	push_logsr   r   r   )r+   rB   rV   countsrecordprotos_to_submits         r-   rS   LogService.submit_embeddings`   s    
 	#j/**L]O\	
 	'Z	
 }}677z?aI BLM*OF3*MNNXo.0@A	
  Ns   .B=zLogService.subscribe
consume_fnr6   endidc                 F    [         R                  SU S35        [        SS9$ )NzSubscribing to log for , noop for logservicer   )int)rY   rZ   r   )r+   rB   rb   r6   rc   rd   s         r-   	subscribeLogService.subscribe   s%     	-m_<QRS{r/   zLogService.unsubscribesubscription_idc                 6    [         R                  SU S35        g )NzUnsubscribing from rf   )rY   rZ   )r+   rj   s     r-   unsubscribeLogService.unsubscribe   s     	)/)::OPQr/   c                     g)Nr    r+   s    r-   	min_seqidLogService.min_seqid   s    r/   c                 "    [         R                  $ r:   )sysmaxsizerp   s    r-   	max_seqidLogService.max_seqid   s    {{r/   c                     g)Nd   ro   rp   s    r-   max_batch_sizeLogService.max_batch_size   s     r/   recordsc                     [        [        U5      US9nU R                  R                  X0R                  S9nUR
                  $ )N)rB   r|   timeout)r   strr   PushLogsr   record_count)r+   rB   r|   requestresponses        r-   r]   LogService.push_logs   sE    !M0BGT))22:: 3 
 $$$r/   start_offset
batch_sizec                     [        [        U5      UU[        R                  " 5       S9nU R                  R                  X@R                  S9nUR                  $ )N)rB   start_from_offsetr   end_timestampr~   )r	   r   timetime_nsr   PullLogsr   r|   )r+   rB   r   r   r   r   s         r-   	pull_logsLogService.pull_logs   sY     "m,*!,,.	
 ))22:: 3 
 r/   )r   r    r   r   r(   r   )r0   N)NNN))__name__
__module____qualname____firstlineno____doc__r   __annotations__rg   r3   Channelr   r   r*   r   r   ALLr   r6   r<   r@   r   rH   rL   r   r   rT   r   rS   r   r   rh   rl   rq   rv   propertyrz   r]   r
   r   __static_attributes____classcell__)r,   s   @r-   r   r   "   s*    &%!!ll!v ! $&>&B&BC  D #%=%A%AB  C *,D,H,HI  J )+C+G+GH5 5 5  I5 (*B*F*FG5t 5 5  H5 /1I1M1MNE!E.=E	E  OE 02J2N2NO!/7/H	%  PB (*B*F*FG
 "&#!		 '	 		
 e_	 TN	 
	  H	 *,D,H,HIR4 RD R  JR 5   5      %t %h6O %TW % ! 14 BE 	)	   r/   r   )*rt   chromadb.proto.utilsr   r3   r   chromadb.ingestr   r   r   chromadb.proto.convertr   chromadb.proto.logservice_pb2r   r	   r
   "chromadb.proto.logservice_pb2_grpcr   %chromadb.telemetry.opentelemetry.grpcr   chromadb.typesr   r   chromadb.configr    chromadb.telemetry.opentelemetryr   r   r   r   	overridesr   typingr   r   r   uuidr   logging	getLoggerr   rY   r   ro   r/   r-   <module>r      sq    
 A   
 3 U U = A #   + +  			8	$S 8 S r/   