Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from mindee import ClientV2, InferenceParameters, InferenceResponse, PathInput
from mindee import (
ClientV2,
InferenceParameters,
InferenceResponse,
PathInput,
)

input_path = "/path/to/the/file.ext"
api_key = "MY_API_KEY"
Expand Down
2 changes: 1 addition & 1 deletion mindee/parsing/v2/inference_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class InferenceResponse(BaseResponse):

inference: Inference
"""Inference result."""
_slug: str = "inferences"
_slug: str = "products/extraction/results"
"""Slug of the inference."""

def __init__(self, raw_response: StringDict) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class ClassificationParameters(BaseParameters):
Parameters accepted by the classification utility v2 endpoint.
"""

_slug: str = "utilities/classification"
_slug: str = "products/classification"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ClassificationResponse(BaseResponse):
inference: ClassificationInference
"""Inference object for classification inference."""

_slug: str = "utilities/classification"
_slug: str = "products/classification/results"
"""Slug of the inference."""

def __init__(self, raw_response: StringDict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion mindee/v2/product/crop/crop_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class CropParameters(BaseParameters):
Parameters accepted by the crop utility v2 endpoint.
"""

_slug: str = "utilities/crop"
_slug: str = "products/crop"
2 changes: 1 addition & 1 deletion mindee/v2/product/crop/crop_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CropResponse(BaseResponse):
inference: CropInference
"""Inference object for crop inference."""

_slug: str = "utilities/crop"
_slug: str = "products/crop/results"
"""Slug of the inference."""

