* feat: better hardware setting * chore: update layout * feat: better hardware setting * chore: fix title section * chore: added hardware engine management * chore: integrate gpus and enable set gpu activate * chore: update calculate ram and vram * chore: update calulate vram and ram used * fix: set active gpus * chore: fix progress bar spacing * chore: always update cache vram gpu * chore: update cpu usage percentage * chore: fix type usage cpu * chore: update ram cpus usage getsystemmonitor from new api harware engine management system * test: update test case data using hardware management extension * chore: resolve conflict lock json * chore: cleanup app services * chore: update type OperationSystemInfo * chore: update app service * chore: show list gpus on system monitor * chore: remove monitoring extension * chore: update test case app service * chore: remove unused hooks useGpusSetting * chore: remove monitor from shource index * chore: fix test core * chore: update gpu and cpu info on engine management ext * chore: fix app service test * chore: update test appService include cpu info * chore: filter gpus show or hide on system monitor based activated gpu * chore: remove unused run_mode * chore: remove tensort * chore: update check gpu run_mode * chore: handle undefined gpus * chore: cleanup PR * chore: cleanup process node error * chore: fix type
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import {
|
|
executeOnMain,
|
|
HardwareManagementExtension,
|
|
HardwareInformation,
|
|
} from '@janhq/core'
|
|
import ky from 'ky'
|
|
import PQueue from 'p-queue'
|
|
|
|
/**
|
|
* JSONHardwareManagementExtension is a HardwareManagementExtension implementation that provides
|
|
* functionality for managing engines.
|
|
*/
|
|
export default class JSONHardwareManagementExtension extends HardwareManagementExtension {
|
|
queue = new PQueue({ concurrency: 1 })
|
|
|
|
/**
|
|
* Called when the extension is loaded.
|
|
*/
|
|
async onLoad() {
|
|
// Run Healthcheck
|
|
this.queue.add(() => this.healthz())
|
|
}
|
|
|
|
/**
|
|
* Called when the extension is unloaded.
|
|
*/
|
|
onUnload() {}
|
|
|
|
/**
|
|
* Do health check on cortex.cpp
|
|
* @returns
|
|
*/
|
|
async healthz(): Promise<void> {
|
|
return ky
|
|
.get(`${API_URL}/healthz`, {
|
|
retry: { limit: 20, delay: () => 500, methods: ['get'] },
|
|
})
|
|
.then(() => {})
|
|
}
|
|
|
|
/**
|
|
* @returns A Promise that resolves to an object of hardware.
|
|
*/
|
|
async getHardware(): Promise<HardwareInformation> {
|
|
return this.queue.add(() =>
|
|
ky
|
|
.get(`${API_URL}/v1/hardware`)
|
|
.json<HardwareInformation>()
|
|
.then((e) => e)
|
|
) as Promise<HardwareInformation>
|
|
}
|
|
|
|
/**
|
|
* @returns A Promise that resolves to an object of set gpu activate.
|
|
*/
|
|
async setAvtiveGpu(data: { gpus: number[] }): Promise<{
|
|
message: string
|
|
activated_gpus: number[]
|
|
}> {
|
|
return this.queue.add(() =>
|
|
ky.post(`${API_URL}/v1/hardware/activate`, { json: data }).then((e) => e)
|
|
) as Promise<{
|
|
message: string
|
|
activated_gpus: number[]
|
|
}>
|
|
}
|
|
}
|