mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-12 04:37:44 +02:00
Merge remote-tracking branch 'origin/eric/dev' into eric/dev
This commit is contained in:
@@ -61,8 +61,8 @@ def _delete(dashboard_id: str):
|
||||
os.remove(path)
|
||||
|
||||
|
||||
def _migrate_if_needed():
|
||||
"""One-time migration: if no dashboards exist, create 'Dashboard 1' from old layout."""
|
||||
def migrate_if_needed():
|
||||
"""One-time migration: if no dashboards exist, create the default from old layout."""
|
||||
existing = _load_all()
|
||||
if existing:
|
||||
return
|
||||
@@ -80,7 +80,7 @@ def _migrate_if_needed():
|
||||
except Exception:
|
||||
logger.exception("Failed to read old layout.json, using empty layout")
|
||||
|
||||
dashboard = Dashboard(name="Dashboard 1", layout=layout)
|
||||
dashboard = Dashboard(name="Untitled Dashboard", layout=layout)
|
||||
_save(dashboard)
|
||||
logger.info(f"Created default dashboard: {dashboard.id}")
|
||||
|
||||
@@ -105,7 +105,7 @@ def _migrate_if_needed():
|
||||
@asynccontextmanager
|
||||
async def dashboards_lifespan():
|
||||
os.makedirs(DATA_DIR, exist_ok=True)
|
||||
_migrate_if_needed()
|
||||
migrate_if_needed()
|
||||
yield
|
||||
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ def test_migration_survives_corrupt_session(tmp_path, monkeypatch):
|
||||
(sess_dir / "good.json").write_text(json.dumps({"id": "good"}))
|
||||
(sess_dir / "bad.json").write_text("{ truncated ,,,")
|
||||
|
||||
dmod._migrate_if_needed() # must not raise despite the corrupt session
|
||||
dmod.migrate_if_needed() # must not raise despite the corrupt session
|
||||
|
||||
dashboards = dmod._load_all()
|
||||
assert len(dashboards) == 1
|
||||
|
||||
Reference in New Issue
Block a user