Skip to content

sift_client.resources.annotations

CLASS DESCRIPTION
AnnotationLogsAPIAsync

High-level API for an annotation's history.

AnnotationsAPIAsync

High-level API for interacting with annotations.

ATTRIBUTE DESCRIPTION
BATCH_LIMIT

Annotations per call to BatchArchiveAnnotations, per the service.

BATCH_LIMIT module-attribute

BATCH_LIMIT = 1000

Annotations per call to BatchArchiveAnnotations, per the service.

AnnotationLogsAPIAsync

AnnotationLogsAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for an annotation's history.

Each log records one event: an assignment, a state change, or a comment. Reachable as client.annotations.logs.

Initialize the AnnotationLogsAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
list_

List annotation logs.

add_comment

Add a comment to an annotation.

ATTRIBUTE DESCRIPTION
client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

list_ async

list_(
    *,
    annotation: str | Annotation,
    annotation_logs: list[str | AnnotationLog]
    | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    modified_after: datetime | None = None,
    modified_before: datetime | None = None,
    created_by: Any | str | None = None,
    kind: AnnotationLogKind | None = None,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[AnnotationLog]

List annotation logs.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID whose history to list.

TYPE: str | Annotation

annotation_logs

Filter to these AnnotationLogs or log IDs.

TYPE: list[str | AnnotationLog] | None DEFAULT: None

created_after

Filter logs created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter logs created before this datetime.

TYPE: datetime | None DEFAULT: None

modified_after

Filter logs modified after this datetime.

TYPE: datetime | None DEFAULT: None

modified_before

Filter logs modified before this datetime.

TYPE: datetime | None DEFAULT: None

created_by

Filter logs created by this user ID.

TYPE: Any | str | None DEFAULT: None

kind

Filter to comments, state updates, or assignments.

TYPE: AnnotationLogKind | None DEFAULT: None

filter_query

Explicit CEL query to filter logs.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by.

TYPE: str | None DEFAULT: None

limit

Maximum number of logs to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

page_size

Number of results to fetch per request.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[AnnotationLog]

A list of AnnotationLog objects that match the filter criteria.

add_comment async

add_comment(
    annotation: str | Annotation,
    text: str | list[AnnotationCommentElement],
) -> AnnotationLog

Add a comment to an annotation.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID to comment on.

TYPE: str | Annotation

text

Plain text, or a list of elements to mix text with user mentions.

TYPE: str | list[AnnotationCommentElement]

RETURNS DESCRIPTION
AnnotationLog

The created AnnotationLog.

AnnotationsAPIAsync

AnnotationsAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for interacting with annotations.

An annotation marks a time range on one or more assets. A data review annotation carries a review state and an assignee. A phase annotation marks a segment of a run and carries no state.

Initialize the AnnotationsAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
get

Get an Annotation.

list_

List annotations.

find

Find one annotation. Takes the same arguments as list_.

create

Create an annotation.

update

Update an Annotation.

archive

Archive an annotation.

unarchive

Unarchive an annotation.

batch_archive

Archive many annotations, one call per BATCH_LIMIT of them.

batch_unarchive

Unarchive many annotations, one call per BATCH_LIMIT of them.

assign_to_user

Assign an annotation to a user for review.

set_accepted

Set the review state to Accepted.

set_failed

Set the review state to Failed.

set_open

Set the review state to Open.

ATTRIBUTE DESCRIPTION
logs

client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

logs instance-attribute

logs = AnnotationLogsAPIAsync(sift_client)

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

get async

get(*, annotation_id: str) -> Annotation

Get an Annotation.

PARAMETER DESCRIPTION
annotation_id

The ID of the annotation.

TYPE: str

RETURNS DESCRIPTION
Annotation

The Annotation.

list_ async

list_(
    *,
    name: str | Iterable[str] | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    annotation_ids: list[str] | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    modified_after: datetime | None = None,
    modified_before: datetime | None = None,
    created_by: Any | str | None = None,
    modified_by: Any | str | None = None,
    tags: list[str] | list[Tag] | None = None,
    metadata: dict[str, Any] | None = None,
    annotation_type: AnnotationType | None = None,
    state: AnnotationState | None = None,
    assigned_to: Any | str | None = None,
    pending: bool | None = None,
    assets: list[Asset] | list[str] | None = None,
    runs: list[Run] | list[str] | None = None,
    rules: list[str | Rule] | None = None,
    reports: list[str | Report] | None = None,
    start_time_after: datetime | None = None,
    start_time_before: datetime | None = None,
    end_time_after: datetime | None = None,
    end_time_before: datetime | None = None,
    description_contains: str | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[Annotation]

List annotations.

PARAMETER DESCRIPTION
name

Exact name, or any iterable of names to match against.

TYPE: str | Iterable[str] | None DEFAULT: None

name_contains

Partial name of the annotation.

TYPE: str | None DEFAULT: None

name_regex

Regular expression to filter annotations by name.

TYPE: str | Pattern | None DEFAULT: None

annotation_ids

Filter to annotations with any of these IDs.

TYPE: list[str] | None DEFAULT: None

created_after

Filter annotations created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter annotations created before this datetime.

TYPE: datetime | None DEFAULT: None

modified_after

Filter annotations modified after this datetime.

TYPE: datetime | None DEFAULT: None

modified_before

Filter annotations modified before this datetime.

TYPE: datetime | None DEFAULT: None

created_by

Filter annotations created by this user ID.

TYPE: Any | str | None DEFAULT: None

modified_by

Filter annotations last modified by this user ID.

TYPE: Any | str | None DEFAULT: None

tags

Filter annotations with any of these Tags or tag names.

TYPE: list[str] | list[Tag] | None DEFAULT: None

metadata

Filter annotations by metadata criteria.

TYPE: dict[str, Any] | None DEFAULT: None

annotation_type

Filter to DATA_REVIEW or PHASE annotations.

TYPE: AnnotationType | None DEFAULT: None

state

Filter to a review state.

TYPE: AnnotationState | None DEFAULT: None

assigned_to

Filter to annotations assigned to this user's name.

TYPE: Any | str | None DEFAULT: None

pending

Filter to annotations from an ongoing rule violation.

TYPE: bool | None DEFAULT: None

rules

Filter to annotations created by any of these Rules or rule IDs.

TYPE: list[str | Rule] | None DEFAULT: None

reports

Filter to annotations in any of these Reports or report IDs.

TYPE: list[str | Report] | None DEFAULT: None

assets

Filter annotations on any of these Assets or asset IDs.

TYPE: list[Asset] | list[str] | None DEFAULT: None

runs

Filter annotations on any of these Runs or run IDs.

TYPE: list[Run] | list[str] | None DEFAULT: None

start_time_after

Filter annotations that start after this datetime.

TYPE: datetime | None DEFAULT: None

start_time_before

Filter annotations that start before this datetime.

TYPE: datetime | None DEFAULT: None

end_time_after

Filter annotations that end after this datetime.

TYPE: datetime | None DEFAULT: None

end_time_before

Filter annotations that end before this datetime.

TYPE: datetime | None DEFAULT: None

description_contains

Partial description of the annotation.

TYPE: str | None DEFAULT: None

include_archived

If True, include archived annotations in results.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query to filter annotations.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by.

TYPE: str | None DEFAULT: None

limit

Maximum number of annotations to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

page_size

Number of results to fetch per request. Lower this if you hit gRPC message size limits on responses. If None, uses the server default.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[Annotation]

A list of Annotation objects that match the filter criteria.

find async

find(**kwargs) -> Annotation | None

Find one annotation. Takes the same arguments as list_.

Raises if more than one matches.

PARAMETER DESCRIPTION
**kwargs

Keyword arguments to pass to list_.

DEFAULT: {}

RETURNS DESCRIPTION
Annotation | None

The Annotation found or None.

create async

create(create: AnnotationCreateBase | dict) -> Annotation

Create an annotation.

Pass an AnnotationCreate for a data review or a PhaseCreate for a phase. A dict picks the model from its annotation_type, which may be a name or a number.

PARAMETER DESCRIPTION
create

The annotation definition. assets takes Assets or asset IDs, tags takes Tags or tag names.

TYPE: AnnotationCreateBase | dict

RETURNS DESCRIPTION
Annotation

The created Annotation.

update async

update(
    annotation: str | Annotation,
    update: AnnotationUpdate | dict,
) -> Annotation

Update an Annotation.

tags, linked_channels, and metadata are replaced, not merged.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID to update.

TYPE: str | Annotation

update

Updates to apply to the Annotation.

TYPE: AnnotationUpdate | dict

RETURNS DESCRIPTION
Annotation

The updated Annotation.

archive async

archive(annotation: str | Annotation) -> Annotation

Archive an annotation.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID to archive.

TYPE: str | Annotation

RETURNS DESCRIPTION
Annotation

The archived Annotation.

unarchive async

unarchive(annotation: str | Annotation) -> Annotation

Unarchive an annotation.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID to unarchive.

TYPE: str | Annotation

RETURNS DESCRIPTION
Annotation

The unarchived Annotation.

batch_archive async

batch_archive(
    annotations: list[str | Annotation],
) -> list[Annotation]

Archive many annotations, one call per BATCH_LIMIT of them.

PARAMETER DESCRIPTION
annotations

The Annotations or annotation IDs to archive.

TYPE: list[str | Annotation]

RETURNS DESCRIPTION
list[Annotation]

The archived Annotations.

batch_unarchive async

batch_unarchive(
    annotations: list[str | Annotation],
) -> list[Annotation]

Unarchive many annotations, one call per BATCH_LIMIT of them.

PARAMETER DESCRIPTION
annotations

The Annotations or annotation IDs to unarchive.

TYPE: list[str | Annotation]

RETURNS DESCRIPTION
list[Annotation]

The unarchived Annotations.

assign_to_user async

assign_to_user(
    annotation: str | Annotation, user: str | User
) -> Annotation

Assign an annotation to a user for review.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID to assign.

TYPE: str | Annotation

user

The User or user ID to assign to.

TYPE: str | User

RETURNS DESCRIPTION
Annotation

The updated Annotation.

set_accepted async

set_accepted(annotation: str | Annotation) -> Annotation

Set the review state to Accepted.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID.

TYPE: str | Annotation

RETURNS DESCRIPTION
Annotation

The updated Annotation.

set_failed async

set_failed(annotation: str | Annotation) -> Annotation

Set the review state to Failed.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID.

TYPE: str | Annotation

RETURNS DESCRIPTION
Annotation

The updated Annotation.

set_open async

set_open(annotation: str | Annotation) -> Annotation

Set the review state to Open.

PARAMETER DESCRIPTION
annotation

The Annotation or annotation ID.

TYPE: str | Annotation

RETURNS DESCRIPTION
Annotation

The updated Annotation.