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
24 changes: 24 additions & 0 deletions engine/extensions/python-engine/python_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,18 @@ void PythonEngine::HandleInference(
std::string model = (*json_body)["model"].asString();
Json::Value body = (*json_body)["body"];

if (models_.find(model) == models_.end()) {
Json::Value error;
error["error"] = "Model '" + model + "' is not loaded!";
Json::Value status;
status["is_done"] = true;
status["has_error"] = true;
status["is_stream"] = false;
status["status_code"] = k400BadRequest;
callback(std::move(status), std::move(error));
return;
}

// Transform Request
std::string transformed_request;
if (!transform_request.empty()) {
Expand Down Expand Up @@ -699,6 +711,18 @@ void PythonEngine::HandleRouteRequest(
std::string model = (*json_body)["model"].asString();
Json::Value body = (*json_body)["body"];

if (models_.find(model) == models_.end()) {
Json::Value error;
error["error"] = "Model '" + model + "' is not loaded!";
Json::Value status;
status["is_done"] = true;
status["has_error"] = true;
status["is_stream"] = false;
status["status_code"] = k400BadRequest;
callback(std::move(status), std::move(error));
return;
}

// Transform Request
std::string transformed_request;
if (!transform_request.empty()) {
Expand Down
7 changes: 1 addition & 6 deletions engine/services/model_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,8 @@ ModelService::DownloadModelFromCortexsoAsync(
pyvenv_cfg.close();
// Add executable permission to python

#ifdef _WIN32
set_permission_utils::SetExecutePermissionsRecursive(
venv_path / std::filesystem::path("Scripts"));
#else
set_permission_utils::SetExecutePermissionsRecursive(
venv_path / std::filesystem::path("bin"));
#endif
venv_path );

} else {
CTL_ERR("Failed to extract venv.zip");
Expand Down
8 changes: 6 additions & 2 deletions engine/utils/curl_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ cpp::result<Json::Value, std::string> SimpleGetJsonRecursive(
if (root.isArray()) {
for (const auto& value : root) {
if (value["type"].asString() == "directory") {
auto temp = SimpleGetJsonRecursive(url + "/" + value["path"].asString(),
timeout);
auto temp = SimpleGetJsonRecursive(
url + "/" +
std::filesystem::path(value["path"].asString())
.filename()
.string(),
timeout);
if (!temp.has_error()) {
if (temp.value().isArray()) {
for (const auto& item : temp.value()) {
Expand Down