Skip to content

model_download

Documentation for ModelDownloader

Class Overview

ModelDownloader is a utility class designed for downloading models with integrated retry logic. It utilizes a provided download function while managing transient network failures, logging attempts and errors to ensure robustness during model retrieval.

Functionality

The primary function of ModelDownloader is to encapsulate the model downloading process, handling temporary failures through retry management. It allows users to retrieve models consistently, even in the face of intermittent connectivity issues.

Parameters

  • retry_config: An optional dictionary that specifies parameters for retry behavior. If not provided, the default settings from the project configuration will be utilized.

Method: download_model

Purpose

The download_model method facilitates the downloading of a specified model while incorporating error handling through retries.

Parameters

  • model_name: The name of the model that is intended to be downloaded.
  • download_fn: A callable that accepts the model name and performs the downloading action.

Usage

This method is crucial for managing model downloads effectively, ensuring that transient errors do not lead to immediate failure during the download process.

Example

from embedding_studio.utils.model_download import ModelDownloader

downloader = ModelDownloader()
model = downloader.download_model(
    'my_model',
    download_fn=lambda name: perform_download(name)
)

Motivation

The design of the ModelDownloader class is driven by the need for a unified and resilient approach to model downloading, enabling users to recover from temporary failures seamlessly. This functionality is particularly important in environments where network stability is a concern.

Inheritance

The ModelDownloader class inherits directly from Python's base object.