fix(stats): fix fail case when previous graph is invalid

When retrieving a graph, it is parsed through pydantic. It is possible that this graph is invalid, and an error is thrown.

Handle this by deleting the failed graph from the stats if this occurs.
This commit is contained in:
psychedelicious 2023-08-18 20:06:09 +10:00
parent 519bcb38c1
commit 81385d7d35

View File

@ -34,6 +34,7 @@ from abc import ABC, abstractmethod
from contextlib import AbstractContextManager
from dataclasses import dataclass, field
from typing import Dict
from pydantic import ValidationError
import torch
@ -269,7 +270,13 @@ class InvocationStatsService(InvocationStatsServiceBase):
"""
completed = set()
for graph_id, node_log in self._stats.items():
current_graph_state = self.graph_execution_manager.get(graph_id)
try:
current_graph_state = self.graph_execution_manager.get(graph_id)
except ValidationError:
del self._stats[graph_id]
del self._cache_stats[graph_id]
continue
if not current_graph_state.is_complete():
continue