mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'main' into logging-facelift
This commit is contained in:
commit
78533714e3
@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from threading import Event, Thread, BoundedSemaphore
|
from threading import Event, Thread, BoundedSemaphore
|
||||||
|
|
||||||
@ -6,6 +7,7 @@ from .invocation_queue import InvocationQueueItem
|
|||||||
from .invoker import InvocationProcessorABC, Invoker
|
from .invoker import InvocationProcessorABC, Invoker
|
||||||
from ..models.exceptions import CanceledException
|
from ..models.exceptions import CanceledException
|
||||||
|
|
||||||
|
import invokeai.backend.util.logging as logger
|
||||||
class DefaultInvocationProcessor(InvocationProcessorABC):
|
class DefaultInvocationProcessor(InvocationProcessorABC):
|
||||||
__invoker_thread: Thread
|
__invoker_thread: Thread
|
||||||
__stop_event: Event
|
__stop_event: Event
|
||||||
@ -34,8 +36,14 @@ class DefaultInvocationProcessor(InvocationProcessorABC):
|
|||||||
try:
|
try:
|
||||||
self.__threadLimit.acquire()
|
self.__threadLimit.acquire()
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
|
try:
|
||||||
queue_item: InvocationQueueItem = self.__invoker.services.queue.get()
|
queue_item: InvocationQueueItem = self.__invoker.services.queue.get()
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug("Exception while getting from queue: %s" % e)
|
||||||
|
|
||||||
if not queue_item: # Probably stopping
|
if not queue_item: # Probably stopping
|
||||||
|
# do not hammer the queue
|
||||||
|
time.sleep(0.5)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
graph_execution_state = (
|
graph_execution_state = (
|
||||||
@ -124,7 +132,16 @@ class DefaultInvocationProcessor(InvocationProcessorABC):
|
|||||||
# Queue any further commands if invoking all
|
# Queue any further commands if invoking all
|
||||||
is_complete = graph_execution_state.is_complete()
|
is_complete = graph_execution_state.is_complete()
|
||||||
if queue_item.invoke_all and not is_complete:
|
if queue_item.invoke_all and not is_complete:
|
||||||
|
try:
|
||||||
self.__invoker.invoke(graph_execution_state, invoke_all=True)
|
self.__invoker.invoke(graph_execution_state, invoke_all=True)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Error while invoking: %s" % e)
|
||||||
|
self.__invoker.services.events.emit_invocation_error(
|
||||||
|
graph_execution_state_id=graph_execution_state.id,
|
||||||
|
node=invocation.dict(),
|
||||||
|
source_node_id=source_node_id,
|
||||||
|
error=traceback.format_exc()
|
||||||
|
)
|
||||||
elif is_complete:
|
elif is_complete:
|
||||||
self.__invoker.services.events.emit_graph_execution_complete(
|
self.__invoker.services.events.emit_graph_execution_complete(
|
||||||
graph_execution_state.id
|
graph_execution_state.id
|
||||||
|
@ -2,6 +2,10 @@ import type { PayloadAction } from '@reduxjs/toolkit';
|
|||||||
import { createSlice } from '@reduxjs/toolkit';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
import { Image } from 'app/types/invokeai';
|
import { Image } from 'app/types/invokeai';
|
||||||
import { imageReceived, thumbnailReceived } from 'services/thunks/image';
|
import { imageReceived, thumbnailReceived } from 'services/thunks/image';
|
||||||
|
import {
|
||||||
|
receivedResultImagesPage,
|
||||||
|
receivedUploadImagesPage,
|
||||||
|
} from '../../../services/thunks/gallery';
|
||||||
|
|
||||||
type GalleryImageObjectFitType = 'contain' | 'cover';
|
type GalleryImageObjectFitType = 'contain' | 'cover';
|
||||||
|
|
||||||
@ -86,6 +90,30 @@ export const gallerySlice = createSlice({
|
|||||||
state.selectedImage.thumbnail = thumbnailPath;
|
state.selectedImage.thumbnail = thumbnailPath;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
builder.addCase(receivedResultImagesPage.fulfilled, (state, action) => {
|
||||||
|
// rehydrate selectedImage URL when results list comes in
|
||||||
|
// solves case when outdated URL is in local storage
|
||||||
|
if (state.selectedImage) {
|
||||||
|
const selectedImageInResults = action.payload.items.find(
|
||||||
|
(image) => image.image_name === state.selectedImage!.name
|
||||||
|
);
|
||||||
|
if (selectedImageInResults) {
|
||||||
|
state.selectedImage.url = selectedImageInResults.image_url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.addCase(receivedUploadImagesPage.fulfilled, (state, action) => {
|
||||||
|
// rehydrate selectedImage URL when results list comes in
|
||||||
|
// solves case when outdated URL is in local storage
|
||||||
|
if (state.selectedImage) {
|
||||||
|
const selectedImageInResults = action.payload.items.find(
|
||||||
|
(image) => image.image_name === state.selectedImage!.name
|
||||||
|
);
|
||||||
|
if (selectedImageInResults) {
|
||||||
|
state.selectedImage.url = selectedImageInResults.image_url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user