---
sidebar:
  hidden: true
title: roboto.experimental.sessions.session
---
## Module Contents

### Session

```python
class roboto.experimental.sessions.session.Session(
    record: roboto.experimental.sessions.record.SessionRecord,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
)
```

`from roboto import Session`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L72-L1798)

A session: an operational time window of a device, such as a drone flight, a vehicle drive, or a robot run.

A session groups the recordings and other data produced during that window, and can span many files or hold only part of one. Because the activity bounds it rather than the recordings, each file it holds can be narrowed to a time window or a range of the file.

The session's time bounds, `min_timestamp_ns` and `max_timestamp_ns`, span every file it holds. Roboto recomputes them whenever the session's files or the wall-clock anchors of their data change, and each method of this class that makes such a change updates this instance with the new bounds before it returns.

A session can have one device attached or several: a single drone for a solo mission, or every drone of a formation flight. `attach_to_device` and `detach_from_device` change which devices are attached. Roboto also attaches, on its own, each device that one of the session's files, or the dataset holding the file, names.

To create a session:

- `create` attaches zero or more devices, and does not require a name.
- [`create_session()`](/docs/reference/python-sdk/roboto/domain/devices/device#roboto.domain.devices.device.Device.create_session) creates one named session on a device, optionally declaring its files and topics in the same call.
- [`create_sessions()`](/docs/reference/python-sdk/roboto/domain/devices/device#roboto.domain.devices.device.Device.create_sessions) creates many such sessions on a device in one call.
- [`create_session()`](/docs/reference/python-sdk/roboto/domain/datasets/dataset#roboto.domain.datasets.dataset.Dataset.create_session) creates a session that holds a dataset's files.

Add files to a session with `add_file` or `add_files`. Get a `Session` from one of those methods, `create_if_not_exists`, or `from_id`. To wrap a [`SessionRecord`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionRecord) already fetched from Roboto, build a `Session` from it directly. Each instance holds a copy of the session's record: methods that change the session's properties update that copy from Roboto's response, and `refresh` fetches changes made elsewhere.

**Parameters**

- **record** (`roboto.experimental.sessions.record.SessionRecord`): Record of the session.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

Who may use a Session also depends on the datasets its files sit in. Besides the access a method needs in the Session's org, a method that reads one Session needs the right to read every such dataset, and a method that changes one Session (including adding files to it and deleting it) needs the right to change every such dataset. Otherwise the method raises [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException). A dataset restricted to the people it is shared with can be read only with a share on it, and changed only with a share that has the editor role, unless you are an admin or owner of its org.

**Usage**

Create a session for a drone flight, add a recording, and list its topics:

```python
from roboto.experimental.sessions import Session
session = Session.create(name="flight-2026-04-23-001", device_ids=["robot-abc"])
session.add_file("fl_12345")
for topic in session.list_topics():
    print(topic.name)
```

Read one topic's data in a session as a DataFrame, then print the maximum of each field of every topic the session holds data of. Both read only the session's files, and only the part of each file that the session holds:

```python
session = Session.from_id("se_12345")
df = session.get_topic("/imu").get_data_as_df(fields_include=[("accel", "x")])
for topic in session.list_topics():
    stats = session.get_topic_stats(topic.topic_id)
    for field in stats.fields:
        print(topic.name, ".".join(field.path), field.stats.get("max"))
```

**Properties**

- **Session.completes_at** (`datetime.datetime | None`): Time Roboto will mark the session complete unless another file is added first.

  `None` while the session is complete, has no completion policy, or has no files.

  Return type: `Optional[datetime.datetime]`

- **Session.completion_policy** (`roboto.experimental.sessions.record.CompletionPolicy | None`): Rule by which Roboto marks the session complete on its own.

  `None` if the session is marked complete only by request, with `complete`.

  Return type: `Optional[roboto.experimental.sessions.record.CompletionPolicy]`

- **Session.created** (`datetime.datetime | None`): Time the session was created.

  Return type: `Optional[datetime.datetime]`

- **Session.created_by** (`str`): Principal that created the session, as `<type>:<id>`, such as `user:<user_id>`.

- **Session.custom_fields** (`dict[str, Any]`): Values of the custom fields the organization defines for sessions, keyed by field name.

  [`custom_fields`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionRecord.custom_fields) says which fields appear as keys. A [`Timestamp`](/docs/reference/python-sdk/roboto/domain/custom_fields/record#roboto.domain.custom_fields.record.CustomFieldType.Timestamp) value is an ISO 8601 string.

- **Session.description** (`str | None`): Human-readable description of the session, or `None` if it has none.

  Return type: `Optional[str]`

- **Session.ingestion_count** (`int`): Number of times Roboto has announced the session ingested.

  [`ingestion_count`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionRecord.ingestion_count) says when Roboto announces it again.

- **Session.max_timestamp_ns** (`int | None`): Latest time covered by the session, in nanoseconds since the Unix epoch.

  `None` while none of its files supplies a time: the session holds no files, or only files added without a time window whose topic data has no time span registered yet.

  Return type: `Optional[int]`

- **Session.metadata** (`dict[str, Any]`): Copy of the key-value metadata on the session.

  Sessions cannot be filtered or sorted by metadata keys. To query a structured attribute of sessions, define a custom field for sessions instead.

- **Session.min_timestamp_ns** (`int | None`): Earliest time covered by the session, in nanoseconds since the Unix epoch.

  `None` while none of its files supplies a time: the session holds no files, or only files added without a time window whose topic data has no time span registered yet.

  Return type: `Optional[int]`

- **Session.modified** (`datetime.datetime | None`): Time the session was last modified.

  Return type: `Optional[datetime.datetime]`

- **Session.modified_by** (`str`): Principal that last modified the session, in the same `<type>:<id>` form as `created_by`.

  Roboto's own system user when Roboto made the change.

- **Session.name** (`str | None`): Human-readable name of the session, at most 120 characters, or `None` if it has none.

  Roboto does not require names to be unique.

  Return type: `Optional[str]`

- **Session.org_id** (`str`): ID of the organization that owns the session.

- **Session.record** (`roboto.experimental.sessions.record.SessionRecord`): Record of the session that this instance holds.

  `refresh` replaces it with the current one.

- **Session.session_id** (`str`): Unique ID of the session, beginning with `se_`.

- **Session.status** (`roboto.experimental.sessions.record.SessionStatus`): Status of the session: whether more of its files are expected.

  Adding a file to a complete session puts it back in progress.

- **Session.tags** (`list[str]`): Copy of the tags on the session.

#### Session.add_file()

```python
def add_file(
    file: Union[roboto.domain.files.File, str],
    data_range: Optional[roboto.domain.topics.record.DataRange] = None,
    min_file_timestamp_ns: Optional[int] = None,
    max_file_timestamp_ns: Optional[int] = None,
    anchor: Optional[roboto.time.Time] = None,
    topics: Optional[collections.abc.Sequence[roboto.experimental.ingest.TopicDeclaration]] = None,
) -> roboto.experimental.sessions.record.SessionFileView
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L618-L686)

Add one file to the session, with the topic data it carries.

Builds one [`SessionFile`](/docs/reference/python-sdk/roboto/experimental/sessions/operations#roboto.experimental.sessions.operations.SessionFile) from the arguments, which that class describes, and sends it with `add_files`, whose failures also apply. Where `add_files` reports a refused entry in its response, this method raises the exception Roboto refused the file with.

**Parameters**

- **file** (`Union[roboto.domain.files.File, str]`): File to add, as a [`File`](/docs/reference/python-sdk/roboto/domain/files/file#roboto.domain.files.file.File) or its ID.
- **data_range** (`Optional[roboto.domain.topics.record.DataRange]`): Part of the file the session holds, as `(start, end)`. `None` holds the whole file.
- **min_file_timestamp_ns** (`Optional[int]`): Inclusive start of the time window, in nanoseconds of the file's own timestamps. Set both bounds or neither. `None` for both spans the entry's topic data, or the whole file when `topics` declares none.
- **max_file_timestamp_ns** (`Optional[int]`): Inclusive end of the time window, in the same form.
- **anchor** (`Optional[roboto.time.Time]`): Wall-clock time at which time 0 of the data this entry names occurred, in nanoseconds since the Unix epoch or any value [`to_epoch_nanoseconds()`](/docs/reference/python-sdk/roboto/time#roboto.time.to_epoch_nanoseconds) accepts. It must fall after the Unix epoch. `None` takes an anchor as [`anchor_ns`](/docs/reference/python-sdk/roboto/experimental/sessions/operations#roboto.experimental.sessions.operations.FileDeclaration.anchor_ns) describes.
- **topics** (`Optional[collections.abc.Sequence[roboto.experimental.ingest.TopicDeclaration]]`): Topics the file carries data for, each over the part of the file that holds it. `None` declares none.

**Returns**

- `roboto.experimental.sessions.record.SessionFileView`: The file as the session holds it, in the form `list_files` yields.

**Raises**

- `TypeError`: `anchor` is not a [`Time`](/docs/reference/python-sdk/roboto/time#roboto.time.Time).
- `ValueError`: `anchor` is a boolean, a negative number, or a string that is neither a number nor an ISO 8601 timestamp.
- `OverflowError`: `anchor` is infinite, such as `float("inf")`.
- `pydantic.ValidationError`: The arguments break a rule `SessionFile` enforces, such as an `anchor` at the Unix epoch or a time window with only one of its two bounds, or the representations listed in `topics` name one file in two storage formats.
- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): With the anchor covering it added, the file's data or the window stated here would fall before the Unix epoch or after `2**63 - 1` nanoseconds past it, or the anchor would move another session's window over the same data outside that span.
- [`RobotoDomainException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDomainException): Roboto refused the file for another reason. The exception raised is the one Roboto reported.

**Usage**

Add a whole file:

```python
session.add_file("fl_12345")
```

Add only the part of a file from 0 to 60 seconds of its own timestamps:

```python
session.add_file(
    "fl_12345",
    min_file_timestamp_ns=0,
    max_file_timestamp_ns=60_000_000_000,
)
```

#### Session.add_files()

```python
def add_files(
    files: collections.abc.Sequence[roboto.experimental.sessions.operations.SessionFile],
) -> roboto.http.BatchResponse[roboto.experimental.sessions.record.SessionFileView]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L688-L745)

Add files to the session, with the topic data they carry.

Each entry states one file's place in the session in the same terms a [`SessionDeclaration`](/docs/reference/python-sdk/roboto/experimental/sessions/operations#roboto.experimental.sessions.operations.SessionDeclaration) uses, so a session built file by file can state everything a declared one does. [`SessionFile`](/docs/reference/python-sdk/roboto/experimental/sessions/operations#roboto.experimental.sessions.operations.SessionFile) describes what an entry states, including how its time window moves when the file is anchored again.

Roboto decides every refusal before it adds anything, so an entry it refuses leaves the others added, while a failure it did not anticipate, such as a timeout, adds none of them. Sending the same entries again leaves the session holding the same files, not each file twice. Roboto then recomputes the session's `min_timestamp_ns` and `max_timestamp_ns` over every file it holds, and this instance holds the new values when the call returns.

**Parameters**

- **files** (`collections.abc.Sequence[roboto.experimental.sessions.operations.SessionFile]`): Files to add, each appearing once and listing all of its topics. An empty sequence returns an empty response without sending a request.

**Returns**

- `roboto.http.BatchResponse[roboto.experimental.sessions.record.SessionFileView]`: One element per entry, in request order, holding either the file as the session holds it or the exception Roboto refused the entry with.

**Raises**

- `pydantic.ValidationError`: The entries name a file more than once, declare more than 500 files and topics together ([`MAX_FILES_AND_TOPICS_PER_REQUEST`](/docs/reference/python-sdk/roboto/experimental/ingest/operations#roboto.experimental.ingest.operations.MAX_FILES_AND_TOPICS_PER_REQUEST)), or list representations that name one file in two storage formats.
- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): A file an entry names, or a file one of its topics' representations names, does not exist in the session's organization or has a status other than [`Available`](/docs/reference/python-sdk/roboto/domain/files/record#roboto.domain.files.record.FileStatus.Available). Nothing is added.
- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): The caller cannot add files to sessions in an organization that owns one of the files, cannot change a dataset that already holds one of the session's files, cannot read a file an entry names, cannot edit a file an entry declares topics on, anchors, or names in a representation, or cannot edit topics in the organization while an entry sets `is_default_for_reads` on a timeline source. Nothing is added.

**Usage**

```python
from roboto.experimental.sessions import SessionFile
added = session.add_files(
    [
        SessionFile(file_id="fl_12345"),
        SessionFile(
            file_id="fl_67890",
            min_file_timestamp_ns=0,
            max_file_timestamp_ns=60_000_000_000,
        ),
    ]
)
print([view.file_id for view in added.succeeded])
```

#### Session.attach_to_device()

```python
def attach_to_device(device_id: str) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L747-L768)

Attach a device to the session.

A session can have several devices attached, such as every drone of a formation flight. Attaching a device that is already attached changes nothing, except that a device Roboto attached because the session's files name it stays attached once those files no longer do.

**Parameters**

- **device_id** (`str`): ID of the device to attach.

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): No device has this ID in the session's organization, or the session no longer exists.

**Returns**

- `None`

**Usage**

```python
session.attach_to_device("wingman")
print(list(session.list_devices()))
```

#### Session.clear_custom_field()

```python
def clear_custom_field(name: str) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L770-L786)

Clear one custom-field value on the session, so the field reads back as `None`.

It calls `update`, whose failures also apply.

**Parameters**

- **name** (`str`): Name of a ready custom field defined for sessions in the session's organization.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session = Session.from_id("se_12345")
session.clear_custom_field("flight_count").custom_fields["flight_count"] is None
# True
```

#### Session.clear_custom_fields()

```python
def clear_custom_fields(names: collections.abc.Sequence[str]) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L788-L803)

Clear several custom-field values on the session, so each field reads back as `None`.

It calls `update`, whose failures also apply.

**Parameters**

- **names** (`collections.abc.Sequence[str]`): Names of ready custom fields defined for sessions in the session's organization.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session = Session.from_id("se_12345")
session.clear_custom_fields(["pilot", "flight_count"])
```

#### Session.clear_unix_offset()

```python
def clear_unix_offset() -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L805-L841)

Return the session's data to an offset of 0, removing its wall-clock anchor.

The session's topic data then reads in its stored timestamps, as nanoseconds since the Unix epoch with nothing added, and Roboto recomputes the session's time bounds. The call reaches the same data `set_unix_offset` writes, and no more, and moves the time windows stated over that data back by the rule `set_unix_offset` moves them by.

It succeeds whatever anchors the data carries. A session whose parts are anchored at different instants is cleared too, each part moving back by its own offset. Clearing a session that carries no anchor, or has no topic data, changes nothing, so repeating the call is safe.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Raises**

- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): Returning the data to an offset of 0 would place it, or a time window stated over it, before the Unix epoch. Data lands there when its own timestamps are negative, and a window does when it starts earlier than its data's anchor.
- [`RobotoConflictException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoConflictException): Another request added files to the session while the anchor was being cleared. Calling again is safe.
- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session no longer exists.

