From 86396300db7bb4d7898a6018c196d8fe9f6de4df Mon Sep 17 00:00:00 2001 From: bxdd Date: Tue, 21 Nov 2023 22:57:48 +0800 Subject: [PATCH 1/3] [FIX] fix system recognize error, udpate setup --- learnware/config.py | 11 +++++------ setup.py | 22 +--------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/learnware/config.py b/learnware/config.py index 094dc2c..02f3bcb 100644 --- a/learnware/config.py +++ b/learnware/config.py @@ -55,13 +55,12 @@ class SystemType(Enum): def get_platform(): import platform - - sys_platform = platform.platform().lower() - if "windows" in sys_platform: - return SystemType.WINDOWS - elif "macos" in sys_platform: + os_name = platform.system().lower() + if "macos" in os_name or "darwin" in os_name: return SystemType.MACOS - elif "linux" in sys_platform: + elif "windows" in os_name: + return SystemType.WINDOWS + elif "linux" in os_name: return SystemType.LINUX raise SystemError("Learnware only support MACOS/Linux/Windows") diff --git a/setup.py b/setup.py index 1992bdc..ebf8e99 100644 --- a/setup.py +++ b/setup.py @@ -29,23 +29,6 @@ VERSION = get_version("learnware/__init__.py") if os.path.exists("MANIFEST"): os.remove("MANIFEST") -class SystemType(Enum): - LINUX = 0 - MACOS = 1 - WINDOWS = 2 - -def get_platform(): - import platform - - sys_platform = platform.platform().lower() - if "windows" in sys_platform: - return SystemType.WINDOWS - elif "macos" in sys_platform: - return SystemType.MACOS - elif "linux" in sys_platform: - return SystemType.LINUX - raise SystemError("Learnware only support MACOS/Linux/Windows") - # What packages are required for this module to be executed? # `estimator` may depend on other packages. In order to reduce dependencies, it is not written here. @@ -92,14 +75,11 @@ FULL_REQUIRED = [ "torch==2.0.1", "torchvision==0.15.2", "torch-optimizer>=0.3.0", + "lightgbm>=3.3.0", "sentence_transformers==2.2.2", "fast_pytorch_kmeans==0.2.0.1", ] -# In MACOS, the lightgbm package should be installed with brew. -if get_platform() != SystemType.MACOS: - FULL_REQUIRED += ["lightgbm>=3.3.0"] - here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() From e267a4a884094ff715ea5236060333f319958be9 Mon Sep 17 00:00:00 2001 From: bxdd Date: Tue, 21 Nov 2023 23:07:55 +0800 Subject: [PATCH 2/3] [MNT] modify client return message --- learnware/client/learnware_client.py | 6 ++++-- learnware/market/classes.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/learnware/client/learnware_client.py b/learnware/client/learnware_client.py index 26bd4d8..4ba1e9e 100644 --- a/learnware/client/learnware_client.py +++ b/learnware/client/learnware_client.py @@ -376,7 +376,8 @@ class LearnwareClient: from ..market import CondaChecker stat_checker = CondaChecker(inner_checker=EasyStatChecker()) - return stat_checker(learnware)[0] != BaseChecker.INVALID_LEARNWARE + check_status, message = stat_checker(learnware) + return check_status != BaseChecker.INVALID_LEARNWARE, message @staticmethod def check_learnware(learnware_zip_path, semantic_specification=None): @@ -399,7 +400,8 @@ class LearnwareClient: if learnware is None: raise Exception("The learnware is not valid.") - assert LearnwareClient._check_stat_specification(learnware), "Stat specification check failed!" + check_status, message = LearnwareClient._check_stat_specification(learnware) + assert check_status is True, message logger.info("The learnware has passed the test.") diff --git a/learnware/market/classes.py b/learnware/market/classes.py index 0c15309..2368ae6 100644 --- a/learnware/market/classes.py +++ b/learnware/market/classes.py @@ -1,4 +1,5 @@ import traceback +from typing import Tuple from .base import BaseChecker from ..learnware import Learnware from ..client.container import LearnwaresContainer @@ -12,14 +13,14 @@ class CondaChecker(BaseChecker): self.inner_checker = inner_checker super(CondaChecker, self).__init__(**kwargs) - def __call__(self, learnware: Learnware) -> int: + def __call__(self, learnware: Learnware) -> Tuple[int, str]: try: with LearnwaresContainer(learnware, ignore_error=False) as env_container: learnwares = env_container.get_learnwares_with_container() check_status, message = self.inner_checker(learnwares[0]) except Exception as e: traceback.print_exc() - message = f"Conda Checker failed due to installed learnware failed and {e}" + message = f"Conda Checker failed due to installed learnware failed or {e}" logger.warning(message) message += "\n" + traceback.format_exc() return BaseChecker.INVALID_LEARNWARE, message From 7e4e2ccb20aeded5848bc9c163dfd3730a25379b Mon Sep 17 00:00:00 2001 From: bxdd Date: Tue, 21 Nov 2023 23:16:22 +0800 Subject: [PATCH 3/3] [MNT] release new beta version --- learnware/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learnware/__init__.py b/learnware/__init__.py index fabc31b..7581076 100644 --- a/learnware/__init__.py +++ b/learnware/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.2.0.1" +__version__ = "0.2.0.2" import os import json