@@ -69,12 +69,12 @@ std::string GetEnginePath(std::string_view e) {
6969};
7070} // namespace
7171
72- cpp::result<void , std::string> EngineService::InstallEngineAsyncV2 (
72+ cpp::result<void , std::string> EngineService::InstallEngineAsync (
7373 const std::string& engine, const std::string& version,
7474 const std::optional<std::string> variant_name) {
7575 auto ne = NormalizeEngine (engine);
76- CTL_INF (" InstallEngineAsyncV2 : " << ne << " , " << version << " , "
77- << variant_name.value_or (" " ));
76+ CTL_INF (" InstallEngineAsync : " << ne << " , " << version << " , "
77+ << variant_name.value_or (" " ));
7878 auto os = hw_inf_.sys_inf ->os ;
7979 if (os == kMacOs && (ne == kOnnxRepo || ne == kTrtLlmRepo )) {
8080 return cpp::fail (" Engine " + ne + " is not supported on macOS" );
@@ -84,7 +84,7 @@ cpp::result<void, std::string> EngineService::InstallEngineAsyncV2(
8484 return cpp::fail (" Engine " + ne + " is not supported on Linux" );
8585 }
8686
87- auto result = DownloadEngineV2 (ne, version, variant_name);
87+ auto result = DownloadEngine (ne, version, variant_name);
8888 if (result.has_error ()) {
8989 return cpp::fail (result.error ());
9090 }
@@ -95,25 +95,6 @@ cpp::result<void, std::string> EngineService::InstallEngineAsyncV2(
9595 return {};
9696}
9797
98- cpp::result<bool , std::string> EngineService::InstallEngineAsync (
99- const std::string& engine, const std::string& version,
100- const std::string& src) {
101- // Although this function is called async, only download tasks are performed async
102- auto ne = NormalizeEngine (engine);
103- if (!src.empty ()) {
104- auto res = UnzipEngine (ne, version, src);
105- // If has error or engine is installed successfully
106- if (res.has_error () || res.value ()) {
107- return res;
108- }
109- }
110- auto result = DownloadEngine (ne, version, true /* async*/ );
111- if (result.has_error ()) {
112- return result;
113- }
114- return DownloadCuda (ne, true /* async*/ );
115- }
116-
11798cpp::result<bool , std::string> EngineService::UnzipEngine (
11899 const std::string& engine, const std::string& version,
119100 const std::string& path) {
@@ -242,7 +223,7 @@ cpp::result<bool, std::string> EngineService::UninstallEngineVariant(
242223 }
243224}
244225
245- cpp::result<void , std::string> EngineService::DownloadEngineV2 (
226+ cpp::result<void , std::string> EngineService::DownloadEngine (
246227 const std::string& engine, const std::string& version,
247228 const std::optional<std::string> variant_name) {
248229 auto normalized_version = version == " latest"
@@ -377,101 +358,6 @@ cpp::result<void, std::string> EngineService::DownloadEngineV2(
377358 return {};
378359}
379360
380- cpp::result<bool , std::string> EngineService::DownloadEngine (
381- const std::string& engine, const std::string& version, bool async) {
382- auto res = GetEngineVariants (engine, version);
383- if (res.has_error ()) {
384- return cpp::fail (" Failed to fetch engine releases: " + res.error ());
385- }
386-
387- if (res.value ().empty ()) {
388- return cpp::fail (" No release found for " + version);
389- }
390-
391- auto os_arch{hw_inf_.sys_inf ->os + " -" + hw_inf_.sys_inf ->arch };
392-
393- std::vector<std::string> variants;
394- for (const auto & asset : res.value ()) {
395- variants.push_back (asset.name );
396- }
397-
398- CTL_INF (" engine: " << engine);
399- CTL_INF (" CUDA version: " << hw_inf_.cuda_driver_version );
400- auto matched_variant = GetMatchedVariant (engine, variants);
401- CTL_INF (" Matched variant: " << matched_variant);
402- if (matched_variant.empty ()) {
403- CTL_ERR (" No variant found for " << os_arch);
404- return cpp::fail (" No variant found for " + os_arch);
405- }
406-
407- for (const auto & asset : res.value ()) {
408- if (asset.name == matched_variant) {
409- CTL_INF (" Download url: " << asset.browser_download_url );
410-
411- std::filesystem::path engine_folder_path =
412- file_manager_utils::GetContainerFolderPath (
413- file_manager_utils::DownloadTypeToString (DownloadType::Engine)) /
414- engine;
415-
416- if (!std::filesystem::exists (engine_folder_path)) {
417- CTL_INF (" Creating " << engine_folder_path.string ());
418- std::filesystem::create_directories (engine_folder_path);
419- }
420- if (IsEngineLoaded (engine)) {
421- CTL_INF (" Engine " << engine << " is already loaded, unloading it" );
422- auto unload_res = UnloadEngine (engine);
423- if (unload_res.has_error ()) {
424- CTL_INF (" Failed to unload engine: " << unload_res.error ());
425- return cpp::fail (unload_res.error ());
426- } else {
427- CTL_INF (" Engine " << engine << " unloaded successfully" );
428- }
429- }
430- CTL_INF (" Engine folder path: " << engine_folder_path.string () << " \n " );
431- auto local_path = engine_folder_path / asset.name ;
432- auto downloadTask{
433- DownloadTask{.id = engine,
434- .type = DownloadType::Engine,
435- .items = {DownloadItem{
436- .id = engine,
437- .downloadUrl = asset.browser_download_url ,
438- .localPath = local_path,
439- }}}};
440-
441- auto on_finished = [](const DownloadTask& finishedTask) {
442- // try to unzip the downloaded file
443- CTL_INF (
444- " Engine zip path: " << finishedTask.items [0 ].localPath .string ());
445-
446- std::filesystem::path extract_path =
447- finishedTask.items [0 ].localPath .parent_path ().parent_path ();
448-
449- archive_utils::ExtractArchive (finishedTask.items [0 ].localPath .string (),
450- extract_path.string ());
451-
452- // remove the downloaded file
453- try {
454- std::filesystem::remove (finishedTask.items [0 ].localPath );
455- } catch (const std::exception& e) {
456- CTL_WRN (" Could not delete file: " << e.what ());
457- }
458- CTL_INF (" Finished!" );
459- };
460-
461- if (async) {
462- auto res = download_service_->AddTask (downloadTask, on_finished);
463- if (res.has_error ()) {
464- return cpp::fail (res.error ());
465- }
466- return true ;
467- } else {
468- return download_service_->AddDownloadTask (downloadTask, on_finished);
469- }
470- }
471- }
472- return true ;
473- }
474-
475361cpp::result<bool , std::string> EngineService::DownloadCuda (
476362 const std::string& engine, bool async) {
477363 if (hw_inf_.sys_inf ->os == " mac" || engine == kOnnxRepo ||
@@ -1032,8 +918,8 @@ cpp::result<EngineUpdateResult, std::string> EngineService::UpdateEngine(
1032918 << default_variant->variant << " is not up-to-date! Current: "
1033919 << default_variant->version << " , latest: " << latest_version->name );
1034920
1035- auto res = InstallEngineAsyncV2 (engine, latest_version->tag_name ,
1036- default_variant->variant );
921+ auto res = InstallEngineAsync (engine, latest_version->tag_name ,
922+ default_variant->variant );
1037923
1038924 return EngineUpdateResult{.engine = engine,
1039925 .variant = default_variant->variant ,
0 commit comments