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 c96ae4c331
commit d1d2d5a47d

View File

@ -268,8 +268,14 @@ class InvocationStatsService(InvocationStatsServiceBase):
is complete.
"""
completed = set()
errored = set()
for graph_id, node_log in self._stats.items():
try:
current_graph_state = self.graph_execution_manager.get(graph_id)
except Exception:
errored.add(graph_id)
continue
if not current_graph_state.is_complete():
continue
@ -302,3 +308,7 @@ class InvocationStatsService(InvocationStatsServiceBase):
for graph_id in completed:
del self._stats[graph_id]
del self._cache_stats[graph_id]
for graph_id in errored:
del self._stats[graph_id]
del self._cache_stats[graph_id]