# Datasets_RepairPoses

`POST /v1/accounts/{account}/datasets/{dataset}:repairPoses`

Adds and removes pose and jaw repairs of a handheld (UMI) upload's takes: each one interpolates one hand's position, rotation or jaw
over take frames, undoes ingest's fills there, or corrects a tracking
slip with a STEP from one frame to the take's end. The repairs are the
upload's `[[repairs]]` in meta/ingest.toml, a set keyed by take, hand,
target and frames; the call composes the new set over the published one
and starts one pose-only publication of the upload, as ResolvePoses
does: it rewrites the pose files from the recorded values, so edits never
stack, and older versions keep what they hold. Poll it as ResolvePoses'.
The same set as published answers no_op; the same request while it runs
answers that operation; a different one is FAILED_PRECONDITION until it
lands (reason `reingest_still_running`).

On a merged dataset the takes stay in their member uploads: the call
makes one pose-only publication per member whose takes it names, fenced
on the dataset's membership as a merged TCP move is, and answers each in
RepairPosesResponse.members. The entry, set and converted-pair checks
below cover every member before any is started; each member's own
admission (its pose files, a copy that left takes out, its head, another
re-ingest) then answers in its status while the others start. While a
member's publication can still land it holds Remove, versions and the
solver on the dataset, as a TCP move does.

FAILED_PRECONDITION unless the upload's (each named member's)
published state is a converted handheld pair with a pose file for
every take: a teleop, egocentric or unconverted upload, a mixture
and an upload merged into a dataset (repair through the merged
dataset) are refused. INVALID_ARGUMENT for a request of more than 200
adds or 200 removes, an entry on a cut piece
or another dataset's take, frames outside the
take, an interpolation that ends at the take's last frame, an add with
no take_identity, an add on a take with an open handheld_pose_late
finding unless the upload holds it already ("fix the pose timing
first"), a remove of an entry the upload does not hold (a remove
retried after it landed included), or a set the repair rules refuse
(overlaps, more than 200 entries): one refusal names the first ten
problems, by the request's `adds[i]` and `removes[i]`, and counts the
rest. ABORTED when every problem is an add whose take_identity is not the
take's any more ("the take was re-processed since it was read"), or when
the published head moved after this call read it: read again.

A STEP is refused INVALID_ARGUMENT on a jaw, without its shift or turn
(three numbers on its target), with an end_frame other than
start_frame + 1, before frame 2 or at the take's last frame, with no
repair_identity, one frame from another step on its hand and target
("merge them into one step"), or inside an interpolation's run, its
anchors or the frame after them; a rotation STEP removed while a later
one on its hand stays ("undo the later step first") or added before one
("remove the later step first"). A STEP add whose repair_identity is not
the take's any more is ABORTED ("the take's repairs changed since it was
read"), as a stale take_identity is.

With `fill`, the call changes the dataset's fill settings instead
(`[pose_fill]`): every take ingest filled is filled again from
its recording, around every repair it holds, and a merged dataset's
change reaches every member. It takes no adds or removes.

- Base URL: `https://api.qualia.dev`
- Authentication: an API key in the `X-API-Key` header

## Parameters

- `account` (path, string, required): The account id.
- `dataset` (path, string, required): The dataset id.

## Request body

Required: `application/json` `qualia.v1.RepairPosesRequest`

## Responses

- `200` OK: `application/json` `qualia.v1.RepairPosesResponse`
- `default` Default error response: `application/json` `google.rpc.Status`

## Schemas

