Skip to content

feat: cortex pull with new model data structure #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ jobs:
id: update-latest-version
run: |
echo "{\"tag_name\": \"v${{ needs.get-update-version.outputs.new_version }}\"}" > version.json
aws s3 sync version.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/version.json
aws s3 sync s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-amd64/cortex-nightly.tar.gz
aws s3 sync s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-arm64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-arm64/cortex-nightly.tar.gz
aws s3 sync s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/linux-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/linux-amd64/cortex-nightly.tar.gz
aws s3 sync s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/windows-amd64/cortex-nightly.tar.gz
aws s3 cp version.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/version.json
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-amd64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-arm64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/mac-arm64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/linux-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/linux-amd64/cortex-nightly.tar.gz
aws s3 cp s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/latest/windows-amd64/cortex-nightly.tar.gz

env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/template-build-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ jobs:
- name: upload to aws s3 if public provider is aws
if: inputs.public_provider == 'aws-s3'
run: |
aws s3 sync ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/linux-amd64-cortex-nightly.tar.gz
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/linux-amd64-cortex-nightly.tar.gz

aws s3 sync ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-amd64/cortex-nightly.tar.gz
aws s3 sync ./engine/${{ steps.set-output-params.outputs.package_name }}.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-amd64/cortex-${{ inputs.new_version }}-linux-amd64-installer.deb
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-amd64/cortex-nightly.tar.gz
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-amd64/cortex-${{ inputs.new_version }}-linux-amd64-installer.deb
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/template-build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ jobs:
- name: upload to aws s3 if public provider is aws
if: inputs.public_provider == 'aws-s3'
run: |
aws s3 sync ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-${{ inputs.arch}}-cortex-nightly.tar.gz
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-${{ inputs.arch}}-cortex-nightly.tar.gz

aws s3 sync ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-nightly.tar.gz
aws s3 sync ./engine/${{ steps.set-output-params.outputs.package_name }}.pkg s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-installer.pkg
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-nightly.tar.gz
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}.pkg s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-installer.pkg
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/template-build-windows-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ jobs:
run: |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv
aws s3 sync ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz

