👍️[Update] Model : cuda版のsoftwareをダウンロードできるようにendpointを追加

This commit is contained in:
misyaguziya
2024-11-05 00:46:45 +09:00
parent 21bd59c915
commit 8d9013ef51
3 changed files with 29 additions and 0 deletions

View File

@@ -357,6 +357,28 @@ class Model:
# run updater
Popen(program_name, cwd=current_directory)
@staticmethod
def updateCudaSoftware():
# try to update at most 5 times
for _ in range(5):
try:
program_name = "update.exe"
current_directory = config.PATH_LOCAL
res = requests_get(config.UPDATER_URL)
assets = res.json()['assets']
url = [i["browser_download_url"] for i in assets if i["name"] == program_name][0]
res = requests_get(url, stream=True)
with open(os_path.join(current_directory, program_name), 'wb') as file:
for chunk in res.iter_content(chunk_size=1024*5):
file.write(chunk)
break
except Exception:
import traceback
with open('error.log', 'a') as f:
traceback.print_exc(file=f)
# run updater
Popen([program_name, "--cuda"], cwd=current_directory)
def getListMicHost(self):
result = [host for host in device_manager.getMicDevices().keys()]
return result

View File

@@ -1416,6 +1416,12 @@ class Controller:
th_start_update_software.start()
return {"status":200, "result":True}
def updateCudaSoftware(self, *args, **kwargs) -> dict:
th_start_update_cuda_software = Thread(target=model.updateCudaSoftware)
th_start_update_cuda_software.daemon = True
th_start_update_cuda_software.start()
return {"status":200, "result":True}
def downloadCtranslate2Weight(self, data:str, *args, **kwargs) -> dict:
weight_type = str(data)
download_ctranslate2 = self.DownloadCTranslate2(

View File

@@ -92,6 +92,7 @@ mapping = {
"/run/swap_your_language_and_target_language": {"status": True, "variable":controller.swapYourLanguageAndTargetLanguage},
"/run/update_software": {"status": True, "variable":controller.updateSoftware},
"/run/update_cuda_software": {"status": True, "variable":controller.updateCudaSoftware},
# Config Window
# Appearance