
                         T    S r SSKJr  SrS rS rS r " S S\R                  5      r	g	)
zFTraffic-specific printer and functions for generating traffic formats.    )custom_printer_baseprofilec                 X    U R                   nU(       d  SnXR                  S-  -   7nUS $ )z*Converts cost to a decimal representation.r   g    eAz.3f)unitsnanos)costr   decimal_values      ?lib/googlecloudsdk/command_lib/run/printers/profiles_printer.pyamount_to_decimalr      s2    
**%	EJJ,,--#    c                     SnU (       a,  U S   R                   (       a  [        U S   R                   5      nSnU (       a,  U S   R                  (       a  [        U S   R                  5      nX!4$ )zjReturns the cost per million normalized output tokens as a decimal.

Args:
  costs: The costs to convert.
zN/Ar   )$costPerMillionNormalizedOutputTokensr   costPerMillionInputTokens)costsoutput_token_costinput_token_costs      r
   get_decimal_costr   !   sf     
uQx<<)a55 
uQx11(q)K)KL
	..r   c           
         / SQnU/nU  GH  n[        UR                  (       a  UR                  R                  OS5      u  pEUR                  UUUR                  (       a  UR                  R                  OSUR                  (       a  UR                  R
                  OSUR                  (       a  UR                  R                  OSUR                  R                  UR                  R                  UR                  R                  /	nUR                  U5        GM     [        R                  " U5      n[        R                  " U/SS9$ )zVTransforms a List[AcceleratorOption] into a table with decimal representation of cost.)	AcceleratorzCost/M Input TokenszCost/M Output TokenszOutput Tokens/sz	NTPOT(ms)zAccelerator CountzModel ServerzModel Server VersionModelN<   max_column_width)r   performanceStatsr   acceleratorTypeoutputTokensPerSecondntpotMillisecondsresourcesUsedacceleratorCountmodelAndModelServerInfomodelServerNamemodelServerVersion	modelNameappendcpTableSection)profilesheaderrowspr   r   rowprofiles_tables           r
   _transform_profilesr.   2   s   
& $a*:#$#5#54+' 	
 	
00010B0B,,,-OO((	!!11	!!44	!!++C 	KK# & 88D>.	^$r	::r   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )ProfilePrinterZ   z=Prints a service's profile in a custom human-readable format.c                 0   > [         [        U ]  USU5        g)z3Overrides ResourcePrinter.Print to set single=True.TN)superr0   Print)self	resourcessingleintermediate	__class__s       r
   r4   ProfilePrinter.Print]   s    	.$%i|Dr   c                     [        UR                  5      /nUR                  UR                  5        [        R
                  " USS9$ )z@Transforms a List[TrafficTargetPair] into a marker class format.r   r   )r.   acceleratorOptionsr$   commentsr%   r'   )r5   responser(   s      r
   	TransformProfilePrinter.Transforma   s8    #H$?$?@AHOOH%%&::h44r    )TF)	__name__
__module____qualname____firstlineno____doc__r4   r?   __static_attributes____classcell__)r9   s   @r
   r0   r0   Z   s    EE5 5r   r0   N)
rF   googlecloudsdk.core.resourcer   r%   PROFILES_PRINTER_FORMATr   r   r.   CustomPrinterBaser0   rA   r   r
   <module>rL      s;    M C $  /"%;P5R)) 5r   