Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7ad487

Browse files
author
Gabrielle Ong
authored
Merge branch 'dev' into chore/update-star-history
2 parents 89291b6 + e290759 commit e7ad487

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ COPY ./docs/static/openapi/cortex.json /app/docs/static/openapi/cortex.json
5656
RUN cd engine && make configure-vcpkg && make build CMAKE_EXTRA_FLAGS="-DCORTEX_CPP_VERSION=${CORTEX_CPP_VERSION} -DCMAKE_BUILD_TEST=OFF -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ${CMAKE_EXTRA_FLAGS}"
5757

5858
# Stage 3: Runtime
59-
59+
FROM common as runtime
6060
WORKDIR /app
6161
COPY --from=build /app/engine/build/cortex /usr/local/bin/cortex
6262
COPY --from=build /app/engine/build/cortex-server /usr/local/bin/cortex-server

engine/cli/commands/model_import_cmd.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#include "model_import_cmd.h"
2-
#include <filesystem>
3-
#include <vector>
4-
#include "config/gguf_parser.h"
5-
#include "config/yaml_config.h"
6-
#include "database/models.h"
2+
#include <json/value.h>
73
#include "httplib.h"
8-
#include "json/json.h"
94
#include "server_start_cmd.h"
10-
#include "utils/file_manager_utils.h"
115
#include "utils/logging_utils.h"
126

137
namespace commands {

engine/common/download_task.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include <json/json.h>
44
#include <filesystem>
5+
#include <optional>
56
#include <sstream>
67
#include <string>
7-
#include <optional>
88

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

@@ -161,4 +161,4 @@ inline DownloadTask GetDownloadTaskFromJson(const Json::Value item_json) {
161161
}
162162
return task;
163163
}
164-
} // namespace common
164+
} // namespace common

engine/services/download_service.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,16 @@ void DownloadService::EmitTaskCompleted(const std::string& task_id) {
544544
}
545545

546546
void DownloadService::ExecuteCallback(const DownloadTask& task) {
547-
std::lock_guard<std::mutex> lock(callbacks_mutex_);
548-
auto it = callbacks_.find(task.id);
549-
if (it != callbacks_.end()) {
550-
it->second(task);
551-
callbacks_.erase(it);
547+
std::lock_guard<std::mutex> active_task_lock(active_tasks_mutex_);
548+
if (auto it = active_tasks_.find(task.id); it != active_tasks_.end()) {
549+
for (auto& item : it->second->items) {
550+
item.downloadedBytes = item.bytes;
551+
}
552+
std::lock_guard<std::mutex> lock(callbacks_mutex_);
553+
auto callback = callbacks_.find(task.id);
554+
if (callback != callbacks_.end()) {
555+
callback->second(*it->second);
556+
callbacks_.erase(callback);
557+
}
552558
}
553559
}

engine/services/model_service.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,12 @@ ModelService::DownloadModelFromCortexsoAsync(
463463
yaml_handler.ModelConfigFromFile(model_yml_item->localPath.string());
464464
auto mc = yaml_handler.GetModelConfig();
465465
mc.model = unique_model_id;
466+
467+
uint64_t model_size = 0;
468+
for (const auto& item : finishedTask.items) {
469+
model_size = model_size + item.bytes.value_or(0);
470+
}
471+
mc.size = model_size;
466472
yaml_handler.UpdateModelConfig(mc);
467473
yaml_handler.WriteYamlFile(model_yml_item->localPath.string());
468474

engine/services/model_service.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <string>
66
#include "common/engine_servicei.h"
77
#include "config/model_config.h"
8-
#include "database/models.h"
98
#include "services/download_service.h"
109
#include "services/inference_service.h"
1110

0 commit comments

Comments
 (0)