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

# plugins.operators.undeclared_fields

Builtin operators.

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

**Functions:**

| [`find_undeclared_fields`](#plugins.operators.undeclared_fields.find_undeclared_fields)(dataset)               | Finds the values stored on the dataset's samples and frames under fields that its schema does not declare.               |
|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| [`remove_undeclared_fields`](#plugins.operators.undeclared_fields.remove_undeclared_fields)(dataset, fields)   | Removes the stored values of the given undeclared fields, and marks the samples and frames that stored them as modified. |
| [`declare_undeclared_fields`](#plugins.operators.undeclared_fields.declare_undeclared_fields)(dataset, fields) | Adds the given undeclared fields to the dataset's schema, with the type of their stored values.                          |

**Classes:**

| [`CleanUpUndeclaredFields`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields)([_builtin])   |    |
|---------------------------------------------------------------------------------------------------------|----|

### plugins.operators.undeclared_fields.find_undeclared_fields(dataset)

Finds the values stored on the dataset’s samples and frames under
fields that its schema does not declare.

A sample or frame that stores such a value cannot be loaded, so it
cannot be saved either. Values like this are typically left behind
when a field is removed from the schema while documents still store
it, for example by a run that is deleted while it is writing.
Undeclared attributes of labels are not reported: labels accept them.

This reads every sample (and frame) of the dataset.

* **Parameters:**
  **dataset** – a [`fiftyone.core.dataset.Dataset`](../../api/fiftyone.core.dataset.md#fiftyone.core.dataset.Dataset)
* **Returns:**
  a dict mapping each undeclared field (frame fields prefixed with
  `"frames."`) to a dict with the `count` of documents that store
  it and the sorted BSON `types` of its stored values

### plugins.operators.undeclared_fields.remove_undeclared_fields(dataset, fields)

Removes the stored values of the given undeclared fields, and marks
the samples and frames that stored them as modified.

A field that the schema declares when this runs is never touched, so a
field declared since it was found keeps its values.

* **Parameters:**
  * **dataset** – a [`fiftyone.core.dataset.Dataset`](../../api/fiftyone.core.dataset.md#fiftyone.core.dataset.Dataset)
  * **fields** – the undeclared fields, as returned by
    [`find_undeclared_fields()`](#plugins.operators.undeclared_fields.find_undeclared_fields)
* **Returns:**
  the list of fields whose values were removed

### plugins.operators.undeclared_fields.declare_undeclared_fields(dataset, fields)

Adds the given undeclared fields to the dataset’s schema, with the
type of their stored values.

The field must hold every stored value, so a field whose values have
more than one type is skipped, except ints mixed with floats, which are
declared as a float field when the ints fit one exactly. So is a field
whose values are documents of different kinds, or whose name cannot be a
field name. A list field whose elements have different types is declared
as an untyped list.

* **Parameters:**
  * **dataset** – a [`fiftyone.core.dataset.Dataset`](../../api/fiftyone.core.dataset.md#fiftyone.core.dataset.Dataset)
  * **fields** – the undeclared fields, as returned by
    [`find_undeclared_fields()`](#plugins.operators.undeclared_fields.find_undeclared_fields)
* **Returns:**
  a tuple of
  - the list of fields that were declared
  - a dict mapping the fields that were skipped to the reason

### *class* plugins.operators.undeclared_fields.CleanUpUndeclaredFields(\_builtin=False)

Bases: [`Operator`](../../api/fiftyone.operators.operator.md#fiftyone.operators.operator.Operator)

**Attributes:**

| [`config`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.config)         | The `OperatorConfig` for the operator.                                                                           |
|-----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [`builtin`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.builtin)       | Whether the operator is builtin.                                                                                 |
| [`name`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.name)             |                                                                                                                  |
| [`risk_level`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.risk_level) | The effective risk level of the operator, which is used by guardrail systems of an agent to classify tool calls. |
| [`uri`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.uri)               | The unique identifier of the operator: `plugin_name/operator_name`.                                              |

**Methods:**

| [`resolve_input`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_input)(ctx)                         | Returns the resolved input property.            |
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [`execute`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.execute)(ctx)                                     | Executes the operator.                          |
| [`resolve_output`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_output)(ctx)                       | Returns the resolved output property.           |
| [`add_secrets`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.add_secrets)(secrets)                         | Adds secrets to the operator.                   |
| [`method_to_uri`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.method_to_uri)(method_name)                 | Converts a method name to a URI.                |
| [`resolve_delegation`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_delegation)(ctx)               | Returns the resolved *forced* delegation flag.  |
| [`resolve_execution_options`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_execution_options)(ctx) | Returns the resolved execution options.         |
| [`resolve_placement`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_placement)(ctx)                 | Returns the resolved placement of the operator. |
| [`resolve_run_name`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_run_name)(ctx)                   | Returns the resolved run name of the operator.  |
| [`resolve_type`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_type)(ctx, type)                     | Returns the resolved input or output property.  |
| [`to_json`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.to_json)()                                        | Returns a JSON representation of the operator.  |

#### *property* config

The `OperatorConfig` for the operator.

#### resolve_input(ctx)

Returns the resolved input property.

Subclasses can implement this method to define the inputs to the
operator. This method should never be called directly. Instead
use [`resolve_type()`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_type).

By default, this method is called once when the operator is created.
If the operator is dynamic, this method is called each time the input
changes.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  a [`fiftyone.operators.types.Property`](../../api/fiftyone.operators.types.md#fiftyone.operators.types.Property), or None

#### execute(ctx)

Executes the operator.

Subclasses must implement this method.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  JSON serializable data, or None

#### resolve_output(ctx)

Returns the resolved output property.

Subclasses can implement this method to define the outputs of the
operator.

By default, this method is called once when the operator is created.
If the operator is dynamic, this method is called after the operator is
executed.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  a [`fiftyone.operators.types.Property`](../../api/fiftyone.operators.types.md#fiftyone.operators.types.Property), or None

#### add_secrets(secrets)

Adds secrets to the operator.

* **Parameters:**
  **secrets** – a list of secrets

#### *property* builtin

Whether the operator is builtin.

#### method_to_uri(method_name)

Converts a method name to a URI.

* **Parameters:**
  **method_name** – the method name
* **Returns:**
  a URI

#### *property* name

#### resolve_delegation(ctx) → [bool](../../api/fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool) | None

Returns the resolved *forced* delegation flag.

Subclasses can implement this method to decide if delegated execution
should be *forced* for the given operation.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  whether the operation should be delegated (True), run immediately
  (False), or None to defer to [`resolve_execution_options()`](#plugins.operators.undeclared_fields.CleanUpUndeclaredFields.resolve_execution_options) to
  specify the available options

#### resolve_execution_options(ctx)

Returns the resolved execution options.

Subclasses can implement this method to define the execution options
available for the operation.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  a [`fiftyone.operators.executor.ExecutionOptions`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionOptions) instance

#### resolve_placement(ctx)

Returns the resolved placement of the operator.

Subclasses can implement this method to define the placement of the
operator.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  a [`fiftyone.operators.types.Placement`](../../api/fiftyone.operators.types.md#fiftyone.operators.types.Placement), or None

#### resolve_run_name(ctx)

Returns the resolved run name of the operator.

Subclasses can implement this method to define the run name of the
operator.

* **Parameters:**
  **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
* **Returns:**
  a string, or None

#### resolve_type(ctx, type)

Returns the resolved input or output property.

* **Parameters:**
  * **ctx** – the [`fiftyone.operators.executor.ExecutionContext`](../../api/fiftyone.operators.executor.md#fiftyone.operators.executor.ExecutionContext)
  * **type** – the type of property to resolve, either `"inputs"` or
    `"outputs"`
* **Returns:**
  a [`fiftyone.operators.types.Property`](../../api/fiftyone.operators.types.md#fiftyone.operators.types.Property), or None

#### *property* risk_level

The effective risk level of the operator, which is used by guardrail
systems of an agent to classify tool calls.

#### to_json()

Returns a JSON representation of the operator.

* **Returns:**
  a JSON dict

#### *property* uri

The unique identifier of the operator:
`plugin_name/operator_name`.
