Skip to content

♻️ update regression test sample + add quick accessor for LocalResponse #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 28, 2025
Merged
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 @@ -56,6 +56,6 @@ jobs:
with:
status: ${{ job.status }}
notify_when: "failure"
notification_title: "Integration test '{workflow}' is failing"
notification_title: "[Python] Integration test '{workflow}' is failing"
env:
SLACK_WEBHOOK_URL: ${{ secrets.PRODUCTION_ISSUES_SLACK_HOOK_URL }}
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,68 @@ for field_name, field_values in result.document.fields.items():
print(field_name, "=", field_values)
```

### Enqueue and Parse a Webhook Response
This is an optional way of handling asynchronous APIs.

```python

```

### Additional Options
Options to pass when sending a file.
```python
from mindee import Client, product
from mindee.client import LocalResponse

# Init a new client
mindee_client = Client()

# Load a file from disk
input_source = mindee_client.source_from_path("/path/to/the/file.ext")

# Parse the file

enqueue_response = mindee_client.enqueue(
product.InternationalIdV2,
input_source,
)

# You can keep track of the job's ID for traceability concerns.
job_id = enqueue_response.job.id


# Load the JSON string sent by the Mindee webhook POST callback.
# Reading the callback data will vary greatly depending on your HTTP server.
# This is therefore beyond the scope of this example.

local_response = LocalResponse(request.body())

# You can also load the json from a local path.
# local_response = LocalResponse("path/to/my/file.ext")

# Optional: verify the HMAC signature
if not local_response.is_valid_hmac_signature(my_secret_key, "some signature"):
raise Error("Invalid HMAC signature!")

# Deserialize the response

result = mindee_client.load_prediction(
product.InternationalIdV2,
local_response
)

# Print a full summary of the parsed data in RST format
print(result.document)
```


#### Page Options
Allows sending only certain pages in a PDF.

In this example we only send the first, penultimate and last pages:

```python
from mindee import Client, product, PageOptions
from mindee import product, PageOptions

result = mindee_client.parse(
product.InvoiceV4,
Expand Down
10 changes: 5 additions & 5 deletions docs/extras/guide/financial_document_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ print(result.document)
########
Document
########
:Mindee ID: b26161ce-35d0-4984-b1ff-886645e160e6
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
:Filename: default_sample.jpg
Inference
Expand All @@ -75,8 +75,8 @@ Prediction
:Document Number: INT-001
:Reference Numbers: 2412/2019
:Purchase Date: 2019-11-02
:Due Date: 2019-02-26
:Payment Date: 2019-02-26
:Due Date: 2019-11-17
:Payment Date: 2019-11-17
:Total Net: 195.00
:Total Amount: 204.75
:Taxes:
Expand Down Expand Up @@ -127,8 +127,8 @@ Page 0
:Document Number: INT-001
:Reference Numbers: 2412/2019
:Purchase Date: 2019-11-02
:Due Date: 2019-02-26
:Payment Date: 2019-02-26
:Due Date: 2019-11-17
:Payment Date: 2019-11-17
:Total Net: 195.00
:Total Amount: 204.75
:Taxes:
Expand Down
10 changes: 5 additions & 5 deletions docs/extras/guide/invoices_v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ print(result.document)
########
Document
########
:Mindee ID: a67b70ea-4b1e-4eac-ae75-dda47a7064ae
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
:Filename: default_sample.jpg
Inference
Expand All @@ -73,8 +73,8 @@ Prediction
:Purchase Order Number: AD29094
:Reference Numbers: AD29094
:Purchase Date: 2018-09-25
:Due Date: 2011-12-01
:Payment Date: 2011-12-01
:Due Date:
:Payment Date:
:Total Net: 2145.00
:Total Amount: 2608.20
:Total Tax: 193.20
Expand Down Expand Up @@ -119,8 +119,8 @@ Page 0
:Purchase Order Number: AD29094
:Reference Numbers: AD29094
:Purchase Date: 2018-09-25
:Due Date: 2011-12-01
:Payment Date: 2011-12-01
:Due Date:
:Payment Date:
:Total Net: 2145.00
:Total Amount: 2608.20
:Total Tax: 193.20
Expand Down
7 changes: 5 additions & 2 deletions mindee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from mindee import product
from mindee.client import Client, PageOptions
from mindee.client import Client
from mindee.input.local_response import LocalResponse
from mindee.input.page_options import PageOptions
from mindee.parsing.common.api_response import ApiResponse
from mindee.parsing.common.async_predict_response import AsyncPredictResponse, Job
from mindee.parsing.common.async_predict_response import AsyncPredictResponse
from mindee.parsing.common.feedback_response import FeedbackResponse
from mindee.parsing.common.job import Job
from mindee.parsing.common.predict_response import PredictResponse
from mindee.parsing.common.workflow_response import WorkflowResponse
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class IndianPassportV1Document(Prediction):
"""Passport - India API version 1.1 document data."""
"""Passport - India API version 1.2 document data."""

address1: StringField
"""The first line of the address of the passport holder."""
Expand Down
2 changes: 1 addition & 1 deletion tests/data
Loading