| @@ -13,6 +13,7 @@ curr_root = os.path.dirname(os.path.abspath(__file__)) | |||||
| def prepare_learnware(learnware_num=10): | def prepare_learnware(learnware_num=10): | ||||
| np.random.seed(2023) | |||||
| for i in range(learnware_num): | for i in range(learnware_num): | ||||
| dir_path = os.path.join(curr_root, "learnware_pool", "svm_%d" % (i)) | dir_path = os.path.join(curr_root, "learnware_pool", "svm_%d" % (i)) | ||||
| os.makedirs(dir_path, exist_ok=True) | os.makedirs(dir_path, exist_ok=True) | ||||
| @@ -171,7 +172,7 @@ def test_stat_search(): | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| learnware_num = 5 | |||||
| learnware_num = 10 | |||||
| # prepare_learnware(learnware_num) | # prepare_learnware(learnware_num) | ||||
| # test_market() | # test_market() | ||||
| @@ -50,4 +50,5 @@ def get_stat_spec_from_config(stat_spec: dict) -> BaseStatSpecification: | |||||
| f"Statistic specification must be type of BaseStatSpecification, not {BaseStatSpecification.__class__.__name__}" | f"Statistic specification must be type of BaseStatSpecification, not {BaseStatSpecification.__class__.__name__}" | ||||
| ) | ) | ||||
| stat_spec_inst.load(stat_spec["file_name"]) | stat_spec_inst.load(stat_spec["file_name"]) | ||||
| return stat_spec["class_name"], stat_spec_inst | return stat_spec["class_name"], stat_spec_inst | ||||
| @@ -1,6 +1,7 @@ | |||||
| import os | import os | ||||
| import json | import json | ||||
| import sqlite3 | import sqlite3 | ||||
| from copy import deepcopy | |||||
| from ..logger import get_module_logger | from ..logger import get_module_logger | ||||
| from ..learnware import get_learnware_from_dirpath | from ..learnware import get_learnware_from_dirpath | ||||
| @@ -79,9 +80,10 @@ def load_market_from_db(cur): | |||||
| new_learnware = get_learnware_from_dirpath( | new_learnware = get_learnware_from_dirpath( | ||||
| id=id, semantic_spec=semantic_spec_dict, learnware_dirpath=folder_path | id=id, semantic_spec=semantic_spec_dict, learnware_dirpath=folder_path | ||||
| ) | ) | ||||
| learnware_list[id] = new_learnware | |||||
| learnware_list[id] = deepcopy(new_learnware) | |||||
| zip_list[id] = zip_path | zip_list[id] = zip_path | ||||
| folder_list = folder_path | |||||
| folder_list[id] = folder_path | |||||
| max_count = max(max_count, int(id)) | max_count = max(max_count, int(id)) | ||||
| LOGGER.info("Market Reloaded from DB.") | LOGGER.info("Market Reloaded from DB.") | ||||
| return learnware_list, zip_list, folder_list, max_count + 1 | return learnware_list, zip_list, folder_list, max_count + 1 | ||||
| @@ -25,7 +25,7 @@ class EasyMarket(BaseMarket): | |||||
| self.learnware_folder_list = {} | self.learnware_folder_list = {} | ||||
| self.count = 0 | self.count = 0 | ||||
| self.semantic_spec_list = C.semantic_specs | self.semantic_spec_list = C.semantic_specs | ||||
| self.reload_market() | |||||
| self.reload_market() | |||||
| logger.info("Market Initialized!") | logger.info("Market Initialized!") | ||||
| def reload_market(self) -> bool: | def reload_market(self) -> bool: | ||||
| @@ -373,7 +373,7 @@ class EasyMarket(BaseMarket): | |||||
| if "RKMEStatSpecification" not in user_info.stat_info: | if "RKMEStatSpecification" not in user_info.stat_info: | ||||
| return None, learnware_list, None | return None, learnware_list, None | ||||
| else: | else: | ||||
| user_rkme = user_info.stat_info["RKMEStatSpecification"] | |||||
| user_rkme = user_info.stat_info["RKMEStatSpecification"] | |||||
| sorted_dist_list, single_learnware_list = self._search_by_rkme_spec_single(learnware_list, user_rkme) | sorted_dist_list, single_learnware_list = self._search_by_rkme_spec_single(learnware_list, user_rkme) | ||||
| weight_list, mixture_learnware_list = self._search_by_rkme_spec_mixture( | weight_list, mixture_learnware_list = self._search_by_rkme_spec_mixture( | ||||
| learnware_list, user_rkme, search_num | learnware_list, user_rkme, search_num | ||||