Refactoring
Move DVC fixture into data fixture module
This commit is contained in:
parent
f12ef4b8ed
commit
0f6e87b8a6
@ -7,6 +7,7 @@ PACKAGE_ROOT_PATH = MODULE_PATH.parents[0]
|
|||||||
REPO_ROOT_PATH = PACKAGE_ROOT_PATH
|
REPO_ROOT_PATH = PACKAGE_ROOT_PATH
|
||||||
|
|
||||||
TEST_DIR_PATH = REPO_ROOT_PATH / "test"
|
TEST_DIR_PATH = REPO_ROOT_PATH / "test"
|
||||||
TEST_DATA_DVC = TEST_DIR_PATH / "test_data.dvc" # TODO: remove once new tests are in place
|
|
||||||
TEST_DATA_DIR = TEST_DIR_PATH / "data"
|
TEST_DATA_DIR = TEST_DIR_PATH / "data"
|
||||||
TEST_PAGE_TEXTURES_DIR = TEST_DATA_DIR / "paper"
|
TEST_DATA_DIR_DVC = TEST_DIR_PATH / "data.dvc"
|
||||||
|
TEST_DATA_SYNTHESIS_DIR = TEST_DATA_DIR / "synthesis"
|
||||||
|
TEST_PAGE_TEXTURES_DIR = TEST_DATA_SYNTHESIS_DIR / "paper"
|
||||||
|
|||||||
@ -130,9 +130,10 @@ class RandomPlot(RandomContentRectangle):
|
|||||||
def generate_random_heat_map(self, rectangle: Rectangle):
|
def generate_random_heat_map(self, rectangle: Rectangle):
|
||||||
|
|
||||||
n = random.randint(3, 7)
|
n = random.randint(3, 7)
|
||||||
x = np.random.uniform(size=(n, n))
|
m = random.randint(3, 7)
|
||||||
|
x = np.random.uniform(size=(n, m))
|
||||||
heat_map_fn = lambda x, y: plt.imshow(x, interpolation="nearest")
|
heat_map_fn = lambda x, y: plt.imshow(x, interpolation="nearest")
|
||||||
ax, fig = self.__generate_random_plot(
|
self.__generate_random_plot(
|
||||||
heat_map_fn,
|
heat_map_fn,
|
||||||
rectangle,
|
rectangle,
|
||||||
x,
|
x,
|
||||||
|
|||||||
1
test/.gitignore
vendored
1
test/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/test_data
|
/test_data
|
||||||
|
/data
|
||||||
|
|||||||
@ -5,6 +5,7 @@ warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
"test.fixtures.table_parsing",
|
"test.fixtures.table_parsing",
|
||||||
"test.fixtures.figure_detection",
|
"test.fixtures.figure_detection",
|
||||||
|
"test.fixtures.data",
|
||||||
"test.fixtures.page_generation.page",
|
"test.fixtures.page_generation.page",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
5
test/data.dvc
Normal file
5
test/data.dvc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
outs:
|
||||||
|
- md5: 4e22cc1a7655987683215d4a4677d645.dir
|
||||||
|
size: 25117769
|
||||||
|
nfiles: 6
|
||||||
|
path: data
|
||||||
13
test/fixtures/data.py
vendored
Normal file
13
test/fixtures/data.py
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import pytest
|
||||||
|
from dvc.repo import Repo
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
from cv_analysis.locations import REPO_ROOT_PATH, TEST_DATA_DIR_DVC
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def dvc_test_data():
|
||||||
|
# noinspection PyCallingNonCallable
|
||||||
|
logger.info("Pulling data with DVC...")
|
||||||
|
Repo(REPO_ROOT_PATH).pull(targets=[str(TEST_DATA_DIR_DVC)])
|
||||||
|
logger.info("Finished pulling data.")
|
||||||
10
test/fixtures/table_parsing.py
vendored
10
test/fixtures/table_parsing.py
vendored
@ -3,12 +3,10 @@ from os.path import join
|
|||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import pytest
|
import pytest
|
||||||
from dvc.repo import Repo
|
|
||||||
from funcy import first
|
from funcy import first
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from cv_analysis.config import get_config
|
from cv_analysis.config import get_config
|
||||||
from cv_analysis.locations import REPO_ROOT_PATH, TEST_DATA_DVC
|
|
||||||
from cv_analysis.utils.drawing import draw_rectangles
|
from cv_analysis.utils.drawing import draw_rectangles
|
||||||
from cv_analysis.utils.input import open_analysis_input_file
|
from cv_analysis.utils.input import open_analysis_input_file
|
||||||
from test.fixtures.figure_detection import paste_text
|
from test.fixtures.figure_detection import paste_text
|
||||||
@ -22,14 +20,6 @@ def client_page_with_table(test_file_index, dvc_test_data):
|
|||||||
return first(open_analysis_input_file(img_path))
|
return first(open_analysis_input_file(img_path))
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
|
||||||
def dvc_test_data():
|
|
||||||
# noinspection PyCallingNonCallable
|
|
||||||
logger.info("Pulling data with DVC...")
|
|
||||||
Repo(REPO_ROOT_PATH).pull(targets=[str(TEST_DATA_DVC)])
|
|
||||||
logger.info("Finished pulling data.")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def expected_table_annotation(test_file_index):
|
def expected_table_annotation(test_file_index):
|
||||||
json_path = join(CV_CONFIG.test_data_dir, f"test{test_file_index}.json")
|
json_path = join(CV_CONFIG.test_data_dir, f"test{test_file_index}.json")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user