
                  	       ~   d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ  ej,                  dddd      Z ej,                  dd ej0                         ej2                  d      Z ej,                  ddd ej0                         ej2                  d      Z ej,                  ddd      Z ej,                  d ej:                  eeed !      d" ej>                  d#      $      Z  ej,                  d%d&dd'(      Z!d) Z"ejF                  fd*Z$y)+z4Flags definition specifically for gcloud ai ray job.    )absolute_import)division)unicode_literalsN)arg_parsers)base)concepts)	constants)flags)region_util)serverless_ray_jobs_util)labels_util)concept_parsersz--entrypointENTRYPOINT_FILE_URITz<The Ray job entrypoint Python file Google Cloud Storage URI.)metavarrequiredhelpz--entrypoint-file-argsARGz^Comma-separated arguments passed to Ray job python file. e.g. --entrypoint-file-args=arg1,arg2)r   typeactionr   z--archive-uriszComma-separated archive URIs that will be copy to the Ray nodes. e.g. --archive-uris=gs://test-bucket/test.tar.gz,gs://test-bucket/test2.tar.gz)r   hiddenr   r   r   z--container-image-uriCONTAINER_IMAGE_URIz7The container image URI to use for the Ray worker node.)r   r   z--resource-spec)zresource-unitz	disk-sizezmax-node-count)specRESOURCE_SPECa        Define the worker pool resource spec for the serverless ray job.

      The spec can contain the following fields:

      *resource-unit*::: Optional. Default to 1. Define how many compute resources(CPU, memory) on each worker node. By default we are using machine e2-standard series, and each resource unit allocates 4 vCPUs and 16GB memory. The resource-unit value can only be 1,2,4,8.
      *disk-size*::: Optional, default to 100. Disk size in GB on one worker node.
      *max-node-count*::: Optional, default to 2000. The max number of worker nodes this job can occupy while running.

      ::::
      Example:
      --resource-spec=resource-unit=2,disk-size=100,max-node-count=10
      )r   r   r   z--service-accountSERVICE_ACCOUNTzbThe service account to use for the Ray job. If not specified, the default service account is used.)r   r   r   c                    t        j                  | dt        j                  t        j
                               t        j                  d      j                  |        t        j                  |        t        j                  |        t        j                  |        t        j                  |        t        j                  |        t        j                  |        t        j                  |        y)z2Adds flags related to create a serverless ray job.zto create a serverless ray jobprompt_funcserverless ray jobN)shared_flagsAddRegionResourceArgr   GetPromptForRegionFuncr	   SUPPORTED_TRAINING_REGIONSGetDisplayNameArgAddToParserr   AddCreateLabelsFlags#_SERVERLESS_RAY_JOB_SERVICE_ACCOUNT_ENTRYPOINT_FILE_URI_RESOURCE_SPEC_ARCHIVE_URIS_ENTRYPOINT_JOB_FILE_ARGS_CONTAINER_IMAGE_URI)parsers    >lib/googlecloudsdk/command_lib/ai/serverless_ray_jobs/flags.pyAddCreateServerlessRayJobFlagsr.   j   s    ##&44

.
.   !56BB6J""6*%11&9""6*V$F#''/""6*    c           	      @   t        j                  t        j                  dt	        j
                  t        j                  |            t         j                  d      }t        j                  j                  d|dj                  |      d      j                  |        y	)
a:  Add a resource argument for a Vertex AI serverless ray job.

  NOTE: Must be used only if it's the only resource arg in the command.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the job resource, such as 'to update'.
    regions: list[str], the list of supported regions.
  r   r   F)resource_collectionresource_namelocationsId
projectsIddisable_auto_completersserverless_ray_jobzThe serverless ray job {}.T)r   N)r   ResourceSpecr   SERVERLESS_RAY_JOB_COLLECTIONr   RegionAttributeConfigr   r!    DEFAULT_PROJECT_ATTRIBUTE_CONFIGr   ConceptParserForResourceformatr$   )r,   verbregionsresource_specs       r-   AddServerlessRayJobResourceArgrA      s     ''2PP(44!88A ::#- ++"))$/	 , 
 Kr/   )%__doc__
__future__r   r   r   textwrapgooglecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   googlecloudsdk.command_lib.air	   r
   r   r   1googlecloudsdk.command_lib.ai.serverless_ray_jobsr   $googlecloudsdk.command_lib.util.argsr   (googlecloudsdk.command_lib.util.conceptsr   Argumentr'   ArgListUpdateActionr*   r)   r+   ArgDictintdedentr(   r&   r.   r"   rA    r/   r-   <module>rR      sZ   ; &  '  / ( 5 3 ? 5 V < D %t}}!	G	  *DMM				##	,	  				##	U
 %t}}!	B  			 !

 	 
 
2 '4dmm	,' #+, $>>r/   