Skip to content

Commit 8532b65

Browse files
committed
✅ better tests of data schema
1 parent bd72dc6 commit 8532b65

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* :sparkles: add support for data schema replace on v2
77
* :coffin: remove unused feedback calls from CLI
88

9+
910
## v4.31.0 - 2025-11-04
1011
### Changes
1112
* :label: better field typing for v2

mindee/input/inference_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class InferenceParameters:
6666
Additional text context used by the model during inference.
6767
Not recommended, for specific use only.
6868
"""
69-
data_schema: Optional[DataSchema] = None
69+
data_schema: Optional[Union[DataSchema, str]] = None
7070
"""
7171
Dynamic changes to the data schema of the model for this inference.
7272
Not recommended, for specific use only.

mindee/parsing/v2/inference_active_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ def __str__(self) -> str:
6060
f"\n:Confidence: {self.confidence}"
6161
f"\n:RAG: {self.rag}"
6262
f"\n:Text Context: {self.text_context}"
63+
f"\n\n{self.data_schema}"
6364
)

tests/v2/test_client_integration.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
from mindee import ClientV2, InferenceParameters, PathInput, UrlInputSource
77
from mindee.error.mindee_http_error_v2 import MindeeHTTPErrorV2
88
from mindee.parsing.v2 import InferenceActiveOptions
9-
from mindee.input.inference_parameters import DataSchema
109
from mindee.parsing.v2.inference_response import InferenceResponse
11-
from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR
10+
from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR, V2_DATA_DIR
1211

1312

1413
@pytest.fixture(scope="session")
@@ -285,6 +284,9 @@ def test_data_schema_must_succeed(
285284
Load a blank PDF from an HTTPS URL and make sure the inference call completes without raising any errors.
286285
"""
287286
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"
287+
data_schema_replace_path = (
288+
V2_DATA_DIR / "inference" / "data_schema_replace_param.json"
289+
)
288290

289291
input_source = PathInput(input_path)
290292
params = InferenceParameters(
@@ -294,24 +296,13 @@ def test_data_schema_must_succeed(
294296
polygon=False,
295297
confidence=False,
296298
webhook_ids=[],
297-
data_schema=DataSchema(
298-
replace={
299-
"fields": [
300-
{
301-
"name": "test",
302-
"title": "Test",
303-
"is_array": False,
304-
"type": "string",
305-
"description": "A test field",
306-
}
307-
]
308-
}
309-
),
310-
alias="py_integration_data_schema_override",
299+
data_schema=data_schema_replace_path.read_text(),
300+
alias="py_integration_data_schema_replace",
311301
)
312302
response: InferenceResponse = v2_client.enqueue_and_get_inference(
313303
input_source, params
314304
)
315305
_basic_assert_success(response=response, page_count=1, model_id=findoc_model_id)
316306
assert response.inference.active_options.data_schema.replace is True
317-
assert response.inference.result.fields["test"] is not None
307+
assert response.inference.result.fields["test_replace"] is not None
308+
assert response.inference.result.fields["test_replace"].value == "a test value"

0 commit comments

Comments
 (0)