**Usage**

The session's bounds return to its stored timestamps:

```python
session.min_timestamp_ns
# 1700000000250000000
session = session.clear_unix_offset()
session.min_timestamp_ns
# 250000000
```

#### Session.complete()

```python
def complete() -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L843-L868)

Mark the session complete: declare that all of its files have been added.

Once the session is complete, Roboto announces it ingested, with a `session.ingested` platform event that triggers can subscribe to, as soon as every [`ingestable`](/docs/reference/python-sdk/roboto/domain/files/record#roboto.domain.files.record.FileRecord.ingestable) file it waits for is ingested. Files that are not ingestable never delay the announcement.

Adding a file to a complete session puts it back in progress; mark it complete again once the new files are added. When its ingestable files change while it stays complete, such as a file uploaded again, removed, or deleted, Roboto announces it again once they are all ingested. Marking a complete session complete changes nothing.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
from roboto.experimental.sessions import SessionStatus
session.add_file("fl_12345")
session = session.complete()
session.status is SessionStatus.Complete
# True
```

#### Session.create()

```python
@classmethod
def create(
    name: Optional[str] = None,
    device_ids: collections.abc.Sequence[str] = (),
    description: Optional[str] = None,
    metadata: Optional[dict[str, Any]] = None,
    tags: Optional[collections.abc.Sequence[str]] = None,
    custom_fields: Optional[dict[str, Any]] = None,
    caller_org_id: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
    completion_policy: Union[roboto.experimental.sessions.record.CompletionPolicy, None, roboto.sentinels.NotSetType] = NotSet,
) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L138-L214)

Create a session, with zero or more devices attached.

Every call creates a new session. To create a session on one device that a resent call reuses instead of duplicating, use [`create_session()`](/docs/reference/python-sdk/roboto/domain/devices/device#roboto.domain.devices.device.Device.create_session), which identifies the session by its name within the device. `attach_to_device` attaches more devices later.

**Parameters**

- **name** (`Optional[str]`): Human-readable name of the session, at most 120 characters. `None` leaves the session unnamed. Roboto does not require names to be unique.
- **device_ids** (`collections.abc.Sequence[str]`): IDs of the devices to attach to the session. Defaults to none.
- **description** (`Optional[str]`): Human-readable description of the session.
- **metadata** (`Optional[dict[str, Any]]`): Key-value metadata to set on the session. Sessions cannot be filtered or sorted by metadata keys; for an attribute to query by, define a custom field for sessions.
- **tags** (`Optional[collections.abc.Sequence[str]]`): Tags to set on the session. Sessions can be filtered by tag but not sorted by tag.
- **custom_fields** (`Optional[dict[str, Any]]`): Initial values for the session's custom fields, keyed by field name. Each name must be a custom field defined for sessions in the organization the session is created in, with status [`Ready`](/docs/reference/python-sdk/roboto/domain/custom_fields/record#roboto.domain.custom_fields.record.CustomFieldStatus.Ready), and each value must match that field's declared type.
- **caller_org_id** (`Optional[str]`): Organization to create the session in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).
- **completion_policy** (`Union[roboto.experimental.sessions.record.CompletionPolicy, None, roboto.sentinels.NotSetType]`): When Roboto marks the session complete on its own. Left unset (`NotSet`), the session takes its organization's default completion policy, if an organization administrator has set one, and the returned session's `completion_policy` shows the policy it took. `None` means the session is marked complete only by `complete`, whatever the organization's default. `update` changes it later.

**Returns**

- `Session`: The new session.

**Raises**

- `pydantic.ValidationError`: `name` is longer than 120 characters. Raised before anything is sent to Roboto.
- [`RobotoIllegalArgumentException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoIllegalArgumentException): A key of `custom_fields` is not a `Ready` custom field defined for sessions, or its value does not match the field's type.
- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): A device in `device_ids` does not exist in the organization. No session is created.

