get_refresh_external_collection_progress()
公测版此操作返回指定外部 Collection 刷新作业的进度。
这需要使用项目 Endpoint 按如下方式设置一个 MilvusClient:
https://{project-id}.{region}.api.zillizcloud.com
请求语法
def get_refresh_external_collection_progress(
参数:
-
job_id (int) -
[必需]
由 refresh_external_collection() 返回的作业 ID。
-
timeout (float) -
此操作的超时时长。将其设置为 None 表示当收到任意响应或发生错误时,此操作即超时。
返回类型:
RefreshExternalCollectionJobInfo
返回:
一个 RefreshExternalCollectionJobInfo 对象,用于记录指定外部 Collection 刷新作业的详细信息。
{
'job_id': 4325693842392,
'collection_name': 'test_collection',
'state': 'RefreshInProgress',
'progress': 67,
'reason': ''
'external_source': 'volume://<my_volume>/<bucket>/'
'start_time': 1776470400000
'end_time': 1776470434567
}
参数:
-
job_id (int) -
当前请求中指定的作业 ID。
-
collection_name (string) -
在
refresh_external_collection()中指定的外部 Collection 名称。 -
state (string) -
指定作业的当前状态。刷新作业会从
RefreshInProgress转变为RefreshCompleted或RefreshFailed。可能的值为:-
RefreshPending
-
RefreshInProgress
-
RefreshFailed
-
RefreshCompleted
-
-
progress (int) -
指定作业的当前进度。该值是一个 0 到 100 之间的整数。
-
external_source (str) -
在
refresh_external_collection()中指定的外部源 URI。 -
external_specs (str) -
在
refresh_external_collection()中指定的外部规格。 -
reason (str) -
如果刷新操作失败,则为错误提示。正常情况下为空字符串。
-
start_time (int) -
指定作业开始时的毫秒级时间戳。
-
end_time (int) -
指定作业结束时的毫秒级时间戳。
示例
import time
from pymilvus import MilvusClient
# 1. Set up a milvus client
client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)
job_id = client.refresh_external_collection(
collection_name="test_collection"
)
while True:
progress = client.get_refresh_external_collection_progress(job_id=job_id)
print(f" {progress.state}: {progress.progress}%")
if progress.state == "RefreshCompleted":
elapsed = progress.end_time - progress.start_time
print(f" Completed in {elapsed}ms")
break
elif progress.state == "RefreshFailed":
print(f" Failed: {progress.reason}")
break
time.sleep(2)
from pymilvus import MilvusClient
# 1. Set up a milvus client
client = MilvusClient(
uri="YOUR_PROJECT_ENDPOINT",
token="YOUR_API_KEY"
)
job_id = client.refresh_external_collection(
collection_name="test_collection"
)
while True:
progress = client.get_refresh_external_collection_progress(job_id=job_id)
print(f" {progress.state}: {progress.progress}%")
if progress.state == "RefreshCompleted":
elapsed = progress.end_time - progress.start_time
print(f" Completed in {elapsed}ms")
return job_id
elif progress.state == "RefreshFailed":
print(f" Failed: {progress.reason}")
return job_id
time.sleep(2)