ClickHouse/src/Interpreters/ExternalModelsLoader.cpp

42 lines
1.2 KiB
C++
Raw Normal View History

2019-09-26 11:19:10 +00:00
#include <Interpreters/ExternalModelsLoader.h>
#include <Interpreters/Context.h>
namespace DB
{
namespace ErrorCodes
{
extern const int INVALID_CONFIG_PARAMETER;
}
ExternalModelsLoader::ExternalModelsLoader(ContextPtr context_)
: ExternalLoader("external model", &Poco::Logger::get("ExternalModelsLoader")), WithContext(context_)
2019-09-26 11:19:10 +00:00
{
2020-07-15 19:25:31 +00:00
setConfigSettings({"model", "name", {}, {}});
2019-09-26 11:19:10 +00:00
enablePeriodicUpdates(true);
}
std::shared_ptr<const IExternalLoadable> ExternalModelsLoader::create(
2019-12-11 11:09:21 +00:00
const std::string & name, const Poco::Util::AbstractConfiguration & config,
const std::string & config_prefix, const std::string & /* repository_name */) const
2019-09-26 11:19:10 +00:00
{
String type = config.getString(config_prefix + ".type");
ExternalLoadableLifetime lifetime(config, config_prefix + ".lifetime");
/// TODO: add models factory.
if (type == "catboost")
{
return std::make_unique<CatBoostModel>(
name, config.getString(config_prefix + ".path"),
getContext()->getConfigRef().getString("catboost_dynamic_library_path"),
2019-09-26 11:19:10 +00:00
lifetime
);
}
else
{
throw Exception("Unknown model type: " + type, ErrorCodes::INVALID_CONFIG_PARAMETER);
}
}
}