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.6.tar.gz (40.4 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.6-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uai_annotation_requests-0.4.6.tar.gz
Algorithm Hash digest
SHA256 d496899a1cb20dc8db724b5b50de99d83fa3483dc153faa9cd152d1c07a00429
MD5 c83ecf62e6dfdfdacb44e6feb97109d8
BLAKE2b-256 dbc28c4d4f0a0630a7df46b2956739ab05cc76e57450310020aee794719ba580

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uai_annotation_requests-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5efac5626389e938451e967c1cef87378df9c57b1dd628469082ace2483bfc1f
MD5 da8f82ec21d880a00af3e1aed0cc067e
BLAKE2b-256 680ab48742789c6819773ace00b93c9b9b321d2f8436e6e2616867fedef403e3

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