
    z             	       ^   S 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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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   \RB                  " S\
RD                  " S\RF                  SS9SSS9r$\RB                  " SSSSS 9r%\RB                  " S!SSS"S#9r&\RB                  " S$\RN                  " S%5      S&9r(\RB                  " S'\RN                  " S(5      S&9r)\RB                  " S)\RT                  " 5       S\RN                  " S*5      S+9r+\RB                  " S,SSS\RN                  " S-5      S.9r,\RB                  " S/SSS\RN                  " S05      S.9r-S1 r.SS2 jr/SS3 jr0SS4 jr1SS5 jr2 SS6 jr3SS7 jr4SS8 jr5S9 r6S: r7S; r8S< r9S= r:S> r;S? r<S@ r=SSA jr>SB r?SC r@SSD jrASSE jrBSF rCSG rDSH rESSI jrFSJ rGSK rHSL rISM rJSN rKSO rLSP rMSQ rNSR rOSS rPST rQSU rRSV rSSW rTSX rUSY rV\R                  4SZ jrXS[\R                  4S\ jrY\R                  4S] jrZS^ r[S_ r\\R                  4S` jr]\R                  4Sa jr^\R                  4Sb jr_Sc r`\R                  4Sd jraSSe jrbSf rcSg rdSSh jreSSi jrfSSj jrgSSk jrhSSl jriSSm jrjSn\R                  4So jrl\R                  4Sp jrmSq rnSr roSs\R                  4St jrp\R                  4Su jrqSv rrSSw jrsSx rtSy ruSz rvS{ rwS| rx SS} jrySS~ jrz SS jr{SS jr|S r}S r~S rS rSS jrSS jrS rS rS rS rS rS rS rS rS rSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrS rS rS rSS jrSS jrSS jrS rSS jrg)zFlag definitions for gcloud ai.    )absolute_import)division)unicode_literalsN)apis)arg_parsers)base)concepts)deps)	constants)errors)region_util)iam_util)resource_args)	arg_utils)concept_parsers)presentation_specs)
properties)	resourcesz--polling-interval   T	unlimited<   zKNumber of seconds to wait between efforts to fetch the latest log messages.typedefaulthelpz--allow-multiline-logs
store_trueFz0Output multiline log messages as single records.)actionr   r   z--task-namez7If set, display only the logs for this particular task.requiredr   r   	--networkz      Full name of the Google Compute Engine network to which the Job
      is peered with. Private services access must already have been configured.
      If unspecified, the Job is not peered with any network.
      r   --public-endpoint-enabledzT      If true, the deployed index will be accessible through public endpoint.
      --service-accountz      The email address of a service account to use when running the
      training appplication. You must have the `iam.serviceAccounts.actAs`
      permission for the specified service account.
      )r   r    r   z--enable-web-accessao        Whether you want Vertex AI to enable [interactive shell access](https://cloud.google.com/vertex-ai/docs/training/monitor-debug-interactive-shell)
      to training containers. If set to ``true'', you can access
      interactive shells at the URIs given by CustomJob.web_access_uris or
      Trial.web_access_uris (within HyperparameterTuningJob.trials).
      r   r    r   r   z--enable-dashboard-accessa        Whether you want Vertex AI to enable dashboard built on the training containers. If set to ``true'', you can access
      the dashboard at the URIs given by CustomJob.web_access_uris or
      Trial.web_access_uris (within HyperparameterTuningJob.trials).
      c                     [         R                  U 5        [        R                  U 5        [        R                  U 5        g N)_POLLING_INTERVAL_FLAGAddToParser
_TASK_NAME_ALLOW_MULTILINE_LOGSparsers    *lib/googlecloudsdk/command_lib/ai/flags.pyAddStreamLogsFlagsr/   u   s,    $$V, ##F+    c                 L   ^^ UU4S jnU R                   R                  U5        g)zAdds `--uri` flag to the parser object for list commands.

Args:
  parser: The argparse parser.
  collection: str, The resource collection name.
  api_version: str, The API version.
c                 v   > [         R                  R                  U R                  TTS9nUR	                  5       $ )N)
collectionapi_version)r   REGISTRYParseRelativeNamenameSelfLink)resourceupdatedr4   r3   s     r.   _GetResourceUri$AddUriFlags.<locals>._GetResourceUri   s:      22*+ 3 G r0   N)display_info
AddUriFunc)r-   r3   r4   r;   s    `` r.   AddUriFlagsr?   {   s     	  1r0   c                     U [         R                  :X  a&  [        R                  " SSSS9R	                  U5        g [        R                  " SSSS9R	                  U5        g )Nz--modelzID of the uploaded model.Tr   r    zVID of the uploaded model. The alpha and beta tracks also support GDC connected models.)r   
GA_VERSIONr   Argumentr)   )versionr-   s     r.   AddModelIdArgrE      sV    	$$$MM( k&MM%  k&r0   c                 .    [         R                  " SSU S9$ )Nz--deployed-model-idzId of the deployed model.rA   r   rC   r    s    r.   GetDeployedModelIdrI          	"=
 r0   c                 ,    [         R                  " SXS9$ )Nz--indexrA   rG   r    helper_texts     r.   GetIndexIdArgrN      s    	y{	FFr0   c                 ,    [         R                  " SXS9$ )Nz--index-endpointrA   rG   rL   s     r.   GetIndexEndpointIdArgrP      s     
)	OOr0   c                 .    [         R                  " SSU S9$ )Nz--deployed-index-idzId of the deployed index.rA   rG   rH   s    r.   GetDeployedIndexIdrR      rJ   r0   c                 H    [         R                  " SUSR                  U S9S9$ )N--display-namezDisplay name of the {noun}.nounr    r   r   rC   formatrV   r    s     r.   GetDisplayNameArgr[      s*    	(//T/:
 r0   c           	      J    [         R                  " SSS SR                  U S9S9$ )N--descriptionFzDescription of the {noun}.rU   r   rX   rU   s    r.   GetDescriptionArgr^      -    	'..D.9	
 r0   c           	      d    [         R                  " SR                  U S9SS SR                  U S9S9$ )Nz--{noun}-idrU   Fz User-specified ID of the {noun}.r   rX   rU   s    r.   GetUserSpecifiedIdArgra      s;    	%-44$4?	
 r0   c                  0    [         R                  " SSS SS9$ )Nr!   FzZThe full name of the Google Compute Engine network to which the endpoint should be peered.r   rG    r0   r.   GetEndpointNetworkArgrd      s    	k	
 r0   c                  0    [         R                  " SSS SS9$ )Nz--encryption-kms-key-nameFa3        The Cloud KMS resource identifier of the customer managed encryption key
      used to protect a resource. Has the form:
      projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key.

      The key needs to be in the same region as where the compute resource is
      created.
      r   rG   rc   r0   r.   GetEncryptionKmsKeyNameArgrf      s!    	!
	
 r0   c                  2    [         R                  " SSS SSS9$ )N--gdce-zoneFTH      The name of the GDCE zone. If set, the endpoint is in GDCE.
      )r    r   hiddenr   rG   rc   r0   r.   GetHiddenGdceZoneArgrk      s$    	

 r0   c                  0    [         R                  " SSS SS9$ )Nrh   Fri   r   rG   rc   r0   r.   GetGdceZoneArgrm      s!    	
	
 r0   c                  0    [         R                  " SSS SS9$ )Nz
--gdc-zoneFzH      The name of the GDC zone. If set, the endpoint is for GDCc.
      r   rG   rc   r0   r.   GetGdcZoneArgro      s!    	
	
 r0   c                     [         R                  " SSSSSS9R                  U 5        [         R                  " SSS[        R                  " 5       SS	9R                  U 5        g )
Nz --enable-private-service-connectFr   z@If true, expose the index endpoint via private service connect.
)r    r   r   r   z--project-allowlistPROJECTSzTList of projects from which the forwarding rule will target the service
attachment.
r    metavarr   r   )r   rC   r)   r   ArgListr,   s    r.   AddPrivateServiceConnectConfigru   
  s]    --( K-- 	 Kr0   c                 N    [         R                  " SUSS9R                  U 5        g)z7Add arguments for different types of predict instances.--json-requesta.        Path to a local file containing the body of a JSON request.

      An example of a JSON request:

          {
            "instances": [
              {"x": [1, 2], "y": [3, 4]},
              {"x": [-1, -2], "y": [-3, -4]}
            ]
          }

      This flag accepts "-" for stdin.
      rW   Nr   rC   r)   r-   r    s     r.   AddPredictInstanceArgrz   !  %    --
" Kr0   c                  .    [         R                  " SSSS9$ )z(Adds arguments for raw-predict requests.z	--requestTa        The request to send to the endpoint.

      If the request starts with the letter '*@*', the rest should be a file
      name to read the request from, or '*@-*' to read from *stdin*. If the
      request body actually starts with '*@*', it must be placed in a file.

      If required, the *Content-Type* header should also be set appropriately,
      particularly for binary data.
      rW   rG   rc   r0   r.   GetRawPredictRequestArgr}   7  s    		

 r0   c                  \    [         R                  " SS[        R                  " [        S9SS9$ )z,Adds arguments for raw-predict http headers.z--http-headerszHEADER=VALUE
value_typez      List of header and value pairs to send as part of the request. For
      example, to set the *Content-Type* and *X-Header*:

        --http-headers=Content-Type="application/json",X-Header=Value
      rs   r   r   )r   rC   r   ArgDictstrrc   r0   r.   GetRawPredictHeadersArgr   I  s,    	#.
	

 
r0   c                 N    [         R                  " SUSS9R                  U 5        g)z>Add arguments for different types of direct predict instances.rw   a`        Path to a local file containing the body of a JSON request.

      An example of a JSON request:

          {
            "inputs": [
              {"dtype": "STRING", shape: [1], "string_val": ["hello world"]},
              {"dtype": "INT32", shape: [1], "int_val": [42]}
            ]
          }

      This flag accepts "-" for stdin.
      rW   Nrx   ry   s     r.   AddDirectPredictInputsArgr   X  r{   r0   c                 N    [         R                  " SUSS9R                  U 5        g)zBAdd arguments for different types of direct raw predict instances.rw   a        Path to a local file containing the body of a JSON request.

      An example of a JSON request:

          {
            "method_name": "my.method.Predict",
            "input": "my request bytes"
          }

      This flag accepts "-" for stdin.
      rW   Nrx   ry   s     r.   AddDirectRawPredictInputArgr   n  s%    --
 Kr0   c                  z    [         R                  " SS[        R                  " [        S9[        R
                  SS9$ ) Add arguments for traffic split.--traffic-splitDEPLOYED_MODEL_ID=VALUEr   EList of pairs of deployed model id and value to set as traffic split.rs   r   r   r   )r   rC   r   r   intUpdateActionrc   r0   r.   GetTrafficSplitArgr     s5    	'#.%%	
 	r0   c                     U R                  SS9nUR                  SS[        R                  " [        S9[        R
                  SS9  UR                  SS	S
S9  g)r   FrH   r   r   r   r   r   z--clear-traffic-splitr   zkClears the traffic split map. If the map is empty, the endpoint is to not accept any traffic at the moment.)r   r   N)add_mutually_exclusive_groupadd_argumentr   r   r   r   )r-   groups     r.   AddTrafficSplitGroupArgsr     sj    

-
-u
-
=%'#.%%  	 8	  r0   c           	         U[         R                  :X  a  [        R                  " S[        R
                  " SSS9SS9R                  U 5        [        R                  " S[        R
                  " SSS9SS9R                  U 5        [        R                  " S	[        R                  " S
[        R                  SS9SS9R                  U 5        gg)z Add arguments for scale to zero.z--min-scaleup-period300s28800s)lower_boundupper_boundzMinimum duration (in seconds) that a deployment will be scaled up before traffic
is evaluated for potential scale-down.
Defaults to 1 hour if min replica count is 0.
r   r   z--idle-scaledown-periodzDuration (in seconds) without traffic before a deployment is scaled down to
zero replicas. Defaults to 1 hour if min replica count is 0.
z--initial-replica-countr   Tr   zInitial number of replicas for the deployment resources the model will be
scaled up to. Cannot be smaller than min replica count or larger than max
replica count.
N)
r   BETA_VERSIONr   rC   r   Durationr)   
BoundedIntsysmaxsize)r-   rD   s     r.   AddScaleToZeroArgsr     s    	&&&MM!!f(K k&MM!!!f(K k&MM!##As{{dC k&9 'r0   c                    U(       aH  [         R                  " S[        R                  " S[        R
                  SS9SS9R                  U 5        OG[         R                  " S[        R                  " S[        R
                  SS9SS9R                  U 5        [         R                  " S	[        R                  " SS
S9SS9R                  U 5        [         R                  " S[        R                  " S[        R
                  SS9SS9R                  U 5        [         R                  " SSS9R                  U 5        [         R                  " S[        R                  " [        [        [        R                  " 5       S.S/S9SS9R                  U 5        [         R                  " SSSSSS9R                  U 5        U[        R                  :X  aw  [         R                  " SSS9R                  U 5        [         R                  " S[        SS9R                  U 5        [         R                  " S [        SS!S"9R                  U 5        [         R                  " S#[        R                  " [        [        S$.S%/S9S&R                  S'R                  [        U5      R                    Vs/ s H  nS(R                  U5      PM     sn5      5      S9R                  U 5        g)s  snf )*z'Add arguments for prediction resources.--min-replica-countr   Tr   a    Minimum number of machine replicas for the deployment resources the
  model will be deployed on. If specified, the value must be equal to or
  larger than 1.

  If not specified and the uploaded models use dedicated resources, the
  default value is 1.
  r   r   a    Minimum number of machine replicas for the deployment resources the model will be
  deployed on. For normal deployments, the value must be equal to or larger than 1.
  If the value is 0, the deployment will be enrolled in the scale-to-zero feature.
  If not specified and the uploaded models use dedicated resources, the default
  value is 1.

  NOTE: DeploymentResourcePools (model-cohosting) is currently not supported for
  scale-to-zero deployments.
  --max-replica-counti   )r   z_Maximum number of machine replicas for the deployment resources the model will be
deployed on.
z--required-replica-countz  Required number of machine replicas for the deployment resources the model will
  be considered successfully deployed. This value must be greater than or equal
  to 1 and less than or equal to min-replica-count.
  --machine-typeThe machine resources to be used for each node of this deployment.
For available machine types, see
https://cloud.google.com/ai-platform-unified/docs/predictions/machine-types.
r"   z--reservation-affinity)reservation-affinity-typekeyvaluesr   specrequired_keyszA ReservationAffinity can be used to configure a Vertex AI resource (e.g., a
DeployedModel) to draw its Compute Engine resources from a Shared Reservation,
or exclusively from on-demand capacity.
z--spotr   Fz7If true, schedule the deployment workload on Spot VMs.
r   r   r    r   z--tpu-topologyzCloudTPU topology to use for this deployment. Required for multihost
CloudTPU deployments:
https://cloud.google.com/kubernetes-engine/docs/concepts/tpus#topology.
z--multihost-gpu-node-countzgThe number of nodes per replica for multihost GPU deployments. Required for
multihost GPU deployments.
z--gpu-partition-sizezThe partition size of the GPU accelerator. This can be used to partition a
single GPU into multiple smaller GPU instances.
See https://cloud.google.com/kubernetes-engine/docs/how-to/gpus-multi#multi-instance_gpu_partitions for more details.
)r   rj   r   z--accelerator)r   countr   a  Manage the accelerator config for GPU serving. When deploying a model with
Compute Engine Machine Types, a GPU accelerator may also
be selected.

*type*::: The type of the accelerator. Choices are {}.

*count*::: The number of accelerators to attach to each machine running the job.
 This is usually 1. If not specified, the default value is 1.

For example:
`--accelerator=type=nvidia-tesla-k80,count=1`, '{}'N)r   rC   r   r   r   r   r)   r   r   rt   r   r   r   rY   joinGetAcceleratorTypeMapperchoices)r-   rD   drpcs       r.   AddPredictionResourcesArgsr     sr    	MM##As{{dC k&MM##As{{dC	 k&--!!!6 K-- !!!S[[DA K-- K--+.#++-
 55 K-- K	&&&MM k&MM$ k&MM		 k&--  1 28
))/8@@@! mmA@ 2)4 Ks   "Kc                  T   [         R                  " SS[        R                  " [        [
        S9[        R                  SR                  SR                  [        [        R                  R                  5       5       V s/ s H  n SR                  U 5      PM     sn 5      5      S9$ s  sn f )z+Add arguments for autoscaling metric specs.z--autoscaling-metric-specszMETRIC-NAME=TARGET)key_typer   a?  Metric specifications that control autoscaling behavior. At most one entry is
allowed per metric.

*METRIC-NAME*::: Resource metric name. Choices are {}.

*TARGET*::: Target value for the given metric. For `cpu-usage` and
`gpu-duty-cycle`, the target is the target resource utilization in percentage
(1% - 100%). For `request-counts-per-minute`, the target is the number of
requests per minute per replica.

For example, to set target CPU usage to 70% and target requests to 600 per
minute per replica:
`--autoscaling-metric-specs=cpu-usage=70,request-counts-per-minute=600`
r   r   r   )r   rC   r   r   r   r   r   rY   r   sortedr   !OP_AUTOSCALING_METRIC_NAME_MAPPERkeys)r   s    r.   GetAutoscalingMetricSpecsArgr   [  s    	""<%% F
))==BBD! mmA '
 (s   =B%c           	      h   [         R                  " S[        R                  " S[        R
                  SS9SR                  U5      S9R                  U 5        [         R                  " S[        SR                  U5      S9R                  U 5        [         R                  " S	S
S9R                  U 5        g)z+Add arguments for the deployment resources.r   r   Tr   zMinimum number of machine replicas the {} will be always deployed
on. If specified, the value must be equal to or larger than 1.
r   r   zEMaximum number of machine replicas the {} will be always deployed on.r   r   r"   N)	r   rC   r   r   r   r   rY   r)   r   r-   resource_types     r.   AddDeploymentResourcesArgsr   {  s    --!!!S[[DA F= K--  &} 5 K-- Kr0   c                     [         R                  " SS[        R                  " 5       SR	                  U5      S9R                  U 5        g)z)Add arguments for the reserved IP ranges.z--reserved-ip-rangesRESERVED_IP_RANGESz2List of reserved IP ranges {} will be deployed to.r   Nr   rC   r   rt   rY   r)   r   s     r.   AddReservedIpRangesArgsr     s=    --" 
>
E
E	 Kr0   c                 t    [         R                  " S[        SR                  U5      S9R	                  U 5        g)z&Add arguments for the encryption spec.--kms-key-namea  Cloud KMS resource identifier of the customer managed encryption key used to
protect a {}. Has the form:
`projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`.
Key needs to be in the same region as where the compute resource is created
r   N)r   rC   r   rY   r)   r   s     r.   AddEncryptionSpecArgr     s1    --
 F=	 Kr0   c                 X    [         R                  " SS[        SS9R                  U 5        g)z#Add arguments for deployment group.z--deployment-groupDEPLOYMENT_GROUPab  Deployment group can be no longer than 64 characters (eg:`test`, `prod`).
If not set, we will use the `default` deployment group.

Creating deployment_groups with `reserved_ip_ranges` is a recommended practice
when the peered network has multiple peering ranges.This creates your
deployments from predictable IP spaces for easier traffic administration.
r   N)r   rC   r   r)   r,   s    r.   AddDeploymentGroupArgr     s(    -- 	 Kr0   c                 $   [         R                  " SS[        R                  " 5       SR	                  U5      S9R                  U 5        [         R                  " SS[        R                  " 5       SR	                  U5      S9R                  U 5        g)	z Add arguments for auth provider.z--audiences	AUDIENCESzList of JWT audiences that are allowed to access a {}.

JWT containing any of these audiences
(https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section -4.1.3)
will be accepted.
r   z--allowed-issuersALLOWED_ISSUERSzList of allowed JWT issuers for a {}.

Each entry must be a valid Google service account, in the following format:
`service-account-name@project-id.iam.gserviceaccount.com`
Nr   r   s     r.   AddAuthConfigArgsr     sx    --  VM K-- 
 VM
 Kr0   c                     [         R                  " S[        R                  " [        [        S.SS/S9SSSS	9R                  U 5        g
)z(Add arguments for PSC automation config.z--psc-automation-configs)
project-idnetworkr   r   r   appendFaT  A pair of `project-id` and `network` the PSC index will be deployed to. For
example: `--psc-automation-configs=project-id=my-project,network=my-network`.
For multiple networks, this flag can be repeated:
`--psc-automation-configs=project-id=my-project,network=my-network --psc-automation-configs=project-id=my-project2,network=my-network2`
)r   r   r    r   N)r   rC   r   r   r   r)   r,   s    r.   AddPscAutomationConfigsArgsr     sH    -- !c2%y1  Kr0   c                  2    [         R                  " SSSSSS9$ )Nz--enable-access-loggingr   FzIf true, online prediction access logs are sent to Cloud Logging.

These logs are standard server access logs, containing information like
timestamp and latency for each prediction request.
r   rG   rc   r0   r.   GetEnableAccessLoggingArgr     s$    	
 r0   c                  2    [         R                  " SSSSSS9$ )Nz--enable-container-loggingr   FzIf true, the container of the deployed model instances will send `stderr` and
`stdout` streams to Cloud Logging.

Currently, only supported for custom-trained Models and AutoML Tabular Models.
r   rG   rc   r0   r.   GetEnableContainerLoggingArgr     s$    	"
 r0   c                  2    [         R                  " SSSSSS9$ )Nz--disable-container-loggingr   Fal  For custom-trained Models and AutoML Tabular Models, the container of the
deployed model instances will send `stderr` and `stdout` streams to
Cloud Logging by default. Please note that the logs incur cost,
which are subject to [Cloud Logging
pricing](https://cloud.google.com/stackdriver/pricing).

User can disable container logging by setting this flag to true.
r   rG   rc   r0   r.   GetDisableContainerLoggingArgr     s$    	#
 r0   c                  0    [         R                  " SSS SS9$ )Nz --request-response-logging-tableFzBigQuery table uri for prediction request & response logging.

You can provide table uri that does not exist, it will be created for you.

Value should be provided in format: bq://``PROJECT_ID''/``DATASET''/``TABLE''
r   rG   rc   r0   r.   !GetRequestResponseLoggingTableArgr   %  s!    	(	
 r0   c                  :    [         R                  " SSS [        SS9$ )Nz--request-response-logging-rateFzJPrediction request & response sampling rate for logging to BigQuery table.)r    r   r   r   r   rC   floatrc   r0   r.    GetRequestResponseLoggingRateArgr   4  s"    	'[
 r0   c                  2    [         R                  " SSSSSS9$ )Nz"--disable-request-response-loggingr   Fz.Disable prediction request & response logging.r%   rG   rc   r0   r.   #GetDisableRequestResponseLoggingArgr   >  s"    	*?
 r0   c                     U R                  SS9n[        5       R                  U5        [        5       R                  U5        g)z:Adds arguments for request-response logging configuration.FrH   N)	add_groupr   r)   r   )r-   logging_config_groups     r.   (AddRequestResponseLoggingConfigGroupArgsr   H  s:    ))5)9#%112FG"$001EFr0   c                 j    U R                  SS9n[        5       R                  U5        [        U5        g)zAAdds arguments for update request-response logging configuration.FrH   N)r   r   r)   r   )r-   logging_update_groups     r.   .AddRequestResponseLoggingConfigUpdateGroupArgsr   O  s1    <<e<L%'334HI*+?@r0   c                  .    [         R                  " SSSS9$ )Nr$   FzService account that the deployed model's container runs as. Specify the
email address of the service account. If this service account is not
specified, the container runs as a service account that doesn't have access
to the resource project.
rW   rG   rc   r0   r.   GetServiceAccountArgr   V  s    		
 	r0   c                     [         R                  " SS[        R                  " S5      [        R                  " [
        R                  R                  R                  5      [        R                  " U SS9/S9$ )Nregionz Cloud region for the {resource}.--regionz6choose one from the prompted list of available regions)functionhint)r7   	help_textfallthroughs)
r	    ResourceParameterAttributeConfigr
   ArgFallthroughPropertyFallthroughr   VALUESair   Fallthroughprompt_funcs    r.   RegionAttributeConfigr   c  sb    		2	22


j
)

"
":#4#4#7#7#>#>
?


"K
 r0   modelc           	      \    [         R                  " SU [         R                  [        US9SS9$ )Nz$aiplatform.projects.locations.modelsr   Fresource_name
projectsIdlocationsIddisable_auto_completers)r	   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIGr   r   r   s     r.   GetModelResourceSpecr  r  s1     
		,!::'K@#
 r0   c                     [         R                  " SS[        US9[         R                  S9n[        R
                  R                  SUSR                  U5      SS9R                  U 5        g	)
au  Add a resource argument for a Vertex AI region.

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 resource, such as 'to update'.
  prompt_func: function, the function to prompt a list of available regions
    and return a string of the region that is selected by user.
zaiplatform.projects.locationsr   r   )r   r  r   r   zCloud region {}.TrH   N)	r	   r  r   r  r   ConceptParserForResourcerY   r)   )r-   verbr   region_resource_specs       r.   AddRegionResourceArgr  ~  sj     "..%'K@::	 ++%	 , 
 Kr0   c                  z    [         R                  " [        R                  S[         R                  [        5       SS9$ )N	operationFr   )r	   r  r   DEFAULT_OPERATION_COLLECTIONr  r   rc   r0   r.   GetDefaultOperationResourceSpecr    s3    			,,::')#
 r0   c                 v    Sn[         R                  R                  U[        5       SSS9R	                  U 5        g)z2Add a resource argument for a Vertex AI operation.r  zThe ID of the operation.TrH   N)r   r  r	  r  r)   )r-   r   s     r.   AddOperationResourceArgr    s;    -++%' 	 , 
 Kr0   c                     Sn[         R                  R                  U[        US9SR	                  U5      SS9R                  U 5        g)a  Add a resource argument for a Vertex AI model.

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 resource, such as 'to update'.
  prompt_func: function, the function to prompt for region from list of
    available regions which returns a string for the region selected. Default
    is region_util.PromptForRegion which contains three regions,
    'us-central1', 'europe-west4', and 'asia-east1'.
r   r   z	Model {}.TrH   Nr   r  r	  r  rY   r)   r-   r
  r   r7   s       r.   AddModelResourceArgr    sJ     
$++
{3	 , 
 Kr0   c                     Sn[         R                  R                  U[        US9SR	                  U5      SS9R                  U 5        g)a  Add a resource argument for a Vertex AI model version.

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 resource, such as 'to update'.
  prompt_func: function, the function to prompt for region from list of
    available regions which returns a string for the region selected. Default
    is region_util.PromptForRegion which contains three regions,
    'us-central1', 'europe-west4', and 'asia-east1'.
model_versionr   zModel version {}.TrH   Nr  r  s       r.   AddModelVersionResourceArgr    sJ     
$++
{3  &	 , 
 Kr0   c           
         [        U SUS9  [        R                  " SSSS9R                  U 5        [        R                  " SSS	S9R                  U 5        [        R                  " S
SSS9R                  U 5        [        R                  " SSSS9R                  U 5        [        R                  " SSS9R                  U 5        U R	                  SS[
        R                  " 5       [
        R                  SS9  U R	                  S[
        R                  " 5       S[
        R                  SS9  U R	                  SS[
        R                  " 5       SS9  U R	                  SS[
        R                  " [
        R                  " SS 5      S!9[
        R                  S"S9  U R	                  S#S[
        R                  " [
        R                  " SS 5      S!9[
        R                  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.[
        R                  " 5       S/S0S19  U R	                  S2[        S3S+9  U R	                  S4[        S5S+9  U R	                  S6[
        R                  " 5       S7S8S19  U R	                  S9[        S:S+9  U R	                  S;[        S<S+9  U R	                  S=S>S9  U R	                  S?S@S9  U R	                  SA[        SBS+9  U R	                  SC[        SDS+9  U R	                  SE[        SFS+9  U R	                  SG[        SHS+9  U R	                  SIS[
        R                  " 5       [
        R                  SJS9  U R	                  SK[        SLS+9  U R	                  SM[        SNS+9  U R	                  SOSP[
        R                  " 5       [
        R                  SQS9  U R	                  SRS[
        R                  " 5       [
        R                  SSS9  gT)UaU  Adds flags for UploadModel.

Args:
  parser: the parser for the command.
  prompt_func: function, the function to prompt for region from list of
    available regions which returns a string for the region selected. Default
    is region_util.PromptForRegion which contains three regions,
    'us-central1', 'europe-west4', and 'asia-east1'.
zto upload modelr   rT   TzDisplay name of the model.rW   r]   FzDescription of the model.z--version-descriptionz!Description of the model version.z--container-image-uriziURI of the Model serving container file in the Container Registry
(e.g. gcr.io/myproject/server:latest).
z--artifact-urizUPath to the directory containing the Model artifact and any of its
supporting files.
r"   z--container-env-vars	KEY=VALUEz8List of key-value pairs to set as environment variables.r   z--container-commandCOMMANDzgEntrypoint for the container image. If not specified, the container
image's default entrypoint is run.
)r   rs   r   r   z--container-argsARGzComma-separated arguments passed to the command run by the container
image. If not specified and no `--command` is provided, the container
image's default command is used.
r   z--container-portsPORTr   i  )element_typez^Container ports to receive http requests at. Must be a number between 1 and
65535, inclusive.
z--container-grpc-portsz^Container ports to receive grpc requests at. Must be a number between 1 and
65535, inclusive.
z--container-predict-routez>HTTP path to send prediction requests to inside the container.z--container-health-routez8HTTP path to send health checks to inside the container.z&--container-deployment-timeout-secondszDeployment timeout in seconds.r   z!--container-shared-memory-size-mbzZThe amount of the VM memory to reserve as the shared memory for the model in
megabytes.
  z--container-startup-probe-execSTARTUP_PROBE_EXECzzExec specifies the action to take. Used by startup probe. An example of this
argument would be ["cat", "/tmp/healthy"].
  )r   rs   r   z(--container-startup-probe-period-secondszbHow often (in seconds) to perform the startup probe. Default to 10 seconds.
Minimum value is 1.
  z)--container-startup-probe-timeout-secondszgNumber of seconds after which the startup probe times out. Defaults to 1 second.
Minimum value is 1.
  z--container-health-probe-execHEALTH_PROBE_EXECzyExec specifies the action to take. Used by health probe. An example of this
argument would be ["cat", "/tmp/healthy"].
  z'--container-health-probe-period-secondszaHow often (in seconds) to perform the health probe. Default to 10 seconds.
Minimum value is 1.
  z(--container-health-probe-timeout-secondszfNumber of seconds after which the health probe times out. Defaults to 1 second.
Minimum value is 1.
  z--explanation-methodzfMethod used for explanation. Accepted values are `integrated-gradients`, `xrai` and `sampled-shapley`.z--explanation-metadata-filezmPath to a local JSON file that contains the metadata describing the Model's input and output for explanation.z--explanation-step-countzANumber of steps to approximate the path integral for explanation.z--explanation-path-countzaNumber of feature permutations to consider when approximating the Shapley values for explanation.z --smooth-grad-noisy-sample-countzNumber of gradient samples used for approximation at explanation. Only applicable to explanation method `integrated-gradients` or `xrai`.z--smooth-grad-noise-sigmazSingle float value used to add noise to all the features for explanation. Only applicable to explanation method `integrated-gradients` or `xrai`.z$--smooth-grad-noise-sigma-by-featurea	  Noise sigma by features for explanation. Noise sigma represents the standard deviation of the gaussian kernel that will be used to add noise to interpolated inputs prior to computing gradients. Only applicable to explanation method `integrated-gradients` or `xrai`.z--parent-modelzResource name of the model into which to upload the version. Only specify this field when uploading a new version.

Value should be provided in format: projects/``PROJECT_ID''/locations/``REGION''/models/``PARENT_MODEL_ID''
z
--model-idzcID to use for the uploaded Model, which will become the final component of the model resource name.z--version-aliasesVERSION_ALIASESzAliases used to reference a model version instead of auto-generated version ID. The aliases mentioned in the flag will replace the aliases set in the model.z--labelsaJ  Labels with user-defined metadata to organize your Models.

Label keys and values can be no longer than 64 characters
(Unicode codepoints), can only contain lowercase letters, numeric
characters, underscores and dashes. International characters are allowed.

See https://goo.gl/xmQnxf for more information and examples of labels.
N)r  r   rC   r)   r   r   r   r   rt   r   r   r   r   )r-   r   s     r.   AddUploadModelFlagsr#    s    v0kJ--,HK--,GK--. K-- K-- K %%E   	 %%  	 	 	  	 	K,B,B1e,LM%%  	 	K,B,B1e,LM%%  	 	!K   	 E   	.+  
 	)   	& "	   	0   	1   	% !	   	/   	0   	C   	#7   	 N  
 	 -	   	(	   	!/	   	, %%P   	   	3	   	 %%'  
 	 %%  r0   c                    [         R                  " SS[        R                  " 5       SS9R	                  U 5        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9  g)zgAdds flags for example-based explanation for UploadModel.

Args:
  parser: the parser for the command.
z--urisURISzyCloud Storage bucket paths where training data is stored. Should be used only
when the explanation method is `examples`.
r   z--explanation-neighbor-countzxThe number of items to return when querying for examples. Should be used only when the explanation method is `examples`.r   z--explanation-modalityMODALITY_UNSPECIFIEDa.  Preset option specifying the modality of the uploaded model, which automatically configures the distance measurement and feature normalization for the underlying example index and queries. Accepted values are `IMAGE`, `TEXT` and `TABULAR`. Should be used only when the explanation method is `examples`.r   z--explanation-queryPRECISEzPreset option controlling parameters for query speed-precision trade-off. Accepted values are `PRECISE` and `FAST`. Should be used only when the explanation method is `examples`.z1--explanation-nearest-neighbor-search-config-filea  Path to a local JSON file that contains the configuration for the generated index,
the semantics are the same as metadata and should match NearestNeighborSearchConfig.
If you specify this parameter, no need to use `explanation-modality` and `explanation-query` for preset.
Should be used only when the explanation method is `examples`.

An example of a JSON config file:

    {
    "contentsDeltaUri": "",
    "config": {
        "dimensions": 50,
        "approximateNeighborsCount": 10,
        "distanceMeasureType": "SQUARED_L2_DISTANCE",
        "featureNormType": "NONE",
        "algorithmConfig": {
            "treeAhConfig": {
                "leafNodeEmbeddingCount": 1000,
                "leafNodesToSearchPercent": 100
            }
        }
      }
    }
r"   N)r   rC   r   rt   r)   r   r   r   r,   s    r.    AddUploadModelFlagsForSimilarityr(    s     -- 	 K$B	   	$=   	=  	 	9  r0   c                    [        U SUS9  [        R                  " SSSS9R                  U 5        [        R                  " SSS	9R                  U 5        U R	                  S
S9nUR                  S[        SS9  UR                  S[        SS9  g)zAdds flags for AddCopyModelFlags.

Args:
  parser: the parser for the command.
  prompt_func: function, the function to prompt a list of available regions
    and return a string of the region that is selected by user.
zto copy the model intor   z--source-modelTzThe resource name of the Model to copy. That Model must be in the same Project.
Format: `projects/{project}/locations/{location}/models/{model}`.
rW   r   a  The Cloud KMS resource identifier of the customer managed encryption key
used to protect the resource.
Has the form:
`projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`.
The key needs to be in the same region as the destination region of the model to be copied.
r"   FrH   z--destination-model-idzCopy source_model into a new Model with this ID. The ID will become the final component of the model resource name.
This value may be up to 63 characters, and valid characters are `[a-z0-9_-]`. The first character cannot be a number or hyphen.
r   z--destination-parent-modelzSpecify this field to copy source_model into this existing Model as a new version.
Format: `projects/{project}/locations/{location}/models/{model}`.
N)r  r   rC   r)   r   r   r   )r-   r   r   s      r.   AddCopyModelFlagsr*  (  s     &K -- K--	 K

-
-u
-
=%   "  r0   c                 H    [         R                  " SUSR                  U S9S9$ )Nz--metadata-filez]Path to a local JSON file that contains the additional metadata information about the {noun}.rU   rW   rX   rZ   s     r.   GetMetadataFilePathArgr,  [  s*    	++16t6+<
 r0   c                 H    [         R                  " SSSR                  U S9S9$ )Nz--metadata-schema-uriFzdPoints to a YAML file stored on Google Cloud Storage describing additional information about {noun}.rU   rW   rX   rU   s    r.   GetMetadataSchemaUriArgr.  f  s*    	228&d&2C
 r0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a Vertex AI index.

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 resource, such as 'to update'.
indexz	Index {}.TrH   N)r   r  r	  GetIndexResourceSpecrY   r)   r-   r
  s     r.   AddIndexResourceArgr3  q  s?     ++#%{'9'9$'?$ , Kr0   c           
          [         R                  " [        R                  U [         R                  [        [        R                  " [        R                  5      S9SS9$ Nr   Fr   )	r	   r  r   INDEXES_COLLECTIONr  r   r   GetPromptForRegionFuncSUPPORTED_OP_REGIONSr   s    r.   r1  r1    sN    			""!::'!88,,
 $

 
r0   c                     UR                  US9n[        U 5      R                  U5        [        U 5      R                  U5        g)z>Add datapoint source group to the parser for StreamUpdate API.rH   N)r   GetDatapointsFilePathArgr)   GetIndexDatapointIdsArg)rV   r-   r    datapoint_source_groups       r.   &AddDatapointSourceGroupForStreamUpdater>    sE    !>> ?  4 ,,-CD$++,BCr0   c                 H    [         R                  " SUSR                  U S9S9$ )Nz--datapoints-from-filez\Path to a local JSON file that contains the data points that need to be added to the {noun}.rU   rW   rX   rZ   s     r.   r;  r;    s*    	%%+VV%6
 r0   c                 X    [         R                  " SU S[        R                  " 5       SS9$ )Nz--update-maskUPDATE_MASK_PATHa=  Update mask is used to specify the fields to be
overwritten in the datapoints by the update. The fields specified in the
update_mask are relative to each IndexDatapoint inside datapoints, not
the full request.

Updatable fields:
* Use --update-mask=`all_restricts` to update both `restricts` and `numeric_restricts`.
rr   r   rC   r   rt   rH   s    r.   GetDynamicMetadataUpdateMaskArgrC    s-    	  
 r0   c           
      r    [         R                  " SUS[        R                  " 5       SR	                  U S9S9$ )Nz--datapoint-idsDATAPOINT_IDSz:List of index datapoint ids to be removed from the {noun}.rU   rr   )r   rC   r   rt   rY   rZ   s     r.   r<  r<    s?    	 GNN O 
 r0   c                 6    [         R                  " SU SSS.SS9$ )Nz--index-update-methodzkcan update datapoints with `upsert-datapoints` and`delete-datapoints` and will be applied nearly real-time.zXcan update index with `gcloud ai indexes update` usingdatapoints files on Cloud Storage.)zstream-updatezbatch-updatezThe update method to use with this index. Choose `stream-update` or
`batch-update` (case insensitive). If not set, batch update will be used by default.
)r    r   help_str)r   ChoiceArgumentrH   s    r.   GetIndexUpdateMethodrI    s0    			J3	
 r0   deployment_resource_poolc           	      x    [         R                  " [        R                  U [         R                  [        US9SS9$ r5  )r	   r  r   $DEPLOYMENT_RESOURCE_POOLS_COLLECTIONr  r   r  s     r.   %GetDeploymentResourcePoolResourceSpecrM    s7     
		44!::'K@#
 r0   c                     [         R                  R                  S[        US9SR	                  U5      SS9R                  U 5        g)a  Add a resource argument for a Vertex AI deployment resource pool.

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 resource, such as 'to update'.
  prompt_func: function, the function to prompt for region from list of
    available regions. Default is
    region_util.PromptForDeploymentResourcePoolSupportedRegion
rJ  r    The deployment resource pool {}.TrH   N)r   r  r	  rM  rY   r)   r-   r
  r   s      r.   AddDeploymentResourcePoolArgrQ    sE      ++ +D(//5	 , 
 Kr0   c           	          [         R                  " [        R                  " S[	        5       SR                  U5      SS9/5      R                  U 5        g )Nz--shared-resourcesrO  T)prefixes)r   r  r   ResourcePresentationSpecrM  rY   r)   r2  s     r.   AddSharedResourcesArgrU    sI    11

/
1
,
3
3D
9	!  [r0   c                  ,    [         R                  " SSS9$ )Nr7   zThe endpoint's id.r"   rG   rc   r0   r.   GetEndpointIdrW    s    	v$8	99r0   endpointc           	      x    [         R                  " [        R                  U [         R                  [        US9SS9$ r5  )r	   r  r   ENDPOINTS_COLLECTIONr  r   r  s     r.   GetEndpointResourceSpecr[    s7     
		$$!::'K@#
 r0   c                     [         R                  R                  S[        US9SR	                  U5      SS9R                  U 5        g)a  Add a resource argument for a Vertex AI endpoint.

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 resource, such as 'to update'.
  prompt_func: function, the function to prompt for region from list of
    available regions. Default is region_util.PromptForRegion which contains
    three regions, 'us-central1', 'europe-west4', and 'asia-east1'.
rX  r   zThe endpoint {}.TrH   N)r   r  r	  r[  rY   r)   rP  s      r.   AddEndpointResourceArgr]    sE     +++6%	 , 
 Kr0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a Vertex AI index endpoint.

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 resource, such as 'to update'.
index_endpointzThe index endpoint {}.TrH   N)r   r  r	  GetIndexEndpointResourceSpecrY   r)   r2  s     r.   AddIndexEndpointResourceArgra  *  sC     ++"$%%d+	 , 
 Kr0   c           
          [         R                  " [        R                  U [         R                  [        [        R                  " [        R                  5      S9SS9$ r5  )	r	   r  r   INDEX_ENDPOINTS_COLLECTIONr  r   r   r7  r8  r9  s    r.   r`  r`  ;  sN    			**!::'!88,,
 $

 
r0   c                  ,    [         R                  " SSS9$ )zAdd arguments for VPC network.r!   za
      The Google Compute Engine network name to which the IndexEndpoint should be peered.
      r"   rG   rc   r0   r.   GetNetworkArgre  J  s    	

 r0   c                  2    [         R                  " SSSSSS9$ )z*Add arguments for public endpoint enabled.r#   r   FzU
      If true, the deployed index will be accessible through public endpoint.
      r%   rG   rc   r0   r.   GetPublicEndpointEnabledArgrg  T  s$    	!

 r0   c                  ,    [         R                  " SSS9$ )Nztensorboard-run-idz-ID of the tensorboard run for the {resource}.r7   r   r	   r   rc   r0   r.   TensorboardRunAttributeConfigrk  a  s    		2	2?
 r0   c                  ,    [         R                  " SSS9$ )Nztensorboard-experiment-idz4ID of the tensorboard experiment for the {resource}.ri  rj  rc   r0   r.   $TensorboardExperimentAttributeConfigrm  h  s    		2	2&F
 r0   c                  ,    [         R                  " SSS9$ )Nztensorboard-idz)ID of the tensorboard for the {resource}.ri  rj  rc   r0   r.   TensorboardAttributeConfigro  o  s    		2	2;
 r0   c                     [         R                  " [        R                  U [	        5       [        5       [        5       [         R                  [        5       SS9$ )NF)r   tensorboardsIdexperimentsIdrunsIdr   r  r  )	r	   r  r   "TENSORBOARD_TIME_SERIES_COLLECTIONro  rm  rk  r  r   r9  s    r.   $GetTensorboardTimeSeriesResourceSpecru  v  sG     
		22!/18:*,::')#	
 	r0   c           
          [         R                  " [        R                  U [	        5       [        5       [         R                  [        5       SS9$ )NF)r   rq  rr  r   r  r  )r	   r  r   TENSORBOARD_RUNS_COLLECTIONro  rm  r  r   r9  s    r.   GetTensorboardRunResourceSpecrx    s?    			++!/18:::')#
 r0   c           	          [         R                  " [        R                  U [	        5       [         R
                  [        5       SS9$ )NF)r   rq  r   r  r  )r	   r  r   "TENSORBOARD_EXPERIMENTS_COLLECTIONro  r  r   r9  s    r.   $GetTensorboardExperimentResourceSpecr{    s;     
		22!/1::')#
 r0   c                 z    [         R                  " [        R                  U [         R                  [        5       SS9$ )NFr   )r	   r  r   TENSORBOARDS_COLLECTIONr  r   r9  s    r.   GetTensorboardResourceSpecr~    s3    			''!::')#
 r0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a Vertex AI Tensorboard time series.

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 resource, such as 'to update'.
tensorboard_time_serieszThe Tensorboard time series {}.TrH   N)r   r  r	  ru  rY   r)   r2  s     r.   #AddTensorboardTimeSeriesResourceArgr    sC     ++*,'..t4	 , 
 Kr0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a Vertex AI Tensorboard run.

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 resource, such as 'to update'.
tensorboard_runzThe Tensorboard run {}.TrH   N)r   r  r	  rx  rY   r)   r2  s     r.   AddTensorboardRunResourceArgr    sC     ++#%&&t,	 , 
 Kr0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a Vertex AI Tensorboard experiment.

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 resource, such as 'to update'.
tensorboard_experimentzThe Tensorboard experiment {}.TrH   N)r   r  r	  r{  rY   r)   r2  s     r.   #AddTensorboardExperimentResourceArgr    sC     ++*,&--d3	 , 
 Kr0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a Vertex AI Tensorboard.

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 resource, such as 'to update'.
tensorboardzThe tensorboard {}.TrH   N)r   r  r	  r~  rY   r)   r2  s     r.   AddTensorboardResourceArgr    sC     ++ """4(	 , 
 Kr0   c                 .    [         R                  " SSU S9$ )Nz--tensorboard-experiment-idz!Id of the Tensorboard experiment.rA   rG   rH   s    r.   GetTensorboardExperimentIdArgr    s    	#.
 r0   c                 .    [         R                  " SSU S9$ )Nz--tensorboard-run-idzID of the Tensorboard run.rA   rG   rH   s    r.   GetTensorboardRunIdArgr    s    	'
 r0   c           	      J    [         R                  " SSS SR                  U S9S9$ )Nz--plugin-nameFzPlugin name of the {noun}.rU   r   rX   rU   s    r.   GetPluginNameArgr    r_   r0   c           	      J    [         R                  " SSS SR                  U S9S9$ )Nz--plugin-dataFzPlugin data of the {noun}.rU   r   rX   rU   s    r.   GetPluginDataArgr    r_   r0   c                  6    [         R                  " S[        SS9$ )Nz--max-data-pointsz8Max data points to read from the Tensorboard time seriesr   r   rC   r   rc   r0   r.   (AddTensorboardTimeSeriesMaxDataPointsArgr    s    	E
 r0   c                 H    [         R                  " SS SR                  U S9S9$ )Nz--filterzFilter for the {noun}.rU   )r   r   rX   rU   s    r.   AddFilterArgr    s)    	$%=%D%D$%D%O
 r0   c                    U c  g[        S [        U5      R                   5       5      nU R                  SS5      nX2;  aT  [        R
                  " SR                  SR                  U Vs/ s H  nSR                  U5      PM     sn5      5      5      eU R                  SS5      nUS	::  a  [        R
                  " S
5      eU[        R                  :X  aA  [        R                  " [        R                  [        R                  U   5      R                  nO@[        R                  " [        R                  [        R                  U   5      R                  n[         R"                  " X6R$                  5      nU" XWS9$ s  snf )z;Validates and returns an accelerator config message object.Nc              3   $   #    U  H  ov   M     g 7fr'   rc   .0r   s     r.   	<genexpr>'ParseAcceleratorFlag.<locals>.<genexpr>   s     DCQqC   r   zBThe type of the accelerator can only be one of the following: {}.
r   r   r   r   r   z5The count of the accelerator must be greater than 0.
)acceleratorCountacceleratorType)listr   r   getr   ArgumentErrorrY   r   r   r   r   GetMessagesModuleAI_PLATFORM_API_NAMEAI_PLATFORM_API_VERSION'GoogleCloudAiplatformV1beta1MachineSpec"GoogleCloudAiplatformV1MachineSpecr   ChoiceToEnumAcceleratorTypeValueValuesEnum)acceleratorrD   typesraw_typer   accelerator_countaccelerator_msgaccelerator_types           r.   ParseAcceleratorFlagr    s\   
D27;CCD
D%__VT*(


  
F49961fmmA&678: : "oogq1!


     	&&&,,&&))'2 .- 
 ,,&&))'2 )(  ++>> 
(
 ' 7s   +E>c                    U [         R                  :X  aa  [        R                  " S[        R
                  " [         R                  [         R                  U    5      R                  R                  SS SS9$ [        R                  " S[        R
                  " [         R                  [         R                  U    5      R                  R                  SS SS9$ )z0Get a mapper for accelerator type to enum value.zgeneric-acceleratorz$The available types of accelerators.c                 $    U R                  S5      $ NNVIDIA
startswithxs    r.   <lambda>*GetAcceleratorTypeMapper.<locals>.<lambda>G  s    h!7r0   F)rG  include_filterr    c                 $    U R                  S5      $ r  r  r  s    r.   r  r  Q  s    q||H5r0   )r   r   r   ChoiceEnumMapperr   r  r  r  r  r  r  )rD   s    r.   r   r   =  s    	&&&%%**--g6	
 2
12P2P77	 	 
	#	#


(
(

+
+G
4 	+*+I+I55	
 	r0   c                    U c  g[        S [        5       R                   5       5      nU R                  SS5      nX2;  a;  [        R
                  " SR                  SR                  S U 5       5      5      5      eU[        R                  :X  aA  [        R                  " [        R                  [        R                  U   5      R                  nO@[        R                  " [        R                  [        R                  U   5      R                  nU" [         R"                  " UUR$                  5      S9nU R                  SS5      b  U R                  S5      Ul        U R                  S	S5      b  U R                  S	5      Ul        U$ )
zCValidates and returns a reservation affinity config message object.Nc              3   $   #    U  H  ov   M     g 7fr'   rc   r  s     r.   r  /ParseReservationAffinityFlag.<locals>.<genexpr>Z  s     EDQqDr  r   zKThe type of the reservation affinity can only be one of the following: {}.
r   c              3   D   #    U  H  nS R                  U5      v   M     g7f)r   N)rY   r  s     r.   r  r  _  s     5u!V]]1%%us    )reservationAffinityTyper   r   )r   GetReservationAffinityTypeMapperr   r  r   r  rY   r   r   r   r   r  r  r  /GoogleCloudAiplatformV1beta1ReservationAffinity*GoogleCloudAiplatformV1ReservationAffinityr   r  &ReservationAffinityTypeValueValuesEnumr   r   )reservation_affinityrD   r  r  reservation_affinity_msgs        r.   ParseReservationAffinityFlagr  V  sb   !
E:<DDE
E%!%%&A4H(


  
F4995u5568 8 	&&&#55&&))'2  65 
  $55&&))'2  10  6'44

"
I
I h-9&:&>&>x&H#eT*6#7#;#;E#B 	!!r0   c                      [         R                  " S[        R                  " [        R
                  [        R                  [        R                     5      R                  R                  SSS9$ )z9Get a mapper for reservation affinity type to enum value.r   z,The available types of reservation affinity.F)rG  r    )
r   r  r   r  r   r  r  rB   r  r  rc   r0   r.   r  r  w  sW    		#	#!


(
(

+
+I,@,@
A 	323Y3Y=
 r0   c                 2    Sn[         R                  " XUS9  g)z3Add the --kms-key resource arg to the given parser.zlThe 'Vertex AI Service Agent' service account must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter')permission_infoN)kms_resource_argsAddKmsKeyResourceArg)r-   r9   r  s      r.   r  r    s!    >  ((r0   c                 .    [         R                  " SSU S9$ )Nz
--endpointzId of the endpoint.rA   rG   rH   s    r.   GetEndpointIdArgr    s    	.
 r0   c                 X    [         R                  " SS[        R                  " 5       SU S9$ )Nz--emailsEMAILSzIComma-separated email address list. e.g. --emails=a@gmail.com,b@gmail.com)rs   r   r   r    rB  rH   s    r.   GetEmailsArgr    s/    	 . 	
 	r0   c           	      Z    [         R                  " SS[        R                  " 5       / SU S9$ )Nz--notification-channelsNOTIFICATION_CHANNELSzComma-separated notification channel list. e.g. --notification-channels=projects/fake-project/notificationChannels/123,projects/fake-project/notificationChannels/456)rs   r   r   r   r    rB  rH   s    r.   GetNotificationChannelsArgr    s3    	% C 

 
r0   c                 :    [         R                  " S[        USU S9$ )Nz--prediction-sampling-ratezPrediction sampling rate.r   r   r   r    r   r    r   s     r.   GetPredictionSamplingRateArgr    s"    	"&
 r0   c                 :    [         R                  " S[        USU S9$ )Nz--monitoring-frequencyz%Monitoring frequency, unit is 1 hour.r  r  r  s     r.   GetMonitoringFrequencyArgr    s"    	2
 r0   c                 .    [         R                  " SSU S9$ )Nz--predict-instance-schemaz
      YAML schema file uri(Google Cloud Storage) describing the format of a
      single instance, which are given to format this Endpoint's prediction.
      If not set, predict schema will be generated from collected predict requests.
      rA   rG   rH   s    r.   GetPredictInstanceSchemaArgr    s     	!

 
 r0   c                 0    [         R                  " SSUU S9$ )Nz--analysis-instance-schemaz
      YAML schema file uri(Google Cloud Storage) describing the format of a
      single instance that you want Tensorflow Data Validation (TFDV) to analyze.
      )r   rj   r    rG   )r    rj   s     r.   GetAnalysisInstanceSchemaArgr    s#    	"
 
 r0   c                 .    [         R                  " SSU S9$ )Nz--sample-predict-requestaW        Path to a local file containing the body of a JSON object. Same format as
      [PredictRequest.instances][], this can be set as a replacement of predict-instance-schema.
      If not set, predict schema will be generated from collected predict requests.

      An example of a JSON request:

          {"x": [1, 2], "y": [3, 4]}

      rA   rG   rH   s    r.   GetSamplingPredictRequestArgr    s     	 	
 
 r0   c                 8    [         R                  " S[        SU S9$ )Nz	--log-ttlzL
TTL of BigQuery tables in user projects which stores logs(Day-based unit).
)r   r   r    r  rH   s    r.   GetMonitoringLogTtlArgr    s#    	 
 r0   c                  ,    [         R                  " SSS9$ )Nz--monitoring-config-from-filea~  
Path to the model monitoring objective config file. This file should be a YAML
document containing a `ModelDeploymentMonitoringJob`(https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations.modelDeploymentMonitoringJobs#ModelDeploymentMonitoringJob),
but only the ModelDeploymentMonitoringObjectiveConfig needs to be configured.

Note: Only one of --monitoring-config-from-file and other objective config set,
like --feature-thresholds, --feature-attribution-thresholds needs to be set.

Example(YAML):

  modelDeploymentMonitoringObjectiveConfigs:
  - deployedModelId: '5251549009234886656'
    objectiveConfig:
      trainingDataset:
        dataFormat: csv
        gcsSource:
          uris:
          - gs://fake-bucket/training_data.csv
        targetField: price
      trainingPredictionSkewDetectionConfig:
        skewThresholds:
          feat1:
            value: 0.9
          feat2:
            value: 0.8
  - deployedModelId: '2945706000021192704'
    objectiveConfig:
      predictionDriftDetectionConfig:
        driftThresholds:
          feat1:
            value: 0.3
          feat2:
            value: 0.4
r"   rG   rc   r0   r.   GetMonitoringConfigFromFiler    s    	%!$
 $r0   c                  r    [         R                  " SS[        R                  " SS9[        R                  SS9$ )Nz--feature-thresholdsr  Tallow_key_onlyaq  
List of feature-threshold value pairs(Apply for all the deployed models under
the endpoint, if you want to specify different thresholds for different deployed
model, please use flag --monitoring-config-from-file or call API directly).
If only feature name is set, the default threshold value would be 0.3.

For example: `--feature-thresholds=feat1=0.1,feat2,feat3=0.2`r   r   rC   r   r   r   rc   r0   r.   GetFeatureThresholdsr     s6    	d3%%A
 r0   c                  r    [         R                  " SS[        R                  " SS9[        R                  SS9$ )Nz --feature-attribution-thresholdsr  Tr  a  
List of feature-attribution score threshold value pairs(Apply for all the
deployed models under the endpoint, if you want to specify different thresholds
for different deployed model, please use flag --monitoring-config-from-file or
call API directly). If only feature name is set, the default threshold value
would be 0.3.

For example: `feature-attribution-thresholds=feat1=0.1,feat2,feat3=0.2`r   r  rc   r0   r.   GetFeatureAttributionThresholdsr  0  s6    	(d3%%K
 r0   c                     U R                  US9nUR                  SS9n[        5       R                  U5        [	        5       R                  U5        [        5       R                  U5        g)zQAdd model monitoring objective config related flags to the parser for Update API.rH   FmutexN)r   r   r  r)   r  r  )r-   r    objective_config_groupthresholds_groups       r.    AddObjectiveConfigGroupForUpdater  A  sg    !>> ?  ,55E5B$$%56!#//0@A++,BCr0   c                    U R                  US9nUR                  SS9n[        5       R                  U5        [	        5       R                  U5        UR                  S[        SSS9  UR                  SS	S
9  UR                  SS9nUR                  SSS
9  UR                  SSS
9  UR                  SS9nUR                  SSS
9  UR                  SS[        R                  " 5       SS9  [        5       R                  U5        g)zRAdd model monitoring objective config related flags to the parser for Create API..rH   Fr  z--training-sampling-rate      ?zTraining Dataset sampling rate.r   z--target-fieldzu
Target field name the model is to predict. Must be provided if you'd like to
do training-prediction skew detection.
r"   Tz	--datasetz1Id of Vertex AI Dataset used to train this Model.z--bigquery-urizw
BigQuery table of the unmanaged Dataset used to train this Model.
For example: `bq://projectId.bqDatasetId.bqTableId`.z--data-formatz
Data format of the dataset, must be provided if the input is from Google Cloud Storage.
The possible formats are: tf-record, csvz
--gcs-urisGCS_URISz^
Comma-separated Google Cloud Storage uris of the unmanaged Datasets used to train this Model.r   N)
r   r   r  r)   r  r   r   r   rt   r  )r-   r    r  r  training_data_groupgcs_data_source_groups         r.    AddObjectiveConfigGroupForCreater  L  sO   !>> ?  ,55E5B$$%56!#//0@A ,	        )222>""K #  ""8 #  .77e7D$$, %  $$ a	 %  ++,BCr0   c           
          [         R                  " [        R                  U [         R                  [        [        R                  " [        R                  5      S9SS9$ r5  )	r	   r  r    MODEL_MONITORING_JOBS_COLLECTIONr  r   r   r7  'SUPPORTED_MODEL_MONITORING_JOBS_REGIONSr9  s    r.   GetMonitoringJobResourceSpecr  |  sN    			00!::'!88??
 $

 
r0   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)a  Add a resource argument for a Vertex AI model deployment monitoring 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 resource, such as 'to update'.
monitoring_jobz'The model deployment monitoring job {}.TrH   N)r   r  r	  r  rY   r)   r2  s     r.    AddModelMonitoringJobResourceArgr    sC     ++"$/66t<	 , 
 Kr0   c                 L    [         R                  " S[        R                  SU S9$ )Nz--anomaly-cloud-loggingz/If true, anomaly will be sent to Cloud Logging.)r   r   r    )r   rC   r   StoreTrueFalseActionrH   s    r.   GetAnomalyCloudLoggingArgr    s%    	--@	
 r0   r'   )NN)T)TzID of the index.)TzID of the index endpoint.)F)r0  )r_  )r  )r  )r  )r  )Tr  )F   )FF)r   )__doc__
__future__r   r   r   r   textwrapgooglecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr	   r
   googlecloudsdk.command_lib.air   r   r   googlecloudsdk.command_lib.iamr   core_iam_utilgooglecloudsdk.command_lib.kmsr   r  $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer   r   rC   r   r   r(   r+   r*   dedentNETWORKPUBLIC_ENDPOINT_ENABLEDGetIamAccountFormatValidatorTRAINING_SERVICE_ACCOUNTENABLE_WEB_ACCESSENABLE_DASHBOARD_ACCESSr/   r?   rE   rI   rN   rP   rR   r[   r^   ra   rd   rf   rk   rm   ro   ru   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   PromptForRegionr   r  r  r  r  r  r  r#  r(  r*  r,  r.  r3  r1  r>  r;  rC  r<  rI  .PromptForDeploymentResourcePoolSupportedRegionrM  rQ  rU  rW  r[  r]  ra  r`  re  rg  rk  rm  ro  ru  rx  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rc   r0   r.   <module>r     sL   & &  ' 
  , / ( 5 1 3 0 5 D M : D G * )			3;;$	?	  	;	  ]]	B	
 --	 
 
 --	 
 
   ==		3	3	5	 
 
		  MM	 
 
  --	 
 

 ,2$$G
  ;P 	.,$,(0BOd@<"8&$GA
 '2&A&A   {'B'B	 4?3N3N 4 3>2M2M . *990 -8,G,G @FGT +6*E*E 0fD$	, -JJ
  JJ0:
 +*E*E	 *99,"
 ,	 +
""""B2"B

		"%P "D-D`"r0   