Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.4.13 to main with new Cortex version #2926

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/inference-nitro-extension/bin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.4
0.4.7
20 changes: 13 additions & 7 deletions extensions/inference-nitro-extension/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const SUPPORTED_MODEL_FORMAT = '.gguf'
let subprocess: ChildProcessWithoutNullStreams | undefined = undefined

// The current model settings
let currentSettings: ModelSettingParams & { model?: string } | undefined = undefined
let currentSettings: (ModelSettingParams & { model?: string }) | undefined =
undefined

/**
* Stops a Nitro subprocess.
Expand Down Expand Up @@ -153,7 +154,10 @@ async function loadModel(
* 3. Validate model status
* @returns
*/
async function runNitroAndLoadModel(modelId: string, systemInfo?: SystemInformation) {
async function runNitroAndLoadModel(
modelId: string,
systemInfo?: SystemInformation
) {
// Gather system information for CPU physical cores and memory
return killSubprocess()
.then(() =>
Expand Down Expand Up @@ -320,19 +324,23 @@ async function killSubprocess(): Promise<void> {
})
}

if (subprocess?.pid) {
if (subprocess?.pid && process.platform !== 'darwin') {
log(`[CORTEX]::Debug: Killing PID ${subprocess.pid}`)
const pid = subprocess.pid
return new Promise((resolve, reject) => {
terminate(pid, function (err) {
if (err) {
log('[CORTEX]::Failed to kill PID - sending request to kill')
killRequest().then(resolve).catch(reject)
} else {
tcpPortUsed
.waitUntilFree(PORT, NITRO_PORT_FREE_CHECK_INTERVAL, 5000)
.then(() => resolve())
.then(() => log(`[CORTEX]::Debug: cortex process is terminated`))
.then(() => resolve())
.catch(() => {
log(
'[CORTEX]::Failed to kill PID (Port check timeout) - sending request to kill'
)
killRequest().then(resolve).catch(reject)
})
}
Expand All @@ -358,9 +366,7 @@ function spawnNitroProcess(systemInfo?: SystemInformation): Promise<any> {
log(
`[CORTEX]::Debug: Spawn cortex at path: ${executableOptions.executablePath}, and args: ${args}`
)
log(
path.parse(executableOptions.executablePath).dir
)
log(path.parse(executableOptions.executablePath).dir)
subprocess = spawn(
executableOptions.executablePath,
['1', LOCAL_HOST, PORT.toString()],
Expand Down
Loading