Browse Source

[MNT] refactor utils to folder, decouple base model with torch

tags/v0.3.2
bxdd 2 years ago
parent
commit
c047307b46
4 changed files with 33 additions and 2 deletions
  1. +0
    -1
      examples/dataset_text_workflow/get_data.py
  2. +1
    -0
      examples/dataset_text_workflow/requirements.txt
  3. +32
    -0
      learnware/utils/import_utils.py
  4. +0
    -1
      setup.py

+ 0
- 1
examples/dataset_text_workflow/get_data.py View File

@@ -1,4 +1,3 @@
import torch
from torchtext.datasets import SST2




+ 1
- 0
examples/dataset_text_workflow/requirements.txt View File

@@ -0,0 +1 @@
torchtext>=0.14.1

+ 32
- 0
learnware/utils/import_utils.py View File

@@ -0,0 +1,32 @@
from ..logger import get_module_logger

logger = get_module_logger("import_utils")


def is_torch_avaliable():
try:
import torch
except ModuleNotFoundError as err:
logger.warning("ModuleNotFoundError: torch is not installed, please install pytorch!")
return False
return True


def is_lightgbm_avaliable():
try:
import lightgbm
except ModuleNotFoundError as err:
logger.warning("ModuleNotFoundError: lightgbm is not installed, please install lightgbm!")
return False
return True


def is_geatpy_avaliable():
try:
import geatpy
except ModuleNotFoundError as err:
logger.warning(
"ModuleNotFoundError: geatpy is not installed, please install geatpy (only support python version<3.11)!"
)
return False
return True

+ 0
- 1
setup.py View File

@@ -70,7 +70,6 @@ REQUIRED = [
"geatpy>=2.7.0",
"docker>=6.1.3",
"rapidfuzz>=3.4.0",
"torchtext>=0.14.1",
"sentence_transformers>=2.2.2",
"torch-optimizer>=0.3.0",
"langdetect>=1.0.9",


Loading…
Cancel
Save