diff --git a/engine/services/model_source_service.cc b/engine/services/model_source_service.cc index 3314fd53e..ea26718e2 100644 --- a/engine/services/model_source_service.cc +++ b/engine/services/model_source_service.cc @@ -432,9 +432,10 @@ cpp::result ModelSourceService::AddCortexsoRepo( } auto author = hub_author; + auto model_author = hu::GetModelAuthorCortexsoHub(model_name); if (auto model_author = hu::GetModelAuthorCortexsoHub(model_name); - model_author.has_value() && !model_author->empty()) { - author = *model_author; + model_author.has_value() && !model_author.value().empty()) { + author = model_author.value(); } // Get models from db @@ -443,6 +444,10 @@ cpp::result ModelSourceService::AddCortexsoRepo( std::unordered_set updated_model_list; std::vector> tasks; for (auto const& [branch, _] : branches.value()) { + if (!model_author.has_error() && branch == "main") { + CTL_DBG("Skip main branch"); + continue; + } CTL_DBG(branch); tasks.push_back(std::async(std::launch::async, [&, branch = branch] { return AddCortexsoRepoBranch(model_source, author, model_name, branch, diff --git a/engine/utils/huggingface_utils.h b/engine/utils/huggingface_utils.h index fde5d11b2..2c4a3cb75 100644 --- a/engine/utils/huggingface_utils.h +++ b/engine/utils/huggingface_utils.h @@ -312,13 +312,13 @@ inline std::optional GetDefaultBranch( } } -inline std::optional GetModelAuthorCortexsoHub( +inline cpp::result GetModelAuthorCortexsoHub( const std::string& model_name) { try { auto remote_yml = curl_utils::ReadRemoteYaml(GetMetadataUrl(model_name)); if (remote_yml.has_error()) { - return std::nullopt; + return cpp::fail(remote_yml.error()); } auto metadata = remote_yml.value(); @@ -326,9 +326,9 @@ inline std::optional GetModelAuthorCortexsoHub( if (author.IsDefined()) { return author.as(); } - return std::nullopt; + return ""; } catch (const std::exception& e) { - return std::nullopt; + return ""; } } } // namespace huggingface_utils