Skip to content

Commit

Permalink
fix: remove redundant gpu detection prompt event (janhq#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Dec 29, 2023
1 parent 28f8832 commit a9579a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
21 changes: 4 additions & 17 deletions extensions/inference-nitro-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export default class JanInferenceNitroExtension implements InferenceExtension {
/**
* Subscribes to events emitted by the @janhq/core package.
*/
async onLoad(): Promise<void> {
async onLoad() {
if (!(await fs.existsSync(JanInferenceNitroExtension._homeDir))) {
await fs.mkdirSync(JanInferenceNitroExtension._homeDir).catch((err) => console.debug(err));
await fs
.mkdirSync(JanInferenceNitroExtension._homeDir)
.catch((err) => console.debug(err));
}

if (!(await fs.existsSync(JanInferenceNitroExtension._settingsDir)))
Expand All @@ -87,21 +89,6 @@ export default class JanInferenceNitroExtension implements InferenceExtension {

// Attempt to fetch nvidia info
await executeOnMain(MODULE, "updateNvidiaInfo", {});

const gpuDriverConf = await fs.readFileSync(
join(JanInferenceNitroExtension._settingsDir, "settings.json")
);
if (gpuDriverConf.notify && gpuDriverConf.run_mode === "cpu") {
// Driver is fully installed, but not in use
if (gpuDriverConf.nvidia_driver?.exist && gpuDriverConf.cuda?.exist) {
events.emit("OnGPUCompatiblePrompt", {});
// Prompt user to switch
} else if (gpuDriverConf.nvidia_driver?.exist) {
// Prompt user to install cuda toolkit
events.emit("OnGPUDriverMissingPrompt", {});
}
}
Promise.resolve()
}

/**
Expand Down
3 changes: 1 addition & 2 deletions extensions/inference-openai-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class JanInferenceOpenAIExtension implements InferenceExtension {
/**
* Subscribes to events emitted by the @janhq/core package.
*/
async onLoad(): Promise<void> {
async onLoad() {
if (!(await fs.existsSync(JanInferenceOpenAIExtension._homeDir))) {
await fs
.mkdirSync(JanInferenceOpenAIExtension._homeDir)
Expand All @@ -77,7 +77,6 @@ export default class JanInferenceOpenAIExtension implements InferenceExtension {
events.on(EventName.OnInferenceStopped, () => {
JanInferenceOpenAIExtension.handleInferenceStopped(this);
});
Promise.resolve();
}

/**
Expand Down
4 changes: 0 additions & 4 deletions web/containers/Providers/EventHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ export default function EventHandler({ children }: { children: ReactNode }) {
}
}
}
function handleGpuCompatiblePrompt() {}
function handleGpuDriverMissingPrompt() {}

useEffect(() => {
if (window.core?.events) {
Expand All @@ -129,8 +127,6 @@ export default function EventHandler({ children }: { children: ReactNode }) {
events.on(EventName.OnModelReady, handleModelReady)
events.on(EventName.OnModelFail, handleModelFail)
events.on(EventName.OnModelStopped, handleModelStopped)
events.on('OnGPUCompatiblePrompt', handleGpuCompatiblePrompt)
events.on('OnGPUDriverMissingPrompt', handleGpuDriverMissingPrompt)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
Expand Down

0 comments on commit a9579a3

Please sign in to comment.