Skip to main content

Python client library for convenient usage of SAP Business Document Processing services

Project description

Python Client Library for the SAP AI Business Services: Document Classification and Document Information Extraction

REUSE status

This repository contains the source code of a Python client library to facilitate the use of the SAP AI Business Services: Document Classification and Document Information Extraction. The client library provides two API Client classes that contain convenient methods to access these services and issue calls to the Document Classification REST API and Document Information Extraction REST API respectively. To use the library you need to have access to SAP Business Technology Platform.

Check out the usage examples, they are very useful to get started with the services.

Have a look at API documentation in order to use the library.

Notes for users of the sap-document-classification-client library

This library includes all the capabilities of the sap-document-classification-client, which will not be developed further. However, the code is still available here. If you want to switch to this library, you have to be aware of the following changes:

  • The DCApiClient can now be imported directly from the top module via: from sap_business_document_processing import DCApiClient
  • The functions classifiy_documents, upload_documents_to_dataset, upload_documents_directory_to_dataset now return an iterator instead of a list. You can either analyze individual results using with result = next(iterator) within a try-catch block (e.g. to handle each failed document) or use results = list(iterator) to turn it to a list. The latter will raise an error if at least one document failed.
  • The function get_datasets_info now returns a list which is the "dataset" part of the API response json. (You just need to delete the ["dataset"] from the response to work with it as until now)
  • The function get_classification_documents_info now returns a list which is the "results" part of the API response json.
  • The function get_training_models_info now returns a list which is the "models" part of the API response json.
  • The function get_deployed_models_info now returns a list which is the "deployments" part of the API response json.
  • The library now raises the following custom exceptions:
    • BDPApiException: Base exception for all exceptions of this library. Raise when no other exception is applicable.
    • BDPClientException: Raised when an HTTP response with status code between 400 and 500 is returned. Usually means incorrect user input. (Replaces some HTTPErrors)
    • BDPServerException: Raised when an HTTP response with status code between 500 and 600 is returned. Usually means that the server had some internal error. (Replaces some HTTPErrors)
    • BDPUnauthorizedException: Raised when an HTTP response with status code 401 is returned. Usually means that a wrong OAuth credentials were provided.
    • BDPFailedAsynchronousOperationException: Raised when an asynchronous job failed during processing. (Replaces FailedCallException)
    • BDPPollingTimeoutException: Raised when an asynchronous job exceeds the set polling_max_attempts. (Replaces PollingTimeoutException)
  • The function _poll_for_url now doesn`t expect an 'url' and 'payload' parameters, but 'path' and 'json' parameters instead.

Requirements

This library requires properly setup Python 3.6 (or higher version) environment.

Download and Installation

This Python library should be consumed in the standard way by running

pip install sap-business-document-processing

or adding the library as a dependency of your code in requirements.txt file.

Demo usage

Prerequisites:

Document Classification

To try out the Document classification service using the document classification client library you can also run the two demo links below:

  • Try out classification using default model demo
  • Try out training and classification using custom model demo (requires an enterprise account, trial account is not sufficient)

Document Information Extraction

Try out the Document Information Extraction service with this showcase

Known Issues

Please see the issues section.

How to obtain support

In case you would like to contribute to this project, ask any questions or get support, please open an issue containing the description of your question or planned contribution in GitHub and we will get in touch.

Licensing

Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file sap-business-document-processing-0.2.0.tar.gz.

File metadata

  • Download URL: sap-business-document-processing-0.2.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for sap-business-document-processing-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1a808f2b2e2cd31108889033c2300f09e520e516befded2753c23f5dff68447e
MD5 dd13f42bbbb90cde70e03c25d704d5d5
BLAKE2b-256 eea86f9aa6057e6fc1165839e9385063f38d0e49291b05e3b2ac61256aff2cea

See more details on using hashes here.

File details

Details for the file sap_business_document_processing-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sap_business_document_processing-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for sap_business_document_processing-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8198648b506405257b84c32a40fbe2ed837afd02f05c9c886e6943eec0ce2218
MD5 bf32368998c880d523c3e7bceab79251
BLAKE2b-256 12c347c08a2d53e9a9a9b64bf5160b7a113509e78609f6972e204163ce73ae71

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page