Skip to content
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/docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Publish Documentation to GitHub pages.
#
name: Documentation
name: Publish Documentation

on:
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.py') }}
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-lic-

Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/test-code-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test Code Samples

on:
pull_request:
schedule:
- cron: '0 0 * * *'

# Allow running this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
name: Run Tests
timeout-minutes: 30
strategy:
matrix:
python-version:
- "3.7"
- "3.11"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-samples-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-samples-

- name: Install dependencies
run: |
python -m pip install pip
pip install -e .

- name: Tests code samples
run: |
./tests/test_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-test-${{ hashFiles('**/setup.py') }}
key: ${{ runner.os }}-test-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-test-

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ dmypy.json
# Temp files
*.swp
*-swp
_test.py
13 changes: 13 additions & 0 deletions docs/extras/code_samples/cropper_v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from mindee import Client, documents

# Init a new client
mindee_client = Client(api_key="my-api-key")

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

# Parse the Cropper by passing the appropriate type
result = input_doc.parse(documents.TypeCropperV1)

# Print a brief summary of the parsed data
print(result.document)
2 changes: 1 addition & 1 deletion docs/extras/code_samples/custom_v1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mindee_client = Client(api_key="my-api-key").add_endpoint(
)

# Load a file from disk and parse it.
# The endpoint name must be specified since it can't be determined from the class.
# The endpoint name must be specified since it cannot be determined from the class.
result = mindee_client.doc_from_path(
"/path/to/the/file.ext"
).parse(documents.TypeCustomV1, endpoint_name="my-endpoint")
Expand Down
10 changes: 10 additions & 0 deletions docs/predictions/standard/documents/cropper_v1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Cropper V1
----------

**Sample Code:**

.. literalinclude:: /extras/code_samples/cropper_v1.txt
:language: Python

.. autoclass:: mindee.documents.CropperV1
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ License Plate V1

**Sample Code:**

.. literalinclude:: /extras/code_samples/license_plate_v1.txt
.. literalinclude:: /extras/code_samples/license_plates_v1.txt
:language: Python

.. autoclass:: mindee.documents.eu.LicensePlateV1
Expand Down
2 changes: 1 addition & 1 deletion docs/predictions/standard/documents/fr/id_card_v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Carte Nationale d'Identité V1

**Sample Code:**

.. literalinclude:: /extras/code_samples/id_card_v1.txt
.. literalinclude:: /extras/code_samples/idcard_fr_v1.txt
:language: Python

.. autoclass:: mindee.documents.fr.IdCardV1
Expand Down
2 changes: 1 addition & 1 deletion docs/predictions/standard/documents/invoice_v3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Invoice V3

**Sample Code:**

.. literalinclude:: /extras/code_samples/invoice_v3.txt
.. literalinclude:: /extras/code_samples/invoices_v3.txt
:language: Python

.. autoclass:: mindee.documents.InvoiceV3
Expand Down
2 changes: 1 addition & 1 deletion docs/predictions/standard/documents/invoice_v4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Invoice V4

**Sample Code:**

.. literalinclude:: /extras/code_samples/invoice_v4.txt
.. literalinclude:: /extras/code_samples/invoices_v4.txt
:language: Python

.. autoclass:: mindee.documents.InvoiceV4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Shipping Container V1

**Sample Code:**

.. literalinclude:: /extras/code_samples/shipping_container_v1.txt
.. literalinclude:: /extras/code_samples/shipping_containers_v1.txt
:language: Python

.. autoclass:: mindee.documents.ShippingContainerV1
Expand Down
1 change: 1 addition & 0 deletions docs/predictions/standard/international.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ International
.. include:: ./documents/passport_v1.rst
.. include:: ./documents/shipping_container_v1.rst
.. include:: ./documents/proof_of_address_v1.rst
.. include:: ./documents/cropper_v1.rst
26 changes: 26 additions & 0 deletions tests/test_code_samples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! /bin/sh
set -e

OUTPUT_FILE='./_test.py'
ACCOUNT=$1
ENDPOINT=$2
API_KEY=$3

for f in $(find ./docs/extras/code_samples -maxdepth 1 -name "*.txt" | sort -h)
do
echo
echo "###############################################"
echo "${f}"
echo "###############################################"
echo

sed "s/my-api-key/${API_KEY}/" "$f" > $OUTPUT_FILE
sed -i 's/\/path\/to\/the\/file.ext/.\/tests\/data\/pdf\/blank_1.pdf/' $OUTPUT_FILE

if echo "$f" | grep -q "custom_v1.txt"
then
sed -i "s/my-account/$ACCOUNT/g" $OUTPUT_FILE
sed -i "s/my-endpoint/$ENDPOINT/g" $OUTPUT_FILE
fi
python $OUTPUT_FILE
done