**Usage**

```python
from roboto.experimental.sessions import Session
session = Session.create(
    name="flight-2026-04-23-001",
    device_ids=["robot-a", "robot-b"],
    description="formation flight #4",
    metadata={"pilot": "alice"},
    tags=["pre-flight-check"],
)
```

#### Session.create_event()

```python
def create_event(
    name: str,
    start_time: roboto.time.Time,
    end_time: Optional[roboto.time.Time] = None,
    topics: collections.abc.Sequence[roboto.experimental.events.EventTopicRequest] = (),
    description: Optional[str] = None,
    tags: Optional[roboto.updates.StrSequence] = None,
    metadata: Optional[dict[str, Any]] = None,
    color: Optional[str] = None,
    custom_fields: Optional[dict[str, Any]] = None,
) -> roboto.experimental.events.Event
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L870-L933)

Create an event on the session.

**Parameters**

- **name** (`str`): Human-readable name of the event, such as `"Hard landing"`. Many events can share a name.
- **start_time** (`roboto.time.Time`): Inclusive start of the event, in nanoseconds since the Unix epoch or any value [`to_epoch_nanoseconds()`](/docs/reference/python-sdk/roboto/time#roboto.time.to_epoch_nanoseconds) accepts.
- **end_time** (`Optional[roboto.time.Time]`): Inclusive end of the event, in the same form. `None` makes an instantaneous event.
- **topics** (`collections.abc.Sequence[roboto.experimental.events.EventTopicRequest]`): Topics, or fields of topics, the event is about, each as a `roboto.experimental.events.EventTopicRequest`. Empty means all of the session's data.
- **description** (`Optional[str]`): Human-readable description of the event.
- **tags** (`Optional[roboto.updates.StrSequence]`): Tags to set on the event.
- **metadata** (`Optional[dict[str, Any]]`): Key-value metadata to set on the event.
- **color** (`Optional[str]`): CSS color the Roboto web app displays the event in.
- **custom_fields** (`Optional[dict[str, Any]]`): Initial values for the event's custom fields, keyed by field name. Each name must be a custom field defined for events in the session's organization, with status [`Ready`](/docs/reference/python-sdk/roboto/domain/custom_fields/record#roboto.domain.custom_fields.record.CustomFieldStatus.Ready), and each value must match that field's declared type.

**Returns**

- `roboto.experimental.events.Event`: The new event, as a `roboto.experimental.events.Event`.

**Raises**

- [`RobotoFeatureNotAvailableException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFeatureNotAvailableException): The session's organization does not support events on sessions.
- [`RobotoIllegalArgumentException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoIllegalArgumentException): A `custom_fields` name is not a ready custom field for events, or its value does not match the field's type.
- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): `name` is blank, the start is negative or after the end, or `topics` names a topic twice, names a topic that does not exist, gives a topic an empty `field_ids`, or names a field that is in none of the schemas of that topic's data in the session.

**Usage**

```python
session = Session.from_id("se_12345")
event = session.create_event(
    "Hard landing",
    start_time=1_722_870_127_000_000_000,
    end_time=1_722_870_128_500_000_000,
    tags=["landing"],
)
```

#### Session.create_if_not_exists()

```python
@classmethod
def create_if_not_exists(
    match_roboql_query: str,
    name: Optional[str] = None,
    device_ids: collections.abc.Sequence[str] = (),
    description: Optional[str] = None,
    metadata: Optional[dict[str, Any]] = None,
    tags: Optional[collections.abc.Sequence[str]] = None,
    custom_fields: Optional[dict[str, Any]] = None,
    completion_policy: Union[roboto.experimental.sessions.record.CompletionPolicy, None, roboto.sentinels.NotSetType] = NotSet,
    caller_org_id: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L217-L296)

Fetch the first session that matches a RoboQL query, creating one when none matches.

Concurrent calls with the same query create one session between them, so a process that handles one file at a time, such as a handler of S3 upload events, can use it to put each file into the session it belongs to.

The session created must match `match_roboql_query`. If `name`, `tags` and the other arguments describe a session the query does not match, every later call creates another one.

When several sessions match, which one is returned is not defined unless the query ends with a `SORT BY` clause, such as `name = 'flight-0042' SORT BY session_id`.

A matching session is returned as it is: the other arguments apply only to a session this call creates, so a match ignores `completion_policy` and the rest. `update` changes a matched session. The session returned may be complete; adding a file to it puts it back in progress. To match only sessions in progress, add `AND status = 'in_progress'` to the query.

**Parameters**

- **match_roboql_query** (`str`): RoboQL query over the organization's sessions, such as `name = 'flight-0042'`.
- **name** (`Optional[str]`): Human-readable name of the session to create when none matches, at most 120 characters.
- **device_ids** (`collections.abc.Sequence[str]`): IDs of the devices to attach to a created session. Defaults to none.
- **description** (`Optional[str]`): Human-readable description of a created session.
- **metadata** (`Optional[dict[str, Any]]`): Key-value metadata to set on a created session.
- **tags** (`Optional[collections.abc.Sequence[str]]`): Tags to set on a created session.
- **custom_fields** (`Optional[dict[str, Any]]`): Initial values for a created session's custom fields, as in `create`.
- **completion_policy** (`Union[roboto.experimental.sessions.record.CompletionPolicy, None, roboto.sentinels.NotSetType]`): Completion policy of a created session, as in `create`.
- **caller_org_id** (`Optional[str]`): Organization to search, and to create the session in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Returns**

- `Session`: The matching or new session.

**Raises**

- `pydantic.ValidationError`: `name` is longer than 120 characters. Raised before anything is sent to Roboto.
- [`RobotoServiceUnavailableException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoServiceUnavailableException): Other calls with the same query kept this one waiting for more than 10 seconds, after the SDK's own retries. Calling again is safe.

**Usage**

```python
from roboto.experimental.sessions import CompletionPolicy, Session
session = Session.create_if_not_exists(
    "name = 'flight-0042'",
    name="flight-0042",
    completion_policy=CompletionPolicy(inactivity_minutes=15),
)
session.add_file("fl_0123456789abcdef")
```

#### Session.delete()

```python
def delete() -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L935-L946)

Delete the session, with its events, custom-field values and AI summary. This cannot be undone.

The session's files and the devices attached to it are not deleted.

**Usage**

```python
session = Session.from_id("se_12345")
session.delete()
```

**Returns**

- `None`

#### Session.detach_from_device()

```python
def detach_from_device(device_id: str) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L948-L964)

Detach a device from the session.

Detaching a device that is not attached changes nothing. When one of the session's files, or the dataset holding the file, names the device, Roboto attaches it again the next time the session's files, or the devices they name, change.

**Parameters**

- **device_id** (`str`): ID of the device to detach.

**Returns**

- `None`

**Usage**

```python
session.detach_from_device("wingman")
```

#### Session.for_dataset()

```python
@classmethod
def for_dataset(
    dataset_id: str,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> collections.abc.Generator[Session, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L321-L361)

List the sessions that include at least one of a dataset's files.

Only the current version of each file counts. Sessions come in the order `for_org` lists them.

**Parameters**

- **dataset_id** (`str`): ID of the dataset whose sessions to list.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Yields**

- Each session that includes a file of the dataset, fetched a page at a time as the generator advances.

**Returns**

- `collections.abc.Generator[Session, None, None]`

**Usage**

```python
from roboto.experimental.sessions import Session
for session in Session.for_dataset("ds_12345"):
    print(session.session_id, session.name)
```

#### Session.for_org()

```python
@classmethod
def for_org(
    org_id: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> collections.abc.Generator[Session, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L364-L407)

List the sessions in an organization.

Sessions with time bounds come first, latest `min_timestamp_ns` first. Sessions without time bounds, such as those with no files yet, follow, most recently created first.

**Parameters**

- **org_id** (`Optional[str]`): Organization whose sessions to list. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Yields**

- Each session in the organization, fetched a page at a time as the generator advances.

**Returns**

- `collections.abc.Generator[Session, None, None]`

**Usage**

```python
from roboto.experimental.sessions import Session
for session in Session.for_org("og_12345"):
    print(session.session_id, session.name)
```

#### Session.from_id()

```python
@classmethod
def from_id(
    session_id: str,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L453-L478)

Fetch a session by its ID.

**Parameters**

- **session_id** (`str`): Unique ID of the session, beginning with `se_`.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): No session has this ID.
- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): The caller may not read a dataset that holds one of the session's files.

