|
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations |
|
|
|
import traceback |
|
|
|
import zipfile |
|
|
|
import tempfile |
|
|
|
from typing import Tuple, Any, List, Union, Dict, Optional |
|
|
|
from typing import Tuple, Any, List, Union, Optional |
|
|
|
from dataclasses import dataclass |
|
|
|
from ..learnware import Learnware, get_learnware_from_dirpath |
|
|
|
from ..logger import get_module_logger |
|
|
|
@@ -45,7 +45,7 @@ class BaseUserInfo: |
|
|
|
|
|
|
|
def update_semantic_spec(self, semantic_spec: dict): |
|
|
|
self.semantic_spec = semantic_spec |
|
|
|
|
|
|
|
|
|
|
|
def update_stat_info(self, name: str, item: Any): |
|
|
|
"""Update stat_info by market |
|
|
|
|
|
|
|
@@ -64,28 +64,35 @@ class SingleSearchItem: |
|
|
|
learnware: Learnware |
|
|
|
score: Optional[float] = None |
|
|
|
|
|
|
|
|
|
|
|
@dataclass |
|
|
|
class MultipleSearchItem: |
|
|
|
learnwares: List[Learnware] |
|
|
|
score: float |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SearchResults: |
|
|
|
def __init__(self, single_results: Optional[List[SingleSearchItem]] = None, multiple_results: Optional[List[MultipleSearchItem]] = None): |
|
|
|
def __init__( |
|
|
|
self, |
|
|
|
single_results: Optional[List[SingleSearchItem]] = None, |
|
|
|
multiple_results: Optional[List[MultipleSearchItem]] = None, |
|
|
|
): |
|
|
|
self.update_single_results([] if single_results is None else single_results) |
|
|
|
self.update_multiple_results([] if multiple_results is None else multiple_results) |
|
|
|
|
|
|
|
|
|
|
|
def get_single_results(self) -> List[SingleSearchItem]: |
|
|
|
return self.single_results |
|
|
|
|
|
|
|
|
|
|
|
def get_multiple_results(self) -> List[MultipleSearchItem]: |
|
|
|
return self.multiple_results |
|
|
|
|
|
|
|
|
|
|
|
def update_single_results(self, single_results: List[SingleSearchItem]): |
|
|
|
self.single_results = single_results |
|
|
|
|
|
|
|
|
|
|
|
def update_multiple_results(self, multiple_results: List[MultipleSearchItem]): |
|
|
|
self.multiple_results = multiple_results |
|
|
|
|
|
|
|
|
|
|
|
class LearnwareMarket: |
|
|
|
"""Base interface for market, it provide the interface of search/add/detele/update learnwares""" |
|
|
|
|
|
|
|
@@ -179,9 +186,7 @@ class LearnwareMarket: |
|
|
|
zip_path=zip_path, semantic_spec=semantic_spec, check_status=check_status, **kwargs |
|
|
|
) |
|
|
|
|
|
|
|
def search_learnware( |
|
|
|
self, user_info: BaseUserInfo, check_status: int = None, **kwargs |
|
|
|
) -> SearchResults: |
|
|
|
def search_learnware(self, user_info: BaseUserInfo, check_status: int = None, **kwargs) -> SearchResults: |
|
|
|
"""Search learnwares based on user_info from learnwares with check_status |
|
|
|
|
|
|
|
Parameters |
|
|
|
|