Skip to content

Commit 61ce795

Browse files
update data
1 parent 6c4b6d4 commit 61ce795

File tree

8 files changed

+36
-24
lines changed

8 files changed

+36
-24
lines changed

mindee/client_v2.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def enqueue(
6767
6868
:param input_source: The document/source file to use. Can be local or remote.
6969
:param params: Parameters to set when sending a file.
70-
:param slug: Slug for the endpoint.
7170
7271
:return: A valid inference response.
7372
"""
@@ -114,6 +113,27 @@ def get_inference(
114113
return self.get_result(inference_id, response_type)
115114

116115
def get_result(
116+
self,
117+
inference_id: str,
118+
response_type: Optional[Type[BaseResponse]] = InferenceResponse,
119+
) -> BaseResponse:
120+
"""
121+
Get the result of an inference that was previously enqueued.
122+
123+
The inference will only be available after it has finished processing.
124+
125+
:param inference_id: UUID of the inference to retrieve.
126+
:param response_type: Class of the product to instantiate.
127+
:return: An inference response.
128+
"""
129+
response_type = response_type or InferenceResponse
130+
response = self._get_result(inference_id, response_type)
131+
assert isinstance(response, response_type), (
132+
f'Invalid response type "{type(response)}"'
133+
)
134+
return response
135+
136+
def _get_result(
117137
self,
118138
inference_id: str,
119139
response_type: Type[BaseResponse] = InferenceResponse,

mindee/input/base_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BaseParameters(ABC):
2323
close_file: bool = True
2424
"""Whether to close the file after product."""
2525

26-
def get_config(self) -> Dict[str, Union[str, List[str]]]:
26+
def get_form_data(self) -> Dict[str, Union[str, List[str]]]:
2727
"""
2828
Return the parameters as a config dictionary.
2929

mindee/input/inference_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ def __post_init__(self):
112112
elif isinstance(self.data_schema, dict):
113113
self.data_schema = DataSchema(**self.data_schema)
114114

115-
def get_config(self) -> Dict[str, Union[str, List[str]]]:
115+
def get_form_data(self) -> Dict[str, Union[str, List[str]]]:
116116
"""
117117
Return the parameters as a config dictionary.
118118
119119
:return: A dict of parameters.
120120
"""
121-
data = super().get_config()
121+
data = super().get_form_data()
122122
if self.data_schema is not None:
123123
data["data_schema"] = str(self.data_schema)
124124
if self.rag is not None:

mindee/mindee_http/mindee_api_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def req_post_inference_enqueue(
8484
:param slug: Slug to use for the enqueueing, defaults to 'inferences'.
8585
:return: requests response.
8686
"""
87-
data = params.get_config()
87+
data = params.get_form_data()
8888
url = f"{self.url_root}/{slug}/enqueue"
8989

9090
if isinstance(input_source, LocalInputSource):

tests/v2/parsing/test_split_integration.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from mindee import ClientV2, PathInput
66
from mindee.input import SplitParameters
77
from mindee.v2 import SplitResponse
8-
from tests.utils import V1_PRODUCT_DATA_DIR
8+
from tests.utils import V2_UTILITIES_DATA_DIR
99

1010

1111
@pytest.fixture(scope="session")
@@ -16,20 +16,13 @@ def split_model_id() -> str:
1616

1717
@pytest.fixture(scope="session")
1818
def v2_client() -> ClientV2:
19-
"""
20-
Real V2 client configured with the user-supplied API key
21-
(or skipped when the key is absent).
22-
"""
23-
api_key = os.getenv("MINDEE_V2_API_KEY")
24-
return ClientV2(api_key)
19+
return ClientV2()
2520

2621

2722
@pytest.mark.integration
2823
@pytest.mark.v2
2924
def test_split_blank(v2_client: ClientV2, split_model_id: str):
30-
input_source = PathInput(
31-
V1_PRODUCT_DATA_DIR / "invoice_splitter" / "default_sample.pdf"
32-
)
25+
input_source = PathInput(V2_UTILITIES_DATA_DIR / "split" / "default_sample.pdf")
3326
response = v2_client.enqueue_and_get_result(
3427
SplitResponse, input_source, SplitParameters(split_model_id)
3528
) # Note: do not use blank_1.pdf for this.

tests/v2/parsing/test_split_response.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
@pytest.mark.v2
1212
def test_split_single():
13-
input_inference = LocalResponse(V2_UTILITIES_DATA_DIR / "split_single.json")
13+
input_inference = LocalResponse(
14+
V2_UTILITIES_DATA_DIR / "split" / "split_single.json"
15+
)
1416
split_response = input_inference.deserialize_response(SplitResponse)
1517
assert isinstance(split_response.inference, SplitInference)
1618
assert split_response.inference.result.splits
@@ -22,7 +24,9 @@ def test_split_single():
2224

2325
@pytest.mark.v2
2426
def test_split_multiple():
25-
input_inference = LocalResponse(V2_UTILITIES_DATA_DIR / "split_multiple.json")
27+
input_inference = LocalResponse(
28+
V2_UTILITIES_DATA_DIR / "split" / "split_multiple.json"
29+
)
2630
split_response = input_inference.deserialize_response(SplitResponse)
2731
assert isinstance(split_response.inference, SplitInference)
2832
assert isinstance(split_response.inference.result, SplitResult)

tests/v2/test_client_integration.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ def findoc_model_id() -> str:
1818

1919
@pytest.fixture(scope="session")
2020
def v2_client() -> ClientV2:
21-
"""
22-
Real V2 client configured with the user-supplied API key
23-
(or skipped when the key is absent).
24-
"""
25-
api_key = os.getenv("MINDEE_V2_API_KEY")
26-
return ClientV2(api_key)
21+
return ClientV2()
2722

2823

2924
def _basic_assert_success(

0 commit comments

Comments
 (0)