Skip to content

Commit

Permalink
Merge pull request #1006 from openvinotoolkit/ik/move_cli_tests
Browse files Browse the repository at this point in the history
Ik/move cli tests
  • Loading branch information
Ilya-Krylov authored Mar 25, 2022
2 parents 83e96b2 + 7301d0d commit 0d4ce2c
Show file tree
Hide file tree
Showing 20 changed files with 723 additions and 524 deletions.
14 changes: 5 additions & 9 deletions QUICK_START_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@
git checkout -b develop origin/develop
git submodule update --init --recursive
```
2. Export `OTE_SDK_PATH` environment variable to use it inside our scripts:
```
export OTE_SDK_PATH=`pwd`/ote_sdk
```
3. Install prerequisites by running the following:
2. Install prerequisites by running the following:
```
sudo apt-get install python3-pip python3-venv
```
4. Search for available scripts that create python virtual environments for different task types:
3. Search for available scripts that create python virtual environments for different task types:
```bash
find external/ -name init_venv.sh
```
Expand All @@ -38,15 +34,15 @@
Each line in the output gives an `init_venv.sh` script that creates a virtual environment
for the corresponding task type.

5. Let's choose a task type.
4. Let's choose a task type.
Let it be `external/mmdetection` for Object Detection task.
```bash
TASK_ALGO_DIR=./external/mmdetection/
```
Note that we will not use the variable `TASK_ALGO_DIR` inside our scripts, we set it just to
simplify this guide.

6. Let's create, activate virtual environment for the chosen task, and install `ote_cli`.
5. Let's create, activate virtual environment for the chosen task, and install `ote_cli`.
Note that the virtual environment folder may be created in any place in your system,
but we will create it in the folder `./cur_task_venv` for convenience.
```bash
Expand All @@ -62,7 +58,7 @@
from the chosen task folder is used to avoid breaking constraints
for the OTE task.

7. As soon as `ote_cli` is installed in the virtual environment, you can use
6. As soon as `ote_cli` is installed in the virtual environment, you can use
`ote` command line interface described below to run
train/eval/export/other action for templates related to the chosen task type.

Expand Down
12 changes: 4 additions & 8 deletions external/anomaly/init_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ if [[ $PYTHON_VERSION != "3.8" && $PYTHON_VERSION != "3.9" ]]; then
exit 1
fi

if [[ -z $OTE_SDK_PATH ]]; then
echo "The environment variable OTE_SDK_PATH is not set -- it is required for creating virtual environment"
exit 1
fi

cd ${work_dir}

if [[ -e ${venv_dir} ]]; then
Expand Down Expand Up @@ -109,10 +104,11 @@ else
echo torchvision==${TORCHVISION_VERSION}+cu${CUDA_VERSION_CODE} >> ${CONSTRAINTS_FILE}
fi

pip install -r requirements.txt
pip install -e .
pip install -r requirements.txt || exit 1
pip install -e . || exit 1

pip install -e $OTE_SDK_PATH || exit 1
# Install OTE SDK
pip install -e ../../ote_sdk/ || exit 1

deactivate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component

from ote_cli.registry import Registry
from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
ote_demo_deployment_testing,
Expand All @@ -42,28 +42,28 @@


args = {
'--train-ann-file': 'data/anomaly/classification/train.json',
'--train-data-roots': 'data/anomaly/shapes',
'--val-ann-file': 'data/anomaly/classification/val.json',
'--val-data-roots': 'data/anomaly/shapes',
'--test-ann-files': 'data/anomaly/classification/test.json',
'--test-data-roots': 'data/anomaly/shapes',
'--input': 'data/anomaly/shapes/test/hexagon',
'train_params': [],
"--train-ann-file": "data/anomaly/classification/train.json",
"--train-data-roots": "data/anomaly/shapes",
"--val-ann-file": "data/anomaly/classification/val.json",
"--val-data-roots": "data/anomaly/shapes",
"--test-ann-files": "data/anomaly/classification/test.json",
"--test-data-roots": "data/anomaly/shapes",
"--input": "data/anomaly/shapes/test/hexagon",
"train_params": [],
}

root = '/tmp/ote_cli/'
root = "/tmp/ote_cli/"
ote_dir = os.getcwd()

templates = Registry('external').filter(task_type='ANOMALY_CLASSIFICATION').templates
templates = Registry("external").filter(task_type="ANOMALY_CLASSIFICATION").templates
templates_ids = [template.model_template_id for template in templates]


class TestToolsAnomalyClassification:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os

import pytest
from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
nncf_eval_openvino_testing,
Expand All @@ -41,28 +41,28 @@
from ote_cli.registry import Registry

