Skip to content

Commit ef5930c

Browse files
feat: add ImportModelEvaluation in aiplatform v1 model_service.proto (#1105)
* feat: add ImportModelEvaluation in aiplatform v1 model_service.proto feat: add data_item_schema_uri, annotation_schema_uri, explanation_specs to ModelEvaluationExplanationSpec in aiplatform v1 model_evaluation.proto feat: add ImportModelEvaluation in aiplatform v1beta1 model_service.proto PiperOrigin-RevId: 436869915 Source-Link: googleapis/googleapis@9ba488b Source-Link: googleapis/googleapis-gen@908e7f8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTA4ZTdmODk2Zjg3NmRhNmE0ZDA1Y2QwY2M0ZjhlYjE5YzNjYzdhOSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 52273c2 commit ef5930c

30 files changed

+1614
-54
lines changed

google/cloud/aiplatform_v1/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@
348348
from .types.model_service import GetModelEvaluationRequest
349349
from .types.model_service import GetModelEvaluationSliceRequest
350350
from .types.model_service import GetModelRequest
351+
from .types.model_service import ImportModelEvaluationRequest
351352
from .types.model_service import ListModelEvaluationSlicesRequest
352353
from .types.model_service import ListModelEvaluationSlicesResponse
353354
from .types.model_service import ListModelEvaluationsRequest
@@ -720,6 +721,7 @@
720721
"ImportFeatureValuesOperationMetadata",
721722
"ImportFeatureValuesRequest",
722723
"ImportFeatureValuesResponse",
724+
"ImportModelEvaluationRequest",
723725
"Index",
724726
"IndexEndpoint",
725727
"IndexEndpointServiceClient",

google/cloud/aiplatform_v1/gapic_metadata.json

+10
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,11 @@
12911291
"get_model_evaluation_slice"
12921292
]
12931293
},
1294+
"ImportModelEvaluation": {
1295+
"methods": [
1296+
"import_model_evaluation"
1297+
]
1298+
},
12941299
"ListModelEvaluationSlices": {
12951300
"methods": [
12961301
"list_model_evaluation_slices"
@@ -1346,6 +1351,11 @@
13461351
"get_model_evaluation_slice"
13471352
]
13481353
},
1354+
"ImportModelEvaluation": {
1355+
"methods": [
1356+
"import_model_evaluation"
1357+
]
1358+
},
13491359
"ListModelEvaluationSlices": {
13501360
"methods": [
13511361
"list_model_evaluation_slices"

google/cloud/aiplatform_v1/services/model_service/async_client.py

+103
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from google.cloud.aiplatform_v1.types import model
4141
from google.cloud.aiplatform_v1.types import model as gca_model
4242
from google.cloud.aiplatform_v1.types import model_evaluation
43+
from google.cloud.aiplatform_v1.types import model_evaluation as gca_model_evaluation
4344
from google.cloud.aiplatform_v1.types import model_evaluation_slice
4445
from google.cloud.aiplatform_v1.types import model_service
4546
from google.cloud.aiplatform_v1.types import operation as gca_operation
@@ -886,6 +887,108 @@ def sample_export_model():
886887
# Done; return the response.
887888
return response
888889

890+
async def import_model_evaluation(
891+
self,
892+
request: Union[model_service.ImportModelEvaluationRequest, dict] = None,
893+
*,
894+
parent: str = None,
895+
model_evaluation: gca_model_evaluation.ModelEvaluation = None,
896+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
897+
timeout: float = None,
898+
metadata: Sequence[Tuple[str, str]] = (),
899+
) -> gca_model_evaluation.ModelEvaluation:
900+
r"""Imports an externally generated ModelEvaluation.
901+
902+
.. code-block:: python
903+
904+
from google.cloud import aiplatform_v1
905+
906+
def sample_import_model_evaluation():
907+
# Create a client
908+
client = aiplatform_v1.ModelServiceClient()
909+
910+
# Initialize request argument(s)
911+
request = aiplatform_v1.ImportModelEvaluationRequest(
912+
parent="parent_value",
913+
)
914+
915+
# Make the request
916+
response = client.import_model_evaluation(request=request)
917+
918+
# Handle the response
919+
print(response)
920+
921+
Args:
922+
request (Union[google.cloud.aiplatform_v1.types.ImportModelEvaluationRequest, dict]):
923+
The request object. Request message for
924+
[ModelService.ImportModelEvaluation][google.cloud.aiplatform.v1.ModelService.ImportModelEvaluation]
925+
parent (:class:`str`):
926+
Required. The name of the parent model resource. Format:
927+
``projects/{project}/locations/{location}/models/{model}``
928+
929+
This corresponds to the ``parent`` field
930+
on the ``request`` instance; if ``request`` is provided, this
931+
should not be set.
932+
model_evaluation (:class:`google.cloud.aiplatform_v1.types.ModelEvaluation`):
933+
Required. Model evaluation resource
934+
to be imported.
935+
936+
This corresponds to the ``model_evaluation`` field
937+
on the ``request`` instance; if ``request`` is provided, this
938+
should not be set.
939+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
940+
should be retried.
941+
timeout (float): The timeout for this request.
942+
metadata (Sequence[Tuple[str, str]]): Strings which should be
943+
sent along with the request as metadata.
944+
945+
Returns:
946+
google.cloud.aiplatform_v1.types.ModelEvaluation:
947+
A collection of metrics calculated by
948+
comparing Model's predictions on all of
949+
the test data against annotations from
950+
the test data.
951+
952+
"""
953+
# Create or coerce a protobuf request object.
954+
# Quick check: If we got a request object, we should *not* have
955+
# gotten any keyword arguments that map to the request.
956+
has_flattened_params = any([parent, model_evaluation])
957+
if request is not None and has_flattened_params:
958+
raise ValueError(
959+
"If the `request` argument is set, then none of "
960+
"the individual field arguments should be set."
961+
)
962+
963+
request = model_service.ImportModelEvaluationRequest(request)
964+
965+
# If we have keyword arguments corresponding to fields on the
966+
# request, apply these.
967+
if parent is not None:
968+
request.parent = parent
969+
if model_evaluation is not None:
970+
request.model_evaluation = model_evaluation
971+
972+
# Wrap the RPC method; this adds retry and timeout information,
973+
# and friendly error handling.
974+
rpc = gapic_v1.method_async.wrap_method(
975+
self._client._transport.import_model_evaluation,
976+
default_timeout=None,
977+
client_info=DEFAULT_CLIENT_INFO,
978+
)
979+
980+
# Certain fields should be provided within the metadata header;
981+
# add these here.
982+
metadata = tuple(metadata) + (
983+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
984+
)
985+
986+
# Send the request.
987+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
988+
989+
# Done; return the response.
990+
return response
991+
889992
async def get_model_evaluation(
890993
self,
891994
request: Union[model_service.GetModelEvaluationRequest, dict] = None,

google/cloud/aiplatform_v1/services/model_service/client.py

+103
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from google.cloud.aiplatform_v1.types import model
4444
from google.cloud.aiplatform_v1.types import model as gca_model
4545
from google.cloud.aiplatform_v1.types import model_evaluation
46+
from google.cloud.aiplatform_v1.types import model_evaluation as gca_model_evaluation
4647
from google.cloud.aiplatform_v1.types import model_evaluation_slice
4748
from google.cloud.aiplatform_v1.types import model_service
4849
from google.cloud.aiplatform_v1.types import operation as gca_operation
@@ -1143,6 +1144,108 @@ def sample_export_model():
11431144
# Done; return the response.
11441145
return response
11451146

1147+
def import_model_evaluation(
1148+
self,
1149+
request: Union[model_service.ImportModelEvaluationRequest, dict] = None,
1150+
*,
1151+
parent: str = None,
1152+
model_evaluation: gca_model_evaluation.ModelEvaluation = None,
1153+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1154+
timeout: float = None,
1155+
metadata: Sequence[Tuple[str, str]] = (),
1156+
) -> gca_model_evaluation.ModelEvaluation:
1157+
r"""Imports an externally generated ModelEvaluation.
1158+
1159+
.. code-block:: python
1160+
1161+
from google.cloud import aiplatform_v1
1162+
1163+
def sample_import_model_evaluation():
1164+
# Create a client
1165+
client = aiplatform_v1.ModelServiceClient()
1166+
1167+
# Initialize request argument(s)
1168+
request = aiplatform_v1.ImportModelEvaluationRequest(
1169+
parent="parent_value",
1170+
)
1171+
1172+
# Make the request
1173+
response = client.import_model_evaluation(request=request)
1174+
1175+
# Handle the response
1176+
print(response)
1177+
1178+
Args:
1179+
request (Union[google.cloud.aiplatform_v1.types.ImportModelEvaluationRequest, dict]):
1180+
The request object. Request message for
1181+
[ModelService.ImportModelEvaluation][google.cloud.aiplatform.v1.ModelService.ImportModelEvaluation]
1182+
parent (str):
1183+
Required. The name of the parent model resource. Format:
1184+
``projects/{project}/locations/{location}/models/{model}``
1185+
1186+
This corresponds to the ``parent`` field
1187+
on the ``request`` instance; if ``request`` is provided, this
1188+
should not be set.
1189+
model_evaluation (google.cloud.aiplatform_v1.types.ModelEvaluation):
1190+
Required. Model evaluation resource
1191+
to be imported.
1192+
1193+
This corresponds to the ``model_evaluation`` field
1194+
on the ``request`` instance; if ``request`` is provided, this
1195+
should not be set.
1196+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1197+
should be retried.
1198+
timeout (float): The timeout for this request.
1199+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1200+
sent along with the request as metadata.
1201+
1202+
Returns:
1203+
google.cloud.aiplatform_v1.types.ModelEvaluation:
1204+
A collection of metrics calculated by
1205+
comparing Model's predictions on all of
1206+
the test data against annotations from
1207+
the test data.
1208+
1209+
"""
1210+
# Create or coerce a protobuf request object.
1211+
# Quick check: If we got a request object, we should *not* have
1212+
# gotten any keyword arguments that map to the request.
1213+
has_flattened_params = any([parent, model_evaluation])
1214+
if request is not None and has_flattened_params:
1215+
raise ValueError(
1216+
"If the `request` argument is set, then none of "
1217+
"the individual field arguments should be set."
1218+
)
1219+
1220+
# Minor optimization to avoid making a copy if the user passes
1221+
# in a model_service.ImportModelEvaluationRequest.
1222+
# There's no risk of modifying the input as we've already verified
1223+
# there are no flattened fields.
1224+
if not isinstance(request, model_service.ImportModelEvaluationRequest):
1225+
request = model_service.ImportModelEvaluationRequest(request)
1226+
# If we have keyword arguments corresponding to fields on the
1227+
# request, apply these.
1228+
if parent is not None:
1229+
request.parent = parent
1230+
if model_evaluation is not None:
1231+
request.model_evaluation = model_evaluation
1232+
1233+
# Wrap the RPC method; this adds retry and timeout information,
1234+
# and friendly error handling.
1235+
rpc = self._transport._wrapped_methods[self._transport.import_model_evaluation]
1236+
1237+
# Certain fields should be provided within the metadata header;
1238+
# add these here.
1239+
metadata = tuple(metadata) + (
1240+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1241+
)
1242+
1243+
# Send the request.
1244+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1245+
1246+
# Done; return the response.
1247+
return response
1248+
11461249
def get_model_evaluation(
11471250
self,
11481251
request: Union[model_service.GetModelEvaluationRequest, dict] = None,

google/cloud/aiplatform_v1/services/model_service/transports/base.py

+18
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from google.cloud.aiplatform_v1.types import model
3030
from google.cloud.aiplatform_v1.types import model as gca_model
3131
from google.cloud.aiplatform_v1.types import model_evaluation
32+
from google.cloud.aiplatform_v1.types import model_evaluation as gca_model_evaluation
3233
from google.cloud.aiplatform_v1.types import model_evaluation_slice
3334
from google.cloud.aiplatform_v1.types import model_service
3435
from google.longrunning import operations_pb2 # type: ignore
@@ -144,6 +145,11 @@ def _prep_wrapped_messages(self, client_info):
144145
self.export_model: gapic_v1.method.wrap_method(
145146
self.export_model, default_timeout=None, client_info=client_info,
146147
),
148+
self.import_model_evaluation: gapic_v1.method.wrap_method(
149+
self.import_model_evaluation,
150+
default_timeout=None,
151+
client_info=client_info,
152+
),
147153
self.get_model_evaluation: gapic_v1.method.wrap_method(
148154
self.get_model_evaluation,
149155
default_timeout=None,
@@ -236,6 +242,18 @@ def export_model(
236242
]:
237243
raise NotImplementedError()
238244

245+
@property
246+
def import_model_evaluation(
247+
self,
248+
) -> Callable[
249+
[model_service.ImportModelEvaluationRequest],
250+
Union[
251+
gca_model_evaluation.ModelEvaluation,
252+
Awaitable[gca_model_evaluation.ModelEvaluation],
253+
],
254+
]:
255+
raise NotImplementedError()
256+
239257
@property
240258
def get_model_evaluation(
241259
self,

google/cloud/aiplatform_v1/services/model_service/transports/grpc.py

+30
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from google.cloud.aiplatform_v1.types import model
2929
from google.cloud.aiplatform_v1.types import model as gca_model
3030
from google.cloud.aiplatform_v1.types import model_evaluation
31+
from google.cloud.aiplatform_v1.types import model_evaluation as gca_model_evaluation
3132
from google.cloud.aiplatform_v1.types import model_evaluation_slice
3233
from google.cloud.aiplatform_v1.types import model_service
3334
from google.longrunning import operations_pb2 # type: ignore
@@ -413,6 +414,35 @@ def export_model(
413414
)
414415
return self._stubs["export_model"]
415416

417+
@property
418+
def import_model_evaluation(
419+
self,
420+
) -> Callable[
421+
[model_service.ImportModelEvaluationRequest],
422+
gca_model_evaluation.ModelEvaluation,
423+
]:
424+
r"""Return a callable for the import model evaluation method over gRPC.
425+
426+
Imports an externally generated ModelEvaluation.
427+
428+
Returns:
429+
Callable[[~.ImportModelEvaluationRequest],
430+
~.ModelEvaluation]:
431+
A function that, when called, will call the underlying RPC
432+
on the server.
433+
"""
434+
# Generate a "stub function" on-the-fly which will actually make
435+
# the request.
436+
# gRPC handles serialization and deserialization, so we just need
437+
# to pass in the functions for each.
438+
if "import_model_evaluation" not in self._stubs:
439+
self._stubs["import_model_evaluation"] = self.grpc_channel.unary_unary(
440+
"/google.cloud.aiplatform.v1.ModelService/ImportModelEvaluation",
441+
request_serializer=model_service.ImportModelEvaluationRequest.serialize,
442+
response_deserializer=gca_model_evaluation.ModelEvaluation.deserialize,
443+
)
444+
return self._stubs["import_model_evaluation"]
445+
416446
@property
417447
def get_model_evaluation(
418448
self,

0 commit comments

Comments
 (0)