Skip to content

Commit

Permalink
fix: clarify state updates type
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-v4s committed Sep 20, 2024
1 parent 04de4df commit 83fb120
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions qualibrate_runner/api/routes/others.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated, Optional
from typing import Annotated, Mapping, Optional, cast

from fastapi import APIRouter, Depends, HTTPException, status

Expand All @@ -8,7 +8,11 @@
from qualibrate_runner.config import (
State,
)
from qualibrate_runner.core.models.last_run import LastRun, RunStatus
from qualibrate_runner.core.models.last_run import (
LastRun,
RunStatus,
StateUpdate,
)

others_router = APIRouter()

Expand Down Expand Up @@ -54,5 +58,6 @@ def state_updated(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Unknown state update key.",
)
state_updates = cast(Mapping[str, StateUpdate], state_updates)
state_updates[key].updated = True
return state.last_run
4 changes: 3 additions & 1 deletion qualibrate_runner/core/models/last_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class LastRun(BaseModel):
runnable_type: RunnableType
passed_parameters: Mapping[str, Any] = Field(default_factory=dict)
run_result: Optional[Union[NodeRunSummary, GraphRunSummary]] = None
state_updates: Mapping[str, StateUpdate] = Field(default_factory=dict)
state_updates: Union[
Mapping[str, StateUpdate], Mapping[str, Mapping[str, StateUpdate]]
] = Field(default_factory=dict)
error: Optional[RunError] = None

@computed_field
Expand Down

0 comments on commit 83fb120

Please sign in to comment.