Browse Source

[MNT] Update database and file operations

tags/v0.3.2
chenzx 3 years ago
parent
commit
1342a06df8
2 changed files with 6 additions and 7 deletions
  1. +1
    -4
      learnware/market/database_ops.py
  2. +5
    -3
      learnware/market/easy.py

+ 1
- 4
learnware/market/database_ops.py View File

@@ -75,10 +75,7 @@ def load_market_from_db(cur):
for item in cursor:
id, semantic_spec, zip_path, folder_path = item
semantic_spec_dict = json.loads(semantic_spec)
config_file_path = os.path.join(folder_path, "learnware.yaml")
new_learnware = get_learnware_from_dirpath(
id=id, semantic_spec=semantic_spec_dict, file_config=config_file_path
)
new_learnware = get_learnware_from_dirpath(id=id, semantic_spec=semantic_spec_dict, file_config=folder_path)
learnware_list[id] = new_learnware
zip_list[id] = zip_path
max_count = max(max_count, int(id))


+ 5
- 3
learnware/market/easy.py View File

@@ -98,7 +98,7 @@ class EasyMarket(BaseMarket):
target_folder_dir = os.path.join(C.learnware_folder_pool_path, id)
copyfile(zip_path, target_zip_dir)
with zipfile.ZipFile(target_zip_dir, "r") as z_file:
z_file.extractall(target_folder_dir)
z_file.extractall(C.learnware_folder_pool_path)
# config_file_dir = os.path.join(target_folder_dir, "learnware.yaml")

new_learnware = get_learnware_from_dirpath(
@@ -114,7 +114,6 @@ class EasyMarket(BaseMarket):
self.count += 1
add_learnware_to_db(
id,
name=learnware_name,
semantic_spec=semantic_spec,
zip_path=target_folder_dir,
folder_path=target_folder_dir,
@@ -388,7 +387,10 @@ class EasyMarket(BaseMarket):
pass

def get_learnware_path_by_ids(self, id: str) -> str:
pass
if not id in self.learnware_zip_list:
raise Exception("Target id not found in market")
else:
return self.learnware_zip_list[id]

def __len__(self):
return len(self.learnware_list.keys())


Loading…
Cancel
Save