
                             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SKJr  SSKJr  SSKJr  S	rS
 rS rS r\R*                  \R,                  " \R.                  R0                  5       " S S\
R2                  5      5       5       rg)zCLists compatible accelerator profiles for GKE Inference Quickstart.    )
exceptions)util)base)commands)profiles_csv_printer)profiles_printer_ga)resource_printerzx
To list compatible accelerator profiles for a model, run:

$ {command} --model=deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
c                 >    [        U 5      n[        X-
  S-  5      nX4$ )z5Converts a decimal representation to an Amount proto.    eA)int)decimal_valueunitsnanoss      )lib/surface/container/ai/profiles/list.pydecimal_to_amountr   "   s(     m
%
}$+
,%
    c                 X    U R                   nU(       d  SnXR                  S-  -   7nUS $ )z*Converts cost to a decimal representation.r   r   z.3fr   r   )costr   r   s      r   amount_to_decimalr   +   s2    
**%	EJJ,,--#r   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   4   sf     
uQx22)a++ 
uQx11(q)K)KL
	..r   c                   .    \ rS rSrSr\S 5       rS rSrg)ListE   a  List compatible accelerator profiles.

This command lists all supported accelerators with their performance details.
By default, the supported accelerators are displayed in a table format with
select information for each accelerator. To see all details, use
--format=yaml or --format=csvprofile.

To get supported model, model servers, and model server versions, run `gcloud
container ai profiles models list`, `gcloud container ai
profiles model-servers list`, and `gcloud container ai profiles
model-server-versions list`.
c                 z   U R                  SSS9  U R                  SSS9  U R                  SSS9  U R                  S[        S	S
9  U R                  S[        SS
9  U R                  S[        SSS9  U R                  S[        SSS9  U R                  SS[        SS9  U R                  SSS9  [        R
                  " [        R                  [        R                  5        [        R
                  " [        R                  [        R                  5        U R                  R                  [        R                  5        g )Nz--modelz
The model.)helpz--model-serverzThe model server version. Default is latest. Other options include the model server version of a profile, all which returns all versions.z--model-server-versionzPThe model server version. If not specified, this defaults to the latest version.z--target-ntpot-millisecondsa  The target normalized time per output token (NTPOT) in milliseconds. NTPOT is measured as the request_latency / output_tokens. If this field is set, the command will only return accelerators that can meet the target ntpot milliseconds and display their throughput performance at the target latency. Otherwise, the command will return all accelerators and display their highest throughput performance.)typer"   z--target-ttft-millisecondsax  The target time to first token (TTFT) in milliseconds. TTFT is measured as the request_latency / output_tokens. If this field is set, the command will only return profiles that can meet the target ttft milliseconds and display their throughput performance at the target latency. Otherwise, the command will return all profiles and display their highest throughput performance.z'--target-cost-per-million-output-tokensFzfThe target cost per million output tokens to filter profiles by, unit is 1 USD up to 5 decimal places.)r#   requiredr"   z&--target-cost-per-million-input-tokenszeThe target cost per million input tokens to filter profiles by, unit is 1 USD up to 5 decimal places.z--pricing-modelzsThe pricing model to use to calculate token cost. Currently, this supports on-demand, spot, 3-years-cud, 1-year-cud)r$   r#   r"   z--formatzThe output format. Default is profile, which displays the profile information in a table format, including cost conversions. csvprofile displays the profile information in a CSV format.Options include csvprofile, profile, and yaml. )add_argumentr   floatstrr	   RegisterFormatterprofiles_printerPROFILES_PRINTER_FORMATProfilePrinterr   ProfileCSVPrinterdisplay_info	AddFormat)parsers    r   Args	List.ArgsU   s~   
          %5	   $5	   15   05   A   F   &&00'' &&44.. !!"2"J"JKr   c                    [         R                  " [        R                  R                  5      n[         R
                  " [        R                  R                  5      nUR                  5       nUR                  (       a  UR                  Ul        UR                  (       a  UR                  Ul
        UR                  (       d"  UR                  (       d  UR                  (       a  UR                  5       nUR                  (       a+  [        UR                  5      u  pgUR!                  XgS9Ul        UR                  (       a+  [        UR                  5      u  pgUR!                  XgS9Ul        UR                  (       a  UR                  Ul        XTl         UR+                  UR,                  UR.                  UR0                  S9nUR                  c  UR                  c  UR(                  b  XHl        UR4                  R7                  U5      n	U	R8                  (       a  U	R8                  $ / $ ! [:        R<                   a*  n
[>        R@                  " U
[         RB                  5      eS n
A
ff = f)Nr   )modelmodelServermodelServerVersion)"r   GetClientInstancer   ReleaseTrackGAGetMessagesModulePerformanceRequirementstarget_ntpot_millisecondstargetNtpotMillisecondstarget_ttft_millisecondstargetTtftMilliseconds%target_cost_per_million_output_tokens$target_cost_per_million_input_tokenspricing_modelCostr   Amountr   r   pricingModel
targetCostFetchProfilesRequestr3   model_servermodel_server_versionperformanceRequirementsprofilesFetchprofileapitools_exceptions	HttpErrorr   HttpExceptionHTTP_ERROR_FORMAT)selfargsclientmessagesperformance_requirementsr   r   r   requestresponseerrors              r   RunList.Run   s   ##D$5$5$8$89F%%d&7&7&:&:;H'??A%%

(
( 6 $$

'
' 5
 	2244]]_d		3	3(66
 +3// +: +
' 
	2	2(55
 *2 *9 *
& 
		 ..,0)D--

''!66 . g #
:
:
F%<<H%00<*B'&&w/h				(( D$$UD,B,BCCDs   BH+ )H+ +I)?%I$$I) N)	__name__
__module____qualname____firstlineno____doc__staticmethodr0   rY   __static_attributes__r[   r   r   r   r   E   s&     [L [Lz8Dr   r   N)r`   apitools.base.pyr   rM   %googlecloudsdk.api_lib.ai.recommenderr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   googlecloudsdk.command_lib.runr   'googlecloudsdk.command_lib.run.printersr   r   r)   googlecloudsdk.core.resourcer	   	_EXAMPLESr   r   r   DefaultUniverseOnlyReleaseTracksr7   r8   r   r[   r   r   <module>rm      s    J > 6 2 ( 3 H [ 9	 /" D%%(()dD8== dD * dDr   