-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
71 lines (53 loc) · 1.91 KB
/
Copy pathcli.py
File metadata and controls
71 lines (53 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import argparse
import json
import sys
from sqlalchemy import select
from src.db import Job, JobAuditLog, SessionLocal
def inspect_job(job_id: str) -> None:
session = SessionLocal()
try:
job = session.execute(
select(Job).where(Job.id == job_id)
).scalar_one_or_none()
if not job:
print(f"Job {job_id} not found")
sys.exit(1)
print(f"\n{'='*60}")
print(f"Job: {job.id}")
print(f"{'='*60}")
print(f" Status: {job.status.value}")
print(f" Analysis Type: {job.analysis_type.value}")
print(f" Document URL: {job.document_url}")
print(f" Tokens Used: {job.tokens_used}")
print(f" Created: {job.created_at}")
print(f" Updated: {job.updated_at}")
print(f" Idempotency: {job.idempotency_key}")
if job.error:
print(f"\n Error: {job.error}")
if job.result:
print(f"\n Result:")
print(f" {json.dumps(job.result, indent=2)}")
audits = session.execute(
select(JobAuditLog)
.where(JobAuditLog.job_id == job.id)
.order_by(JobAuditLog.timestamp)
).scalars().all()
if audits:
print(f"\n Audit Trail:")
for a in audits:
print(f" {a.timestamp} | {a.from_status or 'None'} → {a.to_status} | {a.detail or ''}")
print()
finally:
session.close()
def main() -> None:
parser = argparse.ArgumentParser(description="Document Processing Agent CLI")
sub = parser.add_subparsers(dest="command")
inspect = sub.add_parser("inspect-job", help="Inspect a job by ID")
inspect.add_argument("job_id", help="UUID of the job")
args = parser.parse_args()
if args.command == "inspect-job":
inspect_job(args.job_id)
else:
parser.print_help()
if __name__ == "__main__":
main()