googleapis / googleapis/python-aiplatform

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

オープン
#3,049 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
api: vertex-ai
主要言語
Python
スター
905
フォーク
465
平均マージ
1日 13時間
マージ済み PR(30日)
44

説明

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。