Spaces:
Sleeping
Sleeping
Commit History
-
Speed up chat + emit >=10 figures/tables per Phase-2 model run
Two user-visible fixes from the post-deployment feedback: 1. Chat felt slower than before the fallback chain landed. Root cause was not the chain itself (it exits on the first parseable response), but three pile-on effects that compound on a cold HF worker: a. max_tokens was 900 for a JSON output that is well under 200. The Gemini free tier generates up to the cap. Lowered to 400. b. Every chat call re-built the provider object, paying the GeminiProvider/_http setup cost on a cold worker. Now cached at module level (_provider_cache). c. LLMConfig.timeout_s was 30s, so a stalled provider cost the full 30 before the chain rolled over. Lowered to 12 with a CDPR_LLM_TIMEOUT_S env override for slow links. gradio_app.py also pre-warms the chain at module load time so the FIRST chat after a Space restart doesn't pay construction cost --- it pays it once, before the user even sees the page. simulation_builder gains…0c4152d
-
Diagnose HF push: surface token role + fine-grained scope + email status
The first pass of the diagnostic only verified identity (token user matches Space owner) and existence. The user's actual failure had identity + ownership both correct, so the cause must be in: * token role (Read vs Write vs Fine-grained), or * email verification status, or * fine-grained scope coverage of the target Space. This pass reads auth.accessToken.role and auth.accessToken.fineGrained from /api/whoami-v2, plus emailVerified, then prints a tailored fix ladder per case: - read-scope token -> 'create Write token' (return 8) - fine-grained, no Space -> 'add space:JoeTach/cdpr-simulator to token permissions, or make a classic Write token' (return 9) - unverified email -> 'click HF's verify-email link' (return 7) - everything OK -> push should work; if it doesn't, look at Space settings / HF status page Also fixed the SyntaxWarning from \d in the module do…b2af897 -
Add scripts/diagnose_hf_push.py to definitively diagnose the HF auth failure
The 'pre-receive hook declined' pattern combined with successful object upload means the token authenticates but the token's account lacks write permission on JoeTach/cdpr-simulator. This script calls HF's REST API directly with the user's token and reports: 1. Whether the token is valid (whoami-v2) 2. Which HF account the token actually belongs to 3. Whether the target Space exists and who owns it 4. The exact mismatch and three concrete fix paths Uses only stdlib urllib --- no install required. Token never echoes in any output; only the last 6 characters appear in the diagnostic header. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>0ee834d -
LLM provider abstraction + conversational simulation builder + token leak fix
Implements the directive's LLM integration layer cleanly: five providers, zero hard SDK dependencies, never crashes when no key is configured. Also fixes the immediate security issue: the previous deploy attempt embedded a write-scope HF token directly in the git remote URL (visible to anyone running git remote -v). Security fix The token-embedded remote URL was sanitised: git remote set-url space https://huggingface.co/spaces/JoeTach/cdpr-simulator The leaked token MUST also be revoked manually at https://huggingface.co/settings/tokens . See the runbook in docs/hf-auth-troubleshoot.md for the full rotation procedure. src/cdpr/llm/ --- provider-agnostic LLM layer base.py LLMProvider Protocol + LLMMessage / LLMResponse dataclasses + LLMUnavailableError. config.py LLMConfig.from_env() that reads .env via dotenv (optional dep), with canonical env-var names (GEMINI_API_KEY, OPENROUTER_API_KEY, OLLAMA…1f10b7b
-
Smart data ingestion + figure safety + synthetic manifest + HF auth fix
Addresses the directive's six Major Problems without disturbing the primary Gradio workflow at http://127.0.0.1:7860. Major Problem 1 — robust multi-format CSV ingestion New module cdpr.ingest.smart_loader provides load_dataset() and ProfileReport across CSV / TSV / TXT / XLSX / XLS / ODS / Parquet / Feather. Auto-detects format from extension and magic bytes; missing engine surfaces a clean ImportError with the install command rather than a tangled traceback. Timestamp handling: any column whose normalised name matches the alias table (time/timestamp/ts/sec/date/...) OR any string column whose first non-null values parse as datetime is converted to seconds-from-first-sample under a new 't' column. The directive's exact failure case --- 2025-05-07 15:01:27.548198 --- yields t = 0, 1, 2, 3, 4 (seconds). Missing-value handling: recognises the full sentinel set the directive listed (none/None/NULL/NaN/nan/N/A/missing/blank plus common spreadshe…2ad96a7
-
Five built-in CDPR_SIMULATOR examples (3 trajectories + 2 data-driven)
Implements the directive's selectable demonstration set as built-in tutorials accessible identically from PowerShell and the Streamlit GUI. The registry in scripts/examples.py is the single source of truth. Phase 1 — physics-based motion simulation: * circle --- 3-DoF planar circular tracking on the dissertation_8cable robot. 0.05 m radius, 2 revolutions, ~12.6 s, quintic time-scaling for smooth start / stop. * spiral --- 6-DoF helical sweep (the directive's "one example with all six DoFs" requirement). 3-revolution spiral at z = 0.65 m +/- 0.04 m with bounded sinusoidal yaw (+/-17°), pitch (+/-6°) and roll (+/-3°) at distinct phase offsets. Bounded amplitudes (not monotonic rotations) are essential under pure PD: without orientation feedforward, a growing angle saturates the QP --- bounded oscillation keeps the angular error inside the cable wrench envelope…4a660db -
Phase-2 hardening sweep: parametric robots, URL CSVs, schema aliases
Implements all 14 improvements proposed in the post-mortem of the dissertation_8cable CSV failure log: #1 Register dissertation_8cable in the canonical build_robot() factory. The directive geometry moved from scripts/run_simulation.py into src/cdpr/robots/dissertation.py and is now reachable through the same public API as the catalog robots. Replay / PPO / SAC no longer crash on CSVs produced by --preset dissertation-circle. #2 Persist the full robot description (anchors, attachments, mass, inertia, tension bounds) in manifest.json under a new "robot_spec" block. A manifest-aware helper, robot_from_manifest_or_catalog, rebuilds any robot from this block --- catalog OR custom JSON OR inline override. Phase-2 workflows now work on any run_simulation.py output regardless of geometry source. #3 Cable-indexed column filter requires a numeric suffix. ``Layer`` no longer crashes the loader with int('ayer'). Same fix in train_from_csv, compare_…bdbf666 -
Physics-correct circular tracking: closed-loop PD + bounded tensions
The previous Phase-1 runs were producing tensions of 1289 N and 11778 N under nominally 5-500 N constraints. Two distinct defects were masquerading as one symptom: 1. `simulate()` was being called with ``controller=None``, which in the simulator means *ignore the reference trajectory and just hold the initial pose*. The reference was being constructed but never tracked. The QP was then asked to balance gravity at the start pose only. 2. The catalog robot's tension limits (IPAnema = 20-2000 N, CoGiRo = 50-20000 N) were what the QP enforced --- not the directive's 5-500 N spec. The 1289 N number was lawful under the catalog's bounds, just not the directive's. Fixes (scripts/run_simulation.py): * New CLI flags: ``--controller {none,pd,ct}``, ``--kp-pos``, ``--kp-rot``, ``--kd-pos``, ``--kd-rot``, ``--t-min``, ``--t-max``, ``--preset dissertation-circle``. Default controller is now PD. * New ``--robot dissertation_8cable`` factory builds the directive's exact…48653ae -
Unified Phase-1 + Phase-2 workflow with dual web/PowerShell parity
This commit fulfils the unified recovery directive: Phase-1 defined- trajectory simulation and Phase-2 CSV-driven training are now first- class on both the PowerShell terminal and the Streamlit web interface, with the CLI as the guaranteed scientific fallback while the deployed Streamlit Cloud worker remains intermittently flaky. Phase-1 (scripts/run_simulation.py): * 13 publication-grade figures per run (was 6) --- position, velocity, angular_velocity, acceleration, cable_tensions, cable_lengths, cable_stretch, tracking_error, rms_error_evolution, condition_number, trajectory_xy/_xz/_yz, scene_3d. Each plot wrapped in try/except so a single failure never drops the others; matplotlib figures are explicitly closed after savefig to bound worker memory. Phase-2 (scripts/train_from_csv.py + scripts/compare_models.py): * Five workflows on the CSVs Phase-1 emits: replay (analytic re-sim), mlp + pinn (supervised inverse-dynamics fit, z-scored I/O so loss curves are interpretab…310e4a9 -
Add PowerShell CLI escape hatch + Streamlit diagnostic fallback
The deployed Streamlit Cloud worker keeps blanking on every interaction even after the GUI was reconciled with the real SimulationRequest / TrajectorySpec contract --- the issue is now almost certainly in Streamlit Cloud's runtime, not in the Python script. Render, Cloudflare Pages, Supabase, and GitHub Actions are all green; only the Streamlit worker is unreliable. This commit lands two escape hatches plus one diagnostic toggle so the user is not blocked by the Cloud-side flakiness: scripts/run_simulation.py PowerShell-friendly local driver: python scripts/run_simulation.py --robot ipanema_class --kind circle produces every plot the Streamlit GUI would have shown, plus a timeseries CSV and a manifest with the git hash, into ./out/<robot>-<kind>-<timestamp>/. Each plot is wrapped in its own try/except so a single render failure does not drop the others. scripts/call_render.ps1 PowerShell wrapper around the live FastAPI on Render: .\scripts\call_render.…6045fb3