2021-10-03 04:46:29 +02:00
|
|
|
# Standard Packages
|
|
|
|
import pytest
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
# Internal Packages
|
|
|
|
from src.search_type import asymmetric, image_search
|
2021-12-09 14:50:38 +01:00
|
|
|
from src.utils.rawconfig import ContentTypeConfig, ImageSearchConfig, TextSearchConfig
|
2021-10-03 04:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def model_dir(tmp_path_factory):
|
|
|
|
model_dir = tmp_path_factory.mktemp('data')
|
|
|
|
|
|
|
|
# Generate Image Embeddings from Test Images
|
2021-12-09 14:50:38 +01:00
|
|
|
search_config = ContentTypeConfig()
|
|
|
|
search_config.image = ImageSearchConfig(
|
2021-10-03 04:46:29 +02:00
|
|
|
input_directory = Path('tests/data'),
|
|
|
|
embeddings_file = model_dir.joinpath('.image_embeddings.pt'),
|
|
|
|
batch_size = 10,
|
2021-12-04 18:02:19 +01:00
|
|
|
use_xmp_metadata = False)
|
2021-10-03 04:46:29 +02:00
|
|
|
|
2021-12-05 15:31:39 +01:00
|
|
|
image_search.setup(search_config.image, regenerate=False, verbose=True)
|
2021-10-03 04:46:29 +02:00
|
|
|
|
|
|
|
# Generate Notes Embeddings from Test Notes
|
2021-12-09 14:50:38 +01:00
|
|
|
search_config.org = TextSearchConfig(
|
2021-10-03 04:46:29 +02:00
|
|
|
input_files = [Path('tests/data/main_readme.org'), Path('tests/data/interface_emacs_readme.org')],
|
|
|
|
input_filter = None,
|
|
|
|
compressed_jsonl = model_dir.joinpath('.notes.jsonl.gz'),
|
2021-12-04 18:02:19 +01:00
|
|
|
embeddings_file = model_dir.joinpath('.note_embeddings.pt'))
|
2021-10-03 04:46:29 +02:00
|
|
|
|
2021-12-05 15:31:39 +01:00
|
|
|
asymmetric.setup(search_config.notes, regenerate=False, verbose=True)
|
2021-10-03 04:46:29 +02:00
|
|
|
|
|
|
|
return model_dir
|
2021-10-03 05:28:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def search_config(model_dir):
|
2021-12-09 14:50:38 +01:00
|
|
|
search_config = ContentTypeConfig()
|
|
|
|
search_config.org = TextSearchConfig(
|
2021-10-03 05:28:33 +02:00
|
|
|
input_files = [Path('tests/data/main_readme.org'), Path('tests/data/interface_emacs_readme.org')],
|
|
|
|
input_filter = None,
|
|
|
|
compressed_jsonl = model_dir.joinpath('.notes.jsonl.gz'),
|
2021-12-04 18:02:19 +01:00
|
|
|
embeddings_file = model_dir.joinpath('.note_embeddings.pt'))
|
2021-10-03 05:28:33 +02:00
|
|
|
|
2021-12-09 14:50:38 +01:00
|
|
|
search_config.image = ImageSearchConfig(
|
2021-10-03 05:28:33 +02:00
|
|
|
input_directory = Path('tests/data'),
|
|
|
|
embeddings_file = Path('tests/data/.image_embeddings.pt'),
|
|
|
|
batch_size = 10,
|
2021-12-04 18:02:19 +01:00
|
|
|
use_xmp_metadata = False)
|
2021-10-03 05:28:33 +02:00
|
|
|
|
|
|
|
return search_config
|