Annotation Import Sessions

Access import sessions through client.annotation_import_sessions in the Datature Vi SDK.

client.annotations.upload() already orchestrates annotation imports end to end. It creates a session, registers files, polls status, and returns a populated AnnotationUploadResult. This resource exposes those same underlying sessions for direct read access, so you can browse historical imports, stream logs while an upload is in flight, sample the files the server received, and cancel a stuck import.

All endpoints are scoped to a single dataset.

Before You Start

Get started with the Vi SDK →

You Usually Do Not Need This

For normal uploads, call client.annotations.upload() and let it manage the session. Reach for this resource when you need visibility into an import that already ran, or manual control over one that did not finish.


Methods

list()

List annotation import sessions for a dataset.

sessions = client.annotation_import_sessions.list("dataset_abc123")

for session in sessions.items:
    print(session["annotationImportSessionId"], session.get("status"))
for session in client.annotation_import_sessions(dataset_id="dataset_abc123"):
    print(session["annotationImportSessionId"], session.get("status"))
failed = [
    s for s in client.annotation_import_sessions.list("dataset_abc123").all_items()
    if s.get("status") == "Failed"
]

print(f"{len(failed)} failed imports")

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Owning dataset.
Required
page_size
integer
Page size cap.
Optional
None
page
string
Pagination cursor from a previous call.
Optional
None

Returns: PaginatedResponse[dict]. A page of session documents.


get()

Fetch a single annotation import session by ID.

session = client.annotation_import_sessions.get(
    dataset_id="dataset_abc123",
    annotation_import_session_id="ais_xyz789",
)

print(session["status"])

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Owning dataset.
Required
annotation_import_session_id
string
Session identifier.
Required

Returns: dict. The session document, including current status and counts.


get_logs()

Fetch the structured log stream for an import session.

logs = client.annotation_import_sessions.get_logs(
    dataset_id="dataset_abc123",
    annotation_import_session_id="ais_xyz789",
)

for entry in logs.get("items", []):
    print(entry)

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Owning dataset.
Required
annotation_import_session_id
string
Session identifier.
Required

Returns: dict. Logs document with the platform's structured entries.


get_files_sample()

Fetch a sample of the files attached to an import session.

Useful for debugging: the platform returns a handful of the files the session received, so you can verify file naming, MIME types, and that the server interpreted them as expected.

sample = client.annotation_import_sessions.get_files_sample(
    dataset_id="dataset_abc123",
    annotation_import_session_id="ais_xyz789",
)

print(sample)

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Owning dataset.
Required
annotation_import_session_id
string
Session identifier.
Required

Returns: dict. Files-sample document.


update_status()

Patch the status of an annotation import session. The common use is cancelling a stuck import.

client.annotation_import_sessions.update_status(
    dataset_id="dataset_abc123",
    annotation_import_session_id="ais_xyz789",
    body={"spec": {"status": "Cancelled"}},
)

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Owning dataset.
Required
annotation_import_session_id
string
Session identifier.
Required
body
object
Status patch payload, for example {'spec': {'status': 'Cancelled'}}.
Required

Returns: dict. The updated session document.


add_files()

Register additional files on an in-flight import session.

Advanced

client.annotations.upload() calls this automatically. Use it directly only if you are orchestrating uploads manually.

client.annotation_import_sessions.add_files(
    dataset_id="dataset_abc123",
    annotation_import_session_id="ais_xyz789",
    body={"files": [{"filename": "batch2.jsonl"}]},
)

Parameters

Name
Type
Description
Required
Default
dataset_id
string
Owning dataset.
Required
annotation_import_session_id
string
Session identifier.
Required
body
object
Files request payload matching the platform's InsertImportSessionFilesRequest schema.
Required

Returns: dict. The files-insert response document.


Response format

Sessions are returned as plain dictionaries mirroring the platform's session documents.

Common fields

Name
Type
Description
Required
Default
annotationImportSessionId
string
Unique session identifier
Optional
status
string
Current session status, for example Pending, Running, Completed, Failed, or Cancelled
Optional
metadata
object
Creation and update timestamps
Optional

Related resources

Annotations API

Upload, list, get, download, and delete annotations.

Upload Annotations

UI guide for importing annotations into a dataset.

Ontologies API

Manage the label taxonomy that annotations reference.

Assets With Objects API

Read assets paired with their annotation objects in one call.


Did this page help you?