exb_sdk.workflow_client¶
Submodules¶
Attributes¶
Exceptions¶
Raised when an error occurs during an extraction. |
|
Raised when an HTTP unhandled error is returned by the app. |
|
Raised when the client is closed while extractions are running. |
|
Raised when a result is not found by the TestClient. |
Classes¶
A client for getting results of a given document. |
|
A client that can be used when writing tests. |
Package Contents¶
- class exb_sdk.workflow_client.Client[source]¶
A client for getting results of a given document.
- base_url¶
The base URL of the ExB app.
- customer_id¶
The customer ID of the solution.
- solution_id¶
The solution ID where the workflow exists.
- token¶
The API credential token used for authorization.
- dev_mode¶
When enabled allows to cache file upload and faster result polling. Useful during development when extracting results of the same file multiple times. Do not use when running this in production! Defaults to False.
- async __aexit__(exc_type, exc, tb)[source]¶
- Parameters:
exc_type (type[BaseException] | None)
exc (BaseException | None)
tb (types.TracebackType | None)
- Return type:
None
- async get_result(document_path)[source]¶
Run an extraction in the ExB for the given document and return its result.
- Parameters:
document_path (pathlib.Path) – The path of the document to be uploaded and extracted.
- Raises:
WaitForResultCancelledError – if the client gets closed while waiting for a result.
DocumentProcessingError – if the extraction failed.
HttpError – if any operation to upload or getting the result fails with an unexpected error.
- Returns:
The result of the extraction as a dictionary.
- Return type:
Result
- exb_sdk.workflow_client.Result¶
- exception exb_sdk.workflow_client.DocumentProcessingError[source]¶
Bases:
Exception
Raised when an error occurs during an extraction.
- message = 'Error processing document'¶
- exception exb_sdk.workflow_client.HttpError(message, response)[source]¶
Bases:
Exception
Raised when an HTTP unhandled error is returned by the app.
- Parameters:
message (str)
response (httpx.Response)
- response¶
- exception exb_sdk.workflow_client.WaitForResultCancelledError[source]¶
Bases:
Exception
Raised when the client is closed while extractions are running.
- message = 'Wait for result cancelled for document'¶
- exception exb_sdk.workflow_client.ResultNotFoundError(document_path)[source]¶
Bases:
Exception
Raised when a result is not found by the TestClient.
- Parameters:
document_path (pathlib.Path)
- message¶
- exb_sdk.workflow_client.Results¶
- class exb_sdk.workflow_client.TestClient[source]¶
Bases:
exb_sdk.workflow_client.client.Client
A client that can be used when writing tests.
>>> from exb_sdk.workflow_client import TestClient >>> workflow_client = TestClient.create(results={Path("mydoc.pdf"): {"documentId": "1234"}}) >>> await my_processing_function(workflow_client=workflow_client)
- __test__ = False¶
- results: Results¶
- classmethod create(results)[source]¶
Create a test client by configuring results.
This should be the only method used for creating a TestClient.
- Parameters:
results (Results) – A dictionary of document paths to their result.
- Returns:
A new TestClient instance.
- Return type:
Self
- async get_result(document_path)[source]¶
An overridden method for the test client not to make any external requests.
- Parameters:
document_path (pathlib.Path) – The path of the document to be uploaded and extracted.
- Raises:
ResultNotFoundError – if the document_path is not part of the pre-configured results.
- Returns:
The result of the pre-configured document as a dictionary.
- Return type:
exb_sdk.workflow_client.client.Result