**Returns**

- `Session`

**Usage**

```python
from roboto.experimental.sessions import Session
session = Session.from_id("se_12345")
print(session.name)
```

#### Session.generate_summary()

```python
def generate_summary() -> roboto.ai.summary.StreamingAISummary
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L966-L998)

Start generating a new AI summary of the session.

Roboto's AI reads the session's topics, metrics, files and devices and writes the summary in the background. This method returns once generation has started; the returned object fetches the rest of the summary from Roboto when you wait for it or stream its text. Each generation is charged against the organization's AI credits.

A session has one summary, which every generation and every `set_summary` call overwrites:

- Starting a generation clears the current summary text at once.
- If the generation fails, the summary is left [`Failed`](/docs/reference/python-sdk/roboto/ai/summary#roboto.ai.summary.AISummaryStatus.Failed).
- Text written with `set_summary` is replaced when a later generation completes.

**Returns**

- `roboto.ai.summary.StreamingAISummary`: The summary being generated, which starts in the [`Pending`](/docs/reference/python-sdk/roboto/ai/summary#roboto.ai.summary.AISummaryStatus.Pending) state.

**Raises**

- [`RobotoLimitExceededException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoLimitExceededException): The organization is out of AI credits. Nothing is generated, and the current summary is unchanged.

**Usage**

