
                            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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0rS rS r\R.                  " \R0                  R2                  5       " S S\R4                  5      5       r\R.                  " \R0                  R8                  \R0                  R:                  5       " S S\R4                  5      5       r\\l        \\l        g)z/Vertex AI model monitoring jobs create command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)flags)model_monitoring_jobs_util)region_util)
validation)labels_util)logEXAMPLESaf  
    To create a model deployment monitoring job under project ``example'' in region ``us-central1'' for endpoint ``123'', run:

      $ {command} --project=example --region=us-central1 --display-name=my_monitoring_job --emails=a@gmail.com,b@gmail.com --endpoint=123 --prediction-sampling-rate=0.2

    To create a model deployment monitoring job with drift detection for all the deployed models under the endpoint ``123'', run:

      $ {command} --project=example --region=us-central1 --display-name=my_monitoring_job --emails=a@gmail.com,b@gmail.com --endpoint=123 --prediction-sampling-rate=0.2 --feature-thresholds=feat1=0.1,feat2=0.2,feat3=0.2,feat4=0.3

    To create a model deployment monitoring job with skew detection for all the deployed models under the endpoint ``123'', with training dataset from Google Cloud Storage, run:

      $ {command} --project=example --region=us-central1 --display-name=my_monitoring_job --emails=a@gmail.com,b@gmail.com --endpoint=123 --prediction-sampling-rate=0.2 --feature-thresholds=feat1=0.1,feat2=0.2,feat3=0.2,feat4=0.3 --target-field=price --data-format=csv --gcs-uris=gs://test-bucket/dataset.csv

    To create a model deployment monitoring job with skew detection for all the deployed models under the endpoint ``123'', with training dataset from Vertex AI dataset ``456'', run:

      $ {command} --project=example --region=us-central1 --display-name=my_monitoring_job --emails=a@gmail.com,b@gmail.com --endpoint=123 --prediction-sampling-rate=0.2 --feature-thresholds=feat1=0.1,feat2=0.2,feat3=0.2,feat4=0.3 --target-field=price --dataset=456

    To create a model deployment monitoring job with different drift detection or skew detection for different deployed models, run:

      $ {command} --project=example --region=us-central1 --display-name=my_monitoring_job --emails=a@gmail.com,b@gmail.com --endpoint=123 --prediction-sampling-rate=0.2 --monitoring-config-from-file=your_objective_config.yaml

    After creating the monitoring job, be sure to send some predict requests. It will be used to generate some metadata for analysis purpose, like predict and analysis instance schema.
    c                    [         R                  " U S[        R                  " [        R
                  5      S9  [         R                  " S5      R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                  " SS9R                  U 5        [         R                   " U SS9  [         R"                  " U S5        [         R$                  " SS9R                  U 5        [         R&                  " SS9R                  U 5        [(        R*                  " U 5        g)zAdd flags for create command.z)to create model deployment monitoring job)prompt_funczmodel deployment monitoring jobT)requiredFN)r
   AddRegionResourceArgr   GetPromptForRegionFuncr   'SUPPORTED_MODEL_MONITORING_JOBS_REGIONSGetDisplayNameArgAddToParserGetEndpointIdArgGetEmailsArgGetPredictionSamplingRateArgGetMonitoringFrequencyArgGetPredictInstanceSchemaArgGetAnalysisInstanceSchemaArgGetSamplingPredictRequestArgGetMonitoringLogTtlArg AddObjectiveConfigGroupForCreateAddKmsKeyResourceArgGetAnomalyCloudLoggingArgGetNotificationChannelsArgr   AddCreateLabelsFlagsparsers    .lib/surface/ai/model_monitoring_jobs/create.py_Argsr)   <   sr   144

;
;=>
 ;<HHP$'33F;d#//7$$d3??G!!51==fE##U3??G$$e4@@H$$e4@@H.::6B((%@V%FG!!51==fE""E2>>vF""6*    c           	      B   [         R                  " U R                  5        U R                  R                  R                  5       nUR                  5       S   n[        R                  " XS9   [        R                  " US9R                  X05      nSnU(       a  USU-   -  n[        R                  R                  [        R                   R#                  [$        R&                  " UR(                  5      UUR*                  S95        UsSSS5        $ ! , (       d  f       g= f)zRun method for create command.locationsId)versionregion)r-   gcloud )id
cmd_prefixstateN)r   ValidateDisplayNamedisplay_nameCONCEPTSr.   ParseAsDictr	   AiplatformEndpointOverridesr   ModelMonitoringJobsClientCreater   statusPrintr   -MODEL_MONITORING_JOB_CREATION_DISPLAY_MESSAGEformatr   ParseJobNamenamer3   )argsr-   release_prefix
region_refr.   responser2   s          r(   _RunrF   S   s      !2!23}}##))+*}-&00&//@GGHJC.((jJJ??FF)66x}}E!.. 	G 	"#
 & & &s   ,BD
Dc                   .    \ rS rSrSr\S 5       rS rSrg)CreateGag   ,Create a new Vertex AI model monitoring job.c                     [        U 5        g Nr)   r&   s    r(   ArgsCreateGa.Argsk   	    	&Mr*   c                 h    [        U[        R                  U R                  5       R                  5      $ rL   )rF   r   
GA_VERSIONReleaseTrackprefixselfrB   s     r(   RunCreateGa.Runo   s&    i**D,=,=,?,F,FGGr*    N	__name__
__module____qualname____firstlineno____doc__staticmethodrN   rW   __static_attributes__rY   r*   r(   rH   rH   g   s    4 Hr*   rH   c                   .    \ rS rSrSr\S 5       rS rSrg)r;   s   rJ   c                     [        U 5        g rL   rM   r&   s    r(   rN   Create.Argsw   rP   r*   c                 h    [        U[        R                  U R                  5       R                  5      $ rL   )rF   r   BETA_VERSIONrS   rT   rU   s     r(   rW   
Create.Run{   s&    i,,d.?.?.A.H.HIIr*   rY   NrZ   rY   r*   r(   r;   r;   s   s    4 Jr*   r;   N) r_   
__future__r   r   r   /googlecloudsdk.api_lib.ai.model_monitoring_jobsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   DETAILED_HELPr)   rF   ReleaseTracksrS   GACreateCommandrH   ALPHABETAr;   detailed_helprY   r*   r(   <module>rv      s    6 &  ' B ( 3 7 / D 5 4 < # 	8+.( D%%(()Ht!! H *H D%%++T->->-C-CDJT J EJ % & r*   