@@ -27,8 +27,8 @@ void ParseGguf(const DownloadItem& ggufDownloadItem,
2727 model_config.id =
2828 ggufDownloadItem.localPath .parent_path ().filename ().string ();
2929 // use relative path for files
30- auto file_rel_path = fmu::Subtract ( fs::path (ggufDownloadItem. localPath ),
31- fmu::GetCortexDataPath ( ));
30+ auto file_rel_path =
31+ fmu::ToRelativeCortexDataPath ( fs::path (ggufDownloadItem. localPath ));
3232 model_config.files = {file_rel_path.string ()};
3333 model_config.model = ggufDownloadItem.id ;
3434 yaml_handler.UpdateModelConfig (model_config);
@@ -44,8 +44,7 @@ void ParseGguf(const DownloadItem& ggufDownloadItem,
4444 auto branch = url_obj.pathParams [3 ];
4545 CTL_INF (" Adding model to modellist with branch: " << branch);
4646
47- auto rel = file_manager_utils::Subtract (
48- yaml_name, file_manager_utils::GetCortexDataPath ());
47+ auto rel = file_manager_utils::ToRelativeCortexDataPath (yaml_name);
4948 CTL_INF (" path_to_model_yaml: " << rel.string ());
5049
5150 auto author_id = author.has_value () ? author.value () : " cortexso" ;
@@ -304,8 +303,8 @@ cpp::result<std::string, std::string> ModelService::DownloadModelFromCortexso(
304303 yaml_handler.UpdateModelConfig (mc);
305304 yaml_handler.WriteYamlFile (model_yml_item->localPath .string ());
306305
307- auto rel = file_manager_utils::Subtract (
308- model_yml_item-> localPath , file_manager_utils::GetCortexDataPath () );
306+ auto rel =
307+ file_manager_utils::ToRelativeCortexDataPath (model_yml_item-> localPath );
309308 CTL_INF (" path_to_model_yaml: " << rel.string ());
310309
311310 cortex::db::Models modellist_utils_obj;
@@ -376,9 +375,8 @@ cpp::result<void, std::string> ModelService::DeleteModel(
376375 CTL_WRN (" Error: " + model_entry.error ());
377376 return cpp::fail (model_entry.error ());
378377 }
379- auto yaml_fp =
380- fmu::GetAbsolutePath (fmu::GetCortexDataPath (),
381- fs::path (model_entry.value ().path_to_model_yaml ));
378+ auto yaml_fp = fmu::ToAbsoluteCortexDataPath (
379+ fs::path (model_entry.value ().path_to_model_yaml ));
382380 yaml_handler.ModelConfigFromFile (yaml_fp.string ());
383381 auto mc = yaml_handler.GetModelConfig ();
384382 // Remove yaml file
@@ -389,12 +387,12 @@ cpp::result<void, std::string> ModelService::DeleteModel(
389387 if (mc.engine == " cortex.llamacpp" ) {
390388 for (auto & file : mc.files ) {
391389 std::filesystem::path gguf_p (
392- fmu::GetAbsolutePath ( fmu::GetCortexDataPath (), fs::path (file)));
390+ fmu::ToAbsoluteCortexDataPath ( fs::path (file)));
393391 std::filesystem::remove (gguf_p);
394392 }
395393 } else {
396- std::filesystem::path f (fmu::GetAbsolutePath ( fmu::GetCortexDataPath (),
397- fs::path (mc.files [0 ])));
394+ std::filesystem::path f (
395+ fmu::ToAbsoluteCortexDataPath ( fs::path (mc.files [0 ])));
398396 std::filesystem::remove_all (f);
399397 }
400398 } else {
@@ -428,8 +426,8 @@ cpp::result<bool, std::string> ModelService::StartModel(
428426 return cpp::fail (model_entry.error ());
429427 }
430428 yaml_handler.ModelConfigFromFile (
431- fmu::GetAbsolutePath ( fmu::GetCortexDataPath (),
432- fs::path (model_entry.value ().path_to_model_yaml ))
429+ fmu::ToAbsoluteCortexDataPath (
430+ fs::path (model_entry.value ().path_to_model_yaml ))
433431 .string ());
434432 auto mc = yaml_handler.GetModelConfig ();
435433
@@ -439,8 +437,7 @@ cpp::result<bool, std::string> ModelService::StartModel(
439437 if (mc.files .size () > 0 ) {
440438 // TODO(sang) support multiple files
441439 json_data[" model_path" ] =
442- fmu::GetAbsolutePath (fmu::GetCortexDataPath (), fs::path (mc.files [0 ]))
443- .string ();
440+ fmu::ToAbsoluteCortexDataPath (fs::path (mc.files [0 ])).string ();
444441 } else {
445442 LOG_WARN << " model_path is empty" ;
446443 return false ;
@@ -489,8 +486,8 @@ cpp::result<bool, std::string> ModelService::StopModel(
489486 return cpp::fail (model_entry.error ());
490487 }
491488 yaml_handler.ModelConfigFromFile (
492- fmu::GetAbsolutePath ( fmu::GetCortexDataPath (),
493- fs::path (model_entry.value ().path_to_model_yaml ))
489+ fmu::ToAbsoluteCortexDataPath (
490+ fs::path (model_entry.value ().path_to_model_yaml ))
494491 .string ());
495492 auto mc = yaml_handler.GetModelConfig ();
496493
@@ -538,8 +535,8 @@ cpp::result<bool, std::string> ModelService::GetModelStatus(
538535 return cpp::fail (model_entry.error ());
539536 }
540537 yaml_handler.ModelConfigFromFile (
541- fmu::GetAbsolutePath ( fmu::GetCortexDataPath (),
542- fs::path (model_entry.value ().path_to_model_yaml ))
538+ fmu::ToAbsoluteCortexDataPath (
539+ fs::path (model_entry.value ().path_to_model_yaml ))
543540 .string ());
544541 auto mc = yaml_handler.GetModelConfig ();
545542
0 commit comments