[Bug]: Model download sleeps after its final failed attempt

Đang mở
#855 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@elysiopires đang làm issue này rồi.

Từ ngày 29/10/2026.

  • #856 của @elysiopires — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

The issue identifies ModelManagement.download_model() in fastembed/common/model_management.py and describes mocked regression cases for one and three attempts, with and without URL fallback. Read the retry and sleep logic, then run the regression cases described in the issue. Done means sleeps occur only between attempts while the attempt count, URL fallback, offline behavior, and final exception remain unchanged.

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

Mô tả

What happened?

ModelManagement.download_model() sleeps after the final failed download attempt, even when its retry counter has reached zero.

With the default retries=3, failed downloads sleep for 3, 9 and 27 seconds. Only the first two sleeps precede another attempt; the last 27 seconds delay the final ValueError without retrying anything. With retries=1, a failed attempt still sleeps for three seconds before returning the error.

Minimal reproduction

This reproducer mocks model downloads and sleep, so it needs no model weights or network access:

from unittest.mock import Mock, patch
from fastembed.common.model_description import BaseModelDescription, ModelSource
from fastembed.common.model_management import ModelManagement

model = BaseModelDescription(
    model="test/missing-model",
    sources=ModelSource(hf="test/missing-model"),
    model_file="model.onnx",
    description="Test fixture",
    license="Apache-2.0",
    size_in_GB=0.0,
)
with patch.object(ModelManagement, "download_files_from_huggingface", side_effect=OSError("unavailable")), patch("fastembed.common.model_management.time.sleep") as sleep:
    try:
        ModelManagement.download_model(model, "/tmp/unused-fastembed-repro", retries=3)
    except ValueError:
        pass
    print(sleep.call_args_list)

Actual: [call(3.0), call(9.0), call(27.0)]

Expected: [call(3.0), call(9.0)]

Run with HF_HUB_OFFLINE unset.

Proposed fix

Sleep only when another attempt remains. Preserve the number of attempts, exponential delays between them, URL fallback, offline behavior and the final exception.

I reproduced this with four regression cases covering one/three attempts, with and without URL fallback. All four fail before the fix because of the extra sleep.

Environment
  • FastEmbed 0.9.1 from current main
  • Python 3.11.9 on macOS
  • Downloads and sleeps mocked; no model downloaded or credentials used

AI assistance: OpenAI Codex. The regression cases were run locally.

Ngôn ngữ chính
Python
Star
3.3k
Fork
289
Merge trung bình
3 ngày 13 giờ
Pull request đã merge (30 ngày)
58

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của qdrant/fastembed

Tất cả issue của qdrant/fastembed

Issue tương tự

Thêm issue về Python

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.