@@ -1140,71 +1140,6 @@ bool EngineService::IsRemoteEngine(const std::string& engine_name) {
11401140 return true ;
11411141}
11421142
1143- cpp::result<bool , std::string> EngineService::GenerateRemoteModel (
1144- const std::string& engine_name) {
1145- namespace fmu = file_manager_utils;
1146- namespace fs = std::filesystem;
1147- auto exist_engine = GetEngineByNameAndVariant (engine_name);
1148- if (exist_engine.has_error ()) {
1149- return cpp::fail (" Remote engine '" + engine_name + " ' is not installed" );
1150- }
1151-
1152- if (!IsEngineLoaded (engine_name)) {
1153- engines_[engine_name].engine = new remote_engine::RemoteEngine (engine_name);
1154- CTL_INF (" Loaded engine: " << engine_name);
1155- }
1156-
1157- auto remote_engine_json = exist_engine.value ().ToJson ();
1158- auto & e = std::get<RemoteEngineI*>(engines_[engine_name].engine );
1159- auto url = remote_engine_json[" metadata" ][" get_models_url" ].asString ();
1160- auto api_key = remote_engine_json[" api_key" ].asString ();
1161- auto api_key_template =
1162- remote_engine_json[" metadata" ][" api_key_template" ].asString ();
1163- auto res = e->GetRemoteModels (url, api_key, api_key_template);
1164- if (!res[" error" ].isNull ()) {
1165- return cpp::fail (res[" error" ].asString ());
1166- } else {
1167- for (auto & d : res[" data" ]) {
1168- auto model_handle = d[" id" ].asString ();
1169- config::RemoteModelConfig model_config;
1170- Json::Value body =
1171- json_helper::ParseJsonString (config::kDefaultRemoteModelConfig );
1172- body[" model" ] = model_handle;
1173- body[" engine" ] = engine_name;
1174- // CTL_INF(body.toStyledString());
1175- model_config.LoadFromJson (body);
1176- cortex::db::Models modellist_utils_obj;
1177-
1178- std::string model_yaml_path =
1179- (file_manager_utils::GetModelsContainerPath () /
1180- std::filesystem::path (" remote" ) /
1181- std::filesystem::path (model_handle + " .yml" ))
1182- .string ();
1183- try {
1184- auto yaml_rel_path =
1185- fmu::ToRelativeCortexDataPath (fs::path (model_yaml_path));
1186- cortex::db::ModelEntry model_entry{
1187- model_handle, " " , " " , yaml_rel_path.string (),
1188- model_handle, " remote" , " imported" , cortex::db::ModelStatus::Remote,
1189- engine_name};
1190- std::filesystem::create_directories (
1191- std::filesystem::path (model_yaml_path).parent_path ());
1192- if (modellist_utils_obj.AddModelEntry (model_entry).value ()) {
1193- model_config.SaveToYamlFile (model_yaml_path);
1194- } else {
1195- CTL_INF (" Fail to import model, model_id '" + model_handle +
1196- " ' already exists!" );
1197- }
1198- } catch (const std::exception& e) {
1199- return cpp::fail (" Error while adding Remote model with model_id '" +
1200- model_handle + " ': " + e.what ());
1201- }
1202- }
1203- }
1204-
1205- return true ;
1206- }
1207-
12081143cpp::result<std::vector<std::string>, std::string>
12091144EngineService::GetSupportedEngineNames () {
12101145 return file_manager_utils::GetCortexConfig ().supportedEngines ;
0 commit comments