refactor: reuse resume run store
This commit is contained in:
+5
-15
@@ -2,10 +2,12 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from dataclasses import asdict
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any, Protocol
|
||||
|
||||
from wf_artifacts import (
|
||||
DependencyDiagnostic,
|
||||
ResumeAttempt,
|
||||
RunStore,
|
||||
StoredRunStatus,
|
||||
WorkflowArtifact,
|
||||
@@ -266,7 +268,7 @@ class WorkflowRunApi:
|
||||
)
|
||||
if has_blocking_diagnostics(diagnostics):
|
||||
blocked = mark_resume_blocked(
|
||||
store=self._run_store(),
|
||||
store=store,
|
||||
record=record,
|
||||
diagnostics=diagnostics,
|
||||
)
|
||||
@@ -291,20 +293,8 @@ class WorkflowRunApi:
|
||||
# the ACTIVE marker so recovery fails closed instead of presenting
|
||||
# the old checkpoint as safe to retry. Every stopped result echoes
|
||||
# the attempt identity back for matching.
|
||||
from datetime import UTC as _UTC
|
||||
from datetime import datetime as _datetime
|
||||
|
||||
from wf_artifacts.runs.models import ResumeAttempt
|
||||
|
||||
store = self._run_store()
|
||||
existing_attempt = store.get_resume_attempt(run_id)
|
||||
if existing_attempt is not None and existing_attempt.state == "ACTIVE":
|
||||
raise ValueError(
|
||||
f"workflow run {run_id!r} has an ambiguous active resume attempt; "
|
||||
"recovery must fail it closed before retry"
|
||||
)
|
||||
attempt_id = store.allocate_resume_attempt_id()
|
||||
now_marker = _datetime.now(_UTC)
|
||||
now_marker = datetime.now(UTC)
|
||||
store.save_resume_attempt(
|
||||
ResumeAttempt(
|
||||
run_id=run_id,
|
||||
@@ -335,7 +325,7 @@ class WorkflowRunApi:
|
||||
run_id=run_id,
|
||||
attempt_id=attempt_id,
|
||||
)
|
||||
cleared_at = _datetime.now(_UTC)
|
||||
cleared_at = datetime.now(UTC)
|
||||
store.save_resume_attempt(
|
||||
ResumeAttempt(
|
||||
run_id=run_id,
|
||||
|
||||
Reference in New Issue
Block a user