
                             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rSSKrSSKJ	r
  SrS	 rS
 rS r " S S\
R                  5      rg)zCProfiles-specific printer and functions for generating CSV formats.    )absolute_import)division)print_function)unicode_literalsN)custom_printer_base
csvprofilec                 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      Clib/googlecloudsdk/command_lib/run/printers/profiles_csv_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   )costPerMillionOutputTokensr   costPerMillionInputTokens)costsoutput_token_costinput_token_costs      r   get_decimal_costr   (   sf     
uQx22)a++ 
uQx11(q)K)KL
	..r   c                    / n/ SQnUR                  U5        U  H  nUR                  (       d  M  UR                   H  n[        UR                  5      u  pVUR                  UR
                  UR                  R                  UR                  R                  UR                  R                  UR                  UR                  UR                  UR                  UU/nUR                  U5        M     M     U$ )z@Transforms profiles to a CSV format, including cost conversions.)zInstance TypezAccelerator Typez
Model NamezModel Server NamezModel Server VersionzOutput Tokens/sz
NTPOT (ms)z	TTFT (ms)QPSzCost/M Input TokenszCost/M Output Tokens)appendperformanceStatsr   r   instanceTypeacceleratorTypemodelServerInfomodelmodelServermodelServerVersionoutputTokensPerSecondntpotMillisecondsttftMillisecondsqueriesPerSecond)profilescsv_dataheaderprofilestatsr   r   rows           r   _transform_profilesr,   9   s    (& //&g++%.>JJ/
+   ####))##//##66''##""""
 	# , ( 
/r   c                   (    \ rS rSrSrS rSS jrSrg)ProfileCSVPrintera   z=Prints a service's profile in a custom human-readable format.c                     [        U5      $ )z7Transforms a List[TrafficTargetPair] into a CSV format.)r,   )selfr&   s     r   	TransformProfileCSVPrinter.Transformd   s    x((r   c                     [         R                  " [        R                  SS9nUR	                  U R                  U5      5        g)z3Overrides ResourcePrinter.Print to set single=True.
)lineterminatorN)csvwritersysstdout	writerowsr2   )r1   	resourcessingleintermediater8   s        r   PrintProfileCSVPrinter.Printh   s-    ZZ

48F
T^^I./r    N)TF)__name__
__module____qualname____firstlineno____doc__r2   r?   __static_attributes__rA   r   r   r.   r.   a   s    E)0r   r.   )rF   
__future__r   r   r   r   r7   r9   googlecloudsdk.core.resourcer   cpPROFILES_PRINTER_FORMATr   r   r,   CustomPrinterBaser.   rA   r   r   <module>rM      sJ    J &  % ' 
 
 B '  /"%P
0,, 
0r   