ClickHouse/src/Interpreters/ExternalModelsLoader.cpp

43 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(Context & context_)
2020-05-30 21:57:37 +00:00
: ExternalLoader("external model", &Poco::Logger::get("ExternalModelsLoader"))
, context(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"),
context.getConfigRef().getString("catboost_dynamic_library_path"),
lifetime
);
}
else
{
throw Exception("Unknown model type: " + type, ErrorCodes::INVALID_CONFIG_PARAMETER);
}
}
}