Browse Source

[ENH] add docker runnable_option in load

tags/v0.3.2
Gene 2 years ago
parent
commit
3a00a2dbf6
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      learnware/client/learnware_client.py

+ 7
- 3
learnware/client/learnware_client.py View File

@@ -306,14 +306,15 @@ class LearnwareClient:
the option for instantiating learnwares the option for instantiating learnwares
- "normal": instantiate learnware without installing environment - "normal": instantiate learnware without installing environment
- "conda_env": instantiate learnware with installing conda virtual environment - "conda_env": instantiate learnware with installing conda virtual environment
- "docker": instantiate learnware with creating docker container


Returns Returns
------- -------
Learnware Learnware
The contructed learnware object or object list The contructed learnware object or object list
""" """
if runnable_option is not None and runnable_option not in ["normal", "conda_env"]:
raise logger.warning(f"runnable_option must be one of ['normal', 'conda_env'], but got {runnable_option}")
if runnable_option is not None and runnable_option not in ["normal", "conda_env", "docker"]:
raise logger.warning(f"runnable_option must be one of ['normal', 'conda_env', 'docker'], but got {runnable_option}")


if learnware_path is None and learnware_id is None: if learnware_path is None and learnware_id is None:
raise ValueError("Requires one of learnware_path or learnware_id") raise ValueError("Requires one of learnware_path or learnware_id")
@@ -379,7 +380,10 @@ class LearnwareClient:
for i in range(len(learnware_list)): for i in range(len(learnware_list)):
learnware_list[i].instantiate_model() learnware_list[i].instantiate_model()
elif runnable_option == "conda_env": elif runnable_option == "conda_env":
with LearnwaresContainer(learnware_list, zip_paths, cleanup=False) as env_container:
with LearnwaresContainer(learnware_list, zip_paths, cleanup=False, mode="conda") as env_container:
learnware_list = env_container.get_learnwares_with_container()
elif runnable_option == "docker":
with LearnwaresContainer(learnware_list, zip_paths, cleanup=False, mode="docker") as env_container:
learnware_list = env_container.get_learnwares_with_container() learnware_list = env_container.get_learnwares_with_container()


if len(learnware_list) == 1: if len(learnware_list) == 1:


Loading…
Cancel
Save