-
Notifications
You must be signed in to change notification settings - Fork 216
Cmake builds libgit2 and --pull_hf_mode for ovms #3105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/server.cpp
Outdated
parser.prepare(&serverSettings, &modelsSettings); | ||
parser.prepare(&serverSettings, &modelsSettings, &hfDownloader); | ||
|
||
if (hfDownloader.pull_hf_model) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be responsibility of ServableModule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should separate the server mode and hf download mode.
third_party/libgt2/libgt2_engine.bzl
Outdated
import fnmatch | ||
import sys | ||
|
||
def remove_japanese_txt(directory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using this in other repo's already. Calling this should be some kind of bazel procedure loaded from *.bzl file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to placed exactly in the repository ctx directory on every build. This script will remove a directory not only files because we cannot filter the files by extension like it was done in the other python script.
…t/model_server into CVS-163308_libgt2
@@ -66,4 +66,10 @@ struct ModelsSettingsImpl { | |||
std::string configPath; | |||
}; | |||
|
|||
struct HFSettingsImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why separate structure instead of nesting this inside server settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure will grow and the settings are not about server functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can nest the new structure in server settings as agreed on sync.
src/hf_pull_model_module.cpp
Outdated
#include "logging.hpp" | ||
#include "server.hpp" | ||
#include "status.hpp" | ||
#include "libgt2/libgt2.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
external dependencies should be before ovms headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"libgt2/libgt2.hpp" is our wrapper implementation.
src/libgt2/libgt2.hpp
Outdated
void setSourceModel(std::string inSourceModel); | ||
void setRepositoryPath(std::string inRepoPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we set repo path once per start as well as source mode. Why do we need setters here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove them now.
src/libgt2/libgt2.hpp
Outdated
int cloneRepository(); | ||
void setSourceModel(std::string inSourceModel); | ||
void setRepositoryPath(std::string inRepoPath); | ||
void setPullHfModelMode(bool isOn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't create HfDownloader anyway if we don't pull so why we change mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option can be used in the future. We can remove setter though.
src/libgt2/libgt2.cpp
Outdated
this->repoUrl = ""; | ||
} | ||
|
||
HfDownloader::HfDownloader(const HfDownloader& hfDownloader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need cpy constructor? If we need default then = default;
should suffice here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore.
bool HfDownloader::CheckIfProxySet() { | ||
const char* envCred = std::getenv("https_proxy"); | ||
if (!envCred) | ||
return false; | ||
return true; | ||
} | ||
|
||
bool HfDownloader::CheckIfTokenSet() { | ||
const char* envCred = std::getenv("HF_TOKEN"); | ||
if (!envCred) | ||
return false; | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those are not methods but utility functions here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly connected and used in the class. Can we keep them as private?
src/libgt2/libgt2.cpp
Outdated
void HfDownloader::SetHfEndpoint() { | ||
const char* envCred = std::getenv("HF_ENDPOINT"); | ||
this->hfEndpoint = "huggingface.co"; | ||
if (envCred) { | ||
this->hfEndpoint = std::string(envCred); | ||
} else { | ||
printf("Info: HF_ENDPOINT environment variable not set.\n"); | ||
} | ||
|
||
if (!endsWith(this->hfEndpoint, "/")) { | ||
this->hfEndpoint.append("/"); | ||
} | ||
} | ||
|
||
void HfDownloader::UpdateRepoUrl() { | ||
this->repoUrl = "https://"; | ||
this->repoUrl += this->hfEndpoint + this->sourceModel; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hfEndpoint is used only to create repo url so this does not need to be a member. We don't need to store it as state after cloning repository. Same is true for repoUrl
src/libgt2/libgt2.cpp
Outdated
return true; | ||
} | ||
|
||
void HfDownloader::GetRepositoryUrlWithPassword(std::string& passRepoUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take endpoint & source model as argument. Return passRepoUrl instead of passing ref.
src/hf_pull_model_module.cpp
Outdated
state = ModuleState::STARTED_INITIALIZE; | ||
SPDLOG_INFO("{} starting", HF_MODEL_PULL_MODULE_NAME); | ||
|
||
this->hfDownloader = std::make_unique<HfDownloader>(config.getHfSettings().sourceModel, config.getHfSettings().repoPath, config.getHfSettings().pullHfModelMode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put HfSettings as a member of server settings.
Why pass all settings separatelly when we can pass them all at once?
Addiditonally I would consider checking for ENV variables here and passing content below for easier (less intertwined testing). You cannot now verify different behavior with different env variables at the level of module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module will have clone methods. This can be tested for env settings.
commit = "338e6fb681369ff0537719095e22ce9dc602dbf0", # Dec 28, 2024 - v1.9.0 | ||
build_file = "@_libgt2_engine//:BUILD", | ||
patch_args = ["-p1"], | ||
patches = ["lfs.patch"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put commend here why this patch is needed
@@ -2712,6 +2715,7 @@ cc_test( | |||
"test/pipelinedefinitionstatus_test.cpp", | |||
"test/predict_validation_test.cpp", | |||
"test/prediction_service_test.cpp", | |||
"test/pull_hf_model_test.cpp", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate test target. check eg openvino_tests/openvino_remote_tensor_tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is standard tests, does not require additional settings nor dependencies.
src/test/test_utils.cpp
Outdated
while ((server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME) != ovms::ModuleState::SHUTDOWN) && | ||
(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now() - start).count() < timeoutSeconds)) { | ||
} | ||
ASSERT_EQ(server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME), ovms::ModuleState::SHUTDOWN) << "OVMS did not download model in allowed time:" << timeoutSeconds << "s. Check machine load"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT_EQ(server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME), ovms::ModuleState::SHUTDOWN) << "OVMS did not download model in allowed time:" << timeoutSeconds << "s. Check machine load"; | |
ASSERT_EQ(server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME), ovms::ModuleState::SHUTDOWN) << "OVMS did not download model in allowed time:" << timeoutSeconds << "s. Check machine & network load"; |
@@ -696,6 +702,30 @@ void EnsureServerStartedWithTimeout(ovms::Server& server, int timeoutSeconds) { | |||
ASSERT_EQ(server.getModuleState(ovms::SERVABLE_MANAGER_MODULE_NAME), ovms::ModuleState::INITIALIZED) << "OVMS did not fully load until allowed time:" << timeoutSeconds << "s. Check machine load"; | |||
} | |||
|
|||
void EnsureServerModelDownloadFinishedWithTimeout(ovms::Server& server, int timeoutSeconds) { | |||
auto start = std::chrono::high_resolution_clock::now(); | |||
while ((server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME) != ovms::ModuleState::SHUTDOWN) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be != AVAILABLE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module shutdowns after clone() is executed.
src/hf_pull_model_module.cpp
Outdated
state = ModuleState::INITIALIZED; | ||
SPDLOG_INFO("{} started", HF_MODEL_PULL_MODULE_NAME); | ||
|
||
status = this->hfDownloader->cloneRepository(); | ||
if (!status.ok()) { | ||
return status; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state = ModuleState::INITIALIZED; | |
SPDLOG_INFO("{} started", HF_MODEL_PULL_MODULE_NAME); | |
status = this->hfDownloader->cloneRepository(); | |
if (!status.ok()) { | |
return status; | |
} | |
SPDLOG_INFO("{} started", HF_MODEL_PULL_MODULE_NAME); | |
status = this->hfDownloader->cloneRepository(); | |
if (!status.ok()) { | |
return status; | |
} | |
state = ModuleState::INITIALIZED; |
?
🛠 Summary
JIRA CVS-163308
Current usage:
bazel-bin/src/ovms --pull_hf_model --source_model OpenVINO/TinyLlama-1.1B-Chat-v1.0-int8-ov --repo_path /download
🧪 Checklist
``