Skip to content

fix(lora): wait for in-flight Civitai download before raising FileNotFoundError (#937)#939

Open
livepeer-tessa wants to merge 2 commits intomainfrom
fix/937-lora-civitai-download-race
Open

fix(lora): wait for in-flight Civitai download before raising FileNotFoundError (#937)#939
livepeer-tessa wants to merge 2 commits intomainfrom
fix/937-lora-civitai-download-race

Conversation

@livepeer-tessa
Copy link
Copy Markdown
Contributor

Problem

Fixes #937.

When a session is re-initialised with a Civitai-hosted LoRA (e.g. [flux.2.klein]pixelart_redmond-000032.safetensors), the download from Civitai is re-triggered asynchronously while pipeline_manager concurrently calls LongLivePipeline.__init__. load_lora_weights was called synchronously before the download finished, causing:

ERROR - LongLivePipeline.__init__: LoRA file not found: /tmp/.daydream-scope/assets/lora/[flux.2.klein]pixelart_redmond-000032.safetensors

The session recovered on a retry (~1–2 min later) but the false error polluted logs alongside real missing-file errors (#923).

Fix

Added _wait_for_lora_file() in lora/utils.py. Before load_lora_weights raises FileNotFoundError, it now polls for the file's existence for up to 120 seconds (configurable via SCOPE_LORA_DOWNLOAD_WAIT_TIMEOUT).

  • No change to public API or callers
  • FileNotFoundError semantics preserved for files that genuinely don't exist
  • timeout=0 disables the wait entirely
  • Env var SCOPE_LORA_DOWNLOAD_WAIT_TIMEOUT overrides the default

Tests

tests/test_lora_wait_for_file.py — 7 tests covering all branches.

Tessa (livepeer-tessa) added 2 commits April 14, 2026 06:25
…peline ID (#936)

Signed-off-by: Tessa (livepeer-tessa) <tessa@livepeer.org>
…FoundError

Fixes #937.

When a session is re-initialised with a Civitai-hosted LoRA, the local
Civitai download is re-triggered asynchronously while pipeline_manager
concurrently calls LongLivePipeline.__init__.  load_lora_weights was
called synchronously before the download completed, causing a spurious
FileNotFoundError that failed the pipeline load and left the session
needing a manual retry.

Fix: add _wait_for_lora_file() in lora/utils.py that polls for the
file's existence before raising.  The timeout defaults to 120 s and is
configurable via SCOPE_LORA_DOWNLOAD_WAIT_TIMEOUT.  No change to
callers; existing FileNotFoundError semantics are preserved when the
file genuinely does not appear within the timeout.

Also adds tests/test_lora_wait_for_file.py covering:
- file already present → returns immediately
- file appears during wait → returns True
- file never appears → returns False / raises after timeout
- timeout=0 → disables waiting
- SCOPE_LORA_DOWNLOAD_WAIT_TIMEOUT env var override

Signed-off-by: Tessa (livepeer-tessa) <tessa@livepeer.org>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8674b284-1994-493f-9df0-a59fa6bc0a07

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/937-lora-civitai-download-race

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 fal.ai Preview Deployment

App ID daydream/scope-pr-939--preview
WebSocket wss://fal.run/daydream/scope-pr-939--preview/ws
Commit 6ee0470

Livepeer Runner

App ID daydream/scope-livepeer-pr-939--preview
WebSocket wss://fal.run/daydream/scope-livepeer-pr-939--preview/ws
Auth private

Testing Livepeer Mode

SCOPE_CLOUD_MODE=livepeer SCOPE_CLOUD_APP_ID="daydream/scope-livepeer-pr-939--preview/ws" uv run daydream-scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fal.ai] longlive: LoRA file not found on session reinit — Civitai download races pipeline __init__ for [flux.2.klein] LoRA

1 participant