# Annotation Tasks

## Update or assign annotation tasks in bulk

`annotation_tasks.batch_update(AnnotationTaskBatchUpdateParams**kwargs)  -> AnnotationTaskBatchUpdateResponse`

**patch** `/v5/annotation-tasks/batch`

Update many annotation tasks in one request, operating in one of two mutually exclusive modes.

In ids mode, provide a list of task IDs together with an `assigned_to` and/or a `status`
(limited to `pending_redo` or `completed`) to apply those field changes to each listed task;
only tasks that currently exist are affected and IDs that do not resolve are silently skipped.
In audit_assignment mode, provide an evaluation ID, queue ID, and evaluation item IDs to assign
Level 1 and/or Level 2 auditors for those items, creating the underlying audit tasks when they do
not yet exist; a Level 2 auditor cannot be assigned unless a Level 1 auditor is already present.
Exactly one of `ids` or `audit_assignment` must be supplied, and `assigned_to`/`status` are only
valid in ids mode. Access and state checks run before any write, so the request is rejected as a
whole with nothing persisted if any task is inaccessible, if a status change is attempted without
a modification role, or if an already-completed task would be reassigned; audit assignment also
requires a modification role. Reassigning a task to a new user emits a task-start lineage event,
and the response returns the affected annotation tasks.

### Parameters

- `assigned_to: Optional[str]`

- `audit_assignment: Optional[AuditAssignment]`

  - `evaluation_id: str`

  - `evaluation_item_ids: Sequence[str]`

  - `queue_id: str`

  - `level_1_assigned_to: Optional[str]`

  - `level_2_assigned_to: Optional[str]`

- `ids: Optional[Sequence[str]]`

- `status: Optional[Literal["PENDING_REDO", "COMPLETED"]]`

  - `"PENDING_REDO"`

  - `"COMPLETED"`

### Returns

- `class AnnotationTaskBatchUpdateResponse: …`

  - `items: List[AnnotationTask]`

    - `id: str`

    - `evaluation_id: str`

    - `evaluation_item_id: str`

    - `priority: int`

    - `queue_id: str`

    - `status: Literal["NOT_READY", "PENDING", "PENDING_REDO", 2 more]`

      - `"NOT_READY"`

      - `"PENDING"`

      - `"PENDING_REDO"`

      - `"COMPLETED"`

      - `"FIXED"`

    - `task_type: Literal["EVALUATION_ANNOTATION", "EVALUATION_AUDIT", "CONTRIBUTOR_ANNOTATION", "CONTRIBUTOR_AUDIT"]`

      - `"EVALUATION_ANNOTATION"`

      - `"EVALUATION_AUDIT"`

      - `"CONTRIBUTOR_ANNOTATION"`

      - `"CONTRIBUTOR_AUDIT"`

    - `updated_at: datetime`

    - `assigned_to: Optional[str]`

    - `assignment_expires_at: Optional[datetime]`

    - `duration_seconds: Optional[int]`

    - `flagged_for_review: Optional[bool]`

    - `object: Optional[Literal["annotation_task"]]`

      - `"annotation_task"`

    - `review_comment: Optional[str]`

  - `object: Optional[Literal["list"]]`

    - `"list"`

### Example

```python
import os
from scale_gp_beta import SGPClient

client = SGPClient(
    api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
)
response = client.annotation_tasks.batch_update()
print(response.items)
```

#### Response

```json
{
  "items": [
    {
      "id": "id",
      "evaluation_id": "evaluation_id",
      "evaluation_item_id": "evaluation_item_id",
      "priority": 0,
      "queue_id": "queue_id",
      "status": "NOT_READY",
      "task_type": "EVALUATION_ANNOTATION",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "assigned_to": "assigned_to",
      "assignment_expires_at": "2019-12-27T18:11:19.117Z",
      "duration_seconds": 0,
      "flagged_for_review": true,
      "object": "annotation_task",
      "review_comment": "review_comment"
    }
  ],
  "object": "list"
}
```

## Domain Types

### Annotation Task

- `class AnnotationTask: …`

  - `id: str`

  - `evaluation_id: str`

  - `evaluation_item_id: str`

  - `priority: int`

  - `queue_id: str`

  - `status: Literal["NOT_READY", "PENDING", "PENDING_REDO", 2 more]`

    - `"NOT_READY"`

    - `"PENDING"`

    - `"PENDING_REDO"`

    - `"COMPLETED"`

    - `"FIXED"`

  - `task_type: Literal["EVALUATION_ANNOTATION", "EVALUATION_AUDIT", "CONTRIBUTOR_ANNOTATION", "CONTRIBUTOR_AUDIT"]`

    - `"EVALUATION_ANNOTATION"`

    - `"EVALUATION_AUDIT"`

    - `"CONTRIBUTOR_ANNOTATION"`

    - `"CONTRIBUTOR_AUDIT"`

  - `updated_at: datetime`

  - `assigned_to: Optional[str]`

  - `assignment_expires_at: Optional[datetime]`

  - `duration_seconds: Optional[int]`

  - `flagged_for_review: Optional[bool]`

  - `object: Optional[Literal["annotation_task"]]`

    - `"annotation_task"`

  - `review_comment: Optional[str]`

### Annotation Task Batch Update Response

- `class AnnotationTaskBatchUpdateResponse: …`

  - `items: List[AnnotationTask]`

    - `id: str`

    - `evaluation_id: str`

    - `evaluation_item_id: str`

    - `priority: int`

    - `queue_id: str`

    - `status: Literal["NOT_READY", "PENDING", "PENDING_REDO", 2 more]`

      - `"NOT_READY"`

      - `"PENDING"`

      - `"PENDING_REDO"`

      - `"COMPLETED"`

      - `"FIXED"`

    - `task_type: Literal["EVALUATION_ANNOTATION", "EVALUATION_AUDIT", "CONTRIBUTOR_ANNOTATION", "CONTRIBUTOR_AUDIT"]`

      - `"EVALUATION_ANNOTATION"`

      - `"EVALUATION_AUDIT"`

      - `"CONTRIBUTOR_ANNOTATION"`

      - `"CONTRIBUTOR_AUDIT"`

    - `updated_at: datetime`

    - `assigned_to: Optional[str]`

    - `assignment_expires_at: Optional[datetime]`

    - `duration_seconds: Optional[int]`

    - `flagged_for_review: Optional[bool]`

    - `object: Optional[Literal["annotation_task"]]`

      - `"annotation_task"`

    - `review_comment: Optional[str]`

  - `object: Optional[Literal["list"]]`

    - `"list"`