```python
session = Session.from_id("se_12345")
summary = session.generate_summary()
print(summary.complete_text)
```

#### Session.get_summary()

```python
def get_summary() -> roboto.ai.summary.StreamingAISummary
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1000-L1022)

Fetch the session's AI summary, without generating one.

**Returns**

- `roboto.ai.summary.StreamingAISummary`: The session's summary. If its generation is still running, the summary is [`Pending`](/docs/reference/python-sdk/roboto/ai/summary#roboto.ai.summary.AISummaryStatus.Pending); its `await_completion` and `text_stream` methods wait for the rest.

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session has no AI summary. Call `generate_summary` to create one.

**Usage**

Get the existing summary, generating one first if there is none:

```python
from roboto.exceptions import RobotoNotFoundException
session = Session.from_id("se_12345")
try:
    summary = session.get_summary()
except RobotoNotFoundException:
    summary = session.generate_summary()
print(summary.complete_text)
```

#### Session.get_topic()

```python
def get_topic(topic_name: str) -> roboto.experimental.topics.Topic
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1024-L1053)

Fetch the topic of this name whose data the session holds, limited to that data.

The returned topic's `get_data*` methods read only the data the session holds, and need neither `start_time` nor `end_time`.

**Parameters**

- **topic_name** (`str`): Exact name of the topic, such as `"/camera/image"`.

**Returns**

- `roboto.experimental.topics.Topic`: The topic, as a `roboto.experimental.topics.Topic`.

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session holds no data of a topic with this name, including when the organization has no such topic.

**Usage**

```python
topic = session.get_topic("/camera/image")
for timestamp, record in topic.get_data():
    print(timestamp, record)
```

#### Session.get_topic_stats()

```python
def get_topic_stats(
    topic_id: str,
) -> roboto.experimental.sessions.record.SessionTopicStats
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1273-L1298)

Fetch the statistics of one topic over the session's data, grouped by field.

The statistics are the session's `topic_stats.` metrics, which Roboto computes after the session is announced ingested. A field with no statistics, such as a string or an array, is absent.

**Parameters**

- **topic_id** (`str`): ID of a topic `list_topics` lists.

**Returns**

- `roboto.experimental.sessions.record.SessionTopicStats`: The topic's statistics. Its `fields` is empty and its `message_count` is `None` while no statistics have been computed for the topic.

**Raises**

- [`RobotoFeatureNotAvailableException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFeatureNotAvailableException): Topic statistics are not available in the session's organization.
- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session holds no data of the topic.

**Usage**

```python
for topic in session.list_topics():
    stats = session.get_topic_stats(topic.topic_id)
    for field in stats.fields:
        print(topic.name, ".".join(field.path), field.stats.get("max"))
```

#### Session.get_topic_stats_run()

```python
def get_topic_stats_run() -> roboto.experimental.sessions.record.SessionTopicStatsRun
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1300-L1320)

Fetch the status of the latest run Roboto triggered to compute the session's topic statistics.

Roboto runs the `session_metrics` action on a session each time the session is announced ingested, but only while the organization's session-metrics trigger is installed and enabled. When no run was triggered on the latest announcement and none is scheduled, the status may describe the run on an earlier one. While a run is [`Running`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionTopicStatsRunStatus.Running), `get_topic_stats` may return statistics from an earlier run, or none.

**Raises**

- [`RobotoFeatureNotAvailableException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFeatureNotAvailableException): Topic statistics are not available in the session's organization.

**Returns**

- `roboto.experimental.sessions.record.SessionTopicStatsRun`

**Usage**

```python
from roboto.experimental.sessions import SessionTopicStatsRunStatus
run = session.get_topic_stats_run()
if run.status == SessionTopicStatsRunStatus.Running:
    print("Topic statistics are still being computed")
```

#### Session.ingestion_status()

