mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add listeners for model load events
- currently only exposed as DEBUG-level logs
This commit is contained in:
@ -5,6 +5,8 @@ import {
|
||||
InvocationCompleteEvent,
|
||||
InvocationErrorEvent,
|
||||
InvocationStartedEvent,
|
||||
ModelLoadCompletedEvent,
|
||||
ModelLoadStartedEvent,
|
||||
} from 'services/events/types';
|
||||
|
||||
// Common socket action payload data
|
||||
@ -162,3 +164,35 @@ export const socketGeneratorProgress = createAction<
|
||||
export const appSocketGeneratorProgress = createAction<
|
||||
BaseSocketPayload & { data: GeneratorProgressEvent }
|
||||
>('socket/appSocketGeneratorProgress');
|
||||
|
||||
/**
|
||||
* Socket.IO Model Load Started
|
||||
*
|
||||
* Do not use. Only for use in middleware.
|
||||
*/
|
||||
export const socketModelLoadStarted = createAction<
|
||||
BaseSocketPayload & { data: ModelLoadStartedEvent }
|
||||
>('socket/socketModelLoadStarted');
|
||||
|
||||
/**
|
||||
* App-level Model Load Started
|
||||
*/
|
||||
export const appSocketModelLoadStarted = createAction<
|
||||
BaseSocketPayload & { data: ModelLoadStartedEvent }
|
||||
>('socket/appSocketModelLoadStarted');
|
||||
|
||||
/**
|
||||
* Socket.IO Model Load Started
|
||||
*
|
||||
* Do not use. Only for use in middleware.
|
||||
*/
|
||||
export const socketModelLoadCompleted = createAction<
|
||||
BaseSocketPayload & { data: ModelLoadCompletedEvent }
|
||||
>('socket/socketModelLoadCompleted');
|
||||
|
||||
/**
|
||||
* App-level Model Load Completed
|
||||
*/
|
||||
export const appSocketModelLoadCompleted = createAction<
|
||||
BaseSocketPayload & { data: ModelLoadCompletedEvent }
|
||||
>('socket/appSocketModelLoadCompleted');
|
||||
|
@ -1,5 +1,11 @@
|
||||
import { O } from 'ts-toolbelt';
|
||||
import { Graph, GraphExecutionState } from '../api/types';
|
||||
import {
|
||||
BaseModelType,
|
||||
Graph,
|
||||
GraphExecutionState,
|
||||
ModelType,
|
||||
SubModelType,
|
||||
} from '../api/types';
|
||||
|
||||
/**
|
||||
* A progress image, we get one for each step in the generation
|
||||
@ -25,6 +31,25 @@ export type BaseNode = {
|
||||
[key: string]: AnyInvocation[keyof AnyInvocation];
|
||||
};
|
||||
|
||||
export type ModelLoadStartedEvent = {
|
||||
graph_execution_state_id: string;
|
||||
model_name: string;
|
||||
base_model: BaseModelType;
|
||||
model_type: ModelType;
|
||||
submodel: SubModelType;
|
||||
};
|
||||
|
||||
export type ModelLoadCompletedEvent = {
|
||||
graph_execution_state_id: string;
|
||||
model_name: string;
|
||||
base_model: BaseModelType;
|
||||
model_type: ModelType;
|
||||
submodel: SubModelType;
|
||||
hash?: string;
|
||||
location: string;
|
||||
precision: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A `generator_progress` socket.io event.
|
||||
*
|
||||
@ -101,6 +126,8 @@ export type ServerToClientEvents = {
|
||||
graph_execution_state_complete: (
|
||||
payload: GraphExecutionStateCompleteEvent
|
||||
) => void;
|
||||
model_load_started: (payload: ModelLoadStartedEvent) => void;
|
||||
model_load_completed: (payload: ModelLoadCompletedEvent) => void;
|
||||
};
|
||||
|
||||
export type ClientToServerEvents = {
|
||||
|
@ -11,6 +11,8 @@ import {
|
||||
socketConnected,
|
||||
socketDisconnected,
|
||||
socketSubscribed,
|
||||
socketModelLoadStarted,
|
||||
socketModelLoadCompleted,
|
||||
} from '../actions';
|
||||
import { ClientToServerEvents, ServerToClientEvents } from '../types';
|
||||
import { Logger } from 'roarr';
|
||||
@ -44,7 +46,7 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
||||
socketSubscribed({
|
||||
sessionId,
|
||||
timestamp: getTimestamp(),
|
||||
boardId: getState().boards.selectedBoardId,
|
||||
boardId: getState().gallery.selectedBoardId,
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -118,4 +120,28 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Model load started
|
||||
*/
|
||||
socket.on('model_load_started', (data) => {
|
||||
dispatch(
|
||||
socketModelLoadStarted({
|
||||
data,
|
||||
timestamp: getTimestamp(),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Model load completed
|
||||
*/
|
||||
socket.on('model_load_completed', (data) => {
|
||||
dispatch(
|
||||
socketModelLoadCompleted({
|
||||
data,
|
||||
timestamp: getTimestamp(),
|
||||
})
|
||||
);
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user