<!-- # hard line break macro for HTML -->

# plugins.panels.similarity_search.run_manager

Similarity search run manager.

Copyright 2017-2026, Voxel51, Inc.
<br/>
[voxel51.com](https://voxel51.com/)
<br/>
<br/>

**Functions:**

| [`get_head_dataset_id`](#plugins.panels.similarity_search.run_manager.get_head_dataset_id)(dataset)   | Get the head dataset ID for a given dataset or a snapshot.   |
|-------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|

**Classes:**

| [`RunManager`](#plugins.panels.similarity_search.run_manager.RunManager)(ctx)   | Manager class for persisting and retrieving similarity search runs.   |
|---------------------------------------------------------------------------------|-----------------------------------------------------------------------|

### plugins.panels.similarity_search.run_manager.get_head_dataset_id(dataset)

Get the head dataset ID for a given dataset or a snapshot.

* **Parameters:**
  **dataset** – the dataset instance
* **Returns:**
  the head dataset ID as a string

### *class* plugins.panels.similarity_search.run_manager.RunManager(ctx)

Bases: `object`

Manager class for persisting and retrieving similarity search runs.

**Methods:**

| [`create_run`](#plugins.panels.similarity_search.run_manager.RunManager.create_run)(run_params)                                | Create a new run entry.                                      |
|--------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [`get_run`](#plugins.panels.similarity_search.run_manager.RunManager.get_run)(run_id)                                          | Get a run by ID.                                             |
| [`set_run`](#plugins.panels.similarity_search.run_manager.RunManager.set_run)(run_id, run_data)                                | Write a full run record to the store (atomic upsert).        |
| [`update_run`](#plugins.panels.similarity_search.run_manager.RunManager.update_run)(run_id, updates)                           | Update fields on an existing run (read-modify-write).        |
| [`set_operator_run_id`](#plugins.panels.similarity_search.run_manager.RunManager.set_operator_run_id)(run_id, operator_run_id) | Link a delegated operation ID to a run and create index key. |
| [`find_run_by_operator_id`](#plugins.panels.similarity_search.run_manager.RunManager.find_run_by_operator_id)(operator_run_id) | Find a run by its delegated operation ID.                    |
| [`delete_run`](#plugins.panels.similarity_search.run_manager.RunManager.delete_run)(run_id)                                    | Delete a run and its index keys.                             |
| [`list_runs`](#plugins.panels.similarity_search.run_manager.RunManager.list_runs)([owner, current_user_id, can_manage])        | List runs sorted by creation time (newest first).            |

#### create_run(run_params: Dict[str, Any]) → Dict[str, Any]

Create a new run entry.

* **Parameters:**
  **run_params** – run configuration parameters
* **Returns:**
  the full run data dict

#### get_run(run_id: str) → Dict | None

Get a run by ID.

* **Parameters:**
  **run_id** – the run ID
* **Returns:**
  the run data dict, or None

#### set_run(run_id: str, run_data: Dict[str, Any])

Write a full run record to the store (atomic upsert).

* **Parameters:**
  * **run_id** – the run ID
  * **run_data** – the complete run data dict

#### update_run(run_id: str, updates: Dict[str, Any])

Update fields on an existing run (read-modify-write).

For hot paths where the caller already holds the full run dict,
prefer mutating locally and calling [`set_run()`](#plugins.panels.similarity_search.run_manager.RunManager.set_run) directly.

* **Parameters:**
  * **run_id** – the run ID
  * **updates** – dict of fields to update

#### set_operator_run_id(run_id: str, operator_run_id: str)

Link a delegated operation ID to a run and create index key.

* **Parameters:**
  * **run_id** – the run ID
  * **operator_run_id** – the delegated operation document ID

#### find_run_by_operator_id(operator_run_id: str) → Dict | None

Find a run by its delegated operation ID. O(1) lookup.

* **Parameters:**
  **operator_run_id** – the delegated operation document ID
* **Returns:**
  the run data dict, or None

#### delete_run(run_id: str)

Delete a run and its index keys.

* **Parameters:**
  **run_id** – the run ID

#### list_runs(owner: str | None = None, current_user_id: str | None = None, can_manage: [bool](../../api/fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool) = True) → List[Dict]

List runs sorted by creation time (newest first).

* **Parameters:**
  * **owner** – “mine” to restrict to runs whose `created_by`
    matches `current_user_id`; “all” or `None` returns
    every run.
  * **current_user_id** – the current user’s id. Required when
    `owner == "mine"`; ignored otherwise.
  * **can_manage** – whether the current user has manage
    permissions. Non-managers are always restricted to
    their own runs regardless of `owner`.
* **Returns:**
  list of run data dicts
