Add support for extra system stats in error report (#684)

* Add support for extra system stats in error report

* Add toast on error
This commit is contained in:
Chenlei Hu
2024-08-29 21:29:33 -04:00
committed by GitHub
parent aaea05a37b
commit f42609c966
4 changed files with 39 additions and 4 deletions

View File

@@ -70,10 +70,24 @@ const toast = useToast()
const { copy, isSupported } = useClipboard() const { copy, isSupported } = useClipboard()
onMounted(async () => { onMounted(async () => {
generateReport(await api.getSystemStats()) try {
const [systemStats, logs] = await Promise.all([
api.getSystemStats(),
api.getLogs()
])
generateReport(systemStats, logs)
} catch (error) {
console.error('Error fetching system stats or logs:', error)
toast.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to fetch system information',
life: 5000
})
}
}) })
const generateReport = (systemStats: SystemStats) => { const generateReport = (systemStats: SystemStats, logs: string) => {
// The default JSON workflow has about 3000 characters. // The default JSON workflow has about 3000 characters.
const MAX_JSON_LENGTH = 20000 const MAX_JSON_LENGTH = 20000
const workflowJSONString = JSON.stringify(app.graph.serialize()) const workflowJSONString = JSON.stringify(app.graph.serialize())
@@ -93,9 +107,12 @@ const generateReport = (systemStats: SystemStats) => {
${props.error.traceback.join('\n')} ${props.error.traceback.join('\n')}
\`\`\` \`\`\`
## System Information ## System Information
- **ComfyUI Version:** ${systemStats.system.comfyui_version}
- **Arguments:** ${systemStats.system.argv.join(' ')}
- **OS:** ${systemStats.system.os} - **OS:** ${systemStats.system.os}
- **Python Version:** ${systemStats.system.python_version} - **Python Version:** ${systemStats.system.python_version}
- **Embedded Python:** ${systemStats.system.embedded_python} - **Embedded Python:** ${systemStats.system.embedded_python}
- **PyTorch Version:** ${systemStats.system.pytorch_version}
## Devices ## Devices
${systemStats.devices ${systemStats.devices
.map( .map(
@@ -109,7 +126,10 @@ ${systemStats.devices
` `
) )
.join('\n')} .join('\n')}
## Logs
\`\`\`
${logs}
\`\`\`
## Attached Workflow ## Attached Workflow
Please make sure that workflow does not contain any sensitive information such as API keys or passwords. Please make sure that workflow does not contain any sensitive information such as API keys or passwords.
\`\`\` \`\`\`

View File

@@ -13,6 +13,7 @@ import {
User, User,
Settings Settings
} from '@/types/apiTypes' } from '@/types/apiTypes'
import axios from 'axios'
interface QueuePromptRequestBody { interface QueuePromptRequestBody {
client_id: string client_id: string
@@ -46,6 +47,10 @@ class ComfyApi extends EventTarget {
this.initialClientId = sessionStorage.getItem('clientId') this.initialClientId = sessionStorage.getItem('clientId')
} }
internalURL(route: string): string {
return this.api_base + '/internal' + route
}
apiURL(route: string): string { apiURL(route: string): string {
return this.api_base + '/api' + route return this.api_base + '/api' + route
} }
@@ -652,6 +657,10 @@ class ComfyApi extends EventTarget {
} }
return resp.json() return resp.json()
} }
async getLogs(): Promise<string> {
return (await axios.get(this.internalURL('/logs'))).data
}
} }
export const api = new ComfyApi() export const api = new ComfyApi()

View File

@@ -389,7 +389,10 @@ export const zSystemStats = z.object({
system: z.object({ system: z.object({
os: z.string(), os: z.string(),
python_version: z.string(), python_version: z.string(),
embedded_python: z.boolean() embedded_python: z.boolean(),
comfyui_version: z.string(),
pytorch_version: z.string(),
argv: z.array(z.string())
}), }),
devices: z.array( devices: z.array(
z.object({ z.object({

View File

@@ -91,6 +91,9 @@ export default defineConfig({
base: '', base: '',
server: { server: {
proxy: { proxy: {
'/internal': {
target: DEV_SERVER_COMFYUI_URL,
},
'/api': { '/api': {
target: DEV_SERVER_COMFYUI_URL, target: DEV_SERVER_COMFYUI_URL,
// Return empty array for extensions API as these modules // Return empty array for extensions API as these modules