mirror of
https://github.com/leon-ai/leon.git
synced 2024-10-26 18:18:46 +03:00
refactor: unify Python TCP server warnings to ignore
This commit is contained in:
parent
fb5c258cf6
commit
1516b18a11
@ -13,6 +13,7 @@ import getos from 'getos'
|
|||||||
|
|
||||||
import { LogHelper } from '@/helpers/log-helper'
|
import { LogHelper } from '@/helpers/log-helper'
|
||||||
import { SystemHelper } from '@/helpers/system-helper'
|
import { SystemHelper } from '@/helpers/system-helper'
|
||||||
|
import { shouldIgnoreTCPServerError } from '@/utilities'
|
||||||
import {
|
import {
|
||||||
MINIMUM_REQUIRED_RAM,
|
MINIMUM_REQUIRED_RAM,
|
||||||
LEON_VERSION,
|
LEON_VERSION,
|
||||||
@ -295,9 +296,6 @@ dotenv.config()
|
|||||||
const pythonTCPServerCommand = `${PYTHON_TCP_SERVER_BIN_PATH} en`
|
const pythonTCPServerCommand = `${PYTHON_TCP_SERVER_BIN_PATH} en`
|
||||||
const pythonTCPServerStart = Date.now()
|
const pythonTCPServerStart = Date.now()
|
||||||
const p = spawn(pythonTCPServerCommand, { shell: true })
|
const p = spawn(pythonTCPServerCommand, { shell: true })
|
||||||
const ignoredWarnings = [
|
|
||||||
'UserWarning: Unable to retrieve source for @torch.jit._overload function'
|
|
||||||
]
|
|
||||||
|
|
||||||
LogHelper.info(pythonTCPServerCommand)
|
LogHelper.info(pythonTCPServerCommand)
|
||||||
reportDataInput.pythonTCPServer.command = pythonTCPServerCommand
|
reportDataInput.pythonTCPServer.command = pythonTCPServerCommand
|
||||||
@ -322,9 +320,10 @@ dotenv.config()
|
|||||||
|
|
||||||
p.stderr.on('data', (data) => {
|
p.stderr.on('data', (data) => {
|
||||||
const newData = data.toString()
|
const newData = data.toString()
|
||||||
|
const shouldIgnore = shouldIgnoreTCPServerError(newData)
|
||||||
|
|
||||||
// Ignore given warnings on stderr output
|
// Ignore given warnings on stderr output
|
||||||
if (!ignoredWarnings.some((w) => newData.includes(w))) {
|
if (!shouldIgnore) {
|
||||||
pythonTCPServerOutput += newData
|
pythonTCPServerOutput += newData
|
||||||
report.can_start_python_tcp_server.v = false
|
report.can_start_python_tcp_server.v = false
|
||||||
reportDataInput.pythonTCPServer.error = newData
|
reportDataInput.pythonTCPServer.error = newData
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
LLM_PROVIDER,
|
LLM_PROVIDER,
|
||||||
LLM_MANAGER
|
LLM_MANAGER
|
||||||
} from '@/core'
|
} from '@/core'
|
||||||
|
import { shouldIgnoreTCPServerError } from '@/utilities'
|
||||||
import { Updater } from '@/updater'
|
import { Updater } from '@/updater'
|
||||||
import { Telemetry } from '@/telemetry'
|
import { Telemetry } from '@/telemetry'
|
||||||
// import { CustomNERLLMDuty } from '@/core/llm-manager/llm-duties/custom-ner-llm-duty'
|
// import { CustomNERLLMDuty } from '@/core/llm-manager/llm-duties/custom-ner-llm-duty'
|
||||||
@ -57,18 +58,9 @@ import { LogHelper } from '@/helpers/log-helper'
|
|||||||
})
|
})
|
||||||
global.pythonTCPServerProcess.stderr.on('data', (data: Buffer) => {
|
global.pythonTCPServerProcess.stderr.on('data', (data: Buffer) => {
|
||||||
const formattedData = data.toString().trim()
|
const formattedData = data.toString().trim()
|
||||||
const skipError = [
|
const shouldIgnore = shouldIgnoreTCPServerError(formattedData)
|
||||||
'RuntimeWarning:',
|
|
||||||
'FutureWarning:',
|
|
||||||
'UserWarning:',
|
|
||||||
'<00:00',
|
|
||||||
'00:00<',
|
|
||||||
'CUDNN_STATUS_NOT_SUPPORTED',
|
|
||||||
'cls.seq_relationship.weight',
|
|
||||||
'ALSA lib'
|
|
||||||
]
|
|
||||||
|
|
||||||
if (skipError.some((error) => formattedData.includes(error))) {
|
if (shouldIgnore) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,3 +20,22 @@ export function getGlobalEntitiesPath(lang: ShortLanguageCode): string {
|
|||||||
export function getGlobalResolversPath(lang: ShortLanguageCode): string {
|
export function getGlobalResolversPath(lang: ShortLanguageCode): string {
|
||||||
return path.join(GLOBAL_DATA_PATH, lang, 'global-resolvers')
|
return path.join(GLOBAL_DATA_PATH, lang, 'global-resolvers')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Misc
|
||||||
|
*/
|
||||||
|
const TCP_SERVER_WARNINGS_TO_IGNORE = [
|
||||||
|
'RuntimeWarning:',
|
||||||
|
'FutureWarning:',
|
||||||
|
'UserWarning:',
|
||||||
|
'<00:00',
|
||||||
|
'00:00<',
|
||||||
|
'CUDNN_STATUS_NOT_SUPPORTED',
|
||||||
|
'cls.seq_relationship.weight',
|
||||||
|
'ALSA lib'
|
||||||
|
]
|
||||||
|
export function shouldIgnoreTCPServerError(error: string): boolean {
|
||||||
|
return TCP_SERVER_WARNINGS_TO_IGNORE.some((warning) =>
|
||||||
|
error.includes(warning)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user