def __init__(self, raw_response: StringDict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion mindee/v2/product/ocr/ocr_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class OCRParameters(BaseParameters):
Parameters accepted by the ocr utility v2 endpoint.
"""

_slug: str = "utilities/ocr"
_slug: str = "products/ocr"
2 changes: 1 addition & 1 deletion mindee/v2/product/ocr/ocr_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class OCRResponse(BaseResponse):
inference: OCRInference
"""Inference object for ocr inference."""

_slug: str = "utilities/ocr"
_slug: str = "products/ocr/results"
"""Slug of the inference."""

def __init__(self, raw_response: StringDict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion mindee/v2/product/split/split_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class SplitParameters(BaseParameters):
Parameters accepted by the split utility v2 endpoint.
"""

_slug: str = "utilities/split"
_slug: str = "products/split"
2 changes: 1 addition & 1 deletion mindee/v2/product/split/split_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SplitResponse(BaseResponse):
inference: SplitInference
"""Inference object for split inference."""

_slug: str = "utilities/split"
_slug: str = "products/split/results"
"""Slug of the inference."""

def __init__(self, raw_response: StringDict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/data
Submodule data updated 29 files
+0 −38 v2/inference/text_context_enabled.json
+3 −3 v2/products/classification/classification_single.json
+ v2/products/classification/default_invoice.jpg
+3 −3 v2/products/crop/crop_multiple.json
+3 −3 v2/products/crop/crop_single.json
+ v2/products/crop/default_sample.jpg
+ v2/products/crop/multipage_sample.pdf
+3 −0 v2/products/extraction/data_schema_replace.json
+0 −0 v2/products/extraction/data_schema_replace_param.json
+6 −4 v2/products/extraction/deep_nested_fields.json
+3 −3 v2/products/extraction/financial_document/blank.json
+3 −3 v2/products/extraction/financial_document/complete.json
+3 −3 v2/products/extraction/financial_document/complete_with_coordinates.json
+ v2/products/extraction/financial_document/default_sample.jpg
+3 −3 v2/products/extraction/financial_document/default_sample.json
+3 −3 v2/products/extraction/rag_matched.json
+3 −3 v2/products/extraction/rag_not_matched.json
+3 −3 v2/products/extraction/raw_texts.json
+0 −0 v2/products/extraction/raw_texts.txt
+3 −3 v2/products/extraction/standard_field_types.json
+0 −0 v2/products/extraction/standard_field_types.rst
+38 −0 v2/products/extraction/text_context_enabled.json
+ v2/products/ocr/default_sample.jpg
+3 −3 v2/products/ocr/ocr_multiple.json
+3 −3 v2/products/ocr/ocr_single.json
+ v2/products/split/default_sample.pdf
+ v2/products/split/invoice_5p.pdf
+3 −3 v2/products/split/split_multiple.json
+3 −3 v2/products/split/split_single.json
4 changes: 2 additions & 2 deletions tests/v2/input/test_inference_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
DataSchemaReplace,
DataSchemaField,
)
from tests.utils import V2_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR

expected_data_schema_dict = json.loads(
(V2_DATA_DIR / "inference" / "data_schema_replace_param.json").read_text()
(V2_PRODUCT_DATA_DIR / "extraction" / "data_schema_replace_param.json").read_text()
)
expected_data_schema_str = json.dumps(
expected_data_schema_dict, indent=None, sort_keys=True
Expand Down
6 changes: 3 additions & 3 deletions tests/v2/input/test_local_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

from mindee import InferenceResponse
from mindee.input import LocalResponse
from tests.utils import V2_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.fixture
def file_path() -> Path:
return V2_DATA_DIR / "inference" / "standard_field_types.json"
return V2_PRODUCT_DATA_DIR / "extraction" / "standard_field_types.json"


def _assert_local_response(local_response):
fake_hmac_signing = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"
signature = "f390d9f7f57ac04f47b6309d8a40236b0182610804fc20e91b1f6028aaca07a7"
signature = "e51bdf80f1a08ed44ee161100fc30a25cb35b4ede671b0a575dc9064a3f5dbf1"

assert local_response._file is not None
assert not local_response.is_valid_hmac_signature(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mindee import ClientV2, PathInput
from mindee.v2 import ClassificationParameters, ClassificationResponse
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.fixture(scope="session")
Expand All @@ -24,7 +24,7 @@ def test_classification_default_sample(
v2_client: ClientV2, classification_model_id: str
):
input_source = PathInput(
V2_UTILITIES_DATA_DIR / "classification" / "default_invoice.jpg"
V2_PRODUCT_DATA_DIR / "classification" / "default_invoice.jpg"
)
response = v2_client.enqueue_and_get_result(
ClassificationResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
ClassificationResponse,
)
from mindee.v2.product.classification.classification_result import ClassificationResult
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.mark.v2
def test_classification_single():
input_inference = LocalResponse(
V2_UTILITIES_DATA_DIR / "classification" / "classification_single.json"
V2_PRODUCT_DATA_DIR / "classification" / "classification_single.json"
)
classification_response = input_inference.deserialize_response(
ClassificationResponse
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/product/crop/test_crop_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mindee import ClientV2, PathInput
from mindee.v2 import CropParameters, CropResponse
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.fixture(scope="session")
Expand All @@ -21,7 +21,7 @@ def v2_client() -> ClientV2:
@pytest.mark.integration
@pytest.mark.v2
def test_crop_default_sample(v2_client: ClientV2, crop_model_id: str):
input_source = PathInput(V2_UTILITIES_DATA_DIR / "crop" / "default_sample.jpg")
input_source = PathInput(V2_PRODUCT_DATA_DIR / "crop" / "default_sample.jpg")
response = v2_client.enqueue_and_get_result(
CropResponse, input_source, CropParameters(crop_model_id)
)
Expand Down
8 changes: 3 additions & 5 deletions tests/v2/product/crop/test_crop_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from mindee.v2.product.crop import CropInference
from mindee.v2.product.crop.crop_response import CropResponse
from mindee.v2.product.crop.crop_result import CropResult
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.mark.v2
def test_crop_single():
input_inference = LocalResponse(V2_UTILITIES_DATA_DIR / "crop" / "crop_single.json")
input_inference = LocalResponse(V2_PRODUCT_DATA_DIR / "crop" / "crop_single.json")
crop_response = input_inference.deserialize_response(CropResponse)
assert isinstance(crop_response.inference, CropInference)
assert crop_response.inference.result.crops
Expand All @@ -29,9 +29,7 @@ def test_crop_single():

@pytest.mark.v2
def test_crop_multiple():
input_inference = LocalResponse(
V2_UTILITIES_DATA_DIR / "crop" / "crop_multiple.json"
)
input_inference = LocalResponse(V2_PRODUCT_DATA_DIR / "crop" / "crop_multiple.json")
crop_response = input_inference.deserialize_response(CropResponse)
assert isinstance(crop_response.inference, CropInference)
assert isinstance(crop_response.inference.result, CropResult)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from mindee.parsing.v2.inference_file import InferenceFile
from mindee.parsing.v2.inference_model import InferenceModel
from mindee.parsing.v2.rag_metadata import RagMetadata
from tests.utils import V2_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


def _get_samples(json_path: Path, rst_path: Path) -> Tuple[dict, str]:
Expand All @@ -27,14 +27,14 @@ def _get_samples(json_path: Path, rst_path: Path) -> Tuple[dict, str]:


def _get_inference_samples(name: str) -> Tuple[dict, str]:
json_path = V2_DATA_DIR / "inference" / f"{name}.json"
rst_path = V2_DATA_DIR / "inference" / f"{name}.rst"
json_path = V2_PRODUCT_DATA_DIR / "extraction" / f"{name}.json"
rst_path = V2_PRODUCT_DATA_DIR / "extraction" / f"{name}.rst"
return _get_samples(json_path, rst_path)


def _get_product_samples(product, name: str) -> Tuple[dict, str]:
json_path = V2_DATA_DIR / "products" / product / f"{name}.json"
rst_path = V2_DATA_DIR / "products" / product / f"{name}.rst"
json_path = V2_PRODUCT_DATA_DIR / "extraction" / product / f"{name}.json"
rst_path = V2_PRODUCT_DATA_DIR / "extraction" / product / f"{name}.rst"
return _get_samples(json_path, rst_path)


Expand Down Expand Up @@ -299,7 +299,9 @@ def test_text_context_field_is_false() -> None:

@pytest.mark.v2
def test_text_context_field_is_true() -> None:
with open(V2_DATA_DIR / "inference" / "text_context_enabled.json", "r") as file:
with open(
V2_PRODUCT_DATA_DIR / "extraction" / "text_context_enabled.json", "r"
) as file:
json_sample = json.load(file)
response = InferenceResponse(json_sample)
assert isinstance(response.inference.active_options, InferenceActiveOptions)
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/product/ocr/test_ocr_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mindee import ClientV2, PathInput
from mindee.v2 import OCRParameters, OCRResponse
from mindee.v2.product.ocr import OCRInference, OCRResult
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.fixture(scope="session")
Expand All @@ -22,7 +22,7 @@ def v2_client() -> ClientV2:
@pytest.mark.integration
@pytest.mark.v2
def test_ocr_default_sample(v2_client: ClientV2, ocr_model_id: str):
input_source = PathInput(V2_UTILITIES_DATA_DIR / "ocr" / "default_sample.jpg")
input_source = PathInput(V2_PRODUCT_DATA_DIR / "ocr" / "default_sample.jpg")
response = v2_client.enqueue_and_get_result(
OCRResponse, input_source, OCRParameters(ocr_model_id)
)
Expand Down
6 changes: 3 additions & 3 deletions tests/v2/product/ocr/test_ocr_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from mindee.v2.product.ocr import OCRInference
from mindee.v2.product.ocr.ocr_response import OCRResponse
from mindee.v2.product.ocr.ocr_result import OCRResult
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.mark.v2
def test_ocr_single():
input_inference = LocalResponse(V2_UTILITIES_DATA_DIR / "ocr" / "ocr_single.json")
input_inference = LocalResponse(V2_PRODUCT_DATA_DIR / "ocr" / "ocr_single.json")
ocr_response = input_inference.deserialize_response(OCRResponse)
assert isinstance(ocr_response.inference, OCRInference)
assert ocr_response.inference.result.pages
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_ocr_single():

@pytest.mark.v2
def test_ocr_multiple():
input_inference = LocalResponse(V2_UTILITIES_DATA_DIR / "ocr" / "ocr_multiple.json")
input_inference = LocalResponse(V2_PRODUCT_DATA_DIR / "ocr" / "ocr_multiple.json")
ocr_response = input_inference.deserialize_response(OCRResponse)
assert isinstance(ocr_response.inference, OCRInference)
assert isinstance(ocr_response.inference.result, OCRResult)
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/product/split/test_split_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mindee import ClientV2, PathInput
from mindee.v2 import SplitParameters, SplitResponse
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.fixture(scope="session")
Expand All @@ -21,7 +21,7 @@ def v2_client() -> ClientV2:
@pytest.mark.integration
@pytest.mark.v2
def test_split_default_sample(v2_client: ClientV2, split_model_id: str):
input_source = PathInput(V2_UTILITIES_DATA_DIR / "split" / "default_sample.pdf")
input_source = PathInput(V2_PRODUCT_DATA_DIR / "split" / "default_sample.pdf")
response = v2_client.enqueue_and_get_result(
SplitResponse, input_source, SplitParameters(split_model_id)
)
Expand Down
8 changes: 3 additions & 5 deletions tests/v2/product/split/test_split_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
from mindee.v2.product.split import SplitInference
from mindee.v2.product.split.split_response import SplitResponse
from mindee.v2.product.split.split_result import SplitResult
from tests.utils import V2_UTILITIES_DATA_DIR
from tests.utils import V2_PRODUCT_DATA_DIR


@pytest.mark.v2
def test_split_single():
input_inference = LocalResponse(
V2_UTILITIES_DATA_DIR / "split" / "split_single.json"
)
input_inference = LocalResponse(V2_PRODUCT_DATA_DIR / "split" / "split_single.json")
split_response = input_inference.deserialize_response(SplitResponse)
assert isinstance(split_response.inference, SplitInference)
assert split_response.inference.result.splits
Expand All @@ -25,7 +23,7 @@ def test_split_single():
@pytest.mark.v2
def test_split_multiple():
input_inference = LocalResponse(
V2_UTILITIES_DATA_DIR / "split" / "split_multiple.json"
V2_PRODUCT_DATA_DIR / "split" / "split_multiple.json"
)
split_response = input_inference.deserialize_response(SplitResponse)
assert isinstance(split_response.inference, SplitInference)
Expand Down
18 changes: 13 additions & 5 deletions tests/v2/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mindee.parsing.v2.inference import Inference
from mindee.parsing.v2.job import Job
from mindee.parsing.v2.job_response import JobResponse
from tests.utils import FILE_TYPES_DIR, V2_DATA_DIR, dummy_envvars
from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR, V2_DATA_DIR, dummy_envvars


@pytest.fixture
Expand Down Expand Up @@ -57,7 +57,10 @@ class _FakeOkGetInferenceResp:

def json(self):
data_file = (
V2_DATA_DIR / "products" / "financial_document" / "complete.json"
V2_PRODUCT_DATA_DIR
/ "extraction"
/ "financial_document"
/ "complete.json"
)
with data_file.open("r", encoding="utf-8") as fh:
return json.load(fh)
Expand Down Expand Up @@ -141,7 +144,9 @@ def test_enqueue_and_parse_path_with_env_token(custom_base_url_client):
text_context="ignore this message",
data_schema=json.loads(
(
V2_DATA_DIR / "inference" / "data_schema_replace_param.json"
V2_PRODUCT_DATA_DIR
/ "extraction"
/ "data_schema_replace_param.json"
).read_text()
),
),
Expand All @@ -161,7 +166,7 @@ def _assert_findoc_inference(response: InferenceResponse):
@pytest.mark.v2
def test_loads_from_prediction():
input_inference = LocalResponse(
V2_DATA_DIR / "products" / "financial_document" / "complete.json"
V2_PRODUCT_DATA_DIR / "extraction" / "financial_document" / "complete.json"
)
response = input_inference.deserialize_response(InferenceResponse)
_assert_findoc_inference(response)
Expand All @@ -182,7 +187,10 @@ def test_error_handling(custom_base_url_client):
with pytest.raises(MindeeHTTPErrorV2) as e:
custom_base_url_client.enqueue(
PathInput(
V2_DATA_DIR / "products" / "financial_document" / "default_sample.jpg"
V2_PRODUCT_DATA_DIR
/ "extraction"
/ "financial_document"
/ "default_sample.jpg"
),
InferenceParameters("dummy-model"),
)
Expand Down
Loading
Loading