From 596065c25d264705b52425e8b4c9fe4962478576 Mon Sep 17 00:00:00 2001 From: D-X-Y <280835372@qq.com> Date: Wed, 19 May 2021 13:13:11 +0800 Subject: [PATCH] Refine lib -> xautodl --- .github/workflows/basic_test.yml | 7 +++++-- .github/workflows/super_model_test.yml | 4 ++-- scripts/black.sh | 7 +++++++ tests/test_super_transformer.py | 12 ++---------- tests/test_synthetic_env.py | 12 ++---------- tests/test_synthetic_utils.py | 10 +--------- xautodl/xlayers/super_module.py | 2 +- 7 files changed, 20 insertions(+), 34 deletions(-) diff --git a/.github/workflows/basic_test.yml b/.github/workflows/basic_test.yml index 9cad01e..6866af0 100644 --- a/.github/workflows/basic_test.yml +++ b/.github/workflows/basic_test.yml @@ -43,9 +43,13 @@ jobs: run: | python setup.py install + - name: Test Import + run: | + python -m pip install torch torchvision + python -m pytest ./tests/test_import.py + - name: Test Search Space run: | - python -m pip install pytest numpy python -m pip install parameterized echo $PWD @@ -53,7 +57,6 @@ jobs: ls python --version python -m pytest ./tests/test_basic_space.py -s - python -m pytest ./tests/test_import.py shell: bash - name: Test Synthetic Data diff --git a/.github/workflows/super_model_test.yml b/.github/workflows/super_model_test.yml index 2a94d71..cc5e735 100644 --- a/.github/workflows/super_model_test.yml +++ b/.github/workflows/super_model_test.yml @@ -32,6 +32,6 @@ jobs: run: | python -m pip install pytest numpy python -m pip install parameterized - python -m pip install torch torchvision torchaudio - python -m pytest ./tests/test_super_*.py -s + python -m pip install torch torchvision + python -m pytest ./tests/test_super_*.py shell: bash diff --git a/scripts/black.sh b/scripts/black.sh index 58663ec..2d3ac9c 100644 --- a/scripts/black.sh +++ b/scripts/black.sh @@ -1,6 +1,13 @@ #!/bin/bash # bash ./scripts/black.sh +# script=$(readlink -f "$0") +# scriptpath=$(dirname "$script") +# echo $scriptpath + +# delete Python cache files +find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf + black ./tests/ black ./xautodl/procedures black ./xautodl/datasets diff --git a/tests/test_super_transformer.py b/tests/test_super_transformer.py index a7b4466..23fd747 100644 --- a/tests/test_super_transformer.py +++ b/tests/test_super_transformer.py @@ -3,19 +3,11 @@ ##################################################### # pytest ./tests/test_super_model.py -s # ##################################################### -import sys, random import unittest -import pytest -from pathlib import Path - -lib_dir = (Path(__file__).parent / ".." / "lib").resolve() -print("library path: {:}".format(lib_dir)) -if str(lib_dir) not in sys.path: - sys.path.insert(0, str(lib_dir)) import torch -from xlayers.super_core import SuperRunMode -from trade_models import get_transformer +from xautodl.xlayers.super_core import SuperRunMode +from xautodl.trade_models import get_transformer class TestSuperTransformer(unittest.TestCase): diff --git a/tests/test_synthetic_env.py b/tests/test_synthetic_env.py index 4abaa65..ec10b68 100644 --- a/tests/test_synthetic_env.py +++ b/tests/test_synthetic_env.py @@ -3,18 +3,10 @@ ##################################################### # pytest tests/test_synthetic_env.py -s # ##################################################### -import sys, random import unittest -import pytest -from pathlib import Path -lib_dir = (Path(__file__).parent / ".." / "lib").resolve() -print("library path: {:}".format(lib_dir)) -if str(lib_dir) not in sys.path: - sys.path.insert(0, str(lib_dir)) - -from datasets.math_core import ConstantFunc, ComposedSinFunc -from datasets.synthetic_core import SyntheticDEnv +from xautodl.datasets.math_core import ConstantFunc, ComposedSinFunc +from xautodl.datasets.synthetic_core import SyntheticDEnv class TestSynethicEnv(unittest.TestCase): diff --git a/tests/test_synthetic_utils.py b/tests/test_synthetic_utils.py index 5cd33a0..e366ab2 100644 --- a/tests/test_synthetic_utils.py +++ b/tests/test_synthetic_utils.py @@ -3,17 +3,9 @@ ##################################################### # pytest tests/test_synthetic_utils.py -s # ##################################################### -import sys, random import unittest -import pytest -from pathlib import Path -lib_dir = (Path(__file__).parent / ".." / "lib").resolve() -print("library path: {:}".format(lib_dir)) -if str(lib_dir) not in sys.path: - sys.path.insert(0, str(lib_dir)) - -from datasets.synthetic_core import TimeStamp +from xautodl.datasets.synthetic_core import TimeStamp class TestTimeStamp(unittest.TestCase): diff --git a/xautodl/xlayers/super_module.py b/xautodl/xlayers/super_module.py index cc242d8..82d4587 100644 --- a/xautodl/xlayers/super_module.py +++ b/xautodl/xlayers/super_module.py @@ -12,7 +12,7 @@ import torch import torch.nn as nn from enum import Enum -import xautodl.spaces +from xautodl import spaces from .super_utils import IntSpaceType, BoolSpaceType from .super_utils import LayerOrder, SuperRunMode from .super_utils import TensorContainer