From 81385d7d35d046d2762925c550a9f4d4a6b23432 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 18 Aug 2023 20:06:09 +1000 Subject: [PATCH] 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. --- invokeai/app/services/invocation_stats.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/invokeai/app/services/invocation_stats.py b/invokeai/app/services/invocation_stats.py index e8557c40f7..93f797e998 100644 --- a/invokeai/app/services/invocation_stats.py +++ b/invokeai/app/services/invocation_stats.py @@ -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