
    o                         S r SSKJr  SSKJr  SSKJr  SSKJ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.    )absolute_import)division)print_function)unicode_literals)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_profilesr2   6   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$ )ProfilePrinter^   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)superr4   Print)self	resourcessingleintermediate	__class__s       r   r8   ProfilePrinter.Printa   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   )r2   acceleratorOptionsr(   commentsr)   r+   )r9   responser,   s      r   	TransformProfilePrinter.Transforme   s8    #H$?$?@AHOOH%%&::h44r    )TF)	__name__
__module____qualname____firstlineno____doc__r8   rC   __static_attributes____classcell__)r=   s   @r   r4   r4   ^   s    EE5 5r   r4   N)rJ   
__future__r   r   r   r   googlecloudsdk.core.resourcer   r)   PROFILES_PRINTER_FORMATr   r   r2   CustomPrinterBaser4   rE   r   r   <module>rQ      sD    M &  % ' B $  /"%;P5R)) 5r   