Fix inputs parsing in runs list
- Parse inputs JSON string to list in list_runs_by_actor - Add status field to completed runs - Prevents "136 files" display when inputs is a string Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
20
database.py
20
database.py
@@ -1151,6 +1151,23 @@ async def get_run_by_output(output_hash: str) -> Optional[dict]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_inputs(inputs_value):
|
||||||
|
"""Parse inputs from database - may be JSON string, list, or None."""
|
||||||
|
if inputs_value is None:
|
||||||
|
return []
|
||||||
|
if isinstance(inputs_value, list):
|
||||||
|
return inputs_value
|
||||||
|
if isinstance(inputs_value, str):
|
||||||
|
try:
|
||||||
|
parsed = json.loads(inputs_value)
|
||||||
|
if isinstance(parsed, list):
|
||||||
|
return parsed
|
||||||
|
return []
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
return []
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
async def list_runs_by_actor(actor_id: str, offset: int = 0, limit: int = 20) -> List[dict]:
|
async def list_runs_by_actor(actor_id: str, offset: int = 0, limit: int = 20) -> List[dict]:
|
||||||
"""List completed runs for a user, ordered by creation time (newest first)."""
|
"""List completed runs for a user, ordered by creation time (newest first)."""
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
@@ -1171,9 +1188,10 @@ async def list_runs_by_actor(actor_id: str, offset: int = 0, limit: int = 20) ->
|
|||||||
"ipfs_cid": row["ipfs_cid"],
|
"ipfs_cid": row["ipfs_cid"],
|
||||||
"provenance_cid": row["provenance_cid"],
|
"provenance_cid": row["provenance_cid"],
|
||||||
"recipe": row["recipe"],
|
"recipe": row["recipe"],
|
||||||
"inputs": row["inputs"],
|
"inputs": _parse_inputs(row["inputs"]),
|
||||||
"actor_id": row["actor_id"],
|
"actor_id": row["actor_id"],
|
||||||
"created_at": row["created_at"].isoformat() if row["created_at"] else None,
|
"created_at": row["created_at"].isoformat() if row["created_at"] else None,
|
||||||
|
"status": "completed",
|
||||||
}
|
}
|
||||||
for row in rows
|
for row in rows
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user