calesthio/OpenMontage · error · AtlasError

Cannot upload — file not found: {path}

Error message

Cannot upload — file not found: {path}

What it means

Raised by upload_media when the local file at file_path does not exist (Path.exists() is false) before any network activity starts. It is a precondition check so the caller gets a clear 'file not found' instead of an obscure open() traceback or a request with missing content. Causes include wrong path, race (file deleted/moved), or a relative path resolved against the wrong working directory.

Source

Thrown at tools/atlas_client.py:198

    raise AtlasError(
        f"Prediction {prediction_id} did not finish within {timeout:.0f}s "
        f"(last status: {last_status}). The job may still complete — "
        f"check {PREDICTION_ENDPOINT}/{prediction_id}"
    )


def upload_media(file_path: str | Path, api_key: str, timeout: int = 120) -> str:
    """Upload a local file and return the hosted URL Atlas assigns to it.

    Used to turn a local reference image into the `image_url` that image-to-video
    models expect. Atlas has answered this endpoint with both {"data":
    {"download_url": ...}} and a bare {"url": ...}, so both shapes are accepted.
    """
    import requests

    path = Path(file_path)
    if not path.exists():
        raise AtlasError(f"Cannot upload — file not found: {path}")

    try:
        with path.open("rb") as handle:
            response = requests.post(
                UPLOAD_MEDIA_ENDPOINT,
                headers=_headers(api_key, json_body=False),
                files={"file": (path.name, handle)},
                timeout=timeout,
            )
    except Exception as exc:  # noqa: BLE001
        raise AtlasError(f"Uploading {path.name} to Atlas Cloud failed: {exc}") from exc

    _raise_for_status(response, "Atlas Cloud upload")
    data = _payload_of(response)

    url = data.get("download_url") or data.get("url")
    if not url:
        raise AtlasError(f"Atlas Cloud upload returned no URL: {str(data)[:500]}")

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Verify the upstream step that should have produced the file actually succeeded, and fail loudly there if not
  2. Use absolute paths (Path(...).resolve()) before calling upload_media
  3. If a temp file, ensure it isn't deleted (context manager exiting early) before upload runs
  4. Check for stray whitespace/newlines in path strings from config or CLI args

Example fix

// before
url = atlas_client.upload_media("output/frame_001.png", api_key)

// after
from pathlib import Path
p = Path("output/frame_001.png").resolve()
if not p.is_file():
    raise FileNotFoundError(f"reference image missing: {p}")
url = atlas_client.upload_media(p, api_key)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

p = Path(file_path).resolve()
if not p.is_file():
    raise FileNotFoundError(f"cannot upload missing file: {p}")
url = atlas_client.upload_media(p, api_key)

Type guard

def is_uploadable_file(path) -> bool:
    try:
        return Path(path).is_file()
    except OSError:
        return False

Prevention

When it happens

Trigger: Passing a reference-image path that was never written (upstream generation step failed silently); file cleaned up by a temp-dir reaper between creation and upload; relative path resolved from a different cwd in a daemon or worker process.

Common situations: Pipeline stages assuming a prior stage's output exists without checking; path built with os.path.join on Windows using mixed separators; symlink targets deleted; files on unmounted network shares.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/3c878b4e676947aa. Report an issue: GitHub.