Skip to content

Commit 0dc248d

Browse files
fix
1 parent 64f4346 commit 0dc248d

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/cli_parser.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,10 @@ void CLIParser::prepareGraph(ServerSettingsImpl& serverSettings, HFSettingsImpl&
470470

471471
if (result->count("overwrite_models"))
472472
hfSettings.overwriteModels = result->operator[]("overwrite_models").as<bool>();
473-
if (result->count("source_model")){
473+
if (result->count("source_model"))
474474
hfSettings.sourceModel = result->operator[]("source_model").as<std::string>();
475-
} else {
476-
throw std::logic_error("source_model parameter is required for pull mode");
477-
}
478-
if (result->count("model_repository_path")){
475+
if (result->count("model_repository_path"))
479476
hfSettings.downloadPath = result->operator[]("model_repository_path").as<std::string>();
480-
} else {
481-
throw std::logic_error("model_repository_path parameter is required for pull mode");
482-
}
483477
if (result->count("task")) {
484478
hfSettings.task = stringToEnum(result->operator[]("task").as<std::string>());
485479
switch (hfSettings.task) {

src/config.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ bool Config::check_hostname_or_ip(const std::string& input) {
8787

8888
bool Config::validate() {
8989
if (this->serverSettings.serverMode == HF_PULL_MODE) {
90+
if (!serverSettings.hfSettings.sourceModel.size()){
91+
std::cerr << "source_model parameter is required for pull mode";
92+
return false;
93+
}
94+
if (!serverSettings.hfSettings.downloadPath.size()){
95+
std::cerr << "model_repository_path parameter is required for pull mode";
96+
return false;
97+
}
9098
if (this->serverSettings.hfSettings.task == UNKNOWN_GRAPH) {
9199
std::cerr << "Error: --task parameter not set." << std::endl;
92100
return false;

src/test/ovmsconfig_test.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,29 +604,31 @@ TEST_F(OvmsConfigDeathTest, modifyModelConfigDisableMissingModelNameWithPath) {
604604
TEST_F(OvmsConfigDeathTest, hfPullNoSourceModel) {
605605
char* n_argv[] = {
606606
"ovms",
607+
"--pull",
607608
"--model_repository_path",
608609
"/some/path",
609610
"--task",
610611
"embeddings",
611612
"--normalize",
612613
"true",
613614
};
614-
int arg_count = 7;
615-
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "port and rest_port cannot both be unset");
615+
int arg_count = 8;
616+
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "source_model parameter is required for pull mode");
616617
}
617618

618-
TEST_F(OvmsConfigDeathTest, hfPullNoSourceModelRepositoryPath) {
619+
TEST_F(OvmsConfigDeathTest, hfPullNoRepositoryPath) {
619620
char* n_argv[] = {
620621
"ovms",
622+
"--pull",
621623
"--source_model",
622624
"some/model",
623625
"--task",
624626
"embeddings",
625627
"--normalize",
626628
"true",
627629
};
628-
int arg_count = 7;
629-
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "port and rest_port cannot both be unset");
630+
int arg_count = 8;
631+
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "model_repository_path parameter is required for pull mode");
630632
}
631633

632634
TEST(OvmsGraphConfigTest, positiveAllChanged) {
@@ -948,7 +950,7 @@ TEST(OvmsGraphConfigTest, negativeSourceModel) {
948950
};
949951

950952
int arg_count = 6;
951-
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "For now only OpenVINO models are supported");
953+
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "or now OVMS version without python supports pulling OpenVINO models only");
952954
}
953955

954956
TEST(OvmsGraphConfigTest, positiveAllChangedRerank) {

0 commit comments

Comments
 (0)