Skip to content

Commit

Permalink
fix: clean up more
Browse files Browse the repository at this point in the history
  • Loading branch information
sangjanai committed Feb 3, 2025
1 parent 2519d1a commit 28af168
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 164 deletions.
18 changes: 9 additions & 9 deletions docs/docs/basic-usage/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,26 @@ curl --request POST \
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q3-km/metadata.yml",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q3-km/metadata.yml",
"downloaded_bytes": 0,
"id": "metadata.yml",
"localPath": "/home/rpg/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q3-km/metadata.yml"
"local_path": "/home/rpg/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q3-km/metadata.yml"
},
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q3-km/model.gguf",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q3-km/model.gguf",
"downloaded_bytes": 0,
"id": "model.gguf",
"localPath": "/home/rpg/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q3-km/model.gguf"
"local_path": "/home/rpg/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q3-km/model.gguf"
},
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q3-km/model.yml",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q3-km/model.yml",
"downloaded_bytes": 0,
"id": "model.yml",
"localPath": "/home/rpg/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q3-km/model.yml"
"local_path": "/home/rpg/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q3-km/model.yml"
}
],
"type": "Model"
Expand Down
60 changes: 30 additions & 30 deletions docs/docs/capabilities/models/sources/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,26 @@ Unlike the CLI, where users can observe the download progress directly in the te
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/metadata.yml",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/metadata.yml",
"downloaded_bytes": 0,
"id": "metadata.yml",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/metadata.yml"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/metadata.yml"
},
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.gguf",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.gguf",
"downloaded_bytes": 0,
"id": "model.gguf",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.gguf"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.gguf"
},
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.yml",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.yml",
"downloaded_bytes": 0,
"id": "model.yml",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.yml"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.yml"
}
],
"type": "Model"
Expand All @@ -154,9 +154,9 @@ Unlike the CLI, where users can observe the download progress directly in the te
- A `DownloadTask` will have a list of `DownloadItem`s. Each `DownloadItem` will have the following properties:
- `id`: the id of the download item.
- `bytes`: the total size of the download item.
- `downloadedBytes`: the number of bytes that have been downloaded so far.
- `downloaded_bytes`: the number of bytes that have been downloaded so far.
- `checksum`: the checksum of the download item.
- Client can use the `downloadedBytes` and `bytes` properties to calculate the download progress.
- Client can use the `downloaded_bytes` and `bytes` properties to calculate the download progress.

```json
{
Expand All @@ -166,26 +166,26 @@ Unlike the CLI, where users can observe the download progress directly in the te
{
"bytes": 58,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/metadata.yml",
"downloadedBytes": 58,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/metadata.yml",
"downloaded_bytes": 58,
"id": "metadata.yml",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/metadata.yml"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/metadata.yml"
},
{
"bytes": 432131456,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.gguf",
"downloadedBytes": 235619714,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.gguf",
"downloaded_bytes": 235619714,
"id": "model.gguf",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.gguf"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.gguf"
},
{
"bytes": 562,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.yml",
"downloadedBytes": 562,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.yml",
"downloaded_bytes": 562,
"id": "model.yml",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.yml"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.yml"
}
],
"type": "Model"
Expand All @@ -196,7 +196,7 @@ Unlike the CLI, where users can observe the download progress directly in the te

#### Download success event

The DownloadSuccess event indicates that all items in the download task have been successfully downloaded. This event provides details about the download task and its items, including their IDs, download URLs, local paths, and other properties. In this event, the bytes and downloadedBytes properties for each item are set to 0, signifying that the download is complete and no further bytes are pending.
The DownloadSuccess event indicates that all items in the download task have been successfully downloaded. This event provides details about the download task and its items, including their IDs, download URLs, local paths, and other properties. In this event, the bytes and downloaded_bytes properties for each item are set to 0, signifying that the download is complete and no further bytes are pending.

```json
{
Expand All @@ -206,26 +206,26 @@ The DownloadSuccess event indicates that all items in the download task have bee
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/metadata.yml",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/metadata.yml",
"downloaded_bytes": 0,
"id": "metadata.yml",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/metadata.yml"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/metadata.yml"
},
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.gguf",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.gguf",
"downloaded_bytes": 0,
"id": "model.gguf",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.gguf"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.gguf"
},
{
"bytes": 0,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.yml",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/cortexso/tinyllama/resolve/1b-gguf-q2-k/model.yml",
"downloaded_bytes": 0,
"id": "model.yml",
"localPath": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.yml"
"local_path": "/Users/user_name/cortexcpp/models/cortex.so/tinyllama/1b-gguf-q2-k/model.yml"
}
],
"type": "Model"
Expand Down
12 changes: 6 additions & 6 deletions docs/static/openapi/cortex.json
Original file line number Diff line number Diff line change
Expand Up @@ -814,16 +814,16 @@
"checksum": {
"type": "string"
},
"downloadUrl": {
"download_url": {
"type": "string"
},
"downloadedBytes": {
"downloaded_bytes": {
"type": "integer"
},
"id": {
"type": "string"
},
"localPath": {
"local_path": {
"type": "string"
}
}
Expand All @@ -844,10 +844,10 @@
{
"bytes": 3822024352,
"checksum": "N/A",
"downloadUrl": "https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q3_K_L.gguf",
"downloadedBytes": 0,
"download_url": "https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q3_K_L.gguf",
"downloaded_bytes": 0,
"id": "TheBloke:Mistral-7B-Instruct-v0.1-GGUF:mistral-7b-instruct-v0.1.Q3_K_L.gguf",
"localPath": "/Users/user_name/cortexcpp/models/huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/mistral-7b-instruct-v0.1.Q3_K_L.gguf"
"local_path": "/Users/user_name/cortexcpp/models/huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/mistral-7b-instruct-v0.1.Q3_K_L.gguf"
}
],
"type": "Model"
Expand Down
36 changes: 18 additions & 18 deletions engine/cli/commands/cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,16 @@ std::optional<std::string> CortexUpdCmd::HandleGithubRelease(
.type = DownloadType::Cortex,
.items = {DownloadItem{
.id = "cortex",
.downloadUrl = download_url,
.localPath = local_path,
.download_url = download_url,
.local_path = local_path,
}},
}};

