mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): improve log messages
This commit is contained in:
parent
a4c258e9ec
commit
bffdede0fa
@ -16,6 +16,8 @@ import { receivedOpenAPISchema } from 'services/thunks/schema';
|
|||||||
import { isFulfilledAnyGraphBuilt } from 'services/thunks/session';
|
import { isFulfilledAnyGraphBuilt } from 'services/thunks/session';
|
||||||
import { InvocationTemplate, InvocationValue } from '../types/types';
|
import { InvocationTemplate, InvocationValue } from '../types/types';
|
||||||
import { parseSchema } from '../util/parseSchema';
|
import { parseSchema } from '../util/parseSchema';
|
||||||
|
import { log } from 'app/logging/useLogger';
|
||||||
|
import { size } from 'lodash-es';
|
||||||
|
|
||||||
export type NodesState = {
|
export type NodesState = {
|
||||||
nodes: Node<InvocationValue>[];
|
nodes: Node<InvocationValue>[];
|
||||||
@ -85,7 +87,12 @@ const nodesSlice = createSlice({
|
|||||||
parsedOpenAPISchema: (state, action: PayloadAction<OpenAPIV3.Document>) => {
|
parsedOpenAPISchema: (state, action: PayloadAction<OpenAPIV3.Document>) => {
|
||||||
try {
|
try {
|
||||||
const parsedSchema = parseSchema(action.payload);
|
const parsedSchema = parseSchema(action.payload);
|
||||||
console.debug('Parsed schema: ', parsedSchema);
|
|
||||||
|
// TODO: Achtung! Side effect in a reducer!
|
||||||
|
log.info(
|
||||||
|
{ namespace: 'schema', nodes: parsedSchema },
|
||||||
|
`Parsed ${size(parsedSchema)} nodes`
|
||||||
|
);
|
||||||
state.invocationTemplates = parsedSchema;
|
state.invocationTemplates = parsedSchema;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { createAction } from '@reduxjs/toolkit';
|
import { createAction } from '@reduxjs/toolkit';
|
||||||
import {
|
import {
|
||||||
GeneratorProgressEvent,
|
GeneratorProgressEvent,
|
||||||
|
GraphExecutionStateCompleteEvent,
|
||||||
InvocationCompleteEvent,
|
InvocationCompleteEvent,
|
||||||
InvocationErrorEvent,
|
InvocationErrorEvent,
|
||||||
InvocationStartedEvent,
|
InvocationStartedEvent,
|
||||||
@ -45,6 +46,10 @@ export const invocationError = createAction<
|
|||||||
BaseSocketPayload & { data: InvocationErrorEvent }
|
BaseSocketPayload & { data: InvocationErrorEvent }
|
||||||
>('socket/invocationError');
|
>('socket/invocationError');
|
||||||
|
|
||||||
|
export const graphExecutionStateComplete = createAction<
|
||||||
|
BaseSocketPayload & { data: GraphExecutionStateCompleteEvent }
|
||||||
|
>('socket/graphExecutionStateComplete');
|
||||||
|
|
||||||
export const generatorProgress = createAction<
|
export const generatorProgress = createAction<
|
||||||
BaseSocketPayload & { data: GeneratorProgressEvent }
|
BaseSocketPayload & { data: GeneratorProgressEvent }
|
||||||
>('socket/generatorProgress');
|
>('socket/generatorProgress');
|
||||||
|
@ -118,7 +118,9 @@ export const socketMiddleware = () => {
|
|||||||
if (system.sessionId) {
|
if (system.sessionId) {
|
||||||
const sessionLog = moduleLog.child({ sessionId: system.sessionId });
|
const sessionLog = moduleLog.child({ sessionId: system.sessionId });
|
||||||
|
|
||||||
sessionLog.debug('Re-subscribe');
|
sessionLog.debug(
|
||||||
|
`Subscribed to existing session (${system.sessionId})`
|
||||||
|
);
|
||||||
|
|
||||||
socket.emit('subscribe', { session: system.sessionId });
|
socket.emit('subscribe', { session: system.sessionId });
|
||||||
dispatch(
|
dispatch(
|
||||||
@ -158,9 +160,10 @@ export const socketMiddleware = () => {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
if (oldSessionId) {
|
if (oldSessionId) {
|
||||||
sessionLog
|
sessionLog.debug(
|
||||||
.child({ oldSessionId })
|
{ oldSessionId },
|
||||||
.debug('Unsubscribe from old session');
|
`Unsubscribed from old session (${oldSessionId})`
|
||||||
|
);
|
||||||
// Unsubscribe when invocations complete
|
// Unsubscribe when invocations complete
|
||||||
socket.emit('unsubscribe', {
|
socket.emit('unsubscribe', {
|
||||||
session: oldSessionId,
|
session: oldSessionId,
|
||||||
@ -185,7 +188,7 @@ export const socketMiddleware = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionLog.debug('Subscribe');
|
sessionLog.debug(`Subscribe to new session (${sessionId})`);
|
||||||
socket.emit('subscribe', { session: sessionId });
|
socket.emit('subscribe', { session: sessionId });
|
||||||
dispatch(
|
dispatch(
|
||||||
socketSubscribed({
|
socketSubscribed({
|
||||||
|
@ -5,6 +5,7 @@ import { sessionCanceled } from 'services/thunks/session';
|
|||||||
import { Socket } from 'socket.io-client';
|
import { Socket } from 'socket.io-client';
|
||||||
import {
|
import {
|
||||||
generatorProgress,
|
generatorProgress,
|
||||||
|
graphExecutionStateComplete,
|
||||||
invocationComplete,
|
invocationComplete,
|
||||||
invocationError,
|
invocationError,
|
||||||
invocationStarted,
|
invocationStarted,
|
||||||
@ -24,22 +25,22 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
|||||||
const { dispatch, getState } = store;
|
const { dispatch, getState } = store;
|
||||||
// Set up listeners for the present subscription
|
// Set up listeners for the present subscription
|
||||||
socket.on('invocation_started', (data) => {
|
socket.on('invocation_started', (data) => {
|
||||||
sessionLog.child({ data }).info('Invocation started');
|
sessionLog.child({ data }).info(`Invocation started (${data.node.type})`);
|
||||||
dispatch(invocationStarted({ data, timestamp: getTimestamp() }));
|
dispatch(invocationStarted({ data, timestamp: getTimestamp() }));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('generator_progress', (data) => {
|
socket.on('generator_progress', (data) => {
|
||||||
sessionLog.child({ data }).trace('Generator progress');
|
sessionLog.child({ data }).trace(`Generator progress (${data.node.type})`);
|
||||||
dispatch(generatorProgress({ data, timestamp: getTimestamp() }));
|
dispatch(generatorProgress({ data, timestamp: getTimestamp() }));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('invocation_error', (data) => {
|
socket.on('invocation_error', (data) => {
|
||||||
sessionLog.child({ data }).error('Invocation error');
|
sessionLog.child({ data }).error(`Invocation error (${data.node.type})`);
|
||||||
dispatch(invocationError({ data, timestamp: getTimestamp() }));
|
dispatch(invocationError({ data, timestamp: getTimestamp() }));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('invocation_complete', (data) => {
|
socket.on('invocation_complete', (data) => {
|
||||||
sessionLog.child({ data }).info('Invocation complete');
|
sessionLog.child({ data }).info(`Invocation complete (${data.node.type})`);
|
||||||
const sessionId = data.graph_execution_state_id;
|
const sessionId = data.graph_execution_state_id;
|
||||||
|
|
||||||
const { cancelType, isCancelScheduled } = getState().system;
|
const { cancelType, isCancelScheduled } = getState().system;
|
||||||
@ -58,4 +59,13 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('graph_execution_state_complete', (data) => {
|
||||||
|
sessionLog
|
||||||
|
.child({ data })
|
||||||
|
.info(
|
||||||
|
`Graph execution state complete (${data.graph_execution_state_id})`
|
||||||
|
);
|
||||||
|
dispatch(graphExecutionStateComplete({ data, timestamp: getTimestamp() }));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ export const receivedResultImagesPage = createAppAsyncThunk(
|
|||||||
perPage: IMAGES_PER_PAGE,
|
perPage: IMAGES_PER_PAGE,
|
||||||
});
|
});
|
||||||
|
|
||||||
galleryLog.info({ response }, 'Received page of results images');
|
galleryLog.info({ response }, `Received ${response.items.length} results`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ export const receivedUploadImagesPage = createAppAsyncThunk(
|
|||||||
perPage: IMAGES_PER_PAGE,
|
perPage: IMAGES_PER_PAGE,
|
||||||
});
|
});
|
||||||
|
|
||||||
galleryLog.info({ response }, 'Received page of uploads images');
|
galleryLog.info({ response }, `Received ${response.items.length} uploads`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,10 @@ export const imageUploaded = createAppAsyncThunk(
|
|||||||
const response = await ImagesService.uploadImage(arg);
|
const response = await ImagesService.uploadImage(arg);
|
||||||
const { location } = getHeaders(response);
|
const { location } = getHeaders(response);
|
||||||
|
|
||||||
imagesLog.info({ arg: '<Blob>', response, location }, 'Image uploaded');
|
imagesLog.info(
|
||||||
|
{ arg: '<Blob>', response, location },
|
||||||
|
`Image uploaded (${response.image_name})`
|
||||||
|
);
|
||||||
|
|
||||||
return { response, location };
|
return { response, location };
|
||||||
}
|
}
|
||||||
@ -108,7 +111,10 @@ export const imageDeleted = createAppAsyncThunk(
|
|||||||
|
|
||||||
const response = await ImagesService.deleteImage(arg);
|
const response = await ImagesService.deleteImage(arg);
|
||||||
|
|
||||||
imagesLog.info({ arg, response }, 'Image deleted');
|
imagesLog.info(
|
||||||
|
{ arg, response },
|
||||||
|
`Image deleted (${arg.imageType} - ${arg.imageName})`
|
||||||
|
);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { log } from 'app/logging/useLogger';
|
import { log } from 'app/logging/useLogger';
|
||||||
import { createAppAsyncThunk } from 'app/store/storeUtils';
|
import { createAppAsyncThunk } from 'app/store/storeUtils';
|
||||||
import { Model } from 'features/system/store/modelSlice';
|
import { Model } from 'features/system/store/modelSlice';
|
||||||
import { reduce } from 'lodash-es';
|
import { reduce, size } from 'lodash-es';
|
||||||
import { ModelsService } from 'services/api';
|
import { ModelsService } from 'services/api';
|
||||||
|
|
||||||
const models = log.child({ namespace: 'model' });
|
const models = log.child({ namespace: 'model' });
|
||||||
@ -23,7 +23,7 @@ export const receivedModels = createAppAsyncThunk(
|
|||||||
{} as Record<string, Model>
|
{} as Record<string, Model>
|
||||||
);
|
);
|
||||||
|
|
||||||
models.info({ response }, 'Received models');
|
models.info({ response }, `Received ${size(response.models)} models`);
|
||||||
|
|
||||||
return deserializedModels;
|
return deserializedModels;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ export const sessionCreated = createAppAsyncThunk(
|
|||||||
requestBody: arg.graph,
|
requestBody: arg.graph,
|
||||||
});
|
});
|
||||||
|
|
||||||
sessionLog.info({ arg, response }, 'Session created');
|
sessionLog.info({ arg, response }, `Session created (${response.id})`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ export const nodeAdded = createAppAsyncThunk(
|
|||||||
sessionId: arg.sessionId,
|
sessionId: arg.sessionId,
|
||||||
});
|
});
|
||||||
|
|
||||||
sessionLog.info({ arg, response }, 'Node added');
|
sessionLog.info({ arg, response }, `Node added (${response})`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ export const sessionInvoked = createAppAsyncThunk(
|
|||||||
all: true,
|
all: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
sessionLog.info({ arg, response }, 'Session invoked');
|
sessionLog.info({ arg, response }, `Session invoked (${sessionId})`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ export const sessionCanceled = createAppAsyncThunk(
|
|||||||
sessionId,
|
sessionId,
|
||||||
});
|
});
|
||||||
|
|
||||||
sessionLog.info({ arg, response }, 'Session canceled');
|
sessionLog.info({ arg, response }, `Session canceled (${sessionId})`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,10 @@ export const listedSessions = createAppAsyncThunk(
|
|||||||
async (arg: SessionsListedArg, _thunkApi) => {
|
async (arg: SessionsListedArg, _thunkApi) => {
|
||||||
const response = await SessionsService.listSessions(arg);
|
const response = await SessionsService.listSessions(arg);
|
||||||
|
|
||||||
sessionLog.info({ arg, response }, 'Sessions listed');
|
sessionLog.info(
|
||||||
|
{ arg, response },
|
||||||
|
`Sessions listed (${response.items.length})`
|
||||||
|
);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user