googleapis / python-aiplatform

A Python SDK for Vertex AI, a fully managed, end-to-end platform for data science and machine learning.
Apache License 2.0
639 stars 347 forks source link

ModelEvaluation.list returns "invalid model resource name" #2362

Closed pbalm closed 1 year ago

pbalm commented 1 year ago

Environment details

Steps to reproduce

Calling ModelEvaluation.list with just the project and the region causes it to throw an error, but none of the arguments are marked as required.

Code example

from google.cloud import aiplatform as aip

project_id = 'myproject'
region = 'europe-west1'

aip.ModelEvaluation.list(project=project_id, location=region)

Stack trace

---------------------------------------------------------------------------
_InactiveRpcError                         Traceback (most recent call last)
~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     71         try:
---> 72             return callable_(*args, **kwargs)
     73         except grpc.RpcError as exc:

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/grpc/_channel.py in __call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
   1029                                       wait_for_ready, compression)
-> 1030         return _end_unary_response_blocking(state, call, False, None)
   1031 

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/grpc/_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
    909     else:
--> 910         raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    911 

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "List of found errors:    1.Field: parent; Message: Invalid Model resource name.  "
    debug_error_string = "UNKNOWN:Error received from peer ipv4:142.250.200.138:443 {grpc_message:"List of found errors:\t1.Field: parent; Message: Invalid Model resource name.\t", grpc_status:3, created_time:"2023-07-13T18:31:11.205214+02:00"}"
>

The above exception was the direct cause of the following exception:

InvalidArgument                           Traceback (most recent call last)
/var/folders/q7/4tdf_x151sn5v4rjmlwb60jr00vkz8/T/ipykernel_18972/3978770108.py in <cell line: 13>()
     11 # --> requires model evaluation name
     12 
---> 13 aip.ModelEvaluation.list(project=project_id, location=region)

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/google/cloud/aiplatform/base.py in list(cls, filter, order_by, project, location, credentials, parent)
   1251         """
   1252 
-> 1253         return cls._list(
   1254             filter=filter,
   1255             order_by=order_by,

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/google/cloud/aiplatform/base.py in _list(cls, cls_filter, filter, order_by, read_mask, project, location, credentials, parent)
   1124             list_request["order_by"] = order_by
   1125 
-> 1126         resource_list = resource_list_method(request=list_request) or []
   1127 
   1128         return [

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/google/cloud/aiplatform_v1/services/model_service/client.py in list_model_evaluations(self, request, parent, retry, timeout, metadata)
   2411 
   2412         # Send the request.
-> 2413         response = rpc(
   2414             request,
   2415             retry=retry,

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py in __call__(self, timeout, retry, *args, **kwargs)
    111             kwargs["metadata"] = metadata
    112 
--> 113         return wrapped_func(*args, **kwargs)
    114 
    115 

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     72             return callable_(*args, **kwargs)
     73         except grpc.RpcError as exc:
---> 74             raise exceptions.from_grpc_error(exc) from exc
     75 
     76     return error_remapped_callable

InvalidArgument: 400 List of found errors:  1.Field: parent; Message: Invalid Model resource name.   [field_violations {
  field: "parent"
  description: "Invalid Model resource name."
}
]
sararob commented 1 year ago

I've fixed this to require the model resource name in https://github.com/googleapis/python-aiplatform/pull/2364, it will go out with our next release.

In the meantime, you can do either:

aip.ModelEvaluation.list(parent="projects/{}/locations/{}/models/{}")

or

my_model = aip.Model("projects/{}/locations/{}/models/{}")
my_model.list_model_evaluations()
pbalm commented 1 year ago

Thank you! Tested and confirmed.