MCPcopy Create free account
hub / github.com/6174/comflowyspace / verifyIsTorchInstalled

Function verifyIsTorchInstalled

apps/node/src/modules/comfyui/verify-torch.ts:32–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31const tmpFile = path.resolve(getAppTmpDir(), "tmp.py");
32export async function verifyIsTorchInstalled(): Promise<boolean> {
33 const { PIP_PATH, PYTHON_PATH } = conda.getCondaPaths();
34 try {
35 await writeTmpPythonFile(pythonCode);
36 // 使用 execa 执行 conda run 命令,切换到指定的 Conda 环境并运行 Python 代码
37 const { stdout } = await runCommand(`${PYTHON_PATH} ${tmpFile}`);
38
39 // 检查执行结果是否符合预期
40 if (stdout.trim() === expectedOutput) {
41 logger.info('Torch installation verification successful.');
42 return true;
43 } else {
44 console.error('Torch installation verification failed. Unexpected output.');
45 return false;
46 }
47 } catch (error) {
48 console.error('Torch installation verification failed. Error:', error);
49 return false;
50 }
51}
52
53export async function writeTmpPythonFile(code: string) {
54 await fsExtra.writeFile(tmpFile, code, 'utf8');

Callers 2

checkBasicRequirementsFunction · 0.90
ApiBootstrapFunction · 0.90

Calls 3

runCommandFunction · 0.90
writeTmpPythonFileFunction · 0.85
getCondaPathsMethod · 0.80

Tested by

no test coverage detected