Skip to content

Commit 24cf3e5

Browse files
fix: skip main branch for cortexso model source if has metadata.yml (#2042)
Co-authored-by: sangjanai <[email protected]>
1 parent 19f0c26 commit 24cf3e5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

engine/services/model_source_service.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,10 @@ cpp::result<bool, std::string> ModelSourceService::AddCortexsoRepo(
432432
}
433433

434434
auto author = hub_author;
435+
auto model_author = hu::GetModelAuthorCortexsoHub(model_name);
435436
if (auto model_author = hu::GetModelAuthorCortexsoHub(model_name);
436-
model_author.has_value() && !model_author->empty()) {
437-
author = *model_author;
437+
model_author.has_value() && !model_author.value().empty()) {
438+
author = model_author.value();
438439
}
439440

440441
// Get models from db
@@ -443,6 +444,10 @@ cpp::result<bool, std::string> ModelSourceService::AddCortexsoRepo(
443444
std::unordered_set<std::string> updated_model_list;
444445
std::vector<std::future<std::string>> tasks;
445446
for (auto const& [branch, _] : branches.value()) {
447+
if (!model_author.has_error() && branch == "main") {
448+
CTL_DBG("Skip main branch");
449+
continue;
450+
}
446451
CTL_DBG(branch);
447452
tasks.push_back(std::async(std::launch::async, [&, branch = branch] {
448453
return AddCortexsoRepoBranch(model_source, author, model_name, branch,

engine/utils/huggingface_utils.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -312,23 +312,23 @@ inline std::optional<std::string> GetDefaultBranch(
312312
}
313313
}
314314

315-
inline std::optional<std::string> GetModelAuthorCortexsoHub(
315+
inline cpp::result<std::string, std::string> GetModelAuthorCortexsoHub(
316316
const std::string& model_name) {
317317
try {
318318
auto remote_yml = curl_utils::ReadRemoteYaml(GetMetadataUrl(model_name));
319319

320320
if (remote_yml.has_error()) {
321-
return std::nullopt;
321+
return cpp::fail(remote_yml.error());
322322
}
323323

324324
auto metadata = remote_yml.value();
325325
auto author = metadata["author"];
326326
if (author.IsDefined()) {
327327
return author.as<std::string>();
328328
}
329-
return std::nullopt;
329+
return "";
330330
} catch (const std::exception& e) {
331-
return std::nullopt;
331+
return "";
332332
}
333333
}
334334
} // namespace huggingface_utils

0 commit comments

Comments
 (0)