|
43 | 43 | from google.cloud.aiplatform_v1.types import model
|
44 | 44 | from google.cloud.aiplatform_v1.types import model as gca_model
|
45 | 45 | from google.cloud.aiplatform_v1.types import model_evaluation
|
| 46 | +from google.cloud.aiplatform_v1.types import model_evaluation as gca_model_evaluation |
46 | 47 | from google.cloud.aiplatform_v1.types import model_evaluation_slice
|
47 | 48 | from google.cloud.aiplatform_v1.types import model_service
|
48 | 49 | from google.cloud.aiplatform_v1.types import operation as gca_operation
|
@@ -1143,6 +1144,108 @@ def sample_export_model():
|
1143 | 1144 | # Done; return the response.
|
1144 | 1145 | return response
|
1145 | 1146 |
|
| 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 | + |
1146 | 1249 | def get_model_evaluation(
|
1147 | 1250 | self,
|
1148 | 1251 | request: Union[model_service.GetModelEvaluationRequest, dict] = None,
|
|
0 commit comments