googleapis / googleapis/python-aiplatform

Labels of specific version of a model can't be updated using the aiplatform.Model.update method

Đang mở
#3,049 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
api: vertex-ai
Ngôn ngữ chính
Python
Star
905
Fork
465
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
44

Mô tả

The issue is:
model in Model Registry has labels. Every model version has its own labels, and the current behavior of `Model.update(labels=...)` is undocumented and behaves unintuitively.
If I have multiple versions of the model in the model registry, regardless of the model version I select, this method updates only the labels for the model itself and labels for the default version, there is no way how to use any function in `aiplarform` to update labels of specific version.

The root cause is https://github.com/googleapis/python-aiplatform/blob/v1.36.4/google/cloud/aiplatform/models.py#L2914-L2916
which is causing this behavior which ignores all non-default versions, and it seems to be deliberate due to the comment there.
This should be documented. I would also appreciate a method for changing the labels of the model version.

I have made support requests:
- https://console.cloud.google.com/support/cases/detail/v2/43984371?organizationId=676993294933
- https://console.cloud.google.com/support/cases/detail/v2/44432651?organizationId=676993294933
- https://console.cloud.google.com/support/cases/detail/v2/46558387?organizationId=676993294933
and as a result, https://issuetracker.google.com/issues/297582022 was created, but it is still not resolved.

#### Environment details

- OS type and version: windows 10
- Python version: `Python 3.11.5`
- pip version: `pip 23.2.1 from C:\Users\E10270\.conda\envs\py311test\Lib\site-packages\pip (python 3.11)`
- `google-cloud-aiplatform` version:
```
Name: google-cloud-aiplatform
Version: 1.33.1
Summary: Vertex AI API client library
Home-page: https://github.com/googleapis/python-aiplatform
Author: Google LLC
Author-email: googleapis-packages@google.com
License: Apache 2.0
Location: C:\Users\E10270\.conda\envs\py311test\Lib\site-packages
Requires: google-api-core, google-cloud-bigquery, google-cloud-resource-manager, google-cloud-storage, packaging, proto-plus, protobuf, shapely
Required-by:
```

#### Steps to reproduce

1. let's take some model with several versions, e.g.
![image](https://github.com/googleapis/python-aiplatform/assets/5525771/83b692ee-fe35-4875-b269-f745a1a144b5)
2. I run following code:
```python
from google.cloud import aiplatform
location = 'europe-west1'
a_model = aiplatform.Model.list(project='981769406988', location=location,
filter=f'display_name="version-experiment-model"')[0]
print(a_model.versioned_resource_name, a_model.labels)
a_model.update(labels={"test_label": "1"})
```
the value of `a_model.versioned_resource_name`
is `'projects/981769406988/locations/europe-west1/models/version-experiment-model-model@5'`, the value of `a_model.labels` is
{'version': '0_0_4',
'experiment_name': 'development-stuff',
'owner': 'matej_racinsky'}
note that the versioned resource name has specific version.
3. the labels now look like this, note that the new label was added to the model labels and also all versions, but while it replaces the labels for model itself, it just adds the labels to individual model versions:
![image](https://github.com/googleapis/python-aiplatform/assets/5525771/d6abe518-6167-4aef-9ff7-4be3481d5ef2)
4. when I try to use the `aiplatform_v1` api, it works and changes the data only for the specific version without touching the rest, but it has the disadvantage, that it overwrites the data, it does not append, and there is no reasonable way how to obtain labels for specific version, not the model as a whole. This is the code I ran:
```python
from google.cloud import aiplatform_v1
from google.protobuf import field_mask_pb2
a_model_v1 = a_model.api_client.get_model(
name=a_model.versioned_resource_name
)
print(a_model_v1.labels, a_model_v1.name)

# %%
a_model_v1.labels = {
'experiment_name': 'development-stuff',
'test_label':'100',
'new_info':'new_info'
}
print(a_model_v1.labels)
#%%
a_request = aiplatform_v1.UpdateModelRequest(
model=a_model_v1,
update_mask=field_mask_pb2.FieldMask(paths=['labels'])
)
# Make the request
a_response = a_model.api_client.update_model(request=a_request)
```
and this is the stuff it printed:
`{'test_label': '1'} projects/981769406988/locations/europe-west1/models/version-experiment-model-model@5`
and
`{'experiment_name': 'development-stuff', 'test_label': '100', 'new_info': 'new_info'}`
6.
![image](https://github.com/googleapis/python-aiplatform/assets/5525771/f8497f14-919d-4a99-b8d3-37669018b88e)

There is no stack trace, but I hope it's clear what is the problem.
And the docs https://github.com/googleapis/python-aiplatform/blob/v1.36.4/google/cloud/aiplatform/models.py#L2888-L2897 do not describe the current non-intuitive behavior at all. https://github.com/googleapis/python-aiplatform/blob/v1.36.4/google/cloud/aiplatform/models.py#L2888-L2897

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with google/cloud/aiplatform/models.py around lines 2888-2916, especially Model.update, and compare it with the aiplatform_v1 get_model and update_model calls shown in the report. Review the linked API behavior and existing documentation, then verify that the model-level and version-level label semantics and the supported update path are clearly covered.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
google-cloud, python
Lĩnh vực
machine-learning
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.