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 fails with "order_by" #2363

Closed pbalm closed 1 year ago

pbalm commented 1 year ago

Environment details

Call ModelEvaluation.list with a specific order - it throws an exception. The Python SDK supports it but the underlying REST API does not.

Code example

from google.cloud import aiplatform as aip

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

model_id = '123456'

evluations = aip.ModelEvaluation.list(
    project=project_id, 
    location=region, 
    parent=f'projects/{project_id}/locations/{region}/models/{model_id}',
    order_by='create_time'
)

Stack trace

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/q7/4tdf_x151sn5v4rjmlwb60jr00vkz8/T/ipykernel_18972/3392966343.py in <cell line: 13>()
     11 # --> requires model evaluation name
     12 
---> 13 evluations = aip.ModelEvaluation.list(
     14     project=project_id,
     15     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)
   2394         # there are no flattened fields.
   2395         if not isinstance(request, model_service.ListModelEvaluationsRequest):
-> 2396             request = model_service.ListModelEvaluationsRequest(request)
   2397             # If we have keyword arguments corresponding to fields on the
   2398             # request, apply these.

~/customers/caixabank/pipeline/venv/lib/python3.8/site-packages/proto/message.py in __init__(self, mapping, ignore_unknown_fields, **kwargs)
    563                     continue
    564 
--> 565                 raise ValueError(
    566                     "Unknown field for {}: {}".format(self.__class__.__name__, key)
    567                 )

ValueError: Unknown field for ListModelEvaluationsRequest: order_by
sararob commented 1 year ago

Per my comment on https://github.com/googleapis/python-aiplatform/issues/2362, this will also be fixed with https://github.com/googleapis/python-aiplatform/pull/2364.