Skip to content

Commit 79b6523

Browse files
committed
Improve error messaging
1 parent 6157533 commit 79b6523

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/graph_export/graph_export.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ std::string GraphExport::getDraftModelDirectoryPath(const std::string& directory
8484
}
8585

8686
static Status createTextGenerationGraphTemplate(const std::string& directoryPath, const HFSettingsImpl& hfSettings) {
87-
if (!std::holds_alternative<TextGenGraphSettingsImpl>(hfSettings.graphSettings)) { // FIXME do for all
87+
if (!std::holds_alternative<TextGenGraphSettingsImpl>(hfSettings.graphSettings)) {
8888
return StatusCode::INTERNAL_ERROR;
8989
}
9090
auto& graphSettings = std::get<TextGenGraphSettingsImpl>(hfSettings.graphSettings);
@@ -96,7 +96,9 @@ static Status createTextGenerationGraphTemplate(const std::string& directoryPath
9696
SPDLOG_TRACE("modelsPath: {}, directoryPath: {}, ggufFilename: {}", modelsPath, directoryPath, ggufFilename.value_or("std::nullopt"));
9797
auto pluginConfigOrStatus = GraphExport::createPluginString(graphSettings.pluginConfig, exportSettings);
9898
if (std::holds_alternative<Status>(pluginConfigOrStatus)) {
99-
return std::get<Status>(pluginConfigOrStatus);
99+
auto status = std::get<Status>(pluginConfigOrStatus);
100+
SPDLOG_ERROR("Failed to create plugin config: {}", status.string());
101+
return status;
100102
}
101103
// clang-format off
102104
oss << R"(
@@ -379,12 +381,7 @@ Status GraphExport::createServableConfig(const std::string& directoryPath, const
379381
}
380382
}
381383
if (hfSettings.task == TEXT_GENERATION_GRAPH) {
382-
if (std::holds_alternative<TextGenGraphSettingsImpl>(hfSettings.graphSettings)) { // FIXME do for all
383-
return createTextGenerationGraphTemplate(directoryPath, hfSettings);
384-
} else {
385-
SPDLOG_ERROR("Graph options not initialized for text generation.");
386-
return StatusCode::INTERNAL_ERROR;
387-
}
384+
return createTextGenerationGraphTemplate(directoryPath, hfSettings);
388385
} else if (hfSettings.task == EMBEDDINGS_GRAPH) {
389386
if (std::holds_alternative<EmbeddingsGraphSettingsImpl>(hfSettings.graphSettings)) {
390387
return createEmbeddingsGraphTemplate(directoryPath, std::get<EmbeddingsGraphSettingsImpl>(hfSettings.graphSettings));
@@ -429,7 +426,7 @@ std::variant<std::string, Status> GraphExport::createPluginString(const PluginCo
429426
name.SetString(pluginConfig.kvCachePrecision.value().c_str(), d.GetAllocator());
430427
auto itr = d.FindMember("KV_CACHE_PRECISION");
431428
if (itr != d.MemberEnd()) {
432-
return StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS;
429+
return Status(StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS, "Doubled KV_CACHE_PRECISION parameter in plugin config.");
433430
}
434431
d.AddMember("KV_CACHE_PRECISION", name, d.GetAllocator());
435432
configNotEmpty = true;
@@ -440,7 +437,7 @@ std::variant<std::string, Status> GraphExport::createPluginString(const PluginCo
440437
value.SetUint(pluginConfig.maxPromptLength.value());
441438
auto itr = d.FindMember("MAX_PROMPT_LEN");
442439
if (itr != d.MemberEnd()) {
443-
return StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS;
440+
return Status(StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS, "Doubled MAX_PROMPT_LEN parameter in plugin config.");
444441
}
445442
d.AddMember("MAX_PROMPT_LEN", value, d.GetAllocator());
446443
configNotEmpty = true;
@@ -451,7 +448,7 @@ std::variant<std::string, Status> GraphExport::createPluginString(const PluginCo
451448
value.SetString(pluginConfig.modelDistributionPolicy.value().c_str(), d.GetAllocator());
452449
auto itr = d.FindMember("MODEL_DISTRIBUTION_POLICY");
453450
if (itr != d.MemberEnd()) {
454-
return StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS;
451+
return Status(StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS, "Doubled MODEL_DISTRIBUTION_POLICY parameter in plugin config.");
455452
}
456453
d.AddMember("MODEL_DISTRIBUTION_POLICY", value, d.GetAllocator());
457454
configNotEmpty = true;
@@ -461,7 +458,7 @@ std::variant<std::string, Status> GraphExport::createPluginString(const PluginCo
461458
value.SetString(exportSettings.cacheDir.value().c_str(), d.GetAllocator());
462459
auto itr = d.FindMember("CACHE_DIR");
463460
if (itr != d.MemberEnd()) {
464-
return StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS;
461+
return Status(StatusCode::PLUGIN_CONFIG_CONFLICTING_PARAMETERS, "Doubled CACHE_DIR parameter in plugin config.");
465462
}
466463
d.AddMember("CACHE_DIR", value, d.GetAllocator());
467464
configNotEmpty = true;

0 commit comments

Comments
 (0)