Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit a77cd96

Browse files
fix: download recursive (#1838)
* fix: download recursive * fix: handle model not loaded * fix: set permission for all venv folder * format code
1 parent c893b4b commit a77cd96

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

engine/extensions/python-engine/python_engine.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,18 @@ void PythonEngine::HandleInference(
531531
std::string model = (*json_body)["model"].asString();
532532
Json::Value body = (*json_body)["body"];
533533

534+
if (models_.find(model) == models_.end()) {
535+
Json::Value error;
536+
error["error"] = "Model '" + model + "' is not loaded!";
537+
Json::Value status;
538+
status["is_done"] = true;
539+
status["has_error"] = true;
540+
status["is_stream"] = false;
541+
status["status_code"] = k400BadRequest;
542+
callback(std::move(status), std::move(error));
543+
return;
544+
}
545+
534546
// Transform Request
535547
std::string transformed_request;
536548
if (!transform_request.empty()) {
@@ -699,6 +711,18 @@ void PythonEngine::HandleRouteRequest(
699711
std::string model = (*json_body)["model"].asString();
700712
Json::Value body = (*json_body)["body"];
701713

714+
if (models_.find(model) == models_.end()) {
715+
Json::Value error;
716+
error["error"] = "Model '" + model + "' is not loaded!";
717+
Json::Value status;
718+
status["is_done"] = true;
719+
status["has_error"] = true;
720+
status["is_stream"] = false;
721+
status["status_code"] = k400BadRequest;
722+
callback(std::move(status), std::move(error));
723+
return;
724+
}
725+
702726
// Transform Request
703727
std::string transformed_request;
704728
if (!transform_request.empty()) {

engine/services/model_service.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,8 @@ ModelService::DownloadModelFromCortexsoAsync(
582582
pyvenv_cfg.close();
583583
// Add executable permission to python
584584

585-
#ifdef _WIN32
586-
set_permission_utils::SetExecutePermissionsRecursive(
587-
venv_path / std::filesystem::path("Scripts"));
588-
#else
589585
set_permission_utils::SetExecutePermissionsRecursive(
590-
venv_path / std::filesystem::path("bin"));
591-
#endif
586+
venv_path );
592587

593588
} else {
594589
CTL_ERR("Failed to extract venv.zip");

engine/utils/curl_utils.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,12 @@ cpp::result<Json::Value, std::string> SimpleGetJsonRecursive(
271271
if (root.isArray()) {
272272
for (const auto& value : root) {
273273
if (value["type"].asString() == "directory") {
274-
auto temp = SimpleGetJsonRecursive(url + "/" + value["path"].asString(),
275-
timeout);
274+
auto temp = SimpleGetJsonRecursive(
275+
url + "/" +
276+
std::filesystem::path(value["path"].asString())
277+
.filename()
278+
.string(),
279+
timeout);
276280
if (!temp.has_error()) {
277281
if (temp.value().isArray()) {
278282
for (const auto& item : temp.value()) {

0 commit comments

Comments
 (0)