diff --git a/scripts/check.js b/scripts/check.js index 857f5763..64ac2101 100644 --- a/scripts/check.js +++ b/scripts/check.js @@ -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 diff --git a/server/src/index.ts b/server/src/index.ts index b4bdbcdc..62a3f68e 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -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 } diff --git a/server/src/utilities.ts b/server/src/utilities.ts index 4138d513..0549e3c1 100644 --- a/server/src/utilities.ts +++ b/server/src/utilities.ts @@ -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) + ) +}