Skip to main content

Understand.ai Python Client SDK for requesting annotations.

Project description

UAI Annotation Requests

Summary

UAI Annotation Requests: The API lets a client request annotations from UAI, track the progress of the work and fetch the result annotations.

Table of Contents

Example Usage

Example

Below is an example of how an annotation request with data can be submitted to UAI for annotation.

from uai_annotation_requests import UaiAnnotationRequests
from uai_annotation_requests_util import uai_oauth2, uai_upload_data

with UaiAnnotationRequests(
    uai_oauth2=uai_oauth2("<client_id>", "<client_secret>"),
) as uar_client:

    res = uar_client.annotation_request.create(project_id="<id>", clips=[
        {
            "clip_reference_id": "clip_reference_01",
            "display_name": "my first clip",
        },
    ], request_reference_id="request_reference_01", priority=0, display_name="my annotation request")

    # Handle response
    print(res)

    # Upload data directory for each defined clip
    # The upload step here is only relevant for projects
    # That are uploading archived data to UAI where no
    # bucket integration is configured.
    for clip in res.clips:
        uai_upload_data(res, clip, path_to_data)

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
uai_oauth2 oauth2 uai_oauth2 helper or OAuth2 token

To authenticate with the API the uai_oauth2 parameter must be set when initializing the SDK client instance. The uai_oauth2 parameter accepts either the uai_oauth2 helper login function or an OAuth2 token. For example:

from uai_annotation_requests import UaiAnnotationRequests
from uai_annotation_requests_util import uai_oauth2

with UaiAnnotationRequests(
    uai_oauth2=uai_oauth2(client_id="<UAI_CLIENT_ID>", client_secret="<UAI_CLIENT_SECRET>"),
) as uar_client:

    res = uar_client.annotation_request.create(project_id="<id>", clips=[
        {
            "clip_reference_id": "clip_reference_01",
            "display_name": "my first clip",
        },
    ], request_reference_id="request_reference_01", priority=0, display_name="my annotation request")

    # Handle response
    print(res)

Available Resources and Operations

Available methods

annotation_request

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.

By default, an API error will raise a models.APIError exception, which has the following properties:

Property Type Description
.status_code int The HTTP status code
.message str The error message
.raw_response httpx.Response The raw HTTP response
.body str The response content

When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the get_async method may raise the following exceptions:

Error Type Status Code Content Type
models.AnnotationRequestNotFoundDTO 404 application/json
models.APIError 4XX, 5XX */*

Example

import uai_annotation_requests
from uai_annotation_requests import UaiAnnotationRequests, models

with UaiAnnotationRequests(
    uai_oauth2="<YOUR_UAI_OAUTH2_HERE>",
) as uar_client:
    res = None
    try:

        res = uar_client.annotation_request.get(project_id="<id>", field=uai_annotation_requests.FilterField.REQUEST_REFERENCE_ID, value="<value>")

        # Handle response
        print(res)

    except models.AnnotationRequestNotFoundDTO as e:
        # handle e.data: models.AnnotationRequestNotFoundDTOData
        raise(e)
    except models.APIError as e:
        # handle exception
        raise(e)

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

uai_annotation_requests-0.4.4.tar.gz (38.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uai_annotation_requests-0.4.4-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

Details for the file uai_annotation_requests-0.4.4.tar.gz.

File metadata

  • Download URL: uai_annotation_requests-0.4.4.tar.gz
  • Upload date:
  • Size: 38.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.6.72+

File hashes

Hashes for uai_annotation_requests-0.4.4.tar.gz
Algorithm Hash digest
SHA256 21961749d124ae464f644297501209bfcd31829a6171d6fd8acbe3f6ee4ec4d3
MD5 514cde4445900f0aeb367f5a81243f05
BLAKE2b-256 4d5f51d2225590b186ed7679dac12c439ce07de88f45ddbaefe25c1dbc8fe986

See more details on using hashes here.

File details

Details for the file uai_annotation_requests-0.4.4-py3-none-any.whl.

File metadata

File hashes

Hashes for uai_annotation_requests-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 da2924d315efb92ad2346d8152009d15d24de5244b242ba5c46bc3e3c2f44ca4
MD5 95dd42fa2ff09705c1dc329ef68ac789
BLAKE2b-256 b78c0e8f3ba46c94c13dbc132ebcf5ed3c1923a8f273b8f934e119c678a8d689

See more details on using hashes here.

Supported by

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