Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
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
8 changes: 1 addition & 7 deletions engine/cli/commands/model_import_cmd.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#include "model_import_cmd.h"
#include <filesystem>
#include <vector>
#include "config/gguf_parser.h"
#include "config/yaml_config.h"
#include "database/models.h"
#include <json/value.h>
#include "httplib.h"
#include "json/json.h"
#include "server_start_cmd.h"
#include "utils/file_manager_utils.h"
#include "utils/logging_utils.h"

namespace commands {
Expand Down
4 changes: 2 additions & 2 deletions engine/common/download_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <json/json.h>
#include <filesystem>
#include <optional>
#include <sstream>
#include <string>
#include <optional>

enum class DownloadType { Model, Engine, Miscellaneous, CudaToolkit, Cortex };

Expand Down Expand Up @@ -161,4 +161,4 @@ inline DownloadTask GetDownloadTaskFromJson(const Json::Value item_json) {
}
return task;
}
} // namespace common
} // namespace common
16 changes: 11 additions & 5 deletions engine/services/download_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,16 @@ void DownloadService::EmitTaskCompleted(const std::string& task_id) {
}

void DownloadService::ExecuteCallback(const DownloadTask& task) {
std::lock_guard<std::mutex> lock(callbacks_mutex_);
auto it = callbacks_.find(task.id);
if (it != callbacks_.end()) {
it->second(task);
callbacks_.erase(it);
std::lock_guard<std::mutex> active_task_lock(active_tasks_mutex_);
if (auto it = active_tasks_.find(task.id); it != active_tasks_.end()) {
for (auto& item : it->second->items) {
item.downloadedBytes = item.bytes;
}
std::lock_guard<std::mutex> lock(callbacks_mutex_);
auto callback = callbacks_.find(task.id);
if (callback != callbacks_.end()) {
callback->second(*it->second);
callbacks_.erase(callback);
}
}
}
6 changes: 6 additions & 0 deletions engine/services/model_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ ModelService::DownloadModelFromCortexsoAsync(
yaml_handler.ModelConfigFromFile(model_yml_item->localPath.string());
auto mc = yaml_handler.GetModelConfig();
mc.model = unique_model_id;

uint64_t model_size = 0;
for (const auto& item : finishedTask.items) {
model_size = model_size + item.bytes.value_or(0);
}
mc.size = model_size;
yaml_handler.UpdateModelConfig(mc);
yaml_handler.WriteYamlFile(model_yml_item->localPath.string());

Expand Down
1 change: 0 additions & 1 deletion engine/services/model_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string>
#include "common/engine_servicei.h"
#include "config/model_config.h"
#include "database/models.h"
#include "services/download_service.h"
#include "services/inference_service.h"

Expand Down
Loading