diff --git a/examples/workflow_by_code/environment.yml b/examples/workflow_by_code/environment.yml new file mode 100644 index 0000000..2923bdb --- /dev/null +++ b/examples/workflow_by_code/environment.yml @@ -0,0 +1,27 @@ +name: learnware_example_env +channels: + - defaults +dependencies: + - _libgcc_mutex=0.1=main + - _openmp_mutex=5.1=1_gnu + - ca-certificates=2023.01.10=h06a4308_0 + - ld_impl_linux-64=2.38=h1181459_1 + - libffi=3.4.2=h6a678d5_6 + - libgcc-ng=11.2.0=h1234567_1 + - libgomp=11.2.0=h1234567_1 + - libstdcxx-ng=11.2.0=h1234567_1 + - ncurses=6.4=h6a678d5_0 + - openssl=1.1.1t=h7f8727e_0 + - pip=23.0.1=py38h06a4308_0 + - python=3.8.16=h7a1cb2a_3 + - readline=8.2=h5eee18b_0 + - setuptools=66.0.0=py38h06a4308_0 + - sqlite=3.41.2=h5eee18b_0 + - tk=8.6.12=h1ccaba5_0 + - wheel=0.38.4=py38h06a4308_0 + - xz=5.2.10=h5eee18b_1 + - zlib=1.2.13=h5eee18b_0 + - pip: + - joblib==1.2.0 + - learnware==0.0.1.99 + - numpy==1.19.5 diff --git a/learnware/learnware/base.py b/learnware/learnware/base.py index 8a2d197..e2142d2 100644 --- a/learnware/learnware/base.py +++ b/learnware/learnware/base.py @@ -45,7 +45,7 @@ class Learnware: logger.info("The learnware had been instantiated, thus the instantiation operation is ignored!") elif isinstance(self.model, dict): model_module = get_module_by_module_path(self.model["module_path"]) - return getattr(model_module, self.model["class_name"])(**self.model.get("kwargs", {})) + self.model = getattr(model_module, self.model["class_name"])(**self.model.get("kwargs", {})) else: raise TypeError(f"Model must be BaseModel or dict, not {type(self.model)}") diff --git a/learnware/market/base.py b/learnware/market/base.py index 9be0d9c..069209c 100644 --- a/learnware/market/base.py +++ b/learnware/market/base.py @@ -49,6 +49,9 @@ class BaseMarket: learnmarket = BaseMarket() """ + def __init__(self, market_id: str = None): + self.market_id = market_id + def reload_market(self, market_path: str, semantic_spec_list_path: str) -> bool: """Reload the market when server restared. diff --git a/learnware/market/easy.py b/learnware/market/easy.py index 9e25db6..130d918 100644 --- a/learnware/market/easy.py +++ b/learnware/market/easy.py @@ -23,7 +23,7 @@ class EasyMarket(BaseMarket): NOPREDICTION_LEARNWARE = 0 PREDICTION_LEARWARE = 1 - def __init__(self, rebuild: bool = False): + def __init__(self, market_id: str = None, rebuild: bool = False): """Initialize Learnware Market. Automatically reload from db if available. Build an empty db otherwise.