---
sidebar:
  label: roboto.action_runtime.prepare
  order: 5
title: roboto.action_runtime.prepare
---
## Module Contents

### log

```python
roboto.action_runtime.prepare.log
```

`from roboto.action_runtime.prepare import log`

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

### prepare_invocation_input_data()

```python
def roboto.action_runtime.prepare.prepare_invocation_input_data(
    requires_downloaded_inputs: bool,
    input_data: Optional[roboto.domain.actions.InvocationInput],
    target_directory: pathlib.Path,
    download_directory: pathlib.Path,
    inputs_data_manifest_file: pathlib.Path,
    roboto_client: roboto.http.RobotoClient,
    roboto_search: roboto.roboto_search.RobotoSearch,
)
```

`from roboto.action_runtime import prepare_invocation_input_data`

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

Resolve an invocation's input to the files, sessions, and topics it selects, and write them to a manifest.

Roboto calls this when it sets up an invocation, before the action's code starts, and `roboto actions invoke-local` calls it to run an action on your computer. The action reads the manifest through [`get_input()`](/docs/reference/python-sdk/roboto/action_runtime/invocation_context#roboto.action_runtime.invocation_context.InvocationContext.get_input), which expects it to exist once setup completes, so an invocation with no input, such as one run against only a dataset, gets a manifest that selects nothing.

With `requires_downloaded_inputs`, the selected files are downloaded to `download_directory` and, when `target_directory` differs from it, hard-linked into `target_directory` at their paths within their datasets. When the files come from more than one dataset, each link goes under a directory named for its dataset's ID, as `<target_directory>/<dataset_id>/<path>`. The manifest records each file's linked path, or its downloaded path when no link is made.

**Parameters**

- **requires_downloaded_inputs** (`bool`): Whether to download the selected files.
- **input_data** (`Optional[roboto.domain.actions.InvocationInput]`): Input selectors of the invocation. `None` selects nothing.
- **target_directory** (`pathlib.Path`): Directory the action reads its input files from.
- **download_directory** (`pathlib.Path`): Directory to download the files to, as [`resolve_input_spec()`](/docs/reference/python-sdk/roboto/action_runtime/action_input/input_resolver#roboto.action_runtime.action_input.input_resolver.ActionInputResolver.resolve_input_spec) lays them out.
- **inputs_data_manifest_file** (`pathlib.Path`): File to write the manifest to, as [`ActionInputRecord`](/docs/reference/python-sdk/roboto/action_runtime/action_input/action_input#roboto.action_runtime.action_input.action_input.ActionInputRecord) JSON. Created, with its parent directories, when missing.
- **roboto_client** (`roboto.http.RobotoClient`): Client to make requests to Roboto with.
- **roboto_search** (`roboto.roboto_search.RobotoSearch`): [`RobotoSearch`](/docs/reference/python-sdk/roboto/roboto_search#roboto.roboto_search.RobotoSearch) that runs the selectors' RoboQL queries.

**Raises**

- [`PrepareEnvException`](/docs/reference/python-sdk/roboto/action_runtime/exceptions#roboto.action_runtime.exceptions.PrepareEnvException): A request to Roboto failed, such as a lookup of an ID that matches nothing. Its exit code is [`InternalError`](/docs/reference/python-sdk/roboto/action_runtime/exit_codes#roboto.action_runtime.exit_codes.ExitCode.InternalError) when Roboto failed (HTTP status 500 or above) and [`UsageError`](/docs/reference/python-sdk/roboto/action_runtime/exit_codes#roboto.action_runtime.exit_codes.ExitCode.UsageError) otherwise.
- `ExceptionGroup`: With `requires_downloaded_inputs`, one or more files still failed to download after three attempts.
- [`RobotoIllegalArgumentException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoIllegalArgumentException): A file's path within its dataset resolves outside `target_directory`.

### prepare_invocation_parameters()

```python
def roboto.action_runtime.prepare.prepare_invocation_parameters(
    action_parameters: collections.abc.Iterable[roboto.domain.actions.ActionParameter],
    provided_parameter_values: collections.abc.Mapping[str, Any],
    parameters_values_file: pathlib.Path,
    secrets_file: pathlib.Path,
    org_id: Optional[str],
    roboto_client: roboto.http.RobotoClient,
)
```

`from roboto.action_runtime import prepare_invocation_parameters`

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

Write an invocation's parameter values, and the values of the secrets they name, to files the action reads.

Roboto calls this when it sets up an invocation, before the action's code starts, and `roboto actions invoke-local` calls it to run an action on your computer. The action reads both files through [`InvocationContext`](/docs/reference/python-sdk/roboto/action_runtime/invocation_context#roboto.action_runtime.invocation_context.InvocationContext). Each file holds a JSON object keyed by parameter name, and is created, with its parent directories, when missing.

A parameter that `provided_parameter_values` leaves out takes its default, when it has one. A value that is a secret URI (`roboto-secret://<name>` or `roboto-secret://<name>@<org_id>`) is written as given to `parameters_values_file`, and the secret's value is written under the same parameter name to `secrets_file`. `secrets_file` is written only when some value names a secret.

**Parameters**

- **action_parameters** (`collections.abc.Iterable[roboto.domain.actions.ActionParameter]`): Parameters the action declares, whose defaults fill in the values left out.
- **provided_parameter_values** (`collections.abc.Mapping[str, Any]`): Parameter values the invocation gives, by parameter name. They override defaults.
- **parameters_values_file** (`pathlib.Path`): File to write every parameter value to.
- **secrets_file** (`pathlib.Path`): File to write the values of the secrets the parameters name to.
- **org_id** (`Optional[str]`): Organization that owns a secret whose URI names none. `None` uses the organization the caller acts in.
- **roboto_client** (`roboto.http.RobotoClient`): Client to make requests to Roboto with.

**Raises**

- [`PrepareEnvException`](/docs/reference/python-sdk/roboto/action_runtime/exceptions#roboto.action_runtime.exceptions.PrepareEnvException): A parameter names a secret that does not exist or the caller cannot read. Its exit code is [`InternalError`](/docs/reference/python-sdk/roboto/action_runtime/exit_codes#roboto.action_runtime.exit_codes.ExitCode.InternalError).

### prepare_metadata_changeset_manifest()

```python
def roboto.action_runtime.prepare.prepare_metadata_changeset_manifest(
    dataset_metadata_changeset_path: pathlib.Path,
)
```

`from roboto.action_runtime import prepare_metadata_changeset_manifest`

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

Create the empty file in which an action records changes to its dataset's tags and metadata.

Roboto calls this when it sets up an invocation, before the action's code starts, and `roboto actions invoke-local` calls it to run an action on your computer. Roboto applies the changes the action records when the invocation finishes.

**Parameters**

- **dataset_metadata_changeset_path** (`pathlib.Path`): File to create, with its parent directories. An existing file is left unchanged.
