Spaces:
Running on Zero
Running on Zero
Fix timestamps computation error
Browse files- src/mfa.py +10 -4
src/mfa.py
CHANGED
|
@@ -86,9 +86,15 @@ def _mfa_wait_result(event_id, headers, base):
|
|
| 86 |
sse_resp.raise_for_status()
|
| 87 |
|
| 88 |
result_data = None
|
|
|
|
| 89 |
for line in sse_resp.iter_lines(decode_unicode=True):
|
| 90 |
-
if line and line.startswith("
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
if result_data is None:
|
| 94 |
raise RuntimeError("No data received from MFA align_batch SSE stream")
|
|
@@ -98,8 +104,8 @@ def _mfa_wait_result(event_id, headers, base):
|
|
| 98 |
if isinstance(parsed, list) and len(parsed) == 1:
|
| 99 |
parsed = parsed[0]
|
| 100 |
|
| 101 |
-
if parsed.get("status") != "ok":
|
| 102 |
-
raise RuntimeError(f"MFA align_batch failed: {parsed
|
| 103 |
|
| 104 |
return parsed["results"]
|
| 105 |
|
|
|
|
| 86 |
sse_resp.raise_for_status()
|
| 87 |
|
| 88 |
result_data = None
|
| 89 |
+
current_event = None
|
| 90 |
for line in sse_resp.iter_lines(decode_unicode=True):
|
| 91 |
+
if line and line.startswith("event: "):
|
| 92 |
+
current_event = line[7:]
|
| 93 |
+
elif line and line.startswith("data: "):
|
| 94 |
+
if current_event == "complete":
|
| 95 |
+
result_data = line[6:]
|
| 96 |
+
elif current_event == "error":
|
| 97 |
+
raise RuntimeError(f"MFA align_batch SSE error: {line[6:]}")
|
| 98 |
|
| 99 |
if result_data is None:
|
| 100 |
raise RuntimeError("No data received from MFA align_batch SSE stream")
|
|
|
|
| 104 |
if isinstance(parsed, list) and len(parsed) == 1:
|
| 105 |
parsed = parsed[0]
|
| 106 |
|
| 107 |
+
if not isinstance(parsed, dict) or parsed.get("status") != "ok":
|
| 108 |
+
raise RuntimeError(f"MFA align_batch failed: {parsed}")
|
| 109 |
|
| 110 |
return parsed["results"]
|
| 111 |
|