mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
self-review (no-mistakes)
This commit is contained in:
@@ -11,6 +11,7 @@ from typing import Literal, Union, assert_never
|
|||||||
|
|
||||||
import celery
|
import celery
|
||||||
from celery.result import AsyncResult
|
from celery.result import AsyncResult
|
||||||
|
from hatchet_sdk.clients.rest.exceptions import ApiException
|
||||||
from hatchet_sdk.clients.rest.models import V1TaskStatus
|
from hatchet_sdk.clients.rest.models import V1TaskStatus
|
||||||
|
|
||||||
from reflector.db.recordings import recordings_controller
|
from reflector.db.recordings import recordings_controller
|
||||||
@@ -124,8 +125,8 @@ async def validate_transcript_for_processing(
|
|||||||
return ValidationAlreadyScheduled(
|
return ValidationAlreadyScheduled(
|
||||||
detail="Hatchet workflow already running"
|
detail="Hatchet workflow already running"
|
||||||
)
|
)
|
||||||
except Exception:
|
except ApiException:
|
||||||
# If we can't get status, allow processing (workflow might be gone)
|
# Workflow might be gone (404) or API issue - allow processing
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return ValidationOk(
|
return ValidationOk(
|
||||||
@@ -244,8 +245,8 @@ async def dispatch_transcript_processing(
|
|||||||
workflow_id=transcript.workflow_run_id,
|
workflow_id=transcript.workflow_run_id,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except ApiException:
|
||||||
# If we can't get status, proceed with new workflow
|
# Workflow might be gone (404) or API issue - proceed with new workflow
|
||||||
pass
|
pass
|
||||||
|
|
||||||
workflow_id = await HatchetClientManager.start_workflow(
|
workflow_id = await HatchetClientManager.start_workflow(
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async def process_transcript(
|
|||||||
status = await HatchetClientManager.get_workflow_run_status(
|
status = await HatchetClientManager.get_workflow_run_status(
|
||||||
transcript.workflow_run_id
|
transcript.workflow_run_id
|
||||||
)
|
)
|
||||||
print(f" Status: {status}", file=sys.stderr)
|
print(f" Status: {status.value}", file=sys.stderr)
|
||||||
|
|
||||||
if status == V1TaskStatus.COMPLETED:
|
if status == V1TaskStatus.COMPLETED:
|
||||||
print("Workflow completed successfully", file=sys.stderr)
|
print("Workflow completed successfully", file=sys.stderr)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ These tests verify:
|
|||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from hatchet_sdk.clients.rest.exceptions import ApiException
|
||||||
from hatchet_sdk.clients.rest.models import V1TaskStatus
|
from hatchet_sdk.clients.rest.models import V1TaskStatus
|
||||||
|
|
||||||
from reflector.db.transcripts import Transcript
|
from reflector.db.transcripts import Transcript
|
||||||
@@ -194,7 +195,7 @@ async def test_hatchet_validation_allows_when_status_check_fails():
|
|||||||
) as mock_hatchet:
|
) as mock_hatchet:
|
||||||
# Status check fails (workflow might be deleted)
|
# Status check fails (workflow might be deleted)
|
||||||
mock_hatchet.get_workflow_run_status = AsyncMock(
|
mock_hatchet.get_workflow_run_status = AsyncMock(
|
||||||
side_effect=Exception("Workflow not found")
|
side_effect=ApiException("Workflow not found")
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
|||||||
Reference in New Issue
Block a user