HKUDS/Vibe-Trading · error · HTTPException

too many running comparisons; wait for one to finish

Error message

too many running comparisons; wait for one to finish

What it means

load_dataframe is the entry point of the trade-journal parsing stack; it takes a filesystem path and raises FileNotFoundError when Path(path).exists() is false. Both .xlsx/.xls and .csv routes sit behind this check, so any missing file fails here regardless of format.

Source

Thrown at agent/src/api/alpha_routes.py:601

    # -----------------------------------------------------------------------

    @app.post(
        "/alpha/compare",
        status_code=202,
        dependencies=[Depends(require_auth)],
    )
    async def kick_off_compare(payload: CompareRequest) -> dict[str, Any]:
        """Queue a background head-to-head comparison and return a job_id."""
        from src.tools.alpha_bench_tool import _parse_period

        try:
            _parse_period(payload.period)
        except ValueError as exc:
            raise HTTPException(status_code=400, detail=f"invalid period: {exc}")

        sem = _get_compare_semaphore()
        if sem.locked() or getattr(sem, "_value", MAX_CONCURRENT_COMPARES) <= 0:
            raise HTTPException(
                status_code=429,
                detail="too many running comparisons; wait for one to finish",
            )

        _prune_old_jobs()

        job_id = uuid.uuid4().hex
        with _JOBS_LOCK:
            ALPHA_COMPARE_JOBS[job_id] = {
                "job_id": job_id,
                "status": "queued",
                "alpha_ids": payload.alpha_ids,
                "universe": payload.universe,
                "period": payload.period,
                "sort": payload.sort,
                "created_at": _now_iso(),
                "progress": {"n_done": 0, "n_total": len(payload.alpha_ids), "current_alpha_id": None},
                "result": None,

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Check existence before parsing: if not Path(p).is_file(): raise/skip early
  2. Expand and absolutize user paths: p = Path(user_path).expanduser().resolve()
  3. Verify the producing step succeeded before invoking the parser in pipelines

Example fix

# before
parse_file('~/uploads/trades.csv')  # '~' not expanded by Path.exists
# after
from pathlib import Path
p = Path('~/uploads/trades.csv').expanduser().resolve()
assert p.is_file(), f'missing {p}'
parse_file(str(p))
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(user_path).expanduser().resolve()
if not p.is_file():
    raise FileNotFoundError(f'upload not found: {p}')
df = load_dataframe(str(p))

Type guard

def is_readable_file(p) -> bool:
    from pathlib import Path
    return Path(p).expanduser().is_file()

Try / catch

try:
    df = load_dataframe(path)
except FileNotFoundError:
    path = locate_upload_elsewhere()  # search/re-download
    df = load_dataframe(path)

Prevention

When it happens

Trigger: Calling parse_file('trades.csv') when the file is absent, in a different CWD, already moved/deleted by a prior step, or when the path contains typos, unexpanded '~', or wrong separators. Also triggered in tests via tmp paths that were never written.

Common situations: Upload handlers that store the file then race with deletion; relative paths resolved against a different working directory; user-supplied Windows-style paths on POSIX; cron/airflow tasks whose upstream file-producing step failed silently.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/5ff5a27fc5a8bb6c. Report an issue: GitHub.