1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-07-14 21:40:34 +03:00

refactor: unify Python TCP server warnings to ignore

This commit is contained in:
louistiti 2024-05-26 09:55:48 +08:00
parent fb5c258cf6
commit 1516b18a11
No known key found for this signature in database
GPG Key ID: 92CD6A2E497E1669
3 changed files with 25 additions and 15 deletions

View File

@ -13,6 +13,7 @@ import getos from 'getos'
import { LogHelper } from '@/helpers/log-helper'
import { SystemHelper } from '@/helpers/system-helper'
import { shouldIgnoreTCPServerError } from '@/utilities'
import {
MINIMUM_REQUIRED_RAM,
LEON_VERSION,
@ -295,9 +296,6 @@ dotenv.config()
const pythonTCPServerCommand = `${PYTHON_TCP_SERVER_BIN_PATH} en`
const pythonTCPServerStart = Date.now()
const p = spawn(pythonTCPServerCommand, { shell: true })
const ignoredWarnings = [
'UserWarning: Unable to retrieve source for @torch.jit._overload function'
]
LogHelper.info(pythonTCPServerCommand)
reportDataInput.pythonTCPServer.command = pythonTCPServerCommand
@ -322,9 +320,10 @@ dotenv.config()
p.stderr.on('data', (data) => {
const newData = data.toString()
const shouldIgnore = shouldIgnoreTCPServerError(newData)
// Ignore given warnings on stderr output
if (!ignoredWarnings.some((w) => newData.includes(w))) {
if (!shouldIgnore) {
pythonTCPServerOutput += newData
report.can_start_python_tcp_server.v = false
reportDataInput.pythonTCPServer.error = newData

View File

@ -18,6 +18,7 @@ import {
LLM_PROVIDER,
LLM_MANAGER
} from '@/core'
import { shouldIgnoreTCPServerError } from '@/utilities'
import { Updater } from '@/updater'
import { Telemetry } from '@/telemetry'
// 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) => {
const formattedData = data.toString().trim()
const skipError = [
'RuntimeWarning:',
'FutureWarning:',
'UserWarning:',
'<00:00',
'00:00<',
'CUDNN_STATUS_NOT_SUPPORTED',
'cls.seq_relationship.weight',
'ALSA lib'
]
const shouldIgnore = shouldIgnoreTCPServerError(formattedData)
if (skipError.some((error) => formattedData.includes(error))) {
if (shouldIgnore) {
return
}

View File

@ -20,3 +20,22 @@ export function getGlobalEntitiesPath(lang: ShortLanguageCode): string {
export function getGlobalResolversPath(lang: ShortLanguageCode): string {
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)
)
}