-
Notifications
You must be signed in to change notification settings - Fork 1
/
write_failed_analysis.py
38 lines (33 loc) · 1.01 KB
/
write_failed_analysis.py
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
import json
import uuid
from datetime import datetime
from pathlib import Path
from typing import Any, Dict
def create_failed_analysis(error: Exception) -> Dict[str, Any]:
created_at = datetime.utcnow().isoformat()
return {
"createdAt": created_at,
"errors": [
{
"id": str(uuid.uuid4()),
"errorType": error.__class__.__name__,
"detail": error.stderr,
"createdAt": created_at,
}
],
"files": [],
"metadata": [],
"commands": [],
"labware": [],
"pipettes": [],
"modules": [],
"liquids": [],
"config": {},
}
def write_failed_analysis(output_path: Path, error: Exception) -> None:
if output_path.exists():
print(f"Analysis file {output_path} already exists, skipping placeholder file.")
return
analysis = create_failed_analysis(error)
with open(output_path, "w") as file:
json.dump(analysis, file, indent=4)