custom python path
This commit is contained in:
parent
b49968c145
commit
796e5f22c0
@ -7,24 +7,33 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *App) StartServer(port int, host string) (string, error) {
|
func (a *App) StartServer(python string, port int, host string) (string, error) {
|
||||||
python, err := GetPython()
|
var err error
|
||||||
|
if python == "" {
|
||||||
|
python, err = GetPython()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return Cmd(python, "./backend-python/main.py", strconv.Itoa(port), host)
|
return Cmd(python, "./backend-python/main.py", strconv.Itoa(port), host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) ConvertModel(modelPath string, strategy string, outPath string) (string, error) {
|
func (a *App) ConvertModel(python string, modelPath string, strategy string, outPath string) (string, error) {
|
||||||
python, err := GetPython()
|
var err error
|
||||||
|
if python == "" {
|
||||||
|
python, err = GetPython()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return Cmd(python, "./backend-python/convert_model.py", "--in", modelPath, "--out", outPath, "--strategy", strategy)
|
return Cmd(python, "./backend-python/convert_model.py", "--in", modelPath, "--out", outPath, "--strategy", strategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) DepCheck() error {
|
func (a *App) DepCheck(python string) error {
|
||||||
python, err := GetPython()
|
var err error
|
||||||
|
if python == "" {
|
||||||
|
python, err = GetPython()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -35,8 +44,11 @@ func (a *App) DepCheck() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) InstallPyDep(cnMirror bool) (string, error) {
|
func (a *App) InstallPyDep(python string, cnMirror bool) (string, error) {
|
||||||
python, err := GetPython()
|
var err error
|
||||||
|
if python == "" {
|
||||||
|
python, err = GetPython()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
|
|
||||||
if (!commonStore.depComplete) {
|
if (!commonStore.depComplete) {
|
||||||
let depErrorMsg = '';
|
let depErrorMsg = '';
|
||||||
await DepCheck().catch((e) => {
|
await DepCheck(commonStore.settings.customPythonPath).catch((e) => {
|
||||||
depErrorMsg = e.message || e;
|
depErrorMsg = e.message || e;
|
||||||
WindowShow();
|
WindowShow();
|
||||||
if (depErrorMsg === 'python zip not found') {
|
if (depErrorMsg === 'python zip not found') {
|
||||||
@ -71,7 +71,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
});
|
});
|
||||||
} else if (depErrorMsg.includes('DepCheck Error')) {
|
} else if (depErrorMsg.includes('DepCheck Error')) {
|
||||||
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
||||||
InstallPyDep(commonStore.settings.cnMirror);
|
InstallPyDep(commonStore.settings.customPythonPath, commonStore.settings.cnMirror);
|
||||||
setTimeout(WindowShow, 1000);
|
setTimeout(WindowShow, 1000);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -83,6 +83,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
commonStore.setDepComplete(true);
|
commonStore.setDepComplete(true);
|
||||||
|
if (commonStore.platform === 'windows')
|
||||||
CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
|
CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
|
||||||
saveCache();
|
saveCache();
|
||||||
}
|
}
|
||||||
@ -109,7 +110,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
|
|
||||||
await exit(1000).catch(() => {
|
await exit(1000).catch(() => {
|
||||||
});
|
});
|
||||||
StartServer(port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1');
|
StartServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1');
|
||||||
setTimeout(WindowShow, 1000);
|
setTimeout(WindowShow, 1000);
|
||||||
|
|
||||||
let timeoutCount = 6;
|
let timeoutCount = 6;
|
||||||
@ -137,7 +138,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
let customCudaFile = '';
|
let customCudaFile = '';
|
||||||
if (modelConfig.modelParameters.device != 'CPU' && modelConfig.modelParameters.useCustomCuda) {
|
if (modelConfig.modelParameters.device != 'CPU' && modelConfig.modelParameters.useCustomCuda) {
|
||||||
customCudaFile = getSupportedCustomCudaFile();
|
customCudaFile = getSupportedCustomCudaFile();
|
||||||
if (customCudaFile) {
|
if (customCudaFile && commonStore.platform === 'windows') {
|
||||||
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => {
|
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => {
|
||||||
// defensive measure. As Python has already been launched, will only take effect the next time it runs.
|
// defensive measure. As Python has already been launched, will only take effect the next time it runs.
|
||||||
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
|
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
|
||||||
|
@ -840,7 +840,7 @@ export const Configs: FC = observer(() => {
|
|||||||
const strategy = getStrategy(selectedConfig);
|
const strategy = getStrategy(selectedConfig);
|
||||||
const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-');
|
const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-');
|
||||||
toast(t('Start Converting'), { autoClose: 1000, type: 'info' });
|
toast(t('Start Converting'), { autoClose: 1000, type: 'info' });
|
||||||
ConvertModel(modelPath, strategy, newModelPath).then(() => {
|
ConvertModel(commonStore.settings.customPythonPath, modelPath, strategy, newModelPath).then(() => {
|
||||||
toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' });
|
toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' });
|
||||||
refreshLocalModels({ models: commonStore.modelSourceList }, false);
|
refreshLocalModels({ models: commonStore.modelSourceList }, false);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
8
frontend/wailsjs/go/backend_golang/App.d.ts
generated
vendored
8
frontend/wailsjs/go/backend_golang/App.d.ts
generated
vendored
@ -6,13 +6,13 @@ export function AddToDownloadList(arg1:string,arg2:string):Promise<void>;
|
|||||||
|
|
||||||
export function ContinueDownload(arg1:string):Promise<void>;
|
export function ContinueDownload(arg1:string):Promise<void>;
|
||||||
|
|
||||||
export function ConvertModel(arg1:string,arg2:string,arg3:string):Promise<string>;
|
export function ConvertModel(arg1:string,arg2:string,arg3:string,arg4:string):Promise<string>;
|
||||||
|
|
||||||
export function CopyFile(arg1:string,arg2:string):Promise<void>;
|
export function CopyFile(arg1:string,arg2:string):Promise<void>;
|
||||||
|
|
||||||
export function DeleteFile(arg1:string):Promise<void>;
|
export function DeleteFile(arg1:string):Promise<void>;
|
||||||
|
|
||||||
export function DepCheck():Promise<void>;
|
export function DepCheck(arg1:string):Promise<void>;
|
||||||
|
|
||||||
export function DownloadFile(arg1:string,arg2:string):Promise<void>;
|
export function DownloadFile(arg1:string,arg2:string):Promise<void>;
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ export function FileExists(arg1:string):Promise<boolean>;
|
|||||||
|
|
||||||
export function GetPlatform():Promise<string>;
|
export function GetPlatform():Promise<string>;
|
||||||
|
|
||||||
export function InstallPyDep(arg1:boolean):Promise<string>;
|
export function InstallPyDep(arg1:string,arg2:boolean):Promise<string>;
|
||||||
|
|
||||||
export function ListDirFiles(arg1:string):Promise<Array<backend_golang.FileInfo>>;
|
export function ListDirFiles(arg1:string):Promise<Array<backend_golang.FileInfo>>;
|
||||||
|
|
||||||
@ -34,6 +34,6 @@ export function ReadJson(arg1:string):Promise<any>;
|
|||||||
|
|
||||||
export function SaveJson(arg1:string,arg2:any):Promise<void>;
|
export function SaveJson(arg1:string,arg2:any):Promise<void>;
|
||||||
|
|
||||||
export function StartServer(arg1:number,arg2:string):Promise<string>;
|
export function StartServer(arg1:string,arg2:number,arg3:string):Promise<string>;
|
||||||
|
|
||||||
export function UpdateApp(arg1:string):Promise<boolean>;
|
export function UpdateApp(arg1:string):Promise<boolean>;
|
||||||
|
16
frontend/wailsjs/go/backend_golang/App.js
generated
16
frontend/wailsjs/go/backend_golang/App.js
generated
@ -10,8 +10,8 @@ export function ContinueDownload(arg1) {
|
|||||||
return window['go']['backend_golang']['App']['ContinueDownload'](arg1);
|
return window['go']['backend_golang']['App']['ContinueDownload'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ConvertModel(arg1, arg2, arg3) {
|
export function ConvertModel(arg1, arg2, arg3, arg4) {
|
||||||
return window['go']['backend_golang']['App']['ConvertModel'](arg1, arg2, arg3);
|
return window['go']['backend_golang']['App']['ConvertModel'](arg1, arg2, arg3, arg4);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CopyFile(arg1, arg2) {
|
export function CopyFile(arg1, arg2) {
|
||||||
@ -22,8 +22,8 @@ export function DeleteFile(arg1) {
|
|||||||
return window['go']['backend_golang']['App']['DeleteFile'](arg1);
|
return window['go']['backend_golang']['App']['DeleteFile'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DepCheck() {
|
export function DepCheck(arg1) {
|
||||||
return window['go']['backend_golang']['App']['DepCheck']();
|
return window['go']['backend_golang']['App']['DepCheck'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DownloadFile(arg1, arg2) {
|
export function DownloadFile(arg1, arg2) {
|
||||||
@ -38,8 +38,8 @@ export function GetPlatform() {
|
|||||||
return window['go']['backend_golang']['App']['GetPlatform']();
|
return window['go']['backend_golang']['App']['GetPlatform']();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InstallPyDep(arg1) {
|
export function InstallPyDep(arg1, arg2) {
|
||||||
return window['go']['backend_golang']['App']['InstallPyDep'](arg1);
|
return window['go']['backend_golang']['App']['InstallPyDep'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ListDirFiles(arg1) {
|
export function ListDirFiles(arg1) {
|
||||||
@ -66,8 +66,8 @@ export function SaveJson(arg1, arg2) {
|
|||||||
return window['go']['backend_golang']['App']['SaveJson'](arg1, arg2);
|
return window['go']['backend_golang']['App']['SaveJson'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StartServer(arg1, arg2) {
|
export function StartServer(arg1, arg2, arg3) {
|
||||||
return window['go']['backend_golang']['App']['StartServer'](arg1, arg2);
|
return window['go']['backend_golang']['App']['StartServer'](arg1, arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpdateApp(arg1) {
|
export function UpdateApp(arg1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user