From eb0a9c59d5ce102bd76e3a37ec009c97811d0bb6 Mon Sep 17 00:00:00 2001 From: Sebastian Olivera Date: Fri, 23 Jun 2023 18:05:37 +0200 Subject: [PATCH] :coffin: removed Shipping Container --- .../code_samples/shipping_containers_v1.txt | 13 ---- .../documents/shipping_container_v1.rst | 10 --- docs/predictions/standard/international.rst | 1 - mindee/cli.py | 4 -- mindee/client.py | 5 -- mindee/documents/__init__.py | 4 -- .../documents/shipping_container/__init__.py | 1 - .../shipping_container_v1.py | 71 ------------------- tests/documents/test_shipping_container_v1.py | 44 ------------ 9 files changed, 153 deletions(-) delete mode 100644 docs/extras/code_samples/shipping_containers_v1.txt delete mode 100644 docs/predictions/standard/documents/shipping_container_v1.rst delete mode 100644 mindee/documents/shipping_container/__init__.py delete mode 100644 mindee/documents/shipping_container/shipping_container_v1.py delete mode 100644 tests/documents/test_shipping_container_v1.py diff --git a/docs/extras/code_samples/shipping_containers_v1.txt b/docs/extras/code_samples/shipping_containers_v1.txt deleted file mode 100644 index c48eec03..00000000 --- a/docs/extras/code_samples/shipping_containers_v1.txt +++ /dev/null @@ -1,13 +0,0 @@ -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 Shipping Container by passing the appropriate type -result = input_doc.parse(documents.TypeShippingContainerV1) - -# Print a brief summary of the parsed data -print(result.document) diff --git a/docs/predictions/standard/documents/shipping_container_v1.rst b/docs/predictions/standard/documents/shipping_container_v1.rst deleted file mode 100644 index 84467f20..00000000 --- a/docs/predictions/standard/documents/shipping_container_v1.rst +++ /dev/null @@ -1,10 +0,0 @@ -Shipping Container V1 ---------------------- - -**Sample Code:** - -.. literalinclude:: /extras/code_samples/shipping_containers_v1.txt - :language: Python - -.. autoclass:: mindee.documents.ShippingContainerV1 - :members: diff --git a/docs/predictions/standard/international.rst b/docs/predictions/standard/international.rst index 093d22be..c75f392b 100644 --- a/docs/predictions/standard/international.rst +++ b/docs/predictions/standard/international.rst @@ -8,7 +8,6 @@ International .. include:: ./documents/receipt_v5.rst .. include:: ./documents/financial_document_v1.rst .. include:: ./documents/passport_v1.rst -.. include:: ./documents/shipping_container_v1.rst .. include:: ./documents/invoice_splitter_v1.rst .. include:: ./documents/proof_of_address_v1.rst .. include:: ./documents/cropper_v1.rst diff --git a/mindee/cli.py b/mindee/cli.py index 7436d422..db092a75 100644 --- a/mindee/cli.py +++ b/mindee/cli.py @@ -47,10 +47,6 @@ class CommandConfig(Generic[TypeDoc]): help="Proof of Address", doc_class=documents.TypeProofOfAddressV1, ), - "shipping-container": CommandConfig( - help="Shipping Container", - doc_class=documents.fr.TypeIdCardV1, - ), "us-bank-check": CommandConfig( help="US Bank Check", doc_class=documents.us.TypeBankCheckV1, diff --git a/mindee/client.py b/mindee/client.py index d483f290..98532233 100644 --- a/mindee/client.py +++ b/mindee/client.py @@ -444,11 +444,6 @@ def _init_default_endpoints(self) -> None: url_name="bank_account_details", version="1", ), - ConfigSpec( - doc_class=documents.ShippingContainerV1, - url_name="shipping_containers", - version="1", - ), ConfigSpec( doc_class=documents.eu.LicensePlateV1, url_name="license_plates", diff --git a/mindee/documents/__init__.py b/mindee/documents/__init__.py index 6225dff9..c6568f99 100644 --- a/mindee/documents/__init__.py +++ b/mindee/documents/__init__.py @@ -25,7 +25,3 @@ TypeReceiptV4, TypeReceiptV5, ) -from mindee.documents.shipping_container import ( - ShippingContainerV1, - TypeShippingContainerV1, -) diff --git a/mindee/documents/shipping_container/__init__.py b/mindee/documents/shipping_container/__init__.py deleted file mode 100644 index 22b0fdee..00000000 --- a/mindee/documents/shipping_container/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .shipping_container_v1 import ShippingContainerV1, TypeShippingContainerV1 diff --git a/mindee/documents/shipping_container/shipping_container_v1.py b/mindee/documents/shipping_container/shipping_container_v1.py deleted file mode 100644 index b164cdf5..00000000 --- a/mindee/documents/shipping_container/shipping_container_v1.py +++ /dev/null @@ -1,71 +0,0 @@ -from typing import Optional, TypeVar - -from mindee.documents.base import Document, TypeApiPrediction, clean_out_string -from mindee.fields.text import TextField - - -class ShippingContainerV1(Document): - """Shipping Container v1 prediction results.""" - - owner: TextField - """The ISO-6346 code for container owner and equipment identifier.""" - serial_number: TextField - """ISO-6346 code for container serial number.""" - size_type: TextField - """ISO 6346 code for container length, height and type.""" - - def __init__( - self, - api_prediction=None, - input_source=None, - page_n: Optional[int] = None, - ): - """ - Shipping Container v1 prediction results. - - :param api_prediction: Raw prediction from HTTP response - :param input_source: Input object - :param page_n: Page number for multi pages pdf input - """ - super().__init__( - input_source=input_source, - document_type="shipping_container", - api_prediction=api_prediction, - page_n=page_n, - ) - self._build_from_api_prediction(api_prediction["prediction"], page_n=page_n) - - def _build_from_api_prediction( - self, api_prediction: TypeApiPrediction, page_n: Optional[int] = None - ) -> None: - """ - Build the object from the prediction API JSON. - - :param api_prediction: Raw prediction from HTTP response - :param page_n: Page number - """ - self.owner = TextField( - api_prediction["owner"], - page_id=page_n, - ) - self.serial_number = TextField( - api_prediction["serial_number"], - page_id=page_n, - ) - self.size_type = TextField( - api_prediction["size_type"], - page_id=page_n, - ) - - def __str__(self) -> str: - return clean_out_string( - "----- Shipping Container V1 -----\n" - f"Filename: {self.filename or ''}\n" - f"Owner: { self.owner }\n" - f"Serial Number: { self.serial_number }\n" - f"Size and Type: { self.size_type }\n" - "----------------------" - ) - - -TypeShippingContainerV1 = TypeVar("TypeShippingContainerV1", bound=ShippingContainerV1) diff --git a/tests/documents/test_shipping_container_v1.py b/tests/documents/test_shipping_container_v1.py deleted file mode 100644 index f37825cc..00000000 --- a/tests/documents/test_shipping_container_v1.py +++ /dev/null @@ -1,44 +0,0 @@ -import json - -import pytest - -from mindee.documents import ShippingContainerV1 - -SHIPPING_CONTAINER_DATA_DIR = "./tests/data/shipping_container" - -FILE_PATH_SHIPPING_CONTAINER_V1_COMPLETE = ( - f"{ SHIPPING_CONTAINER_DATA_DIR }/response_v1/complete.json" -) -FILE_PATH_SHIPPING_CONTAINER_V1_EMPTY = ( - f"{ SHIPPING_CONTAINER_DATA_DIR }/response_v1/empty.json" -) - - -@pytest.fixture -def shipping_container_v1_doc() -> ShippingContainerV1: - json_data = json.load(open(FILE_PATH_SHIPPING_CONTAINER_V1_COMPLETE)) - return ShippingContainerV1(json_data["document"]["inference"], page_n=None) - - -@pytest.fixture -def shipping_container_v1_doc_empty() -> ShippingContainerV1: - json_data = json.load(open(FILE_PATH_SHIPPING_CONTAINER_V1_EMPTY)) - return ShippingContainerV1(json_data["document"]["inference"], page_n=None) - - -@pytest.fixture -def shipping_container_v1_page0(): - json_data = json.load(open(FILE_PATH_SHIPPING_CONTAINER_V1_COMPLETE)) - return ShippingContainerV1(json_data["document"]["inference"]["pages"][0], page_n=0) - - -def test_doc_constructor(shipping_container_v1_doc): - file_path = f"{ SHIPPING_CONTAINER_DATA_DIR }/response_v1/doc_to_string.txt" - reference_str = open(file_path, "r", encoding="utf-8").read().strip() - assert str(shipping_container_v1_doc) == reference_str - - -def test_page0_constructor(shipping_container_v1_page0): - file_path = f"{ SHIPPING_CONTAINER_DATA_DIR }/response_v1/page0_to_string.txt" - reference_str = open(file_path, "r", encoding="utf-8").read().strip() - assert str(shipping_container_v1_page0) == reference_str