aws s3 sync ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-nightly.tar.gz
aws s3 sync ./setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-installer.exe
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-nightly.tar.gz
aws s3 cp ./setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-installer.exe
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 0 additions & 2 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ endif()
find_package(jsoncpp CONFIG REQUIRED)
find_package(Drogon CONFIG REQUIRED)
find_package(yaml-cpp CONFIG REQUIRED)
find_package(jinja2cpp CONFIG REQUIRED)
find_package(httplib CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(CLI11 CONFIG REQUIRED)
Expand All @@ -87,7 +86,6 @@ add_executable(${TARGET_NAME} main.cc

target_link_libraries(${TARGET_NAME} PRIVATE httplib::httplib)
target_link_libraries(${TARGET_NAME} PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(${TARGET_NAME} PRIVATE jinja2cpp)
target_link_libraries(${TARGET_NAME} PRIVATE CLI11::CLI11)
target_link_libraries(${TARGET_NAME} PRIVATE unofficial::minizip::minizip)
target_link_libraries(${TARGET_NAME} PRIVATE LibArchive::LibArchive)
Expand Down
54 changes: 46 additions & 8 deletions engine/commands/cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "utils/archive_utils.h"
#include "utils/file_manager_utils.h"
#include "utils/logging_utils.h"
#include "utils/scope_exit.h"
#include "utils/system_info_utils.h"
#include "utils/url_parser.h"

Expand All @@ -23,6 +24,16 @@ void CortexUpdCmd::Exec(std::string v) {
ssc.Exec();
}
}

// Try to remove cortex temp folder if it exists first
try {
auto n = std::filesystem::remove_all(
std::filesystem::temp_directory_path() / "cortex");
CTL_INF("Deleted " << n << " files or directories");
} catch (const std::exception& e) {
CTL_WRN(e.what());
}

if (CORTEX_VARIANT == file_manager_utils::kProdVariant) {
if (!GetStable(v))
return;
Expand All @@ -38,7 +49,7 @@ void CortexUpdCmd::Exec(std::string v) {

bool CortexUpdCmd::GetStable(const std::string& v) {
auto system_info = system_info_utils::GetSystemInfo();
CTL_INF("OS: " << system_info.os << ", Arch: " << system_info.arch);
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

// Download file
auto github_host = GetHostName();
Expand All @@ -56,7 +67,7 @@ bool CortexUpdCmd::GetStable(const std::string& v) {
}

if (!HandleGithubRelease(json_data["assets"],
{system_info.os + "-" + system_info.arch})) {
{system_info->os + "-" + system_info->arch})) {
return false;
}
} catch (const nlohmann::json::parse_error& e) {
Expand All @@ -75,15 +86,24 @@ bool CortexUpdCmd::GetStable(const std::string& v) {

// Replace binary file
auto executable_path = file_manager_utils::GetExecutableFolderContainerPath();
auto src = std::filesystem::temp_directory_path() / "cortex" / kCortexBinary /
GetCortexBinary();
auto src =
std::filesystem::temp_directory_path() / "cortex" / GetCortexBinary();
auto dst = executable_path / GetCortexBinary();
utils::ScopeExit se([]() {
auto cortex_tmp = std::filesystem::temp_directory_path() / "cortex";
try {
auto n = std::filesystem::remove_all(cortex_tmp);
CTL_INF("Deleted " << n << " files or directories");
} catch (const std::exception& e) {
CTL_WRN(e.what());
}
});
return ReplaceBinaryInflight(src, dst);
}

bool CortexUpdCmd::GetBeta(const std::string& v) {
auto system_info = system_info_utils::GetSystemInfo();
CTL_INF("OS: " << system_info.os << ", Arch: " << system_info.arch);
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

// Download file
auto github_host = GetHostName();
Expand Down Expand Up @@ -113,7 +133,7 @@ bool CortexUpdCmd::GetBeta(const std::string& v) {
}

if (!HandleGithubRelease(json_data["assets"],
{system_info.os + "-" + system_info.arch})) {
{system_info->os + "-" + system_info->arch})) {
return false;
}
} catch (const nlohmann::json::parse_error& e) {
Expand All @@ -135,6 +155,15 @@ bool CortexUpdCmd::GetBeta(const std::string& v) {
auto src =
std::filesystem::temp_directory_path() / "cortex" / GetCortexBinary();
auto dst = executable_path / GetCortexBinary();
utils::ScopeExit se([]() {
auto cortex_tmp = std::filesystem::temp_directory_path() / "cortex";
try {
auto n = std::filesystem::remove_all(cortex_tmp);
CTL_INF("Deleted " << n << " files or directories");
} catch (const std::exception& e) {
CTL_WRN(e.what());
}
});
return ReplaceBinaryInflight(src, dst);
}

Expand Down Expand Up @@ -205,11 +234,11 @@ bool CortexUpdCmd::HandleGithubRelease(const nlohmann::json& assets,

bool CortexUpdCmd::GetNightly(const std::string& v) {
auto system_info = system_info_utils::GetSystemInfo();
CTL_INF("OS: " << system_info.os << ", Arch: " << system_info.arch);
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

// Download file
std::string version = v.empty() ? "latest" : std::move(v);
std::string os_arch{system_info.os + "-" + system_info.arch};
std::string os_arch{system_info->os + "-" + system_info->arch};
const char* paths[] = {
"cortex",
version.c_str(),
Expand Down Expand Up @@ -264,6 +293,15 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
auto src =
std::filesystem::temp_directory_path() / "cortex" / GetCortexBinary();
auto dst = executable_path / GetCortexBinary();
utils::ScopeExit se([]() {
auto cortex_tmp = std::filesystem::temp_directory_path() / "cortex";
try {
auto n = std::filesystem::remove_all(cortex_tmp);
CTL_INF("Deleted " << n << " files or directories");
} catch (const std::exception& e) {
CTL_WRN(e.what());
}
});
return ReplaceBinaryInflight(src, dst);
}
} // namespace commands
5 changes: 3 additions & 2 deletions engine/commands/engine_install_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace commands {

void EngineInstallCmd::Exec(const std::string& engine,
const std::string& version) {
engine_service_.InstallEngine(engine, version);
const std::string& version,
const std::string& src) {
engine_service_.InstallEngine(engine, version, src);
CLI_LOG("Engine " << engine << " installed successfully!");
}
}; // namespace commands
3 changes: 2 additions & 1 deletion engine/commands/engine_install_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class EngineInstallCmd {
public:
explicit EngineInstallCmd() : engine_service_{EngineService()} {};

void Exec(const std::string& engine, const std::string& version = "latest");
void Exec(const std::string& engine, const std::string& version = "latest",
const std::string& src = "");

private:
EngineService engine_service_;
Expand Down
4 changes: 1 addition & 3 deletions engine/commands/model_import_cmd.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include "model_import_cmd.h"
#include <filesystem>
#include <iostream>
#include <vector>
#include "config/gguf_parser.h"
#include "config/yaml_config.h"
#include "trantor/utils/Logger.h"
#include "utils/file_manager_utils.h"
#include "utils/logging_utils.h"
#include "utils/modellist_utils.h"
Expand Down Expand Up @@ -45,7 +43,7 @@ void ModelImportCmd::Exec() {
}

} catch (const std::exception& e) {
// don't need to remove yml file here, because it's written only if model entry is successfully added,
// don't need to remove yml file here, because it's written only if model entry is successfully added,
// remove file here can make it fail with edge case when user try to import new model with existed model_id
CLI_LOG("Error importing model path '" + model_path_ + "' with model_id '" +
model_handle_ + "': " + e.what());
Expand Down
Loading
Loading