```python
def ingestion_status() -> roboto.experimental.sessions.record.SessionIngestionStatus
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1055-L1067)

Fetch the session's ingestion state, with the files it still waits for.

This instance's record is unchanged; call `refresh` to update it.

**Usage**

```python
status = session.ingestion_status()
print(status.state)
print([file.relative_path for file in status.pending_files])
```

**Returns**

- `roboto.experimental.sessions.record.SessionIngestionStatus`

#### Session.ingestion_summaries()

```python
@classmethod
def ingestion_summaries(
    session_ids: collections.abc.Sequence[str],
    org_id: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> list[roboto.experimental.sessions.record.SessionIngestionSummary]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L410-L450)

Fetch the ingestion state of each of several sessions, in counts.

A summary lists no files, only counts, so to find which of many sessions are stuck it costs less than `ingestion_status` on each. The SDK sends one request per 100 sessions ([`MAX_INGESTION_SUMMARIES`](/docs/reference/python-sdk/roboto/experimental/sessions/operations#roboto.experimental.sessions.operations.MAX_INGESTION_SUMMARIES)), and summarizes a session named more than once only once.

**Parameters**

- **session_ids** (`collections.abc.Sequence[str]`): IDs of the sessions to summarize.
- **org_id** (`Optional[str]`): Organization to act in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Returns**

- `list[roboto.experimental.sessions.record.SessionIngestionSummary]`: One summary per session the organization owns, in the order of `session_ids`. Sessions outside the organization are left out.

**Usage**

List the sessions with a file whose latest ingestion run failed:

```python
summaries = Session.ingestion_summaries(["se_12345", "se_67890"])
print([summary.session_id for summary in summaries if summary.failed_file_count])
```

#### Session.list_devices()

```python
def list_devices() -> collections.abc.Generator[str, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1096-L1125)

List the IDs of the devices attached to the session, in order of device ID.

The list includes the devices Roboto attached because one of the session's files, or the dataset holding the file, names them.

**Yields**

- The ID of each attached device, fetched a page at a time as the generator advances.

**Returns**

- `collections.abc.Generator[str, None, None]`

**Usage**

```python
for device_id in session.list_devices():
    print(device_id)
```

#### Session.list_events()

```python
def list_events(
    start_time: Optional[roboto.time.Time] = None,
    end_time: Optional[roboto.time.Time] = None,
) -> collections.abc.Generator[roboto.experimental.events.Event, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1127-L1165)

List the events on the session, in order of start time.

**Parameters**

- **start_time** (`Optional[roboto.time.Time]`): Time at or after which an event must end to be listed, in nanoseconds since the Unix epoch or any value [`to_epoch_nanoseconds()`](/docs/reference/python-sdk/roboto/time#roboto.time.to_epoch_nanoseconds) accepts. `None` sets no such limit.
- **end_time** (`Optional[roboto.time.Time]`): Time at or before which an event must start to be listed, in the same form. `None` sets no such limit.

**Yields**

- Each matching event, as a `roboto.experimental.events.Event`, fetched a page at a time as the generator advances.

**Raises**

- [`RobotoFeatureNotAvailableException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFeatureNotAvailableException): The session's organization does not support events on sessions. It surfaces on the first iteration.

**Returns**

- `collections.abc.Generator[roboto.experimental.events.Event, None, None]`

**Usage**

```python
for event in Session.from_id("se_12345").list_events():
    print(event.name, event.start_time)
```

#### Session.list_files()

```python
def list_files() -> collections.abc.Generator[roboto.experimental.sessions.record.SessionFileView, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1167-L1194)

List the files the session holds, with the part of each file it holds.

**Yields**

- Each file as a [`SessionFileView`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionFileView), fetched a page at a time as the generator advances. `SessionFileView` says which of its fields describe the part of the file the session holds and which describe the file itself.

**Returns**

- `collections.abc.Generator[roboto.experimental.sessions.record.SessionFileView, None, None]`

**Usage**

```python
for file in session.list_files():
    print(file.relative_path, file.data_range)
```

#### Session.list_topics()

```python
def list_topics() -> collections.abc.Generator[roboto.experimental.topics.Topic, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1228-L1271)

List the topics whose data the session holds, each limited to that data.

A topic is listed when the session holds some of its data: a time span of the topic ([`TimelineExtentRecord`](/docs/reference/python-sdk/roboto/domain/topics/record#roboto.domain.topics.record.TimelineExtentRecord)) on one of the session's files, inside the part of that file the session holds and overlapping the time window it holds. Each topic is listed once, however many files carry it, ordered by name and then by topic ID.

Each topic's `get_data*` methods read only the data the session holds, and need neither `start_time` nor `end_time`. Its `record` is a [`SessionTopicRecord`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionTopicRecord), which also carries the topic's schemas, time span, file count and message count in the session. The property is typed [`TopicIdentityRecord`](/docs/reference/python-sdk/roboto/domain/topics/record#roboto.domain.topics.record.TopicIdentityRecord), so narrow it with `isinstance` before reading those fields.

**Yields**

- Each topic, as a `roboto.experimental.topics.Topic`, fetched a page at a time as the generator advances.

**Returns**

- `collections.abc.Generator[roboto.experimental.topics.Topic, None, None]`

**Usage**

```python
for topic in session.list_topics():
    for timestamp, record in topic.get_data():
        print(topic.name, timestamp, record)
```

#### Session.put_metadata()

```python
def put_metadata(metadata: dict[str, Any]) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1375-L1390)

Set metadata keys on the session, adding new keys and overwriting existing ones.

Keys the dict does not name keep their values. A dotted key such as `"weather.condition"` sets `condition` inside the nested `weather` object. It calls `update`, whose failures also apply.

**Parameters**

- **metadata** (`dict[str, Any]`): Key-value metadata to set on the session.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session.put_metadata({"weather": "clear", "pilot": "alice"})
```

#### Session.put_tags()

```python
def put_tags(tags: roboto.updates.StrSequence) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1392-L1406)

Add tags to the session, keeping its existing tags.

A tag the session already has is not added again. It calls `update`, whose failures also apply.

**Parameters**

- **tags** (`roboto.updates.StrSequence`): Tags to add to the session.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session.put_tags(["pre-flight-check", "training"])
```

#### Session.refresh()

```python
def refresh() -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1408-L1428)

Replace this instance's record with the session's current record from Roboto.

Use it to see changes made after this instance was loaded, by other users or processes or by Roboto itself, which recomputes `min_timestamp_ns` and `max_timestamp_ns` whenever the session's files or their anchors change.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session no longer exists.

**Usage**

```python
session = Session.from_id("se_12345")
print(session.refresh().status)
```

#### Session.remove_file()

```python
def remove_file(file: Union[roboto.domain.files.File, str]) -> str
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1430-L1448)

Remove one file from the session.

It calls `remove_files`, whose failures also apply.

**Parameters**

- **file** (`Union[roboto.domain.files.File, str]`): File to remove, as a [`File`](/docs/reference/python-sdk/roboto/domain/files/file#roboto.domain.files.file.File) or its ID.

**Returns**

- `str`: ID of the removed file.

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session does not hold the file.

**Usage**

```python
session.remove_file("fl_12345")
```

#### Session.remove_files()

```python
def remove_files(
    files: collections.abc.Sequence[Union[roboto.domain.files.File, str]],
) -> roboto.http.BatchResponse[str]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1450-L1483)

