33#include < tabulate/table.hpp>
44#include < vector>
55#include " config/yaml_config.h"
6+ #include " database/models.h"
67#include " utils/file_manager_utils.h"
78#include " utils/logging_utils.h"
8- #include " utils/modellist_utils.h"
99
1010namespace commands {
1111
1212void ModelListCmd::Exec () {
1313 auto models_path = file_manager_utils::GetModelsContainerPath ();
14- modellist_utils::ModelListUtils modellist_handler;
14+ cortex::db::Models modellist_handler;
1515 config::YamlHandler yaml_handler;
1616 tabulate::Table table;
1717
@@ -20,24 +20,24 @@ void ModelListCmd::Exec() {
2020 int count = 0 ;
2121 // Iterate through directory
2222
23- try {
24- auto list_entry = modellist_handler.LoadModelList ();
25- for (const auto & model_entry : list_entry) {
26- // auto model_entry = modellist_handler.GetModelInfo(model_handle);
27- try {
28- count += 1 ;
29- yaml_handler.ModelConfigFromFile (model_entry.path_to_model_yaml );
30- auto model_config = yaml_handler.GetModelConfig ();
31- table.add_row ({std::to_string (count), model_entry.model_id ,
32- model_entry.model_alias , model_config.engine ,
33- model_config.version });
34- yaml_handler.Reset ();
35- } catch (const std::exception& e) {
36- CTL_ERR (" Fail to get list model information: " + std::string (e.what ()));
37- }
23+ auto list_entry = modellist_handler.LoadModelList ();
24+ if (list_entry.has_error ()) {
25+ CTL_ERR (" Fail to get list model information: " << list_entry.error ());
26+ return ;
27+ }
28+ for (const auto & model_entry : list_entry.value ()) {
29+ // auto model_entry = modellist_handler.GetModelInfo(model_handle);
30+ try {
31+ count += 1 ;
32+ yaml_handler.ModelConfigFromFile (model_entry.path_to_model_yaml );
33+ auto model_config = yaml_handler.GetModelConfig ();
34+ table.add_row ({std::to_string (count), model_entry.model_id ,
35+ model_entry.model_alias , model_config.engine ,
36+ model_config.version });
37+ yaml_handler.Reset ();
38+ } catch (const std::exception& e) {
39+ CTL_ERR (" Fail to get list model information: " + std::string (e.what ()));
3840 }
39- } catch (const std::exception& e) {
40- CTL_ERR (" Fail to get list model information: " + std::string (e.what ()));
4141 }
4242
4343 for (int i = 0 ; i < 5 ; i++) {
0 commit comments