[object Object]

← back to Exo

Import download utils once all modules are loaded (#1238)

a31b6ee0458d065362023806be9cd9b5aff40068 · 2026-01-21 17:58:06 +0000 · rltakashige

## Motivation

Test failed due to circular import

## Changes

<!-- Describe what you changed in detail -->

## Why It Works

<!-- Explain why your approach solves the problem -->

## Test Plan

### Manual Testing
Tried importing and calling the functions, worked fine.

### Automated Testing
Tests pass again

Files touched

Diff

commit a31b6ee0458d065362023806be9cd9b5aff40068
Author: rltakashige <rl.takashige@gmail.com>
Date:   Wed Jan 21 17:58:06 2026 +0000

    Import download utils once all modules are loaded (#1238)
    
    ## Motivation
    
    Test failed due to circular import
    
    ## Changes
    
    <!-- Describe what you changed in detail -->
    
    ## Why It Works
    
    <!-- Explain why your approach solves the problem -->
    
    ## Test Plan
    
    ### Manual Testing
    Tried importing and calling the functions, worked fine.
    
    ### Automated Testing
    Tests pass again
---
 src/exo/shared/models/model_cards.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/exo/shared/models/model_cards.py b/src/exo/shared/models/model_cards.py
index 78f984ba..8f593316 100644
--- a/src/exo/shared/models/model_cards.py
+++ b/src/exo/shared/models/model_cards.py
@@ -348,12 +348,6 @@ MODEL_CARDS: dict[str, ModelCard] = {
     ),
 }
 
-from exo.worker.download.download_utils import (  # noqa: E402
-    ModelSafetensorsIndex,
-    download_file_with_retry,
-    ensure_models_dir,
-)
-
 
 class ConfigData(BaseModel):
     model_config = {"extra": "ignore"}  # Allow unknown fields
@@ -404,6 +398,11 @@ class ConfigData(BaseModel):
 
 async def get_config_data(model_id: ModelId) -> ConfigData:
     """Downloads and parses config.json for a model."""
+    from exo.worker.download.download_utils import (
+        download_file_with_retry,
+        ensure_models_dir,
+    )
+
     target_dir = (await ensure_models_dir()) / model_id.normalize()
     await aios.makedirs(target_dir, exist_ok=True)
     config_path = await download_file_with_retry(
@@ -421,6 +420,12 @@ async def get_config_data(model_id: ModelId) -> ConfigData:
 
 async def get_safetensors_size(model_id: ModelId) -> Memory:
     """Gets model size from safetensors index or falls back to HF API."""
+    from exo.shared.types.worker.downloads import ModelSafetensorsIndex
+    from exo.worker.download.download_utils import (
+        download_file_with_retry,
+        ensure_models_dir,
+    )
+
     target_dir = (await ensure_models_dir()) / model_id.normalize()
     await aios.makedirs(target_dir, exist_ok=True)
     index_path = await download_file_with_retry(

← 6a9251b9 Add mflux type stubs (#1234)  ·  back to Exo  ·  feat: initial image generation support (#1095) 307f454b →