Skip to content

Automation foundation model for tiny devices: 2-bit, 8-29 MB, tool calls, ASR, structured extraction and embeddings on phones, wearables, smart homes, robots, cars and microcontrollers.

Fix download bug

HenryNdubuakuca2b99f94827
diff --git a/needle/training/finetune.py b/needle/training/finetune.py
index 5702441..e494308 100644
--- a/needle/training/finetune.py
+++ b/needle/training/finetune.py
@@ -212,22 +212,18 @@ def _emit(tag, data):
def _resolve_checkpoint(path):
- """Resolve checkpoint path, downloading from HuggingFace if needed."""
- if path and os.path.exists(path):
- return path
+ """Resolve checkpoint path, always downloading from HuggingFace to ensure freshness."""
from huggingface_hub import hf_hub_download
local_dir = "checkpoints"
os.makedirs(local_dir, exist_ok=True)
filename = os.path.basename(path) if path else "needle.pkl"
- local_path = os.path.join(local_dir, filename)
- if os.path.exists(local_path):
- return local_path
print(f"Downloading {filename} from Cactus-Compute/needle...")
return hf_hub_download(
repo_id="Cactus-Compute/needle",
filename=filename,
repo_type="model",
local_dir=local_dir,
+ force_download=True,
)
diff --git a/needle/ui/server.py b/needle/ui/server.py
index 673e7ee..d75bbc9 100644
--- a/needle/ui/server.py
+++ b/needle/ui/server.py
@@ -738,23 +738,19 @@ _HF_MODEL_FILE = "needle.pkl"
def _resolve_checkpoint(checkpoint_arg):
- """Resolve checkpoint path: download from HuggingFace if not provided or not local."""
- if checkpoint_arg and os.path.exists(checkpoint_arg):
- return checkpoint_arg
+ """Resolve checkpoint path: always download from HuggingFace to ensure freshness."""
from huggingface_hub import hf_hub_download
local_dir = "checkpoints"
os.makedirs(local_dir, exist_ok=True)
filename = os.path.basename(checkpoint_arg) if checkpoint_arg else _HF_MODEL_FILE
repo = _HF_MODEL_REPO
- local_path = os.path.join(local_dir, filename)
- if os.path.exists(local_path):
- return local_path
print(f"Downloading {filename} from {repo}...", file=sys.stderr)
path = hf_hub_download(
repo_id=repo,
filename=filename,
repo_type="model",
local_dir=local_dir,
+ force_download=True,
)
print(f"Downloaded to {path}", file=sys.stderr)
return path