auto result = download_service_->AddDownloadTask(
download_task, [](const DownloadTask& finishedTask) {
// try to unzip the downloaded file
CTL_INF("Downloaded engine path: "
<< finishedTask.items[0].localPath.string());
<< finishedTask.items[0].local_path.string());

CTL_INF("Finished!");
});
Expand Down Expand Up @@ -463,11 +463,11 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {

CTL_INF("Cortex release path: " << url_parser::FromUrl(url_obj));

std::filesystem::path localPath =
std::filesystem::path local_path =
std::filesystem::temp_directory_path() / "cortex" / path_list.back();
try {
if (!std::filesystem::exists(localPath.parent_path())) {
std::filesystem::create_directories(localPath.parent_path());
if (!std::filesystem::exists(local_path.parent_path())) {
std::filesystem::create_directories(local_path.parent_path());
}
} catch (const std::filesystem::filesystem_error& e) {
CLI_LOG_ERROR("Failed to create directories: " << e.what());
Expand All @@ -478,15 +478,15 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
.type = DownloadType::Cortex,
.items = {DownloadItem{
.id = "cortex",
.downloadUrl = url_parser::FromUrl(url_obj),
.localPath = localPath,
.download_url = url_parser::FromUrl(url_obj),
.local_path = local_path,
}}};

auto result = download_service_->AddDownloadTask(
download_task, [](const DownloadTask& finishedTask) {
// try to unzip the downloaded file
CTL_INF("Downloaded cortex path: "
<< finishedTask.items[0].localPath.string());
<< finishedTask.items[0].local_path.string());

CTL_INF("Finished!");
});
Expand All @@ -507,7 +507,7 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
}
});

return InstallNewVersion(dst, localPath.string(), "", "");
return InstallNewVersion(dst, local_path.string(), "", "");
#endif
}

Expand All @@ -529,11 +529,11 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,

CTL_INF("Linux installer script path: " << url_parser::FromUrl(url_obj));

std::filesystem::path localPath =
std::filesystem::path local_path =
std::filesystem::temp_directory_path() / "cortex" / path_list.back();
try {
if (!std::filesystem::exists(localPath.parent_path())) {
std::filesystem::create_directories(localPath.parent_path());
if (!std::filesystem::exists(local_path.parent_path())) {
std::filesystem::create_directories(local_path.parent_path());
}
} catch (const std::filesystem::filesystem_error& e) {
CLI_LOG_ERROR("Failed to create directories: " << e.what());
Expand All @@ -544,15 +544,15 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
.type = DownloadType::Cortex,
.items = {DownloadItem{
.id = "cortex",
.downloadUrl = url_parser::FromUrl(url_obj),
.localPath = localPath,
.download_url = url_parser::FromUrl(url_obj),
.local_path = local_path,
}}};

auto result = download_service_->AddDownloadTask(
download_task, [](const DownloadTask& finishedTask) {
// try to unzip the downloaded file
CTL_INF("Downloaded cortex path: "
<< finishedTask.items[0].localPath.string());
<< finishedTask.items[0].local_path.string());

CTL_INF("Finished!");
});
Expand All @@ -573,7 +573,7 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
}
});
try {
std::filesystem::permissions(localPath,
std::filesystem::permissions(local_path,
std::filesystem::perms::owner_exec |
std::filesystem::perms::group_exec |
std::filesystem::perms::others_exec,
Expand All @@ -583,6 +583,6 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
return false;
}

return InstallNewVersion(dst, localPath.string(), channel, v);
return InstallNewVersion(dst, local_path.string(), channel, v);
}
} // namespace commands
10 changes: 5 additions & 5 deletions engine/cli/commands/model_pull_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ std::optional<std::string> ModelPullCmd::Exec(const std::string& host, int port,
}

auto id = res.value()["id"].asString();
bool is_cortexso = res.value()["modelSource"].asString() == "cortexso";
auto default_branch = res.value()["defaultBranch"].asString();
bool is_cortexso = res.value()["model_source"].asString() == "cortexso";
auto default_branch = res.value()["default_branch"].asString();
std::vector<std::string> downloaded;
for (auto const& v : res.value()["downloadedModels"]) {
for (auto const& v : res.value()["downloaded_models"]) {
downloaded.push_back(v.asString());
}
std::vector<std::string> avails;
for (auto const& v : res.value()["availableModels"]) {
for (auto const& v : res.value()["available_models"]) {
avails.push_back(v.asString());
}
auto download_url = res.value()["downloadUrl"].asString();
auto download_url = res.value()["download_url"].asString();

if (downloaded.empty() && avails.empty()) {
model_id = id;
Expand Down
2 changes: 1 addition & 1 deletion engine/cli/utils/download_progress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool DownloadProgress::Handle(
for (int i = 0; i < ev.download_task_.items.size(); i++) {
auto& it = ev.download_task_.items[i];
if (ev.type_ == DownloadStatus::DownloadUpdated) {
uint64_t downloaded = it.downloadedBytes.value_or(0u);
uint64_t downloaded = it.downloaded_bytes.value_or(0u);
uint64_t total =
it.bytes.value_or(std::numeric_limits<uint64_t>::max());
auto d = std::chrono::duration_cast<std::chrono::seconds>(now - start)
Expand Down
Loading

0 comments on commit 28af168

Please sign in to comment.