---
sidebar:
  label: roboto.action_runtime.file_changeset
  order: 3
title: roboto.action_runtime.file_changeset
---
## Module Contents

### FilesChangesetFileManager

```python
class roboto.action_runtime.file_changeset.FilesChangesetFileManager
```

`from roboto import FilesChangesetFileManager`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L35-L241)

Service that records tag, metadata, and description changes for an action's output files.

An action's output files reach Roboto only after the action finishes, when Roboto uploads its output directory (`ROBOTO_OUTPUT_DIR`), so the action cannot change them with [`update()`](/docs/reference/python-sdk/roboto/domain/files/file#roboto.domain.files.file.File.update) while it runs. Each method of this class instead appends the change to the file at `ROBOTO_FILE_METADATA_CHANGESET_FILE`. After the upload, Roboto applies each change to the file at the same path in the dataset it uploaded to, and skips paths where that dataset has no file.

Each method can be called any number of times while the action runs, and the calls accumulate.

Get the invocation's instance from [`file_changeset_manager`](/docs/reference/python-sdk/roboto/action_runtime/invocation_context#roboto.action_runtime.invocation_context.InvocationContext.file_changeset_manager).

> **Note**
>
> When the first call for a file is `set_description`, Roboto drops the tag and metadata changes of every later call for that file.

**Raises**

- `ValueError`: `ROBOTO_FILE_METADATA_CHANGESET_FILE` is not set.

#### FilesChangesetFileManager.put_fields()

```python
def put_fields(relative_path: str, metadata: dict[str, Any])
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L111-L134)

Set key-value metadata on an output file once Roboto uploads it.

When two calls set the same key, the later call's value wins.

**Parameters**

- **relative_path** (`str`): Path of the file relative to the action's output directory.
- **metadata** (`dict[str, Any]`): Key-value metadata to set on the file.

**Usage**

Set two keys:

```python
from roboto import InvocationContext
manager = InvocationContext.from_env().file_changeset_manager
manager.put_fields("images/front0_raw_000734.jpg", {"cars": 2, "trucks": 3})
```

Change `cars` and add `planes` with a later call:

```python
manager.put_fields("images/front0_raw_000734.jpg", {"cars": 3, "planes": 1})
```

#### FilesChangesetFileManager.put_tags()

```python
def put_tags(relative_path: str, tags: list[str])
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L72-L89)

Add tags to an output file once Roboto uploads it.

**Parameters**

- **relative_path** (`str`): Path of the file relative to the action's output directory.
- **tags** (`list[str]`): Tags to add to the file.

**Usage**

Tag the file the action writes to `images/front0_raw_000734.jpg` in its output directory:

```python
from roboto import InvocationContext
manager = InvocationContext.from_env().file_changeset_manager
manager.put_tags("images/front0_raw_000734.jpg", ["cloudy", "rainy"])
```

#### FilesChangesetFileManager.remove_fields()

```python
def remove_fields(relative_path: str, keys: list[str])
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L136-L154)

Remove metadata keys from an output file once Roboto uploads it.

Roboto applies removals before additions, so it cannot remove a key that a `put_fields` call sets on the same file, whichever call came first.

**Parameters**

- **relative_path** (`str`): Path of the file relative to the action's output directory.
- **keys** (`list[str]`): Metadata keys to remove from the file.

**Usage**

```python
from roboto import InvocationContext
manager = InvocationContext.from_env().file_changeset_manager
manager.remove_fields("images/front0_raw_000734.jpg", ["trucks"])
```

#### FilesChangesetFileManager.remove_tags()

```python
def remove_tags(relative_path: str, tags: list[str])
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L91-L109)

Remove tags from an output file once Roboto uploads it.

Roboto applies removals before additions, so it cannot remove a tag that a `put_tags` call adds to the same file, whichever call came first.

**Parameters**

- **relative_path** (`str`): Path of the file relative to the action's output directory.
- **tags** (`list[str]`): Tags to remove from the file.

**Usage**

```python
from roboto import InvocationContext
manager = InvocationContext.from_env().file_changeset_manager
manager.remove_tags("images/front0_raw_000734.jpg", ["rainy"])
```

#### FilesChangesetFileManager.set_description()

```python
def set_description(relative_path: str, description: Optional[str])
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L156-L170)

Set the description of an output file once Roboto uploads it.

When called more than once for a file, the last call's description wins.

**Parameters**

- **relative_path** (`str`): Path of the file relative to the action's output directory.
- **description** (`Optional[str]`): Human-readable description of the file. `None` clears a description an earlier call set.

**Usage**

```python
from roboto import InvocationContext
manager = InvocationContext.from_env().file_changeset_manager
manager.set_description("images/front0_raw_000734.jpg", "This image was over-exposed")
```

### FilesChangesetItem

```python
class roboto.action_runtime.file_changeset.FilesChangesetItem(/, **data: Any)
```

`from roboto.action_runtime.file_changeset import FilesChangesetItem`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L21-L32)

Bases: `pydantic.BaseModel`

Change to one of an action's output files, stored as one JSON line in `ROBOTO_FILE_METADATA_CHANGESET_FILE`.

Each call to a method of [`FilesChangesetFileManager`](/docs/reference/python-sdk/roboto/action_runtime/file_changeset#roboto.action_runtime.file_changeset.FilesChangesetFileManager), such as [`put_tags()`](/docs/reference/python-sdk/roboto/action_runtime/file_changeset#roboto.action_runtime.file_changeset.FilesChangesetFileManager.put_tags), appends one.

**Parameters**

- **data** (`Any`)

**Attributes**

- **FilesChangesetItem.relative_path** (`str`): Path of the file relative to the action's output directory, and so its path in the dataset after upload.
- **FilesChangesetItem.update** (`roboto.domain.files.UpdateFileRecordRequest`): Change to apply to the file once Roboto uploads it.

### logger

```python
roboto.action_runtime.file_changeset.logger
```

`from roboto.action_runtime.file_changeset import logger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/action_runtime/file_changeset.py#L18-L18)
