mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(nodes): move profiler/stats cleanup logic to function
Harder to miss something going forward.
This commit is contained in:
@ -54,6 +54,17 @@ class DefaultInvocationProcessor(InvocationProcessorABC):
|
|||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def stats_cleanup(graph_execution_state_id: str) -> None:
|
||||||
|
if profiler:
|
||||||
|
profile_path = profiler.stop()
|
||||||
|
stats_path = profile_path.with_suffix(".json")
|
||||||
|
self.__invoker.services.performance_statistics.dump_stats(
|
||||||
|
graph_execution_state_id=graph_execution_state_id, output_path=stats_path
|
||||||
|
)
|
||||||
|
with suppress(GESStatsNotFoundError):
|
||||||
|
self.__invoker.services.performance_statistics.log_stats(graph_execution_state_id)
|
||||||
|
self.__invoker.services.performance_statistics.reset_stats(graph_execution_state_id)
|
||||||
|
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
try:
|
try:
|
||||||
queue_item = self.__invoker.services.queue.get()
|
queue_item = self.__invoker.services.queue.get()
|
||||||
@ -156,15 +167,7 @@ class DefaultInvocationProcessor(InvocationProcessorABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
except CanceledException:
|
except CanceledException:
|
||||||
with suppress(GESStatsNotFoundError):
|
stats_cleanup(graph_execution_state.id)
|
||||||
if profiler:
|
|
||||||
profile_path = profiler.stop()
|
|
||||||
stats_path = profile_path.with_suffix(".json")
|
|
||||||
self.__invoker.services.performance_statistics.dump_stats(
|
|
||||||
graph_execution_state_id=graph_execution_state.id, output_path=stats_path
|
|
||||||
)
|
|
||||||
self.__invoker.services.performance_statistics.log_stats(graph_execution_state.id)
|
|
||||||
self.__invoker.services.performance_statistics.reset_stats(graph_execution_state.id)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -226,15 +229,7 @@ class DefaultInvocationProcessor(InvocationProcessorABC):
|
|||||||
queue_id=queue_item.session_queue_id,
|
queue_id=queue_item.session_queue_id,
|
||||||
graph_execution_state_id=graph_execution_state.id,
|
graph_execution_state_id=graph_execution_state.id,
|
||||||
)
|
)
|
||||||
if profiler:
|
stats_cleanup(graph_execution_state.id)
|
||||||
profile_path = profiler.stop()
|
|
||||||
stats_path = profile_path.with_suffix(".json")
|
|
||||||
self.__invoker.services.performance_statistics.dump_stats(
|
|
||||||
graph_execution_state_id=graph_execution_state.id, output_path=stats_path
|
|
||||||
)
|
|
||||||
with suppress(GESStatsNotFoundError):
|
|
||||||
self.__invoker.services.performance_statistics.log_stats(graph_execution_state.id)
|
|
||||||
self.__invoker.services.performance_statistics.reset_stats(graph_execution_state.id)
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass # Log something? KeyboardInterrupt is probably not going to be seen by the processor
|
pass # Log something? KeyboardInterrupt is probably not going to be seen by the processor
|
||||||
|
Reference in New Issue
Block a user