跳到主要内容

get_refresh_external_collection_progress()

公测版

此操作返回指定外部 Collection 刷新作业的进度。

📘Notes

这需要使用项目 Endpoint 按如下方式设置一个 MilvusClient:

https://{project-id}.{region}.api.zillizcloud.com

请求语法

python
def get_refresh_external_collection_progress(
job_id: int,
timeout: Optional[float] = None,
**kwargs,
) -> RefreshExternalCollectionJobInfo:

参数:

  • job_id (int) -

    [必需]

    refresh_external_collection() 返回的作业 ID。

  • timeout (float) -

    此操作的超时时长。

    将其设置为 None 表示当收到任何响应或发生任何错误时,此操作即超时。

返回类型:

RefreshExternalCollectionJobInfo

返回:

一个 RefreshExternalCollectionJobInfo 对象,用于记录指定外部 Collection 刷新作业的详细信息。

参数:

  • job_id (int) -

    当前请求中指定的作业 ID。

  • collection_name (string) -

    refresh_external_collection() 中指定的外部 Collection 名称。

  • state (string) -

    指定作业的当前状态。可能的值包括:

    • 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) -

    指定作业结束时的毫秒级时间戳。

示例

python
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)
最低 SDK 版本v3.0.x
Ctrl I