Skip to content
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

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

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 }}
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,65 @@ 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.string)
sebastianMindee marked this conversation as resolved.
Show resolved Hide resolved

# 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
33 changes: 1 addition & 32 deletions docs/extras/guide/driver_license_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ parentDoc: 609808f773b0b90051d839de
---
The Python OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/driver_license).

Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg) can be used for testing purposes.
![Driver License sample](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg?raw=true)

# Quick-Start
Expand All @@ -29,37 +29,6 @@ result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
print(result.document)

```

**Output (RST):**
```rst
########
Document
########
:Mindee ID: fbdeae38-ada3-43ac-aa58-e01a3d47e474
:Filename: default_sample.jpg

Inference
#########
:Product: mindee/driver_license v1.0
:Rotation applied: Yes

Prediction
==========
:Country Code: USA
:State: AZ
:ID: D12345678
:Category: D
:Last Name: Sample
:First Name: Jelani
:Date of Birth: 1957-02-01
:Place of Birth:
:Expiry Date: 2018-02-01
:Issued Date: 2013-01-10
:Issuing Authority:
:MRZ:
:DD Number: DD1234567890123456
```

# Field Types
## Standard Fields
These fields are generic and used in several products.
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