-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some tests to assert generators perserve page number. (#78)
* Adding some tests to assert generators perserve page number. * Adding generator test. * Reverting accidental changes. * Typing changes. * Adding an initial test for the core generator. * Adding tests to the vespa generator. * Moving util function. * Adding more tests. * Removing breakpoint. * Removing breakpoint * Removing another breakpoint. * Adding more tests. --------- Co-authored-by: Mark <[email protected]>
- Loading branch information
Showing
10 changed files
with
5,062 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import json | ||
import pytest as pytest | ||
import os | ||
from cloudpathlib import S3Path | ||
|
||
from typing import Any | ||
from pathlib import Path | ||
import numpy as np | ||
|
||
from cpr_data_access.parser_models import ParserOutput | ||
|
||
|
||
def read_local_json_file(file_path: str) -> dict: | ||
"""Read a local json file and return the data.""" | ||
with open(file_path) as json_file: | ||
data = json.load(json_file) | ||
return data | ||
|
||
|
||
def read_local_npy_file(file_path: str) -> Any: | ||
"""Read a local npy file and return the data.""" | ||
return np.load(file_path) | ||
|
||
|
||
@pytest.fixture | ||
def s3_bucket_and_region() -> dict: | ||
return { | ||
"bucket": "test-bucket", | ||
"region": "eu-west-1", | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def indexer_input_prefix(): | ||
return "indexer-input" | ||
|
||
|
||
@pytest.fixture | ||
def embeddings_dir_as_path( | ||
s3_bucket_and_region, | ||
indexer_input_prefix, | ||
) -> S3Path: | ||
return S3Path( | ||
os.path.join("s3://", s3_bucket_and_region["bucket"], indexer_input_prefix) | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def test_document_data() -> tuple[ParserOutput, Any]: | ||
parser_output_json = read_local_json_file( | ||
str( | ||
Path(__file__).parent | ||
/ os.path.join("data", "CCLW.executive.10002.4495.json") | ||
) | ||
) | ||
parser_output = ParserOutput.model_validate(parser_output_json) | ||
|
||
embeddings = read_local_npy_file( | ||
str( | ||
Path(__file__).parent | ||
/ os.path.join("data", "CCLW.executive.10002.4495.npy") | ||
) | ||
) | ||
|
||
return (parser_output, embeddings) |
Oops, something went wrong.