```yaml
qualia.v1.RepairPosesRequest:
  required:
    - name
  type: object
  properties:
    name:
      type: string
      description: |-
        accounts/{account}/datasets/{dataset}: a handheld (UMI) upload, or a
        merged dataset of them.
    adds:
      type: array
      items:
        $ref: "#/components/schemas/qualia.v1.PoseRepair"
      description: |-
        The repairs to add, each with the take_identity it was drawn on and, for
        a STEP, the repair_identity. An add the upload holds already, the same
        kind on the same key (for a STEP, with the same values), changes nothing.
    removes:
      type: array
      items:
        $ref: "#/components/schemas/qualia.v1.PoseRepair"
      description: |-
        The repairs to remove, each named by its key (episode, hand, target and
        frames; kind and take_identity are not read). Applied before the adds,
        so a remove and an add of one key replace it. At least one add or
        remove, unless `fill` is set.
    fill:
      allOf:
        - $ref: "#/components/schemas/qualia.v1.PoseFillSettings"
      description: |-
        The fill settings to hold from now on, in place of any held: with it the
        call takes no adds or removes. INVALID_ARGUMENT for a value out of range.
  description: |-
    Request for Datasets.RepairPoses: one publication of the upload (of each
    member upload a merged dataset's request names takes of).
qualia.v1.PoseRepair:
  required:
    - episode
    - hand
    - target
    - startFrame
    - endFrame
  type: object
  properties:
    episode:
      type: string
      description: |-
        The take: accounts/{account}/datasets/{dataset}/episodes/{episode}, an
        episode of the request's dataset (on a merged dataset, its episode name,
        as SampleEpisodeSeries read it). A split piece's frames are its own and
        are moved onto its take's; a cut piece cannot be repaired.
    hand:
      enum:
        - SIDE_UNSPECIFIED
        - SIDE_LEFT
        - SIDE_RIGHT
      type: string
      description: LEFT or RIGHT.
      format: enum
    kind:
      enum:
        - KIND_UNSPECIFIED
        - INTERPOLATE
        - UNDO_FILL
        - STEP
      type: string
      description: "What it does: required on adds, not read on removes."
      format: enum
    target:
      enum:
        - TARGET_UNSPECIFIED
        - POSITION
        - ROTATION
        - JAW
      type: string
      description: What it edits.
      format: enum
    startFrame:
      type: string
      description: |-
        The frames [start_frame, end_frame) of the take as recorded, not of a
        trimmed window (add a trim's start, window_start_seconds times fps, to a
        trimmed read's frames). An interpolation starts at 1 or later and ends
        before the take's last frame: its anchors are the frames either side.
        A step's is the frame it starts at, 2 or later and before the take's
        last frame.
    endFrame:
      type: string
      description: |-
        The end of the frames, exclusive. A step's is start_frame + 1, on adds
        and removes alike: its key is its frame.
    takeIdentity:
      type: string
      description: |-
        Required on adds, not read on removes: the
        SampleEpisodeSeriesResponse.take_identity of the read the repair was
        drawn on. An add without one is INVALID_ARGUMENT.
    shift:
      type: array
      items:
        type: number
        format: double
      description: |-
        A POSITION step's shift in metres, x, y and z: exactly three numbers on
        a position step's add, empty otherwise. Not read on removes.
    turn:
      type: array
      items:
        type: number
        format: double
      description: |-
        A ROTATION step's turn, a rotation vector (axis times angle) in radians
        composed on the left of the hand's rotation: exactly three numbers on a
        rotation step's add, empty otherwise. Not read on removes.
    repairIdentity:
      type: string
      description: |-
        Required on STEP adds, not read otherwise: the
        SampleEpisodeSeriesResponse.repair_identity of the read the step was
        measured on. A step is measured with the take's earlier steps applied,
        so one whose take's repairs changed since is ABORTED; a STEP add without
        it is INVALID_ARGUMENT. A STEP the upload already holds with the same
        values is not checked: its retry is a no-op.
  description: One pose or jaw repair of one hand over take frames.
qualia.v1.PoseFillSettings:
  type: object
  properties:
    allowedErrorM:
      type: number
      description: |-
        The error a fill may have at the 90th percentile, in metres, when ingest
        measures how long a gap a take's own tracked stretches let it fill:
        above 0, at most 0.1. Default 0.01.
      format: double
    fallbackLimitS:
      type: number
      description: |-
        The longest gap filled, in seconds, in a take with too little tracked
        data to measure its own: above 0, at most 0.5. Default 0.2.
      format: double
  description: |-
    How ingest fills a handheld (UMI) take's short tracking losses
    (`[pose_fill]` in meta/ingest.toml). A value left unset is the default; both
    unset holds the defaults (the table is removed).
qualia.v1.RepairPosesResponse:
  type: object
  properties:
    operationId:
      readOnly: true
      type: string
      description: |-
        The publication's operation id, polled as ResolvePoses' is. Empty when
        no_op is set.
    noOp:
      readOnly: true
      type: boolean
      description: |-
        True when the composed repairs are the published ones: nothing to wait
        for. On a merged dataset, when every member's are.
    members:
      readOnly: true
      type: array
      items:
        $ref: "#/components/schemas/qualia.v1.MemberPoseRepair"
      description: |-
        On a merged dataset, one per member upload whose takes the request
        names, in membership order; operation_id is then empty. Empty for an
        upload.
  description: Response for Datasets.RepairPoses.
qualia.v1.MemberPoseRepair:
  type: object
  properties:
    upload:
      readOnly: true
      type: string
      description: The member upload.
    displayName:
      readOnly: true
      type: string
      description: The member upload's display name.
    state:
      readOnly: true
      enum:
        - STATE_UNSPECIFIED
        - CURRENT
        - RUNNING
        - BUSY
        - REFUSED
      type: string
      description: What its publication did.
      format: enum
    reason:
      readOnly: true
      type: string
      description: Why it is BUSY or REFUSED.
    operationId:
      readOnly: true
      type: string
      description: |-
        Its publication's operation id when RUNNING, polled at the upload's
        reingests/{operation_id} as ResolvePoses' is.
  description: One member upload's part of Datasets.RepairPoses on a merged dataset.
google.rpc.Status:
  oneOf:
    - $ref: "#/components/schemas/ApiError"
    - $ref: "#/components/schemas/GatewayError"
  description: "The body of a failed call: one of the two shapes below."
ApiError:
  title: API error
  type: object
  required:
    - code
    - message
    - retryable
    - details
  properties:
    code:
      type: string
      description: The gRPC code name in upper case, e.g. `NOT_FOUND`.
    message:
      type: string
    retryable:
      type: boolean
      description: Whether the same call may succeed if retried.
    details:
      type: array
      items:
        type: object
      description: "Empty, except when a dataset copy or move is refused: then one `google.rpc.ErrorInfo` with the refusal's `reason` code, its `domain` and, in `metadata`, the datasets it names."
  description: A refusal from the API itself.
GatewayError:
  title: Gateway error
  type: object
  required:
    - detail
  properties:
    detail:
      type: string
      description: What went wrong.
  description: A refusal from the gateway before the call reaches the API, for example `401` bad or missing API key, `403` key lacks the scope or environment closed, `413` body too large.
```
