6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Vertex AI Vector Search の DeployedIndex の index_sync_time を取得する

Last updated at Posted at 2024-12-05

To check whether the change has been propagated, compare the update index operation finish time and the DeployedIndex.index_sync_time

ref: https://cloud.google.com/vertex-ai/docs/vector-search/update-rebuild-index?hl=en

Index の更新が DeployedIndex に伝播されたかを確認するために index_sync_time を参照せよ、とのことだが具体的な参照方法が記載されておらず困った。

色々試してみた結果以下のようにすればよいことが分かった。
DeployedIndex を直接参照する方法が見つからなかったため、まず IndexEndpoint を取得し、IndexEndponit が持つ deployed_indexes を参照する形になっている。

from google.cloud import aiplatform

INDEX_ENDPOINT_NAME='projects/xxxxxx/locations/xxxxxx/indexEndpoints/xxxxxx'
index_endpoint = aiplatform.MatchingEngineIndexEndpoint(
    index_endpoint_name=INDEX_ENDPOINT_NAME
)
index_sync_time = index_endpoint.deployed_indexes[0].index_sync_time

P.S.

DeployedIndex を直接参照する方法はないため、まず IndexEndpoint を取得し、IndexEndponit が持つ deployed_indexes を参照する

IndexEndponit が持つ deployed_indexes の内容は以下のようになっている。

from google.cloud import aiplatform

INDEX_ENDPOINT_NAME='projects/xxxxxx/locations/xxxxxx/indexEndpoints/xxxxxx'
index_endpoint = aiplatform.MatchingEngineIndexEndpoint(
    index_endpoint_name=INDEX_ENDPOINT_NAME
)
print(index_endpoint.deployed_indexes[0])
id: "xxxxxx"
index: "projects/xxxxxx/locations/xxxxxx/indexes/xxxxxx"
display_name: "xxxxxx"
create_time {
  seconds: 1733286121
  nanos: 942464000
}
index_sync_time {
  seconds: 1733366784
  nanos: 183820000
}
automatic_resources {
  min_replica_count: 1
  max_replica_count: 1
}

ちなみに IndexEndpoint ではなく Index からも deployed_indexes を参照できるが、ここには index_sync_time が含まれていなかった。

from google.cloud import aiplatform

INDEX_NAME = "xxxxxx"
index = aiplatform.MatchingEngineIndex(index_name=INDEX_NAME)
print(index.deployed_indexes[0])
index_endpoint: "projects/xxxxxx/locations/xxxxxx/indexEndpoints/xxxxxx"
deployed_index_id: "xxxxxx"
display_name: "xxxxxx"
6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?