args = {
'--train-ann-file': 'data/anomaly/detection/train.json',
'--train-data-roots': 'data/anomaly/shapes',
'--val-ann-file': 'data/anomaly/detection/val.json',
'--val-data-roots': 'data/anomaly/shapes',
'--test-ann-files': 'data/anomaly/detection/test.json',
'--test-data-roots': 'data/anomaly/shapes',
'--input': 'data/anomaly/shapes/test/hexagon',
'train_params': [],
"--train-ann-file": "data/anomaly/detection/train.json",
"--train-data-roots": "data/anomaly/shapes",
"--val-ann-file": "data/anomaly/detection/val.json",
"--val-data-roots": "data/anomaly/shapes",
"--test-ann-files": "data/anomaly/detection/test.json",
"--test-data-roots": "data/anomaly/shapes",
"--input": "data/anomaly/shapes/test/hexagon",
"train_params": [],
}

root = '/tmp/ote_cli/'
root = "/tmp/ote_cli/"
ote_dir = os.getcwd()

templates = Registry('external').filter(task_type='ANOMALY_DETECTION').templates
templates = Registry("external").filter(task_type="ANOMALY_DETECTION").templates
templates_ids = [template.model_template_id for template in templates]


class TestToolsAnomalyDetection:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component

from ote_cli.registry import Registry
from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
ote_demo_deployment_testing,
Expand All @@ -42,28 +42,28 @@


args = {
'--train-ann-file': 'data/anomaly/segmentation/train.json',
'--train-data-roots': 'data/anomaly/shapes',
'--val-ann-file': 'data/anomaly/segmentation/val.json',
'--val-data-roots': 'data/anomaly/shapes',
'--test-ann-files': 'data/anomaly/segmentation/test.json',
'--test-data-roots': 'data/anomaly/shapes',
'--input': 'data/anomaly/shapes/test/hexagon',
'train_params': [],
"--train-ann-file": "data/anomaly/segmentation/train.json",
"--train-data-roots": "data/anomaly/shapes",
"--val-ann-file": "data/anomaly/segmentation/val.json",
"--val-data-roots": "data/anomaly/shapes",
"--test-ann-files": "data/anomaly/segmentation/test.json",
"--test-data-roots": "data/anomaly/shapes",
"--input": "data/anomaly/shapes/test/hexagon",
"train_params": [],
}

root = '/tmp/ote_cli/'
root = "/tmp/ote_cli/"
ote_dir = os.getcwd()

templates = Registry('external').filter(task_type='ANOMALY_SEGMENTATION').templates
templates = Registry("external").filter(task_type="ANOMALY_SEGMENTATION").templates
templates_ids = [template.model_template_id for template in templates]


class TestToolsAnomalySegmentation:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
7 changes: 3 additions & 4 deletions external/deep-object-reid/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
from e2e.conftest_utils import pytest_addoption as _e2e_pytest_addoption # noqa
from e2e import config # noqa
from e2e.utils import get_plugins_from_packages
from ote_sdk.test_suite.pytest_insertions import *
from ote_sdk.test_suite.training_tests_common import REALLIFE_USECASE_CONSTANT
pytest_plugins = get_plugins_from_packages([e2e])
except ImportError:
_e2e_pytest_addoption = None
pass

import config

import pytest
from ote_sdk.test_suite.pytest_insertions import *
from ote_sdk.test_suite.training_tests_common import REALLIFE_USECASE_CONSTANT

pytest_plugins = get_pytest_plugins_from_ote()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component

from ote_cli.registry import Registry
from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
ote_demo_deployment_testing,
Expand Down Expand Up @@ -69,8 +69,8 @@
class TestToolsClassification:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component

from ote_cli.registry import Registry
from common import (
from ote_cli.utils.tests import (
collect_env_vars,
create_venv,
get_some_vars,
Expand Down Expand Up @@ -71,8 +71,8 @@
class TestToolsDetection:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand All @@ -92,7 +92,7 @@ def test_ote_eval(self, template):
@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
def test_ote_eval_openvino(self, template):
ote_eval_openvino_testing(template, root, ote_dir, args, threshold=0.1)
ote_eval_openvino_testing(template, root, ote_dir, args, threshold=0.2)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from ote_cli.registry import Registry

from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
ote_demo_deployment_testing,
Expand Down Expand Up @@ -64,8 +64,8 @@
class TestToolsInstanceSegmentation:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from ote_cli.registry import Registry

from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
ote_demo_deployment_testing,
Expand Down Expand Up @@ -64,8 +64,8 @@
class TestToolsRotatedDetection:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from ote_cli.registry import Registry

from common import (
from ote_cli.utils.tests import (
create_venv,
get_some_vars,
ote_demo_deployment_testing,
Expand Down Expand Up @@ -75,8 +75,8 @@
class TestToolsSegmentation:
@e2e_pytest_component
def test_create_venv(self):
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir, template_work_dir)
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
create_venv(algo_backend_dir, work_dir)

@e2e_pytest_component
@pytest.mark.parametrize("template", templates, ids=templates_ids)
Expand Down
Loading

0 comments on commit 0d4ce2c

Please sign in to comment.