feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Vertex AI model monitoring jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class ModelMonitoringJobs(base.Group):
"""Manage Vertex AI model monitoring jobs."""
category = base.VERTEX_AI_CATEGORY

View File

@@ -0,0 +1,128 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI model monitoring jobs create command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import flags
from googlecloudsdk.command_lib.ai import model_monitoring_jobs_util
from googlecloudsdk.command_lib.ai import region_util
from googlecloudsdk.command_lib.ai import validation
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
DETAILED_HELP = {
'EXAMPLES':
"""
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.
""",
}
def _Args(parser):
"""Add flags for create command."""
flags.AddRegionResourceArg(
parser,
'to create model deployment monitoring job',
prompt_func=region_util.GetPromptForRegionFunc(
constants.SUPPORTED_MODEL_MONITORING_JOBS_REGIONS))
flags.GetDisplayNameArg('model deployment monitoring job').AddToParser(parser)
flags.GetEndpointIdArg(required=True).AddToParser(parser)
flags.GetEmailsArg(required=True).AddToParser(parser)
flags.GetPredictionSamplingRateArg(required=True).AddToParser(parser)
flags.GetMonitoringFrequencyArg(required=False).AddToParser(parser)
flags.GetPredictInstanceSchemaArg(required=False).AddToParser(parser)
flags.GetAnalysisInstanceSchemaArg(required=False).AddToParser(parser)
flags.GetSamplingPredictRequestArg(required=False).AddToParser(parser)
flags.GetMonitoringLogTtlArg(required=False).AddToParser(parser)
flags.AddObjectiveConfigGroupForCreate(parser, required=False)
flags.AddKmsKeyResourceArg(parser, 'model deployment monitoring job')
flags.GetAnomalyCloudLoggingArg(required=False).AddToParser(parser)
flags.GetNotificationChannelsArg(required=False).AddToParser(parser)
labels_util.AddCreateLabelsFlags(parser)
def _Run(args, version, release_prefix):
"""Run method for create command."""
validation.ValidateDisplayName(args.display_name)
region_ref = args.CONCEPTS.region.Parse()
region = region_ref.AsDict()['locationsId']
with endpoint_util.AiplatformEndpointOverrides(
version=version, region=region):
response = client.ModelMonitoringJobsClient(version=version).Create(
region_ref, args)
cmd_prefix = 'gcloud'
if release_prefix:
cmd_prefix += ' ' + release_prefix
log.status.Print(
constants.MODEL_MONITORING_JOB_CREATION_DISPLAY_MESSAGE.format(
id=model_monitoring_jobs_util.ParseJobName(response.name),
cmd_prefix=cmd_prefix,
state=response.state))
return response
@base.ReleaseTracks(base.ReleaseTrack.GA)
class CreateGa(base.CreateCommand):
"""Create a new Vertex AI model monitoring job."""
@staticmethod
def Args(parser):
_Args(parser)
def Run(self, args):
return _Run(args, constants.GA_VERSION, self.ReleaseTrack().prefix)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Create(base.CreateCommand):
"""Create a new Vertex AI model monitoring job."""
@staticmethod
def Args(parser):
_Args(parser)
def Run(self, args):
return _Run(args, constants.BETA_VERSION, self.ReleaseTrack().prefix)
Create.detailed_help = DETAILED_HELP
CreateGa.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI deployment monitoring jobs delete command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai import operations
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import flags
from googlecloudsdk.command_lib.ai import model_monitoring_jobs_util
from googlecloudsdk.command_lib.ai import operations_util
from googlecloudsdk.core.console import console_io
DETAILED_HELP = {
'EXAMPLES':
"""
To delete a model deployment monitoring job `123` of project `example` in region `us-central1`, run:
$ {command} 123 --project=example --region=us-central1
""",
}
def _Run(args, version):
"""Run method for delete command."""
model_monitoring_job_ref = args.CONCEPTS.monitoring_job.Parse()
region = model_monitoring_job_ref.AsDict()['locationsId']
model_monitoring_job_id = model_monitoring_job_ref.AsDict(
)['modelDeploymentMonitoringJobsId']
with endpoint_util.AiplatformEndpointOverrides(version, region=region):
console_io.PromptContinue(
'This will delete model deployment monitoring job [{}]...'.format(
model_monitoring_job_id),
cancel_on_no=True)
operation = client.ModelMonitoringJobsClient(
version=version).Delete(model_monitoring_job_ref)
return operations_util.WaitForOpMaybe(
operations_client=operations.OperationsClient(),
op=operation,
op_ref=model_monitoring_jobs_util.ParseMonitoringJobOperation(
operation.name))
@base.ReleaseTracks(base.ReleaseTrack.GA)
class DeleteGa(base.DeleteCommand):
"""Delete an existing Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to delete')
def Run(self, args):
return _Run(args, constants.GA_VERSION)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Delete(base.DeleteCommand):
"""Delete an existing Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to delete')
def Run(self, args):
return _Run(args, constants.BETA_VERSION)
Delete.detailed_help = DETAILED_HELP
DeleteGa.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI model deployment monitoring jobs describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import flags
DETAILED_HELP = {
'EXAMPLES':
"""
Describe a model deployment monitoring job `123` of project `example` in region `us-central1`, run:
$ {command} 123 --project=example --region=us-central1
""",
}
def _Run(args, version):
"""Run method for describe command."""
model_monitoring_job_ref = args.CONCEPTS.monitoring_job.Parse()
region = model_monitoring_job_ref.AsDict()['locationsId']
with endpoint_util.AiplatformEndpointOverrides(version, region=region):
return client.ModelMonitoringJobsClient(
version=version).Get(model_monitoring_job_ref)
@base.ReleaseTracks(base.ReleaseTrack.GA)
class DescribeGa(base.DescribeCommand):
"""Get detailed model deployment monitoring job information about the given job id."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to describe')
def Run(self, args):
return _Run(args, constants.GA_VERSION)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Describe(base.DescribeCommand):
"""Get detailed model deployment monitoring job information about the given job id."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to describe')
def Run(self, args):
return _Run(args, constants.BETA_VERSION)
Describe.detailed_help = DETAILED_HELP
DescribeGa.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI deployment monitoring jobs list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import flags
from googlecloudsdk.command_lib.ai import region_util
DETAILED_HELP = {
'EXAMPLES':
"""
List the model deployment monitoring jobs of project `example` in region `us-central1`, run:
$ {command} --project=example --region=us-central1
""",
}
def _Run(args, version):
"""Run method for delete command."""
region_ref = args.CONCEPTS.region.Parse()
region = region_ref.AsDict()['locationsId']
with endpoint_util.AiplatformEndpointOverrides(version, region=region):
return client.ModelMonitoringJobsClient(version=version).List(
region_ref=region_ref)
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ListGa(base.ListCommand):
"""List the model deployment monitoring jobs of the given project and region."""
@staticmethod
def Args(parser):
flags.AddRegionResourceArg(
parser,
'to list model deployment monitoring jobs',
prompt_func=region_util.GetPromptForRegionFunc(
constants.SUPPORTED_MODEL_MONITORING_JOBS_REGIONS))
def Run(self, args):
return _Run(args, constants.GA_VERSION)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class List(base.ListCommand):
"""List the model deployment monitoring jobs of the given project and region."""
@staticmethod
def Args(parser):
flags.AddRegionResourceArg(
parser,
'to list model deployment monitoring jobs',
prompt_func=region_util.GetPromptForRegionFunc(
constants.SUPPORTED_MODEL_MONITORING_JOBS_REGIONS))
def Run(self, args):
return _Run(args, constants.BETA_VERSION)
List.detailed_help = DETAILED_HELP
ListGa.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI deployment monitoring jobs pause command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
DETAILED_HELP = {
'EXAMPLES':
"""
To pause a model deployment monitoring job `123` of project `example` in region `us-central1`, run:
$ {command} 123 --project=example --region=us-central1
""",
}
def _Run(args, version, release_prefix):
"""Run method for pause command."""
model_monitoring_job_ref = args.CONCEPTS.monitoring_job.Parse()
region = model_monitoring_job_ref.AsDict()['locationsId']
model_monitoring_job_id = model_monitoring_job_ref.AsDict(
)['modelDeploymentMonitoringJobsId']
with endpoint_util.AiplatformEndpointOverrides(version, region=region):
console_io.PromptContinue(
'This will pause model deployment monitoring job [{}]...'.format(
model_monitoring_job_id),
cancel_on_no=True)
response = client.ModelMonitoringJobsClient(
version=version).Pause(model_monitoring_job_ref)
cmd_prefix = 'gcloud'
if release_prefix:
cmd_prefix += ' ' + release_prefix
log.status.Print(
constants.MODEL_MONITORING_JOB_PAUSE_DISPLAY_MESSAGE.format(
id=model_monitoring_job_ref.Name(), cmd_prefix=cmd_prefix))
return response
@base.ReleaseTracks(base.ReleaseTrack.GA)
class PauseGa(base.SilentCommand):
"""Pause a running Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to pause')
def Run(self, args):
return _Run(args, constants.GA_VERSION, self.ReleaseTrack().prefix)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Pause(base.SilentCommand):
"""Pause a running Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to pause')
def Run(self, args):
return _Run(args, constants.BETA_VERSION, self.ReleaseTrack().prefix)
Pause.detailed_help = DETAILED_HELP
PauseGa.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI deployment monitoring jobs resume command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
DETAILED_HELP = {
'EXAMPLES':
"""
To resume a model deployment monitoring job `123` of project `example` in region `us-central1`, run:
$ {command} 123 --project=example --region=us-central1
""",
}
def _Run(args, version, release_prefix):
"""Run method for resume command."""
model_monitoring_job_ref = args.CONCEPTS.monitoring_job.Parse()
region = model_monitoring_job_ref.AsDict()['locationsId']
model_monitoring_job_id = model_monitoring_job_ref.AsDict(
)['modelDeploymentMonitoringJobsId']
with endpoint_util.AiplatformEndpointOverrides(version, region=region):
console_io.PromptContinue(
'This will resume model deployment monitoring job [{}]...'.format(
model_monitoring_job_id),
cancel_on_no=True)
response = client.ModelMonitoringJobsClient(
version=version).Resume(model_monitoring_job_ref)
cmd_prefix = 'gcloud'
if release_prefix:
cmd_prefix += ' ' + release_prefix
log.status.Print(
constants.MODEL_MONITORING_JOB_RESUME_DISPLAY_MESSAGE.format(
id=model_monitoring_job_ref.Name(), cmd_prefix=cmd_prefix))
return response
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ResumeGa(base.SilentCommand):
"""Resume a paused Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to resume')
def Run(self, args):
return _Run(args, constants.GA_VERSION, self.ReleaseTrack().prefix)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Resume(base.SilentCommand):
"""Resume a paused Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
flags.AddModelMonitoringJobResourceArg(parser, 'to resume')
def Run(self, args):
return _Run(args, constants.BETA_VERSION, self.ReleaseTrack().prefix)
Resume.detailed_help = DETAILED_HELP
ResumeGa.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,119 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Vertex AI model deployment monitoring jobs update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ai.model_monitoring_jobs import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ai import constants
from googlecloudsdk.command_lib.ai import endpoint_util
from googlecloudsdk.command_lib.ai import errors
from googlecloudsdk.command_lib.ai import flags
from googlecloudsdk.command_lib.ai import validation
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
DETAILED_HELP = {
'EXAMPLES':
"""
To update display name of model deployment monitoring job `123` under project `example` in region `us-central1`, run:
$ {command} 123 --display-name=new-name --project=example --region=us-central1
""",
}
def _Args(parser):
"""Add flags for update command."""
flags.AddModelMonitoringJobResourceArg(parser, 'to update')
flags.GetDisplayNameArg(
'model deployment monitoring job', required=False).AddToParser(parser)
flags.GetEmailsArg(required=False).AddToParser(parser)
flags.GetPredictionSamplingRateArg(
required=False, default=None).AddToParser(parser)
flags.GetMonitoringFrequencyArg(
required=False, default=None).AddToParser(parser)
flags.GetAnalysisInstanceSchemaArg(required=False).AddToParser(parser)
flags.GetMonitoringLogTtlArg(required=False).AddToParser(parser)
flags.AddObjectiveConfigGroupForUpdate(parser, required=False)
flags.GetAnomalyCloudLoggingArg(required=False).AddToParser(parser)
flags.GetNotificationChannelsArg(required=False).AddToParser(parser)
labels_util.AddUpdateLabelsFlags(parser)
def _Run(args, version):
"""Run method for update command."""
validation.ValidateDisplayName(args.display_name)
model_monitoring_job_ref = args.CONCEPTS.monitoring_job.Parse()
region = model_monitoring_job_ref.AsDict()['locationsId']
with endpoint_util.AiplatformEndpointOverrides(version, region=region):
try:
result = client.ModelMonitoringJobsClient(version=version).Patch(
model_monitoring_job_ref, args)
except errors.NoFieldsSpecifiedError:
available_update_args = [
'display_name',
'emails',
'prediction_sampling_rate',
'feature_thresholds',
'monitoring_config_from_file',
'monitoring_frequency',
'analysis_instance_schema',
'log_ttl',
'update_labels',
'clear_labels',
'remove_labels',
'anomaly_cloud_logging',
'notification_channels',
]
if not any(args.IsSpecified(arg) for arg in available_update_args):
raise
log.status.Print('No update to perform.')
return None
else:
log.UpdatedResource(
result.name, kind='Vertex AI model deployment monitoring job')
return result
@base.ReleaseTracks(base.ReleaseTrack.GA)
class UpdateGa(base.UpdateCommand):
"""Update an Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
_Args(parser)
def Run(self, args):
return _Run(args, constants.GA_VERSION)
@base.ReleaseTracks(base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA)
class Update(base.UpdateCommand):
"""Update an Vertex AI model deployment monitoring job."""
@staticmethod
def Args(parser):
_Args(parser)
def Run(self, args):
return _Run(args, constants.BETA_VERSION)
Update.detailed_help = DETAILED_HELP
UpdateGa.detailed_help = DETAILED_HELP