Skip to content

Commit 0d4ce2c

Browse files
authored
Merge pull request #1006 from openvinotoolkit/ik/move_cli_tests
Ik/move cli tests
2 parents 83e96b2 + 7301d0d commit 0d4ce2c

File tree

20 files changed

+723
-524
lines changed

20 files changed

+723
-524
lines changed

QUICK_START_GUIDE.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
git checkout -b develop origin/develop
1515
git submodule update --init --recursive
1616
```
17-
2. Export `OTE_SDK_PATH` environment variable to use it inside our scripts:
18-
```
19-
export OTE_SDK_PATH=`pwd`/ote_sdk
20-
```
2117
22-
3. Install prerequisites by running the following:
18+
2. Install prerequisites by running the following:
2319
```
2420
sudo apt-get install python3-pip python3-venv
2521
```
2622
27-
4. Search for available scripts that create python virtual environments for different task types:
23+
3. Search for available scripts that create python virtual environments for different task types:
2824
```bash
2925
find external/ -name init_venv.sh
3026
```
@@ -38,15 +34,15 @@
3834
Each line in the output gives an `init_venv.sh` script that creates a virtual environment
3935
for the corresponding task type.
4036

41-
5. Let's choose a task type.
37+
4. Let's choose a task type.
4238
Let it be `external/mmdetection` for Object Detection task.
4339
```bash
4440
TASK_ALGO_DIR=./external/mmdetection/
4541
```
4642
Note that we will not use the variable `TASK_ALGO_DIR` inside our scripts, we set it just to
4743
simplify this guide.
4844

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

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

external/anomaly/init_venv.sh

+4-8
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ if [[ $PYTHON_VERSION != "3.8" && $PYTHON_VERSION != "3.9" ]]; then
2626
exit 1
2727
fi
2828

29-
if [[ -z $OTE_SDK_PATH ]]; then
30-
echo "The environment variable OTE_SDK_PATH is not set -- it is required for creating virtual environment"
31-
exit 1
32-
fi
33-
3429
cd ${work_dir}
3530

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

112-
pip install -r requirements.txt
113-
pip install -e .
107+
pip install -r requirements.txt || exit 1
108+
pip install -e . || exit 1
114109

115-
pip install -e $OTE_SDK_PATH || exit 1
110+
# Install OTE SDK
111+
pip install -e ../../ote_sdk/ || exit 1
116112

117113
deactivate
118114

tests/ote_cli/external/anomaly/test_ote_cli_tools_anomaly_classification.py external/anomaly/tests/ote_cli/test_anomaly_classification.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component
2121

2222
from ote_cli.registry import Registry
23-
from common import (
23+
from ote_cli.utils.tests import (
2424
create_venv,
2525
get_some_vars,
2626
ote_demo_deployment_testing,
@@ -42,28 +42,28 @@
4242

4343

4444
args = {
45-
'--train-ann-file': 'data/anomaly/classification/train.json',
46-
'--train-data-roots': 'data/anomaly/shapes',
47-
'--val-ann-file': 'data/anomaly/classification/val.json',
48-
'--val-data-roots': 'data/anomaly/shapes',
49-
'--test-ann-files': 'data/anomaly/classification/test.json',
50-
'--test-data-roots': 'data/anomaly/shapes',
51-
'--input': 'data/anomaly/shapes/test/hexagon',
52-
'train_params': [],
45+
"--train-ann-file": "data/anomaly/classification/train.json",
46+
"--train-data-roots": "data/anomaly/shapes",
47+
"--val-ann-file": "data/anomaly/classification/val.json",
48+
"--val-data-roots": "data/anomaly/shapes",
49+
"--test-ann-files": "data/anomaly/classification/test.json",
50+
"--test-data-roots": "data/anomaly/shapes",
51+
"--input": "data/anomaly/shapes/test/hexagon",
52+
"train_params": [],
5353
}
5454

55-
root = '/tmp/ote_cli/'
55+
root = "/tmp/ote_cli/"
5656
ote_dir = os.getcwd()
5757

58-
templates = Registry('external').filter(task_type='ANOMALY_CLASSIFICATION').templates
58+
templates = Registry("external").filter(task_type="ANOMALY_CLASSIFICATION").templates
5959
templates_ids = [template.model_template_id for template in templates]
6060

6161

6262
class TestToolsAnomalyClassification:
6363
@e2e_pytest_component
6464
def test_create_venv(self):
65-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
66-
create_venv(algo_backend_dir, work_dir, template_work_dir)
65+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
66+
create_venv(algo_backend_dir, work_dir)
6767

6868
@e2e_pytest_component
6969
@pytest.mark.parametrize("template", templates, ids=templates_ids)

tests/ote_cli/external/anomaly/test_ote_cli_tools_anomaly_detection.py external/anomaly/tests/ote_cli/test_anomaly_detection.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818

1919
import pytest
20-
from common import (
20+
from ote_cli.utils.tests import (
2121
create_venv,
2222
get_some_vars,
2323
nncf_eval_openvino_testing,
@@ -41,28 +41,28 @@
4141
from ote_cli.registry import Registry
4242

4343
args = {
44-
'--train-ann-file': 'data/anomaly/detection/train.json',
45-
'--train-data-roots': 'data/anomaly/shapes',
46-
'--val-ann-file': 'data/anomaly/detection/val.json',
47-
'--val-data-roots': 'data/anomaly/shapes',
48-
'--test-ann-files': 'data/anomaly/detection/test.json',
49-
'--test-data-roots': 'data/anomaly/shapes',
50-
'--input': 'data/anomaly/shapes/test/hexagon',
51-
'train_params': [],
44+
"--train-ann-file": "data/anomaly/detection/train.json",
45+
"--train-data-roots": "data/anomaly/shapes",
46+
"--val-ann-file": "data/anomaly/detection/val.json",
47+
"--val-data-roots": "data/anomaly/shapes",
48+
"--test-ann-files": "data/anomaly/detection/test.json",
49+
"--test-data-roots": "data/anomaly/shapes",
50+
"--input": "data/anomaly/shapes/test/hexagon",
51+
"train_params": [],
5252
}
5353

54-
root = '/tmp/ote_cli/'
54+
root = "/tmp/ote_cli/"
5555
ote_dir = os.getcwd()
5656

57-
templates = Registry('external').filter(task_type='ANOMALY_DETECTION').templates
57+
templates = Registry("external").filter(task_type="ANOMALY_DETECTION").templates
5858
templates_ids = [template.model_template_id for template in templates]
5959

6060

6161
class TestToolsAnomalyDetection:
6262
@e2e_pytest_component
6363
def test_create_venv(self):
64-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
65-
create_venv(algo_backend_dir, work_dir, template_work_dir)
64+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
65+
create_venv(algo_backend_dir, work_dir)
6666

6767
@e2e_pytest_component
6868
@pytest.mark.parametrize("template", templates, ids=templates_ids)

tests/ote_cli/external/anomaly/test_ote_cli_tools_anomaly_segmentation.py external/anomaly/tests/ote_cli/test_anomaly_segmentation.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component
2121

2222
from ote_cli.registry import Registry
23-
from common import (
23+
from ote_cli.utils.tests import (
2424
create_venv,
2525
get_some_vars,
2626
ote_demo_deployment_testing,
@@ -42,28 +42,28 @@
4242

4343

4444
args = {
45-
'--train-ann-file': 'data/anomaly/segmentation/train.json',
46-
'--train-data-roots': 'data/anomaly/shapes',
47-
'--val-ann-file': 'data/anomaly/segmentation/val.json',
48-
'--val-data-roots': 'data/anomaly/shapes',
49-
'--test-ann-files': 'data/anomaly/segmentation/test.json',
50-
'--test-data-roots': 'data/anomaly/shapes',
51-
'--input': 'data/anomaly/shapes/test/hexagon',
52-
'train_params': [],
45+
"--train-ann-file": "data/anomaly/segmentation/train.json",
46+
"--train-data-roots": "data/anomaly/shapes",
47+
"--val-ann-file": "data/anomaly/segmentation/val.json",
48+
"--val-data-roots": "data/anomaly/shapes",
49+
"--test-ann-files": "data/anomaly/segmentation/test.json",
50+
"--test-data-roots": "data/anomaly/shapes",
51+
"--input": "data/anomaly/shapes/test/hexagon",
52+
"train_params": [],
5353
}
5454

55-
root = '/tmp/ote_cli/'
55+
root = "/tmp/ote_cli/"
5656
ote_dir = os.getcwd()
5757

58-
templates = Registry('external').filter(task_type='ANOMALY_SEGMENTATION').templates
58+
templates = Registry("external").filter(task_type="ANOMALY_SEGMENTATION").templates
5959
templates_ids = [template.model_template_id for template in templates]
6060

6161

6262
class TestToolsAnomalySegmentation:
6363
@e2e_pytest_component
6464
def test_create_venv(self):
65-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
66-
create_venv(algo_backend_dir, work_dir, template_work_dir)
65+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
66+
create_venv(algo_backend_dir, work_dir)
6767

6868
@e2e_pytest_component
6969
@pytest.mark.parametrize("template", templates, ids=templates_ids)

external/deep-object-reid/tests/conftest.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
from e2e.conftest_utils import pytest_addoption as _e2e_pytest_addoption # noqa
66
from e2e import config # noqa
77
from e2e.utils import get_plugins_from_packages
8-
from ote_sdk.test_suite.pytest_insertions import *
9-
from ote_sdk.test_suite.training_tests_common import REALLIFE_USECASE_CONSTANT
108
pytest_plugins = get_plugins_from_packages([e2e])
119
except ImportError:
1210
_e2e_pytest_addoption = None
1311
pass
14-
1512
import config
16-
13+
import pytest
14+
from ote_sdk.test_suite.pytest_insertions import *
15+
from ote_sdk.test_suite.training_tests_common import REALLIFE_USECASE_CONSTANT
1716

1817
pytest_plugins = get_pytest_plugins_from_ote()
1918

tests/ote_cli/external/deep-object-reid/test_ote_cli_tools_classification.py external/deep-object-reid/tests/ote_cli/test_classification.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component
2121

2222
from ote_cli.registry import Registry
23-
from common import (
23+
from ote_cli.utils.tests import (
2424
create_venv,
2525
get_some_vars,
2626
ote_demo_deployment_testing,
@@ -69,8 +69,8 @@
6969
class TestToolsClassification:
7070
@e2e_pytest_component
7171
def test_create_venv(self):
72-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
73-
create_venv(algo_backend_dir, work_dir, template_work_dir)
72+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
73+
create_venv(algo_backend_dir, work_dir)
7474

7575
@e2e_pytest_component
7676
@pytest.mark.parametrize("template", templates, ids=templates_ids)

tests/ote_cli/external/mmdetection/test_ote_cli_tools_detection.py external/mmdetection/tests/ote_cli/test_detection.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ote_sdk.test_suite.e2e_test_system import e2e_pytest_component
2222

2323
from ote_cli.registry import Registry
24-
from common import (
24+
from ote_cli.utils.tests import (
2525
collect_env_vars,
2626
create_venv,
2727
get_some_vars,
@@ -71,8 +71,8 @@
7171
class TestToolsDetection:
7272
@e2e_pytest_component
7373
def test_create_venv(self):
74-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
75-
create_venv(algo_backend_dir, work_dir, template_work_dir)
74+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
75+
create_venv(algo_backend_dir, work_dir)
7676

7777
@e2e_pytest_component
7878
@pytest.mark.parametrize("template", templates, ids=templates_ids)
@@ -92,7 +92,7 @@ def test_ote_eval(self, template):
9292
@e2e_pytest_component
9393
@pytest.mark.parametrize("template", templates, ids=templates_ids)
9494
def test_ote_eval_openvino(self, template):
95-
ote_eval_openvino_testing(template, root, ote_dir, args, threshold=0.1)
95+
ote_eval_openvino_testing(template, root, ote_dir, args, threshold=0.2)
9696

9797
@e2e_pytest_component
9898
@pytest.mark.parametrize("template", templates, ids=templates_ids)

tests/ote_cli/external/mmdetection/test_ote_cli_tools_instance_segmentation.py external/mmdetection/tests/ote_cli/test_instance_segmentation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from ote_cli.registry import Registry
2424

25-
from common import (
25+
from ote_cli.utils.tests import (
2626
create_venv,
2727
get_some_vars,
2828
ote_demo_deployment_testing,
@@ -64,8 +64,8 @@
6464
class TestToolsInstanceSegmentation:
6565
@e2e_pytest_component
6666
def test_create_venv(self):
67-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
68-
create_venv(algo_backend_dir, work_dir, template_work_dir)
67+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
68+
create_venv(algo_backend_dir, work_dir)
6969

7070
@e2e_pytest_component
7171
@pytest.mark.parametrize("template", templates, ids=templates_ids)

tests/ote_cli/external/mmdetection/test_ote_cli_tools_rotated_detection.py external/mmdetection/tests/ote_cli/test_rotated_detection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from ote_cli.registry import Registry
2424

25-
from common import (
25+
from ote_cli.utils.tests import (
2626
create_venv,
2727
get_some_vars,
2828
ote_demo_deployment_testing,
@@ -64,8 +64,8 @@
6464
class TestToolsRotatedDetection:
6565
@e2e_pytest_component
6666
def test_create_venv(self):
67-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
68-
create_venv(algo_backend_dir, work_dir, template_work_dir)
67+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
68+
create_venv(algo_backend_dir, work_dir)
6969

7070
@e2e_pytest_component
7171
@pytest.mark.parametrize("template", templates, ids=templates_ids)

tests/ote_cli/external/mmsegmentation/test_ote_cli_tools_segmentation.py external/mmsegmentation/tests/ote_cli/test_segmentation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from ote_cli.registry import Registry
2424

25-
from common import (
25+
from ote_cli.utils.tests import (
2626
create_venv,
2727
get_some_vars,
2828
ote_demo_deployment_testing,
@@ -75,8 +75,8 @@
7575
class TestToolsSegmentation:
7676
@e2e_pytest_component
7777
def test_create_venv(self):
78-
work_dir, template_work_dir, algo_backend_dir = get_some_vars(templates[0], root)
79-
create_venv(algo_backend_dir, work_dir, template_work_dir)
78+
work_dir, _, algo_backend_dir = get_some_vars(templates[0], root)
79+
create_venv(algo_backend_dir, work_dir)
8080

8181
@e2e_pytest_component
8282
@pytest.mark.parametrize("template", templates, ids=templates_ids)

0 commit comments

Comments
 (0)