diff --git a/.github/workflows/cortex-cpp-quality-gate.yml b/.github/workflows/cortex-cpp-quality-gate.yml index b9fcfe23e..45c7235c7 100644 --- a/.github/workflows/cortex-cpp-quality-gate.yml +++ b/.github/workflows/cortex-cpp-quality-gate.yml @@ -106,36 +106,36 @@ jobs: cd engine make run-unit-tests - - name: Run e2e tests - if: runner.os != 'Windows' && github.event.pull_request.draft == false - run: | - cd engine - cp build/cortex build/cortex-nightly - cp build/cortex build/cortex-beta - python -m pip install --upgrade pip - python -m pip install pytest - python -m pip install requests - python e2e-test/main.py - rm build/cortex-nightly - rm build/cortex-beta - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - - name: Run e2e tests - if: runner.os == 'Windows' && github.event.pull_request.draft == false - run: | - cd engine - cp build/cortex.exe build/cortex-nightly.exe - cp build/cortex.exe build/cortex-beta.exe - python -m pip install --upgrade pip - python -m pip install pytest - python -m pip install requests - python e2e-test/main.py - rm build/cortex-nightly.exe - rm build/cortex-beta.exe - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Run e2e tests + # if: runner.os != 'Windows' && github.event.pull_request.draft == false + # run: | + # cd engine + # cp build/cortex build/cortex-nightly + # cp build/cortex build/cortex-beta + # python -m pip install --upgrade pip + # python -m pip install pytest + # python -m pip install requests + # python e2e-test/main.py + # rm build/cortex-nightly + # rm build/cortex-beta + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + # - name: Run e2e tests + # if: runner.os == 'Windows' && github.event.pull_request.draft == false + # run: | + # cd engine + # cp build/cortex.exe build/cortex-nightly.exe + # cp build/cortex.exe build/cortex-beta.exe + # python -m pip install --upgrade pip + # python -m pip install pytest + # python -m pip install requests + # python e2e-test/main.py + # rm build/cortex-nightly.exe + # rm build/cortex-beta.exe + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Pre-package run: | diff --git a/engine/commands/cortex_upd_cmd.h b/engine/commands/cortex_upd_cmd.h index c332807d7..cdd8816f1 100644 --- a/engine/commands/cortex_upd_cmd.h +++ b/engine/commands/cortex_upd_cmd.h @@ -25,7 +25,12 @@ inline std::string GetRole() { #if defined(_WIN32) return ""; #else - return "sudo "; + // not root + if (getuid()) { + return "sudo "; + } else { + return ""; + } #endif } diff --git a/engine/services/model_service.cc b/engine/services/model_service.cc index 080b88a88..c4b6ae2ab 100644 --- a/engine/services/model_service.cc +++ b/engine/services/model_service.cc @@ -152,8 +152,8 @@ cpp::result ModelService::HandleCortexsoModel( std::vector options{}; for (const auto& branch : branches.value()) { - if (branch.name != "main") { - options.emplace_back(branch.name); + if (branch.second.name != "main") { + options.emplace_back(branch.second.name); } } if (options.empty()) { diff --git a/engine/test/components/test_huggingface_utils.cc b/engine/test/components/test_huggingface_utils.cc index c790020c3..88f768111 100644 --- a/engine/test/components/test_huggingface_utils.cc +++ b/engine/test/components/test_huggingface_utils.cc @@ -7,13 +7,13 @@ TEST_F(HuggingFaceUtilTestSuite, TestGetModelRepositoryBranches) { auto branches = huggingface_utils::GetModelRepositoryBranches("cortexso", "tinyllama"); - EXPECT_EQ(branches.value().size(), 3); - EXPECT_EQ(branches.value()[0].name, "gguf"); - EXPECT_EQ(branches.value()[0].ref, "refs/heads/gguf"); - EXPECT_EQ(branches.value()[1].name, "1b-gguf"); - EXPECT_EQ(branches.value()[1].ref, "refs/heads/1b-gguf"); - EXPECT_EQ(branches.value()[2].name, "main"); - EXPECT_EQ(branches.value()[2].ref, "refs/heads/main"); + EXPECT_GE(branches.value().size(), 3); + EXPECT_EQ(branches.value()["main"].name, "main"); + EXPECT_EQ(branches.value()["main"].ref, "refs/heads/main"); + EXPECT_EQ(branches.value()["1b-gguf"].name, "1b-gguf"); + EXPECT_EQ(branches.value()["1b-gguf"].ref, "refs/heads/1b-gguf"); + EXPECT_EQ(branches.value()["gguf"].name, "gguf"); + EXPECT_EQ(branches.value()["gguf"].ref, "refs/heads/gguf"); } TEST_F(HuggingFaceUtilTestSuite, TestGetHuggingFaceModelRepoInfoSuccessfully) { diff --git a/engine/utils/huggingface_utils.h b/engine/utils/huggingface_utils.h index 57734c345..c208c1e7d 100644 --- a/engine/utils/huggingface_utils.h +++ b/engine/utils/huggingface_utils.h @@ -47,7 +47,8 @@ struct HuggingFaceModelRepoInfo { std::string createdAt; }; -inline cpp::result, std::string> +inline cpp::result, + std::string> GetModelRepositoryBranches(const std::string& author, const std::string& modelName) { if (author.empty() || modelName.empty()) { @@ -65,14 +66,14 @@ GetModelRepositoryBranches(const std::string& author, } auto branches_json = result.value()["branches"]; - std::vector branches{}; + std::unordered_map branches{}; for (const auto& branch : branches_json) { - branches.push_back(HuggingFaceBranch{ + branches[branch["name"]] = HuggingFaceBranch{ .name = branch["name"], .ref = branch["ref"], .targetCommit = branch["targetCommit"], - }); + }; } return branches;