Remove files from the session.

Roboto removes every named file the session holds, and reports each file it does not hold as a `RobotoNotFoundException` in that file's element of the response. A failure Roboto did not anticipate, such as a timeout, removes none of the files. Roboto then recomputes the session's `min_timestamp_ns` and `max_timestamp_ns` over the files that remain, and this instance holds the new values when the call returns.

**Parameters**

- **files** (`collections.abc.Sequence[Union[roboto.domain.files.File, str]]`): Files to remove, each a [`File`](/docs/reference/python-sdk/roboto/domain/files/file#roboto.domain.files.file.File) or its ID. An empty sequence returns an empty response without sending a request.

**Returns**

- `roboto.http.BatchResponse[str]`: One element per named file, in request order, holding either its ID or the exception Roboto refused to remove it with.

**Raises**

- `pydantic.ValidationError`: `files` names a file more than once, or names more than 500 files ([`MAX_FILES_AND_TOPICS_PER_REQUEST`](/docs/reference/python-sdk/roboto/experimental/ingest/operations#roboto.experimental.ingest.operations.MAX_FILES_AND_TOPICS_PER_REQUEST)).

**Usage**

```python
removed = session.remove_files(["fl_12345", "fl_67890"])
print(removed.succeeded)
```

#### Session.remove_metadata()

```python
def remove_metadata(metadata: roboto.updates.StrSequence) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1485-L1500)

Remove metadata keys from the session. Keys the session does not have are ignored.

A dotted key such as `"weather.condition"` removes `condition` from inside the nested `weather` object. It calls `update`, whose failures also apply.

**Parameters**

- **metadata** (`roboto.updates.StrSequence`): Metadata keys to remove.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session.remove_metadata(["pilot", "weather.condition"])
```

#### Session.remove_tags()

```python
def remove_tags(tags: roboto.updates.StrSequence) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1502-L1516)

Remove tags from the session. Tags the session does not have are ignored.

It calls `update`, whose failures also apply.

**Parameters**

- **tags** (`roboto.updates.StrSequence`): Tags to remove from the session.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session.remove_tags(["training"])
```

#### Session.set_custom_field()

```python
def set_custom_field(name: str, value: Any) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1518-L1535)

Set one custom-field value on the session.

It calls `update`, whose failures also apply.

**Parameters**

- **name** (`str`): Name of a custom field defined for sessions in the session's organization, with status [`Ready`](/docs/reference/python-sdk/roboto/domain/custom_fields/record#roboto.domain.custom_fields.record.CustomFieldStatus.Ready).
- **value** (`Any`): Value to set, which must match the field's declared type.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session = Session.from_id("se_12345")
session.set_custom_field("flight_count", 12)
```

#### Session.set_custom_fields()

```python
def set_custom_fields(fields: dict[str, Any]) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1537-L1554)

Set several custom-field values on the session. Fields not named keep their values.

It calls `update`, whose failures also apply.

**Parameters**

- **fields** (`dict[str, Any]`): New values keyed by field name. Each name must be a custom field defined for sessions in the session's organization, with status [`Ready`](/docs/reference/python-sdk/roboto/domain/custom_fields/record#roboto.domain.custom_fields.record.CustomFieldStatus.Ready), and each value must match that field's declared type.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Usage**

```python
session = Session.from_id("se_12345")
session.set_custom_fields({"pilot": "alice", "flight_count": 12})
```

#### Session.set_summary()

```python
def set_summary(summary: str) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1556-L1575)

Set the text of the session's AI summary.

Use it when an action or another program writes a more specialized summary than `generate_summary` would. The text stays until the next generation starts or this method is called again.

**Parameters**

- **summary** (`str`): Text of the summary, rendered as Markdown. It may include `roboto://` links to resources.

**Returns**

- `Session`: This instance. Its record is unchanged.

**Usage**

```python
session.set_summary("Flight ended early: the battery voltage dropped below 3.3 V per cell.")
```

#### Session.set_unix_offset()

```python
def set_unix_offset(anchor: roboto.time.Time) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1577-L1642)

Anchor the session's data to wall-clock time.

`anchor` becomes the wall-clock time of stored time 0 for all of the session's topic data, and Roboto recomputes the session's time bounds from it.

The anchor reaches the session's data and no more. Where several sessions share one file, each holding part of it, it anchors the parts this session holds and leaves the file's other parts at the anchors they have. Data another session also holds is shared, not copied, so that session reads the same anchor. A time window stated over a file moves with its data only when all the data the window covers carries one anchor before the call and one after.

Data carries an anchor only when one is given: as the data is added, with the `anchor` argument of `add_file` or [`anchor_ns`](/docs/reference/python-sdk/roboto/experimental/sessions/operations#roboto.experimental.sessions.operations.FileDeclaration.anchor_ns), or with this method. Until then, its offset is 0 and its stored timestamps read as nanoseconds since the Unix epoch. A new anchor replaces the one the data carried; giving the one it already carries changes nothing, so repeating the call is safe. Declaring a file's data again without an anchor keeps the anchor it has.

**Parameters**

- **anchor** (`roboto.time.Time`): Wall-clock time of stored time 0, in nanoseconds since the Unix epoch or any value [`to_epoch_nanoseconds()`](/docs/reference/python-sdk/roboto/time#roboto.time.to_epoch_nanoseconds) accepts. It must fall after the Unix epoch; to return the session to an offset of 0, use `clear_unix_offset`.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Raises**

- `TypeError`: `anchor` is not a [`Time`](/docs/reference/python-sdk/roboto/time#roboto.time.Time).
- `ValueError`: `anchor` is a boolean, a string that is neither a number nor an ISO 8601 timestamp, the Unix epoch or earlier, or at least `2**63` nanoseconds after it. The epoch itself and a value that large raise `pydantic.ValidationError`, a subclass of `ValueError`.
- `OverflowError`: `anchor` is infinite, such as `float("inf")`.
- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): The session has no topic data to anchor; its data already carries several different anchors, so Roboto cannot tell which to move from; or the anchor would move the session's data, or a time window stated over it, before the Unix epoch or past `2**63 - 1` nanoseconds after it. To anchor data that carries several anchors, anchor one topic at a time with `roboto.experimental.topics.Topic.set_unix_offset` on a topic from `get_topic` or `list_topics`, or one whole file with [`set_timeline_offset()`](/docs/reference/python-sdk/roboto/domain/files/file#roboto.domain.files.file.File.set_timeline_offset).
- [`RobotoConflictException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoConflictException): Another request added files to the session while the anchor was being set. Calling again is safe.
- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): The session no longer exists.

