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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
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"),
|
2021-04-10 23:33:54 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|