**Usage**

The session's bounds become the anchor plus its stored timestamps:

```python
session.min_timestamp_ns
# 250000000
session = session.set_unix_offset(1_700_000_000_000_000_000)
session.min_timestamp_ns
# 1700000000250000000
```

The same anchor given as a `datetime`:

```python
import datetime
session = session.set_unix_offset(
    datetime.datetime(2023, 11, 14, 22, 13, 20, tzinfo=datetime.timezone.utc)
)
session.min_timestamp_ns
# 1700000000250000000
```

#### Session.skip_waiting_for()

```python
def skip_waiting_for(
    file_ids: collections.abc.Sequence[str],
) -> roboto.experimental.sessions.record.SkipWaitingResponse
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1069-L1094)

Stop the session waiting for files to be ingested, such as files whose ingestion failed.

A complete session is then announced ingested once its other ingestable files are. The skip covers the version of each file that is current when it is made: editing the file's tags, metadata, or description keeps it, and uploading the file again ends it, so the session waits for the new version. Skipped files stay in the session, and [`skipped_files`](/docs/reference/python-sdk/roboto/experimental/sessions/record#roboto.experimental.sessions.record.SessionIngestionStatus.skipped_files) lists them.

**Parameters**

- **file_ids** (`collections.abc.Sequence[str]`): IDs of the session's files to stop waiting for. A file not in the session is skipped over and listed in the response.

**Returns**

- `roboto.experimental.sessions.record.SkipWaitingResponse`: The session's ingestion state after the skip, and the requested files that are not in the session.

**Raises**

- `pydantic.ValidationError`: `file_ids` is empty or names more than 1,000 files.

**Usage**

```python
response = session.skip_waiting_for(["fl_12345"])
print(response.ingestion.state, response.not_in_session)
```

#### Session.update()

```python
def update(
    description: Optional[Union[str, roboto.sentinels.NotSetType]] = NotSet,
    metadata_changeset: Union[roboto.updates.MetadataChangeset, roboto.sentinels.NotSetType] = NotSet,
    name: Optional[Union[str, roboto.sentinels.NotSetType]] = NotSet,
    custom_fields_changeset: Optional[roboto.updates.CustomFieldChangeset] = None,
    completion_policy: Union[roboto.experimental.sessions.record.CompletionPolicy, None, roboto.sentinels.NotSetType] = NotSet,
) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1644-L1699)

Update the session's description, name, tags, metadata, custom fields or completion policy.

An argument left at its default (`NotSet` or `None`) leaves that property unchanged.

**Parameters**

- **description** (`Optional[Union[str, roboto.sentinels.NotSetType]]`): Human-readable description of the session. `None` clears it.
- **metadata_changeset** (`Union[roboto.updates.MetadataChangeset, roboto.sentinels.NotSetType]`): Changes to the session's tags and metadata. `put_tags`, `remove_tags`, `put_metadata` and `remove_metadata` each make one kind of change.
- **name** (`Optional[Union[str, roboto.sentinels.NotSetType]]`): Human-readable name of the session, at most 120 characters. `None` clears it.
- **custom_fields_changeset** (`Optional[roboto.updates.CustomFieldChangeset]`): Changes to the session's custom-field values. Each field name it references must be a ready custom field defined for sessions in the session's organization. Fields it does not name are unchanged.
- **completion_policy** (`Union[roboto.experimental.sessions.record.CompletionPolicy, None, roboto.sentinels.NotSetType]`): When Roboto marks the session complete on its own. `None` removes the policy, so the session is marked complete only by `complete`. On a session in progress that has files, a new policy counts its inactivity from now. A complete session stays complete, and the policy applies once a file is added to it.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Raises**

- `pydantic.ValidationError`: `name` is longer than 120 characters.
- [`RobotoIllegalArgumentException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoIllegalArgumentException): A `custom_fields_changeset` name is not a ready custom field for sessions, or a value it sets does not match the field's type.

**Usage**

```python
session.update(description="formation flight #4", name="flight-2026-04-23-001")
```

Let Roboto mark the session complete 30 minutes after its last file is added:

```python
from roboto.experimental.sessions import CompletionPolicy
session.update(completion_policy=CompletionPolicy(inactivity_minutes=30))
```

#### Session.wait_until_ingested()

```python
def wait_until_ingested(timeout: float = 600, poll_interval: int = 15) -> Session
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/sessions/session.py#L1701-L1760)

Wait until every ingestable file the session waits for is ingested and Roboto has announced it ingested.

The wait ends once Roboto records the announcement, the `session.ingested` platform event, which raises `ingestion_count`. A session already announced ingested since it was last marked complete returns at once.

A session in progress is waited for when it will complete on its own: it has a `completion_policy` and files, so `completes_at` is set, and the wait then includes the policy's inactivity. A session in progress that will not complete on its own raises, since only `complete` would complete it.

The default `timeout` of 10 minutes may be too short for a session of large recordings. Pass a longer one, such as `timeout=2 * 60 * 60` for two hours.

**Parameters**

- **timeout** (`float`): Maximum time to wait, in seconds.
- **poll_interval** (`int`): Time between checks of the session's ingestion state, in seconds.

**Returns**

- `Session`: This instance, with its record updated from Roboto's response.

**Raises**

- `RuntimeError`: The session is in progress and will not complete on its own: it has no completion policy, or it has one but no files.
- [`roboto.waiters.TimeoutError`](/docs/reference/python-sdk/roboto/waiters#roboto.waiters.TimeoutError): `timeout` passed first. The message says where the session stands and lists up to 10 of the files it still waits for. It subclasses the built-in `TimeoutError`.

**Usage**

```python
session = session.complete().wait_until_ingested(timeout=2 * 60 * 60)
```
