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

# fiftyone.core.odm.dataset

Documents that track datasets and their sample schemas in the database.

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

**Classes:**

| [`SampleFieldDocument`](#fiftyone.core.odm.dataset.SampleFieldDocument)(\*args, \*\*kwargs)   | Description of a sample field.                                                   |
|-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [`SidebarGroupDocument`](#fiftyone.core.odm.dataset.SidebarGroupDocument)(\*args, \*\*kwargs) | Description of a sidebar group in the App.                                       |
| [`ActiveFields`](#fiftyone.core.odm.dataset.ActiveFields)(\*args, \*\*kwargs)                 | Description of active fields in the App as defined by the sidebar's checkboxes   |
| [`ColorScheme`](#fiftyone.core.odm.dataset.ColorScheme)(\*args, \*\*kwargs)                   | Description of a color scheme in the App.                                        |
| [`KeypointSkeleton`](#fiftyone.core.odm.dataset.KeypointSkeleton)(\*args, \*\*kwargs)         | Description of a keypoint skeleton.                                              |
| [`DatasetAppConfig`](#fiftyone.core.odm.dataset.DatasetAppConfig)(\*args, \*\*kwargs)         | Dataset-specific settings that customize how a dataset is visualized in the App. |
| [`DatasetDocument`](#fiftyone.core.odm.dataset.DatasetDocument)(\*\*kwargs)                   | Backing document for datasets.                                                   |

### *class* fiftyone.core.odm.dataset.SampleFieldDocument(\*args, \*\*kwargs)

Bases: [`EmbeddedDocument`](fiftyone.core.odm.embedded_document.md#fiftyone.core.odm.embedded_document.EmbeddedDocument)

Description of a sample field.

**Attributes:**

| [`name`](#fiftyone.core.odm.dataset.SampleFieldDocument.name)                           | A unicode string field.                                                                                                      |
|-----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [`ftype`](#fiftyone.core.odm.dataset.SampleFieldDocument.ftype)                         | A unicode string field.                                                                                                      |
| [`embedded_doc_type`](#fiftyone.core.odm.dataset.SampleFieldDocument.embedded_doc_type) | A unicode string field.                                                                                                      |
| [`subfield`](#fiftyone.core.odm.dataset.SampleFieldDocument.subfield)                   | A unicode string field.                                                                                                      |
| [`fields`](#fiftyone.core.odm.dataset.SampleFieldDocument.fields)                       | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`db_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.db_field)                   | A unicode string field.                                                                                                      |
| [`description`](#fiftyone.core.odm.dataset.SampleFieldDocument.description)             | A unicode string field.                                                                                                      |
| [`info`](#fiftyone.core.odm.dataset.SampleFieldDocument.info)                           | A dictionary field that wraps a standard Python dictionary.                                                                  |
| [`read_only`](#fiftyone.core.odm.dataset.SampleFieldDocument.read_only)                 | A boolean field.                                                                                                             |
| [`created_at`](#fiftyone.core.odm.dataset.SampleFieldDocument.created_at)               | A datetime field.                                                                                                            |
| [`STRICT`](#fiftyone.core.odm.dataset.SampleFieldDocument.STRICT)                       |                                                                                                                              |
| [`field_names`](#fiftyone.core.odm.dataset.SampleFieldDocument.field_names)             | An ordered tuple of the public fields of this document.                                                                      |

**Methods:**

| [`to_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.to_field)()                                     | Creates the [`fiftyone.core.fields.Field`](fiftyone.core.fields.md#fiftyone.core.fields.Field) specified by this document.   |
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [`from_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.from_field)(field)                            | Creates a [`SampleFieldDocument`](#fiftyone.core.odm.dataset.SampleFieldDocument) for a field.                               |
| [`clean`](#fiftyone.core.odm.dataset.SampleFieldDocument.clean)()                                           | Hook for doing document level data cleaning (usually validation or assignment) before validation is run.                     |
| [`clear_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.clear_field)(field_name)                     | Clears the field from the document.                                                                                          |
| [`copy`](#fiftyone.core.odm.dataset.SampleFieldDocument.copy)()                                             | Returns a deep copy of the document.                                                                                         |
| [`fancy_repr`](#fiftyone.core.odm.dataset.SampleFieldDocument.fancy_repr)([class_name, select_fields, ...]) | Generates a customizable string representation of the document.                                                              |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.SampleFieldDocument.field_to_mongo)(field_name)               |                                                                                                                              |
| [`field_to_python`](#fiftyone.core.odm.dataset.SampleFieldDocument.field_to_python)(field_name, value)      |                                                                                                                              |
| [`from_dict`](#fiftyone.core.odm.dataset.SampleFieldDocument.from_dict)(d[, extended])                      | Loads the document from a BSON/JSON dictionary.                                                                              |
| [`from_json`](#fiftyone.core.odm.dataset.SampleFieldDocument.from_json)(s)                                  | Loads the document from a JSON string.                                                                                       |
| [`get_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.get_field)(field_name)                         | Gets the field of the document.                                                                                              |
| [`get_text_score`](#fiftyone.core.odm.dataset.SampleFieldDocument.get_text_score)()                         | Get text score from text query                                                                                               |
| [`has_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.has_field)(field_name)                         | Determines whether the document has a field of the given name.                                                               |
| [`iter_fields`](#fiftyone.core.odm.dataset.SampleFieldDocument.iter_fields)()                               | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                                     |
| [`merge`](#fiftyone.core.odm.dataset.SampleFieldDocument.merge)(doc[, merge_lists, merge_dicts, overwrite]) | Merges the contents of the given document into this document.                                                                |
| [`set_field`](#fiftyone.core.odm.dataset.SampleFieldDocument.set_field)(field_name, value[, create])        | Sets the value of a field of the document.                                                                                   |
| [`to_dict`](#fiftyone.core.odm.dataset.SampleFieldDocument.to_dict)([extended])                             | Serializes this document to a BSON/JSON dictionary.                                                                          |
| [`to_json`](#fiftyone.core.odm.dataset.SampleFieldDocument.to_json)([pretty_print])                         | Serializes the document to a JSON string.                                                                                    |
| [`to_mongo`](#fiftyone.core.odm.dataset.SampleFieldDocument.to_mongo)(\*args, \*\*kwargs)                   | Return as SON data ready for use with MongoDB.                                                                               |
| [`validate`](#fiftyone.core.odm.dataset.SampleFieldDocument.validate)([clean])                              | Ensure that all fields' values are valid and that required fields are present.                                               |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.SampleFieldDocument.my_metaclass)   |    |
|---------------------------------------------------------------------------------|----|

#### name

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### ftype

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### embedded_doc_type

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### subfield

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### fields

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### db_field

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### description

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### info

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### read_only

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### created_at

A datetime field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### to_field()

Creates the [`fiftyone.core.fields.Field`](fiftyone.core.fields.md#fiftyone.core.fields.Field) specified by this
document.

* **Returns:**
  a [`fiftyone.core.fields.Field`](fiftyone.core.fields.md#fiftyone.core.fields.Field)

#### *classmethod* from_field(field)

Creates a [`SampleFieldDocument`](#fiftyone.core.odm.dataset.SampleFieldDocument) for a field.

* **Parameters:**
  **field** – a [`fiftyone.core.fields.Field`](fiftyone.core.fields.md#fiftyone.core.fields.Field) instance
* **Returns:**
  a [`SampleFieldDocument`](#fiftyone.core.odm.dataset.SampleFieldDocument)

#### STRICT *= False*

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### copy()

Returns a deep copy of the document.

* **Returns:**
  a `SerializableDocument`

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### my_metaclass

alias of `DocumentMetaclass`

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.

### *class* fiftyone.core.odm.dataset.SidebarGroupDocument(\*args, \*\*kwargs)

Bases: [`EmbeddedDocument`](fiftyone.core.odm.embedded_document.md#fiftyone.core.odm.embedded_document.EmbeddedDocument)

Description of a sidebar group in the App.

* **Parameters:**
  * **name** – the name of the sidebar group
  * **paths** ( *[* *]*) – the list of `field` or `embedded.field.name` paths in
    the group
  * **expanded** (*None*) – whether this group should be expanded by default

**Attributes:**

| [`name`](#fiftyone.core.odm.dataset.SidebarGroupDocument.name)               | A unicode string field.                                                                                                      |
|------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [`paths`](#fiftyone.core.odm.dataset.SidebarGroupDocument.paths)             | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`expanded`](#fiftyone.core.odm.dataset.SidebarGroupDocument.expanded)       | A boolean field.                                                                                                             |
| [`STRICT`](#fiftyone.core.odm.dataset.SidebarGroupDocument.STRICT)           |                                                                                                                              |
| [`field_names`](#fiftyone.core.odm.dataset.SidebarGroupDocument.field_names) | An ordered tuple of the public fields of this document.                                                                      |

**Methods:**

| [`clean`](#fiftyone.core.odm.dataset.SidebarGroupDocument.clean)()                                           | Hook for doing document level data cleaning (usually validation or assignment) before validation is run.   |
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [`clear_field`](#fiftyone.core.odm.dataset.SidebarGroupDocument.clear_field)(field_name)                     | Clears the field from the document.                                                                        |
| [`copy`](#fiftyone.core.odm.dataset.SidebarGroupDocument.copy)()                                             | Returns a deep copy of the document.                                                                       |
| [`fancy_repr`](#fiftyone.core.odm.dataset.SidebarGroupDocument.fancy_repr)([class_name, select_fields, ...]) | Generates a customizable string representation of the document.                                            |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.SidebarGroupDocument.field_to_mongo)(field_name)               |                                                                                                            |
| [`field_to_python`](#fiftyone.core.odm.dataset.SidebarGroupDocument.field_to_python)(field_name, value)      |                                                                                                            |
| [`from_dict`](#fiftyone.core.odm.dataset.SidebarGroupDocument.from_dict)(d[, extended])                      | Loads the document from a BSON/JSON dictionary.                                                            |
| [`from_json`](#fiftyone.core.odm.dataset.SidebarGroupDocument.from_json)(s)                                  | Loads the document from a JSON string.                                                                     |
| [`get_field`](#fiftyone.core.odm.dataset.SidebarGroupDocument.get_field)(field_name)                         | Gets the field of the document.                                                                            |
| [`get_text_score`](#fiftyone.core.odm.dataset.SidebarGroupDocument.get_text_score)()                         | Get text score from text query                                                                             |
| [`has_field`](#fiftyone.core.odm.dataset.SidebarGroupDocument.has_field)(field_name)                         | Determines whether the document has a field of the given name.                                             |
| [`iter_fields`](#fiftyone.core.odm.dataset.SidebarGroupDocument.iter_fields)()                               | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                   |
| [`merge`](#fiftyone.core.odm.dataset.SidebarGroupDocument.merge)(doc[, merge_lists, merge_dicts, overwrite]) | Merges the contents of the given document into this document.                                              |
| [`set_field`](#fiftyone.core.odm.dataset.SidebarGroupDocument.set_field)(field_name, value[, create])        | Sets the value of a field of the document.                                                                 |
| [`to_dict`](#fiftyone.core.odm.dataset.SidebarGroupDocument.to_dict)([extended])                             | Serializes this document to a BSON/JSON dictionary.                                                        |
| [`to_json`](#fiftyone.core.odm.dataset.SidebarGroupDocument.to_json)([pretty_print])                         | Serializes the document to a JSON string.                                                                  |
| [`to_mongo`](#fiftyone.core.odm.dataset.SidebarGroupDocument.to_mongo)(\*args, \*\*kwargs)                   | Return as SON data ready for use with MongoDB.                                                             |
| [`validate`](#fiftyone.core.odm.dataset.SidebarGroupDocument.validate)([clean])                              | Ensure that all fields' values are valid and that required fields are present.                             |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.SidebarGroupDocument.my_metaclass)   |    |
|----------------------------------------------------------------------------------|----|

#### name

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### paths

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### expanded

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### STRICT *= False*

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### copy()

Returns a deep copy of the document.

* **Returns:**
  a `SerializableDocument`

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### my_metaclass

alias of `DocumentMetaclass`

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.

### *class* fiftyone.core.odm.dataset.ActiveFields(\*args, \*\*kwargs)

Bases: [`EmbeddedDocument`](fiftyone.core.odm.embedded_document.md#fiftyone.core.odm.embedded_document.EmbeddedDocument)

Description of active fields in the App as defined by the sidebar’s
checkboxes

* **Parameters:**
  * **exclude** (*None*) – whether the paths are exclusionary
  * **paths** ( *[* *]*) – the list of `field` or `embedded.field.name` paths

**Attributes:**

| [`exclude`](#fiftyone.core.odm.dataset.ActiveFields.exclude)         | A boolean field.                                                                                                             |
|----------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [`paths`](#fiftyone.core.odm.dataset.ActiveFields.paths)             | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`STRICT`](#fiftyone.core.odm.dataset.ActiveFields.STRICT)           |                                                                                                                              |
| [`field_names`](#fiftyone.core.odm.dataset.ActiveFields.field_names) | An ordered tuple of the public fields of this document.                                                                      |

**Methods:**

| [`clean`](#fiftyone.core.odm.dataset.ActiveFields.clean)()                                           | Hook for doing document level data cleaning (usually validation or assignment) before validation is run.   |
|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [`clear_field`](#fiftyone.core.odm.dataset.ActiveFields.clear_field)(field_name)                     | Clears the field from the document.                                                                        |
| [`copy`](#fiftyone.core.odm.dataset.ActiveFields.copy)()                                             | Returns a deep copy of the document.                                                                       |
| [`fancy_repr`](#fiftyone.core.odm.dataset.ActiveFields.fancy_repr)([class_name, select_fields, ...]) | Generates a customizable string representation of the document.                                            |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.ActiveFields.field_to_mongo)(field_name)               |                                                                                                            |
| [`field_to_python`](#fiftyone.core.odm.dataset.ActiveFields.field_to_python)(field_name, value)      |                                                                                                            |
| [`from_dict`](#fiftyone.core.odm.dataset.ActiveFields.from_dict)(d[, extended])                      | Loads the document from a BSON/JSON dictionary.                                                            |
| [`from_json`](#fiftyone.core.odm.dataset.ActiveFields.from_json)(s)                                  | Loads the document from a JSON string.                                                                     |
| [`get_field`](#fiftyone.core.odm.dataset.ActiveFields.get_field)(field_name)                         | Gets the field of the document.                                                                            |
| [`get_text_score`](#fiftyone.core.odm.dataset.ActiveFields.get_text_score)()                         | Get text score from text query                                                                             |
| [`has_field`](#fiftyone.core.odm.dataset.ActiveFields.has_field)(field_name)                         | Determines whether the document has a field of the given name.                                             |
| [`iter_fields`](#fiftyone.core.odm.dataset.ActiveFields.iter_fields)()                               | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                   |
| [`merge`](#fiftyone.core.odm.dataset.ActiveFields.merge)(doc[, merge_lists, merge_dicts, overwrite]) | Merges the contents of the given document into this document.                                              |
| [`set_field`](#fiftyone.core.odm.dataset.ActiveFields.set_field)(field_name, value[, create])        | Sets the value of a field of the document.                                                                 |
| [`to_dict`](#fiftyone.core.odm.dataset.ActiveFields.to_dict)([extended])                             | Serializes this document to a BSON/JSON dictionary.                                                        |
| [`to_json`](#fiftyone.core.odm.dataset.ActiveFields.to_json)([pretty_print])                         | Serializes the document to a JSON string.                                                                  |
| [`to_mongo`](#fiftyone.core.odm.dataset.ActiveFields.to_mongo)(\*args, \*\*kwargs)                   | Return as SON data ready for use with MongoDB.                                                             |
| [`validate`](#fiftyone.core.odm.dataset.ActiveFields.validate)([clean])                              | Ensure that all fields' values are valid and that required fields are present.                             |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.ActiveFields.my_metaclass)   |    |
|--------------------------------------------------------------------------|----|

#### exclude

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### paths

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### STRICT *= False*

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### copy()

Returns a deep copy of the document.

* **Returns:**
  a `SerializableDocument`

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### my_metaclass

alias of `DocumentMetaclass`

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.

### *class* fiftyone.core.odm.dataset.ColorScheme(\*args, \*\*kwargs)

Bases: [`EmbeddedDocument`](fiftyone.core.odm.embedded_document.md#fiftyone.core.odm.embedded_document.EmbeddedDocument)

Description of a color scheme in the App.

Example:

```default
import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")

# Store a custom color scheme for a dataset
dataset.app_config.color_scheme = fo.ColorScheme(
    color_by="value",
    color_pool=[
        "#ff0000",
        "#00ff00",
        "#0000ff",
        "pink",
        "yellowgreen",
    ],
    fields=[
        {
            "path": "ground_truth",
            "fieldColor": "#ff00ff",
            "colorByAttribute": "label",
            "valueColors": [{"value": "dog", "color": "yellow"}],
            "maskTargetsColors": [
                {"intTarget": 2, "color": "#ff0000"},
                {"intTarget": 12, "color": "#99ff00"},
            ],
        }
    ],
    label_tags={
        "fieldColor": "#00ffff",
        "valueColors": [
            {"value": "correct", "color": "#ff00ff"},
            {"value": "mistake", "color": "#00ff00"},
        ],
    },
    colorscales=[
        {
            "path": "heatmap1",
            "list": [
                {"value": 0, "color": "rgb(0, 0, 255)"},
                {"value": 1, "color": "rgb(0, 255, 255)"},
            ],
        },
        {
            "path": "heatmap2",
            "name": "hsv",
        },
    ],
    multicolor_keypoints=False,
    opacity=0.5,
    show_skeletons=True,
    default_mask_targets_colors=[
        {"intTarget": 1, "color": "#FEC0AA"},
        {"intTarget": 2, "color": "#EC4E20"},
    ],
    default_colorscale={"name": "sunset", "list": None},
)

session = fo.launch_app(dataset)
```

* **Parameters:**
  * **color_by** (*None*) – whether annotations should be colored by `"field"`,
    `"value"`, or `"instance"`
  * **color_pool** (*None*) – an optional list of colors to use as a color pool
    for this dataset
  * **multicolor_keypoints** (*None*) – whether to use multiple colors for
    keypoints
  * **opacity** (*None*) – transparency of the annotation, between 0 and 1
  * **show_skeletons** (*None*) – whether to show skeletons of keypoints
  * **fields** (*None*) – 

    an optional list of dicts of per-field custom colors
    with the following keys:
    - `path` (required): the fully-qualified path to the field
      you’re customizing
    - `fieldColor` (optional): a color to assign to the field in
      the App sidebar
    - `colorByAttribute` (optional): the attribute to use to assign
      per-value colors. Only applicable when the field is an embedded
      document
    - `valueColors` (optional): a list of dicts specifying colors
      to use for individual values of this field
    - `maskTargetsColors` (optional): a list of dicts specifying
      index and color for 2D masks in the same format as described
      below for default mask targets
  * **default_mask_targets_colors** (*None*) – 

    a list of dicts with the following
    keys specifying index and color for 2D masks of the dataset. If a
    field does not have field specific mask targets colors, this list
    will be used:
    - `intTarget`: an integer target value
    - `color`: a color string

    Note that the pixel value `0` is a reserved “background” class
    that is always rendered as invisible in the App
  * **default_colorscale** (*None*) – 

    dataset default colorscale dict with the
    following keys:
    - `name` (optional): a named plotly colorscale, e.g. `"hsv"`.
      See [https://plotly.com/python/builtin-colorscales](https://plotly.com/python/builtin-colorscales)
    - `list` (optional): a list of dicts of colorscale values
      - `value`: a float number between 0 and 1. A valid list
        must have colors defined for 0 and 1
      - `color`: an RGB color string
  * **colorscales** (*None*) – 

    an optional list of dicts of per-field custom
    colorscales with the following keys:
    - `path` (required): the fully-qualified path to the field
      you’re customizing. use “dataset” if you are setting the
      default colorscale for dataset
    - `name` (optional): a named colorscale plotly recognizes
    - `list` (optional): a list of dicts of colorscale values with
      the following keys:
      - `value`: a float number between 0 and 1. A valid list
        must have colors defined for 0 and 1
      - `color`: an RGB color string
  * **label_tags** (*None*) – 

    an optional dict specifying custom colors for label
    tags with the following keys:
    - `fieldColor` (optional): a color to assign to all label tags
    - `valueColors` (optional): a list of dicts
  * **temporal_tags** (*None*) – 

    an optional dict specifying custom colors for
    temporal tags with the following keys:
    - `fieldColor` (optional): a color to assign to all temporal
      tags
    - `valueColors` (optional): a list of dicts

**Attributes:**

| [`id`](#fiftyone.core.odm.dataset.ColorScheme.id)                                                   | An Object ID field.                                                                                                          |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [`color_pool`](#fiftyone.core.odm.dataset.ColorScheme.color_pool)                                   | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`color_by`](#fiftyone.core.odm.dataset.ColorScheme.color_by)                                       | A unicode string field.                                                                                                      |
| [`fields`](#fiftyone.core.odm.dataset.ColorScheme.fields)                                           | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`label_tags`](#fiftyone.core.odm.dataset.ColorScheme.label_tags)                                   | A dictionary field that wraps a standard Python dictionary.                                                                  |
| [`temporal_tags`](#fiftyone.core.odm.dataset.ColorScheme.temporal_tags)                             | A dictionary field that wraps a standard Python dictionary.                                                                  |
| [`multicolor_keypoints`](#fiftyone.core.odm.dataset.ColorScheme.multicolor_keypoints)               | A boolean field.                                                                                                             |
| [`opacity`](#fiftyone.core.odm.dataset.ColorScheme.opacity)                                         | A floating point number field.                                                                                               |
| [`show_skeletons`](#fiftyone.core.odm.dataset.ColorScheme.show_skeletons)                           | A boolean field.                                                                                                             |
| [`default_mask_targets_colors`](#fiftyone.core.odm.dataset.ColorScheme.default_mask_targets_colors) | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`colorscales`](#fiftyone.core.odm.dataset.ColorScheme.colorscales)                                 | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database. |
| [`default_colorscale`](#fiftyone.core.odm.dataset.ColorScheme.default_colorscale)                   | A dictionary field that wraps a standard Python dictionary.                                                                  |
| [`STRICT`](#fiftyone.core.odm.dataset.ColorScheme.STRICT)                                           |                                                                                                                              |
| [`field_names`](#fiftyone.core.odm.dataset.ColorScheme.field_names)                                 | An ordered tuple of the public fields of this document.                                                                      |

**Methods:**

| [`clean`](#fiftyone.core.odm.dataset.ColorScheme.clean)()                                           | Hook for doing document level data cleaning (usually validation or assignment) before validation is run.   |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [`clear_field`](#fiftyone.core.odm.dataset.ColorScheme.clear_field)(field_name)                     | Clears the field from the document.                                                                        |
| [`copy`](#fiftyone.core.odm.dataset.ColorScheme.copy)()                                             | Returns a deep copy of the document.                                                                       |
| [`fancy_repr`](#fiftyone.core.odm.dataset.ColorScheme.fancy_repr)([class_name, select_fields, ...]) | Generates a customizable string representation of the document.                                            |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.ColorScheme.field_to_mongo)(field_name)               |                                                                                                            |
| [`field_to_python`](#fiftyone.core.odm.dataset.ColorScheme.field_to_python)(field_name, value)      |                                                                                                            |
| [`from_dict`](#fiftyone.core.odm.dataset.ColorScheme.from_dict)(d[, extended])                      | Loads the document from a BSON/JSON dictionary.                                                            |
| [`from_json`](#fiftyone.core.odm.dataset.ColorScheme.from_json)(s)                                  | Loads the document from a JSON string.                                                                     |
| [`get_field`](#fiftyone.core.odm.dataset.ColorScheme.get_field)(field_name)                         | Gets the field of the document.                                                                            |
| [`get_text_score`](#fiftyone.core.odm.dataset.ColorScheme.get_text_score)()                         | Get text score from text query                                                                             |
| [`has_field`](#fiftyone.core.odm.dataset.ColorScheme.has_field)(field_name)                         | Determines whether the document has a field of the given name.                                             |
| [`iter_fields`](#fiftyone.core.odm.dataset.ColorScheme.iter_fields)()                               | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                   |
| [`merge`](#fiftyone.core.odm.dataset.ColorScheme.merge)(doc[, merge_lists, merge_dicts, overwrite]) | Merges the contents of the given document into this document.                                              |
| [`set_field`](#fiftyone.core.odm.dataset.ColorScheme.set_field)(field_name, value[, create])        | Sets the value of a field of the document.                                                                 |
| [`to_dict`](#fiftyone.core.odm.dataset.ColorScheme.to_dict)([extended])                             | Serializes this document to a BSON/JSON dictionary.                                                        |
| [`to_json`](#fiftyone.core.odm.dataset.ColorScheme.to_json)([pretty_print])                         | Serializes the document to a JSON string.                                                                  |
| [`to_mongo`](#fiftyone.core.odm.dataset.ColorScheme.to_mongo)(\*args, \*\*kwargs)                   | Return as SON data ready for use with MongoDB.                                                             |
| [`validate`](#fiftyone.core.odm.dataset.ColorScheme.validate)([clean])                              | Ensure that all fields' values are valid and that required fields are present.                             |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.ColorScheme.my_metaclass)   |    |
|-------------------------------------------------------------------------|----|

#### id

An Object ID field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### color_pool

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### color_by

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### fields

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### label_tags

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### temporal_tags

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### multicolor_keypoints

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### opacity

A floating point number field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### show_skeletons

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### default_mask_targets_colors

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### colorscales

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### default_colorscale

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### STRICT *= False*

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### copy()

Returns a deep copy of the document.

* **Returns:**
  a `SerializableDocument`

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### my_metaclass

alias of `DocumentMetaclass`

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.

### *class* fiftyone.core.odm.dataset.KeypointSkeleton(\*args, \*\*kwargs)

Bases: [`EmbeddedDocument`](fiftyone.core.odm.embedded_document.md#fiftyone.core.odm.embedded_document.EmbeddedDocument)

Description of a keypoint skeleton.

Keypoint skeletons can be associated with
[`fiftyone.core.labels.Keypoint`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint) or
[`fiftyone.core.labels.Keypoints`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoints) fields whose
[`points`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint.points) attributes all
contain a fixed number of semantically ordered points.

The `edges` argument contains lists of integer indexes that define the
connectivity of the points in the skeleton, and the optional `labels`
argument defines the label strings for each node in the skeleton.

For example, the skeleton below is defined by edges between the following
nodes:

```default
left hand <-> left shoulder <-> right shoulder <-> right hand
left eye <-> right eye <-> mouth
```

Example:

```default
import fiftyone as fo

# A skeleton for an object made of 7 points
skeleton = fo.KeypointSkeleton(
    labels=[
        "left hand" "left shoulder", "right shoulder", "right hand",
        "left eye", "right eye", "mouth",
    ],
    edges=[[0, 1, 2, 3], [4, 5, 6]],
)
```

* **Parameters:**
  * **labels** (*None*) – an optional list of label strings for each node
  * **edges** – a list of lists of integer indexes defining the connectivity
    between nodes

**Attributes:**

| [`labels`](#fiftyone.core.odm.dataset.KeypointSkeleton.labels)           | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.   |
|--------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| [`edges`](#fiftyone.core.odm.dataset.KeypointSkeleton.edges)             | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.   |
| [`STRICT`](#fiftyone.core.odm.dataset.KeypointSkeleton.STRICT)           |                                                                                                                                |
| [`field_names`](#fiftyone.core.odm.dataset.KeypointSkeleton.field_names) | An ordered tuple of the public fields of this document.                                                                        |

**Methods:**

| [`clean`](#fiftyone.core.odm.dataset.KeypointSkeleton.clean)()                                           | Hook for doing document level data cleaning (usually validation or assignment) before validation is run.   |
|----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [`clear_field`](#fiftyone.core.odm.dataset.KeypointSkeleton.clear_field)(field_name)                     | Clears the field from the document.                                                                        |
| [`copy`](#fiftyone.core.odm.dataset.KeypointSkeleton.copy)()                                             | Returns a deep copy of the document.                                                                       |
| [`fancy_repr`](#fiftyone.core.odm.dataset.KeypointSkeleton.fancy_repr)([class_name, select_fields, ...]) | Generates a customizable string representation of the document.                                            |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.KeypointSkeleton.field_to_mongo)(field_name)               |                                                                                                            |
| [`field_to_python`](#fiftyone.core.odm.dataset.KeypointSkeleton.field_to_python)(field_name, value)      |                                                                                                            |
| [`from_dict`](#fiftyone.core.odm.dataset.KeypointSkeleton.from_dict)(d[, extended])                      | Loads the document from a BSON/JSON dictionary.                                                            |
| [`from_json`](#fiftyone.core.odm.dataset.KeypointSkeleton.from_json)(s)                                  | Loads the document from a JSON string.                                                                     |
| [`get_field`](#fiftyone.core.odm.dataset.KeypointSkeleton.get_field)(field_name)                         | Gets the field of the document.                                                                            |
| [`get_text_score`](#fiftyone.core.odm.dataset.KeypointSkeleton.get_text_score)()                         | Get text score from text query                                                                             |
| [`has_field`](#fiftyone.core.odm.dataset.KeypointSkeleton.has_field)(field_name)                         | Determines whether the document has a field of the given name.                                             |
| [`iter_fields`](#fiftyone.core.odm.dataset.KeypointSkeleton.iter_fields)()                               | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                   |
| [`merge`](#fiftyone.core.odm.dataset.KeypointSkeleton.merge)(doc[, merge_lists, merge_dicts, overwrite]) | Merges the contents of the given document into this document.                                              |
| [`set_field`](#fiftyone.core.odm.dataset.KeypointSkeleton.set_field)(field_name, value[, create])        | Sets the value of a field of the document.                                                                 |
| [`to_dict`](#fiftyone.core.odm.dataset.KeypointSkeleton.to_dict)([extended])                             | Serializes this document to a BSON/JSON dictionary.                                                        |
| [`to_json`](#fiftyone.core.odm.dataset.KeypointSkeleton.to_json)([pretty_print])                         | Serializes the document to a JSON string.                                                                  |
| [`to_mongo`](#fiftyone.core.odm.dataset.KeypointSkeleton.to_mongo)(\*args, \*\*kwargs)                   | Return as SON data ready for use with MongoDB.                                                             |
| [`validate`](#fiftyone.core.odm.dataset.KeypointSkeleton.validate)([clean])                              | Ensure that all fields' values are valid and that required fields are present.                             |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.KeypointSkeleton.my_metaclass)   |    |
|------------------------------------------------------------------------------|----|

#### labels

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### edges

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### STRICT *= False*

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### copy()

Returns a deep copy of the document.

* **Returns:**
  a `SerializableDocument`

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### my_metaclass

alias of `DocumentMetaclass`

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.

### *class* fiftyone.core.odm.dataset.DatasetAppConfig(\*args, \*\*kwargs)

Bases: [`EmbeddedDocument`](fiftyone.core.odm.embedded_document.md#fiftyone.core.odm.embedded_document.EmbeddedDocument)

Dataset-specific settings that customize how a dataset is visualized in
the App.

* **Parameters:**
  * **active_fields** (*None*) – an optional [`ActiveFields`](#fiftyone.core.odm.dataset.ActiveFields) dataset default
  * **color_scheme** (*None*) – an optional [`ColorScheme`](#fiftyone.core.odm.dataset.ColorScheme) dataset default
  * **disable_frame_filtering** (*False*) – whether to disable frame filtering for
    video datasets in the App’s grid view
  * **dynamic_groups_target_frame_rate** (*30*) – the target frame rate when
    rendering ordered dynamic groups of images as videos
  * **grid_media_field** ( *"filepath"*) – the default sample field from which to
    serve media in the App’s grid view
  * **media_fallback** (*False*) – whether to fall back to the default media
    field (`"filepath"`) when the alternate media field value for a
    sample is not defined
  * **media_fields** ( *[* *"filepath"* *]*) – the list of sample fields that contain
    media and should be available to choose from the App’s settings
    menus
  * **modal_media_field** ( *"filepath"*) – the default sample field from which to
    serve media in the App’s modal view
  * **plugins** ( *{}*) – 

    an optional dict mapping plugin names to plugin
    configuration dicts. Builtin plugins include:
    - `"map"`: See the [map plugin docs](../user_guide/app.md#app-map-panel) for
      supported options
    - `"point-cloud"`: See the
      [3D visualizer docs](../user_guide/app.md#app-3d-visualizer-config) for
      supported options
  * **sidebar_groups** (*None*) – an optional list of
    [`SidebarGroupDocument`](#fiftyone.core.odm.dataset.SidebarGroupDocument) describing sidebar groups to use in
    the App

**Attributes:**

| [`active_fields`](#fiftyone.core.odm.dataset.DatasetAppConfig.active_fields)                                       | A field that stores instances of a given type of [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object.   |
|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`color_scheme`](#fiftyone.core.odm.dataset.DatasetAppConfig.color_scheme)                                         | A field that stores instances of a given type of [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object.   |
| [`disable_frame_filtering`](#fiftyone.core.odm.dataset.DatasetAppConfig.disable_frame_filtering)                   | A boolean field.                                                                                                                                                   |
| [`dynamic_groups_target_frame_rate`](#fiftyone.core.odm.dataset.DatasetAppConfig.dynamic_groups_target_frame_rate) | A 32 bit integer field.                                                                                                                                            |
| [`grid_media_field`](#fiftyone.core.odm.dataset.DatasetAppConfig.grid_media_field)                                 | A unicode string field.                                                                                                                                            |
| [`media_fallback`](#fiftyone.core.odm.dataset.DatasetAppConfig.media_fallback)                                     | A boolean field.                                                                                                                                                   |
| [`media_fields`](#fiftyone.core.odm.dataset.DatasetAppConfig.media_fields)                                         | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.                                       |
| [`modal_media_field`](#fiftyone.core.odm.dataset.DatasetAppConfig.modal_media_field)                               | A unicode string field.                                                                                                                                            |
| [`plugins`](#fiftyone.core.odm.dataset.DatasetAppConfig.plugins)                                                   | A dictionary field that wraps a standard Python dictionary.                                                                                                        |
| [`sidebar_groups`](#fiftyone.core.odm.dataset.DatasetAppConfig.sidebar_groups)                                     | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.                                       |
| [`STRICT`](#fiftyone.core.odm.dataset.DatasetAppConfig.STRICT)                                                     |                                                                                                                                                                    |
| [`field_names`](#fiftyone.core.odm.dataset.DatasetAppConfig.field_names)                                           | An ordered tuple of the public fields of this document.                                                                                                            |

**Methods:**

| [`default_active_fields`](#fiftyone.core.odm.dataset.DatasetAppConfig.default_active_fields)(sample_collection)   | Generates the default `active_fields` for the given collection.                                          |
|-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| [`default_sidebar_groups`](#fiftyone.core.odm.dataset.DatasetAppConfig.default_sidebar_groups)(sample_collection) | Generates the default `sidebar_groups` for the given collection.                                         |
| [`is_custom`](#fiftyone.core.odm.dataset.DatasetAppConfig.is_custom)()                                            | Determines whether this app config differs from the default one.                                         |
| [`clean`](#fiftyone.core.odm.dataset.DatasetAppConfig.clean)()                                                    | Hook for doing document level data cleaning (usually validation or assignment) before validation is run. |
| [`clear_field`](#fiftyone.core.odm.dataset.DatasetAppConfig.clear_field)(field_name)                              | Clears the field from the document.                                                                      |
| [`copy`](#fiftyone.core.odm.dataset.DatasetAppConfig.copy)()                                                      | Returns a deep copy of the document.                                                                     |
| [`fancy_repr`](#fiftyone.core.odm.dataset.DatasetAppConfig.fancy_repr)([class_name, select_fields, ...])          | Generates a customizable string representation of the document.                                          |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.DatasetAppConfig.field_to_mongo)(field_name)                        |                                                                                                          |
| [`field_to_python`](#fiftyone.core.odm.dataset.DatasetAppConfig.field_to_python)(field_name, value)               |                                                                                                          |
| [`from_dict`](#fiftyone.core.odm.dataset.DatasetAppConfig.from_dict)(d[, extended])                               | Loads the document from a BSON/JSON dictionary.                                                          |
| [`from_json`](#fiftyone.core.odm.dataset.DatasetAppConfig.from_json)(s)                                           | Loads the document from a JSON string.                                                                   |
| [`get_field`](#fiftyone.core.odm.dataset.DatasetAppConfig.get_field)(field_name)                                  | Gets the field of the document.                                                                          |
| [`get_text_score`](#fiftyone.core.odm.dataset.DatasetAppConfig.get_text_score)()                                  | Get text score from text query                                                                           |
| [`has_field`](#fiftyone.core.odm.dataset.DatasetAppConfig.has_field)(field_name)                                  | Determines whether the document has a field of the given name.                                           |
| [`iter_fields`](#fiftyone.core.odm.dataset.DatasetAppConfig.iter_fields)()                                        | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                 |
| [`merge`](#fiftyone.core.odm.dataset.DatasetAppConfig.merge)(doc[, merge_lists, merge_dicts, overwrite])          | Merges the contents of the given document into this document.                                            |
| [`set_field`](#fiftyone.core.odm.dataset.DatasetAppConfig.set_field)(field_name, value[, create])                 | Sets the value of a field of the document.                                                               |
| [`to_dict`](#fiftyone.core.odm.dataset.DatasetAppConfig.to_dict)([extended])                                      | Serializes this document to a BSON/JSON dictionary.                                                      |
| [`to_json`](#fiftyone.core.odm.dataset.DatasetAppConfig.to_json)([pretty_print])                                  | Serializes the document to a JSON string.                                                                |
| [`to_mongo`](#fiftyone.core.odm.dataset.DatasetAppConfig.to_mongo)(\*args, \*\*kwargs)                            | Return as SON data ready for use with MongoDB.                                                           |
| [`validate`](#fiftyone.core.odm.dataset.DatasetAppConfig.validate)([clean])                                       | Ensure that all fields' values are valid and that required fields are present.                           |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.DatasetAppConfig.my_metaclass)   |    |
|------------------------------------------------------------------------------|----|

#### active_fields

A field that stores instances of a given type of
[`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object.

* **Parameters:**
  * **document_type** – the [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) type
    stored in this field
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### color_scheme

A field that stores instances of a given type of
[`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object.

* **Parameters:**
  * **document_type** – the [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) type
    stored in this field
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### disable_frame_filtering

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### dynamic_groups_target_frame_rate

A 32 bit integer field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### grid_media_field

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### media_fallback

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### media_fields

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### modal_media_field

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### plugins

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### sidebar_groups

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### *static* default_active_fields(sample_collection)

Generates the default `active_fields` for the given collection.

Examples:

```default
import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")

active_fields = fo.DatasetAppConfig.default_active_fields(dataset)
dataset.app_config.active_fields = active_fields
print(dataset.app_config)
```

* **Parameters:**
  **sample_collection** – a
  [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection)
* **Returns:**
  an [`ActiveFields`](#fiftyone.core.odm.dataset.ActiveFields) instance

#### *static* default_sidebar_groups(sample_collection)

Generates the default `sidebar_groups` for the given collection.

Examples:

```default
import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")

sidebar_groups = fo.DatasetAppConfig.default_sidebar_groups(dataset)
dataset.app_config.sidebar_groups = sidebar_groups
print(dataset.app_config)
```

* **Parameters:**
  **sample_collection** – a
  [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection)
* **Returns:**
  a list of [`SidebarGroupDocument`](#fiftyone.core.odm.dataset.SidebarGroupDocument) instances

#### is_custom()

Determines whether this app config differs from the default one.

* **Returns:**
  True/False

#### STRICT *= False*

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### copy()

Returns a deep copy of the document.

* **Returns:**
  a `SerializableDocument`

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### my_metaclass

alias of `DocumentMetaclass`

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.

### *class* fiftyone.core.odm.dataset.DatasetDocument(\*\*kwargs)

Bases: [`Document`](fiftyone.core.odm.document.md#fiftyone.core.odm.document.Document)

Backing document for datasets.

**Attributes:**

| [`name`](#fiftyone.core.odm.dataset.DatasetDocument.name)                                     | A unicode string field.                                                                                                                                          |
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`slug`](#fiftyone.core.odm.dataset.DatasetDocument.slug)                                     | A unicode string field.                                                                                                                                          |
| [`version`](#fiftyone.core.odm.dataset.DatasetDocument.version)                               | A unicode string field.                                                                                                                                          |
| [`created_at`](#fiftyone.core.odm.dataset.DatasetDocument.created_at)                         | A datetime field.                                                                                                                                                |
| [`last_modified_at`](#fiftyone.core.odm.dataset.DatasetDocument.last_modified_at)             | A datetime field.                                                                                                                                                |
| [`last_deletion_at`](#fiftyone.core.odm.dataset.DatasetDocument.last_deletion_at)             | A datetime field.                                                                                                                                                |
| [`last_loaded_at`](#fiftyone.core.odm.dataset.DatasetDocument.last_loaded_at)                 | A datetime field.                                                                                                                                                |
| [`sample_collection_name`](#fiftyone.core.odm.dataset.DatasetDocument.sample_collection_name) | A unicode string field.                                                                                                                                          |
| [`frame_collection_name`](#fiftyone.core.odm.dataset.DatasetDocument.frame_collection_name)   | A unicode string field.                                                                                                                                          |
| [`persistent`](#fiftyone.core.odm.dataset.DatasetDocument.persistent)                         | A boolean field.                                                                                                                                                 |
| [`media_type`](#fiftyone.core.odm.dataset.DatasetDocument.media_type)                         | A unicode string field.                                                                                                                                          |
| [`group_field`](#fiftyone.core.odm.dataset.DatasetDocument.group_field)                       | A unicode string field.                                                                                                                                          |
| [`group_media_types`](#fiftyone.core.odm.dataset.DatasetDocument.group_media_types)           | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`default_group_slice`](#fiftyone.core.odm.dataset.DatasetDocument.default_group_slice)       | A unicode string field.                                                                                                                                          |
| [`tags`](#fiftyone.core.odm.dataset.DatasetDocument.tags)                                     | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.                                     |
| [`description`](#fiftyone.core.odm.dataset.DatasetDocument.description)                       | A unicode string field.                                                                                                                                          |
| [`info`](#fiftyone.core.odm.dataset.DatasetDocument.info)                                     | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`app_config`](#fiftyone.core.odm.dataset.DatasetDocument.app_config)                         | A field that stores instances of a given type of [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object. |
| [`classes`](#fiftyone.core.odm.dataset.DatasetDocument.classes)                               | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`default_classes`](#fiftyone.core.odm.dataset.DatasetDocument.default_classes)               | A `ListField` that stores class label strings.                                                                                                                   |
| [`mask_targets`](#fiftyone.core.odm.dataset.DatasetDocument.mask_targets)                     | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`default_mask_targets`](#fiftyone.core.odm.dataset.DatasetDocument.default_mask_targets)     | A `DictField` that stores mapping between integer keys or RGB string hex keys and string targets.                                                                |
| [`skeletons`](#fiftyone.core.odm.dataset.DatasetDocument.skeletons)                           | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`default_skeleton`](#fiftyone.core.odm.dataset.DatasetDocument.default_skeleton)             | A field that stores instances of a given type of [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object. |
| [`camera_intrinsics`](#fiftyone.core.odm.dataset.DatasetDocument.camera_intrinsics)           | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`static_transforms`](#fiftyone.core.odm.dataset.DatasetDocument.static_transforms)           | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`sample_fields`](#fiftyone.core.odm.dataset.DatasetDocument.sample_fields)                   | A field that stores a list of a given type of [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) objects.   |
| [`frame_fields`](#fiftyone.core.odm.dataset.DatasetDocument.frame_fields)                     | A field that stores a list of a given type of [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) objects.   |
| [`saved_views`](#fiftyone.core.odm.dataset.DatasetDocument.saved_views)                       | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.                                     |
| [`workspaces`](#fiftyone.core.odm.dataset.DatasetDocument.workspaces)                         | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.                                     |
| [`annotation_runs`](#fiftyone.core.odm.dataset.DatasetDocument.annotation_runs)               | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`brain_methods`](#fiftyone.core.odm.dataset.DatasetDocument.brain_methods)                   | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`evaluations`](#fiftyone.core.odm.dataset.DatasetDocument.evaluations)                       | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`runs`](#fiftyone.core.odm.dataset.DatasetDocument.runs)                                     | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`active_label_schemas`](#fiftyone.core.odm.dataset.DatasetDocument.active_label_schemas)     | A list field that wraps a standard `Field`, allowing multiple instances of the field to be stored as a list in the database.                                     |
| [`label_schemas`](#fiftyone.core.odm.dataset.DatasetDocument.label_schemas)                   | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`frame_label_schemas`](#fiftyone.core.odm.dataset.DatasetDocument.frame_label_schemas)       | A dictionary field that wraps a standard Python dictionary.                                                                                                      |
| [`STRICT`](#fiftyone.core.odm.dataset.DatasetDocument.STRICT)                                 |                                                                                                                                                                  |
| [`field_names`](#fiftyone.core.odm.dataset.DatasetDocument.field_names)                       | An ordered tuple of the public fields of this document.                                                                                                          |
| [`id`](#fiftyone.core.odm.dataset.DatasetDocument.id)                                         | A field wrapper around MongoDB's ObjectIds.                                                                                                                      |
| [`in_db`](#fiftyone.core.odm.dataset.DatasetDocument.in_db)                                   | Whether the document has been inserted into the database.                                                                                                        |
| [`pk`](#fiftyone.core.odm.dataset.DatasetDocument.pk)                                         | Get the primary key.                                                                                                                                             |

**Methods:**

| [`get_stored_label_schema`](#fiftyone.core.odm.dataset.DatasetDocument.get_stored_label_schema)(field)                   | Returns the stored label schema for a field path, or `None`.                                                                                                                                     |
|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`set_stored_label_schema`](#fiftyone.core.odm.dataset.DatasetDocument.set_stored_label_schema)(field, label_schema)     | Stores the label schema for a field path in the right store.                                                                                                                                     |
| [`all_stored_label_schemas`](#fiftyone.core.odm.dataset.DatasetDocument.all_stored_label_schemas)()                      | Returns all stored label schemas keyed by full path, with frame schemas re-keyed to their `frames.<field>` path.                                                                                 |
| [`set_all_stored_label_schemas`](#fiftyone.core.odm.dataset.DatasetDocument.set_all_stored_label_schemas)(label_schemas) | Replaces all stored label schemas from a full-path-keyed dict, splitting frame paths into the frame schema store.                                                                                |
| [`get_saved_views`](#fiftyone.core.odm.dataset.DatasetDocument.get_saved_views)()                                        |                                                                                                                                                                                                  |
| [`get_workspaces`](#fiftyone.core.odm.dataset.DatasetDocument.get_workspaces)()                                          |                                                                                                                                                                                                  |
| [`get_annotation_runs`](#fiftyone.core.odm.dataset.DatasetDocument.get_annotation_runs)()                                |                                                                                                                                                                                                  |
| [`get_brain_methods`](#fiftyone.core.odm.dataset.DatasetDocument.get_brain_methods)()                                    |                                                                                                                                                                                                  |
| [`get_evaluations`](#fiftyone.core.odm.dataset.DatasetDocument.get_evaluations)()                                        |                                                                                                                                                                                                  |
| [`get_runs`](#fiftyone.core.odm.dataset.DatasetDocument.get_runs)()                                                      |                                                                                                                                                                                                  |
| [`cascade_save`](#fiftyone.core.odm.dataset.DatasetDocument.cascade_save)(\*\*kwargs)                                    | Recursively save any references and generic references on the document.                                                                                                                          |
| [`clean`](#fiftyone.core.odm.dataset.DatasetDocument.clean)()                                                            | Hook for doing document level data cleaning (usually validation or assignment) before validation is run.                                                                                         |
| [`clear_field`](#fiftyone.core.odm.dataset.DatasetDocument.clear_field)(field_name)                                      | Clears the field from the document.                                                                                                                                                              |
| [`compare_indexes`](#fiftyone.core.odm.dataset.DatasetDocument.compare_indexes)()                                        | Compares the indexes defined in MongoEngine with the ones existing in the database.                                                                                                              |
| [`copy`](#fiftyone.core.odm.dataset.DatasetDocument.copy)([new_id])                                                      | Returns a deep copy of the document.                                                                                                                                                             |
| [`copy_with_new_id`](#fiftyone.core.odm.dataset.DatasetDocument.copy_with_new_id)()                                      |                                                                                                                                                                                                  |
| [`create_index`](#fiftyone.core.odm.dataset.DatasetDocument.create_index)(keys[, background])                            | Creates the given indexes if required.                                                                                                                                                           |
| [`delete`](#fiftyone.core.odm.dataset.DatasetDocument.delete)([signal_kwargs])                                           | Delete the `Document` from the database.                                                                                                                                                         |
| [`drop_collection`](#fiftyone.core.odm.dataset.DatasetDocument.drop_collection)()                                        | Drops the entire collection associated with this `Document` type from the database.                                                                                                              |
| [`ensure_indexes`](#fiftyone.core.odm.dataset.DatasetDocument.ensure_indexes)()                                          | Checks the document meta data and ensures all the indexes exist.                                                                                                                                 |
| [`fancy_repr`](#fiftyone.core.odm.dataset.DatasetDocument.fancy_repr)([class_name, select_fields, ...])                  | Generates a customizable string representation of the document.                                                                                                                                  |
| [`field_to_mongo`](#fiftyone.core.odm.dataset.DatasetDocument.field_to_mongo)(field_name)                                |                                                                                                                                                                                                  |
| [`field_to_python`](#fiftyone.core.odm.dataset.DatasetDocument.field_to_python)(field_name, value)                       |                                                                                                                                                                                                  |
| [`from_dict`](#fiftyone.core.odm.dataset.DatasetDocument.from_dict)(d[, extended])                                       | Loads the document from a BSON/JSON dictionary.                                                                                                                                                  |
| [`from_json`](#fiftyone.core.odm.dataset.DatasetDocument.from_json)(s)                                                   | Loads the document from a JSON string.                                                                                                                                                           |
| [`get_field`](#fiftyone.core.odm.dataset.DatasetDocument.get_field)(field_name)                                          | Gets the field of the document.                                                                                                                                                                  |
| [`get_text_score`](#fiftyone.core.odm.dataset.DatasetDocument.get_text_score)()                                          | Get text score from text query                                                                                                                                                                   |
| [`has_field`](#fiftyone.core.odm.dataset.DatasetDocument.has_field)(field_name)                                          | Determines whether the document has a field of the given name.                                                                                                                                   |
| [`iter_fields`](#fiftyone.core.odm.dataset.DatasetDocument.iter_fields)()                                                | Returns an iterator over the `(name, value)` pairs of the public fields of the document.                                                                                                         |
| [`list_indexes`](#fiftyone.core.odm.dataset.DatasetDocument.list_indexes)()                                              | Lists all indexes that should be created for the Document collection.                                                                                                                            |
| [`merge`](#fiftyone.core.odm.dataset.DatasetDocument.merge)(doc[, merge_lists, merge_dicts, overwrite])                  | Merges the contents of the given document into this document.                                                                                                                                    |
| [`modify`](#fiftyone.core.odm.dataset.DatasetDocument.modify)([query])                                                   | Perform an atomic update of the document in the database and reload the document object using updated version.                                                                                   |
| [`register_delete_rule`](#fiftyone.core.odm.dataset.DatasetDocument.register_delete_rule)(document_cls, ...)             | This method registers the delete rules to apply when removing this object.                                                                                                                       |
| [`reload`](#fiftyone.core.odm.dataset.DatasetDocument.reload)(\*fields, \*\*kwargs)                                      | Reloads the document from the database.                                                                                                                                                          |
| [`save`](#fiftyone.core.odm.dataset.DatasetDocument.save)([upsert, validate, safe])                                      | Saves the document to the database.                                                                                                                                                              |
| [`select_related`](#fiftyone.core.odm.dataset.DatasetDocument.select_related)([max_depth])                               | Handles dereferencing of [`DBRef`](https://pymongo.readthedocs.io/en/stable/api/bson/dbref.html#bson.dbref.DBRef) objects to a maximum depth in order to cut down the number queries to mongodb. |
| [`set_field`](#fiftyone.core.odm.dataset.DatasetDocument.set_field)(field_name, value[, create])                         | Sets the value of a field of the document.                                                                                                                                                       |
| [`switch_collection`](#fiftyone.core.odm.dataset.DatasetDocument.switch_collection)(collection_name[, ...])              | Temporarily switch the collection for a document instance.                                                                                                                                       |
| [`switch_db`](#fiftyone.core.odm.dataset.DatasetDocument.switch_db)(db_alias[, keep_created])                            | Temporarily switch the database for a document instance.                                                                                                                                         |
| [`to_dbref`](#fiftyone.core.odm.dataset.DatasetDocument.to_dbref)()                                                      | Returns an instance of [`DBRef`](https://pymongo.readthedocs.io/en/stable/api/bson/dbref.html#bson.dbref.DBRef) useful in `__raw__` queries.                                                     |
| [`to_dict`](#fiftyone.core.odm.dataset.DatasetDocument.to_dict)(\*args[, no_dereference])                                | Serializes this document to a BSON/JSON dictionary.                                                                                                                                              |
| [`to_json`](#fiftyone.core.odm.dataset.DatasetDocument.to_json)([pretty_print])                                          | Serializes the document to a JSON string.                                                                                                                                                        |
| [`to_mongo`](#fiftyone.core.odm.dataset.DatasetDocument.to_mongo)(\*args, \*\*kwargs)                                    | Return as SON data ready for use with MongoDB.                                                                                                                                                   |
| [`update`](#fiftyone.core.odm.dataset.DatasetDocument.update)(\*\*kwargs)                                                | Performs an update on the `Document` A convenience wrapper to `update()`.                                                                                                                        |
| [`validate`](#fiftyone.core.odm.dataset.DatasetDocument.validate)([clean])                                               | Ensure that all fields' values are valid and that required fields are present.                                                                                                                   |

**Miscellaneous:**

| [`DoesNotExist`](#fiftyone.core.odm.dataset.DatasetDocument.DoesNotExist)                       |    |
|-------------------------------------------------------------------------------------------------|----|
| [`MultipleObjectsReturned`](#fiftyone.core.odm.dataset.DatasetDocument.MultipleObjectsReturned) |    |

**Classes:**

| [`my_metaclass`](#fiftyone.core.odm.dataset.DatasetDocument.my_metaclass)   |    |
|-----------------------------------------------------------------------------|----|

#### name

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### slug

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### version

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### created_at

A datetime field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### last_modified_at

A datetime field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### last_deletion_at

A datetime field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### last_loaded_at

A datetime field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### sample_collection_name

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### frame_collection_name

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### persistent

A boolean field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### media_type

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### group_field

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### group_media_types

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### default_group_slice

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### tags

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### description

A unicode string field.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### info

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### app_config

A field that stores instances of a given type of
[`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object.

* **Parameters:**
  * **document_type** – the [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) type
    stored in this field
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### classes

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### default_classes

A `ListField` that stores class label strings.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### mask_targets

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### default_mask_targets

A `DictField` that stores mapping between integer keys or RGB
string hex keys and string targets.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### skeletons

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### default_skeleton

A field that stores instances of a given type of
[`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) object.

* **Parameters:**
  * **document_type** – the [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) type
    stored in this field
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### camera_intrinsics

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### static_transforms

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### sample_fields

A field that stores a list of a given type of
[`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) objects.

* **Parameters:**
  * **document_type** – the [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) type
    stored in this field
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### frame_fields

A field that stores a list of a given type of
[`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) objects.

* **Parameters:**
  * **document_type** – the [`fiftyone.core.odm.BaseEmbeddedDocument`](fiftyone.core.odm.md#fiftyone.core.odm.BaseEmbeddedDocument) type
    stored in this field
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### saved_views

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### workspaces

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### annotation_runs

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### brain_methods

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### evaluations

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### runs

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### active_label_schemas

A list field that wraps a standard `Field`, allowing multiple
instances of the field to be stored as a list in the database.

If this field is not set, its default value is `[]`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the
    type of the list elements
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### label_schemas

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### frame_label_schemas

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is `{}`.

* **Parameters:**
  * **field** (*None*) – an optional `Field` instance describing the type
    of the values in the dict
  * **description** (*None*) – an optional description
  * **info** (*None*) – an optional info dict
  * **read_only** (*False*) – whether the field is read-only
  * **created_at** (*None*) – the datetime the field was created

#### get_stored_label_schema(field)

Returns the stored label schema for a field path, or `None`.

#### set_stored_label_schema(field, label_schema)

Stores the label schema for a field path in the right store.

#### all_stored_label_schemas()

Returns all stored label schemas keyed by full path, with frame
schemas re-keyed to their `frames.<field>` path.

#### set_all_stored_label_schemas(label_schemas)

Replaces all stored label schemas from a full-path-keyed dict,
splitting frame paths into the frame schema store.

#### get_saved_views()

#### get_workspaces()

#### get_annotation_runs()

#### get_brain_methods()

#### get_evaluations()

#### get_runs()

#### *exception* DoesNotExist

Bases: `DoesNotExist`

**Methods:**

| [`add_note`](#fiftyone.core.odm.dataset.DatasetDocument.DoesNotExist.add_note)(object, /)             | Exception.add_note(note) -- add a note to the exception                         |
|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [`with_traceback`](#fiftyone.core.odm.dataset.DatasetDocument.DoesNotExist.with_traceback)(object, /) | Exception.with_traceback(tb) -- set self._\_traceback_\_ to tb and return self. |

**Attributes:**

| [`args`](#fiftyone.core.odm.dataset.DatasetDocument.DoesNotExist.args)   |    |
|--------------------------------------------------------------------------|----|

#### add_note(object,)

Exception.add_note(note) –
add a note to the exception

#### args

#### with_traceback(object,)

Exception.with_traceback(tb) –
set self._\_traceback_\_ to tb and return self.

#### *exception* MultipleObjectsReturned

Bases: `MultipleObjectsReturned`

**Methods:**

| [`add_note`](#fiftyone.core.odm.dataset.DatasetDocument.MultipleObjectsReturned.add_note)(object, /)             | Exception.add_note(note) -- add a note to the exception                         |
|------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [`with_traceback`](#fiftyone.core.odm.dataset.DatasetDocument.MultipleObjectsReturned.with_traceback)(object, /) | Exception.with_traceback(tb) -- set self._\_traceback_\_ to tb and return self. |

**Attributes:**

| [`args`](#fiftyone.core.odm.dataset.DatasetDocument.MultipleObjectsReturned.args)   |    |
|-------------------------------------------------------------------------------------|----|

#### add_note(object,)

Exception.add_note(note) –
add a note to the exception

#### args

#### with_traceback(object,)

Exception.with_traceback(tb) –
set self._\_traceback_\_ to tb and return self.

#### STRICT *= False*

#### cascade_save(\*\*kwargs)

Recursively save any references and generic references on the
document.

#### clean()

Hook for doing document level data cleaning (usually validation or assignment)
before validation is run.

Any ValidationError raised by this method will not be associated with
a particular field; it will have a special-case association with the
field defined by NON_FIELD_ERRORS.

#### clear_field(field_name)

Clears the field from the document.

* **Parameters:**
  **field_name** – the field name
* **Raises:**
  **ValueError** – if the field does not exist

#### *classmethod* compare_indexes()

Compares the indexes defined in MongoEngine with the ones
existing in the database. Returns any missing/extra indexes.

#### copy(new_id=False)

Returns a deep copy of the document.

* **Parameters:**
  **new_id** (*False*) – whether to generate a new ID for the copied
  document. By default, the ID is left as `None` and will be
  automatically populated when the document is added to the
  database

#### copy_with_new_id()

#### *classmethod* create_index(keys, background=False, \*\*kwargs)

Creates the given indexes if required.

* **Parameters:**
  * **keys** – a single index key or a list of index keys (to
    construct a multi-field index); keys may be prefixed with a **+**
    or a **-** to determine the index ordering
  * **background** – Allows index creation in the background

#### delete(signal_kwargs=None, \*\*write_concern)

Delete the `Document` from the database. This
will only take effect if the document has been previously saved.

* **Parameters:**
  * **signal_kwargs** – (optional) kwargs dictionary to be passed to
    the signal calls.
  * **write_concern** – Extra keyword arguments are passed down which
    will be used as options for the resultant `getLastError` command.
    For example, `save(..., w: 2, fsync: True)` will
    wait until at least two servers have recorded the write and
    will force an fsync on the primary server.

#### *classmethod* drop_collection()

Drops the entire collection associated with this
`Document` type from the database.

Raises `OperationError` if the document has no collection set
(i.g. if it is `abstract`)

#### *classmethod* ensure_indexes()

Checks the document meta data and ensures all the indexes exist.

Global defaults can be set in the meta - see guide/defining-documents

By default, this will get called automatically upon first interaction with the
Document collection (query, save, etc) so unless you disabled `auto_create_index`, you
shouldn’t have to call this manually.

This also gets called upon every call to Document.save if `auto_create_index_on_save` is set to True

If called multiple times, MongoDB will not re-recreate indexes if they exist already

#### NOTE
You can disable automatic index creation by setting
`auto_create_index` to False in the documents meta data

#### fancy_repr(class_name=None, select_fields=None, exclude_fields=None, \*\*kwargs)

Generates a customizable string representation of the document.

* **Parameters:**
  * **class_name** (*None*) – optional class name to use
  * **select_fields** (*None*) – iterable of field names to restrict to
  * **exclude_fields** (*None*) – iterable of field names to exclude
  * **\*\*kwargs** – additional key-value pairs to include in the string
    representation
* **Returns:**
  a string representation of the document

#### *property* field_names

An ordered tuple of the public fields of this document.

#### field_to_mongo(field_name)

#### field_to_python(field_name, value)

#### *classmethod* from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

* **Parameters:**
  * **d** – a dictionary
  * **extended** (*False*) – whether the input dictionary may contain
    serialized extended JSON constructs
* **Returns:**
  a `SerializableDocument`

#### *classmethod* from_json(s)

Loads the document from a JSON string.

* **Returns:**
  a `SerializableDocument`

#### get_field(field_name)

Gets the field of the document.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  the field value
* **Raises:**
  **AttributeError** – if the field does not exist

#### get_text_score()

Get text score from text query

#### has_field(field_name)

Determines whether the document has a field of the given name.

* **Parameters:**
  **field_name** – the field name
* **Returns:**
  True/False

#### id

A field wrapper around MongoDB’s ObjectIds.

#### *property* in_db

Whether the document has been inserted into the database.

#### iter_fields()

Returns an iterator over the `(name, value)` pairs of the
public fields of the document.

* **Returns:**
  an iterator that emits `(name, value)` tuples

#### *classmethod* list_indexes()

Lists all indexes that should be created for the Document collection.
It includes all the indexes from super- and sub-classes.

Note that it will only return the indexes’ fields, not the indexes’ options

#### merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)

Merges the contents of the given document into this document.

* **Parameters:**
  * **doc** – a `SerializableDocument` of same type as this document
  * **merge_lists** (*True*) – whether to merge the elements of top-level list
    fields rather than treating the list as a single value
  * **merge_dicts** (*True*) – whether to recursively merge the contents of
    top-level dict fields rather than treating the dict as a single
    value
  * **overwrite** (*True*) – whether to overwrite (True) or skip (False)
    existing fields

#### modify(query=None, \*\*update)

Perform an atomic update of the document in the database and reload
the document object using updated version.

Returns True if the document has been updated or False if the document
in the database doesn’t match the query.

#### NOTE
All unsaved changes that have been made to the document are
rejected if the method returns True.

* **Parameters:**
  * **query** – the update will be performed only if the document in the
    database matches the query
  * **update** – Django-style update keyword arguments

#### my_metaclass

alias of `TopLevelDocumentMetaclass`

#### *property* pk

Get the primary key.

#### *classmethod* register_delete_rule(document_cls, field_name, rule)

This method registers the delete rules to apply when removing this
object.

#### reload(\*fields, \*\*kwargs)

Reloads the document from the database.

* **Parameters:**
  **\*fields** – an optional args list of specific fields to reload

#### save(upsert=False, validate=True, safe=False, \*\*kwargs)

Saves the document to the database.

If the document already exists, it will be updated, otherwise it will
be created.

* **Parameters:**
  * **upsert** (*False*) – whether to insert the document if it has an `id`
    populated but no document with that ID exists in the database
  * **validate** (*True*) – whether to validate the document
  * **safe** (*False*) – whether to `reload()` the document before raising
    any errors
* **Returns:**
  self

#### select_related(max_depth=1)

Handles dereferencing of [`DBRef`](https://pymongo.readthedocs.io/en/stable/api/bson/dbref.html#bson.dbref.DBRef) objects to
a maximum depth in order to cut down the number queries to mongodb.

#### set_field(field_name, value, create=True)

Sets the value of a field of the document.

* **Parameters:**
  * **field_name** – the field name
  * **value** – the field value
  * **create** (*True*) – whether to create the field if it does not exist
* **Raises:**
  **ValueError** – if `field_name` is not an allowed field name or does
      not exist and `create == False`

#### switch_collection(collection_name, keep_created=True)

Temporarily switch the collection for a document instance.

Only really useful for archiving off data and calling `save()`:

```default
user = User.objects.get(id=user_id)
user.switch_collection('old-users')
user.save()
```

* **Parameters:**
  * **collection_name** (*str*) – The database alias to use for saving the
    document
  * **keep_created** ([*bool*](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)) – keep self._created value after switching collection, else is reset to True

#### SEE ALSO
Use `switch_db`
if you need to read from another database

#### switch_db(db_alias, keep_created=True)

Temporarily switch the database for a document instance.

Only really useful for archiving off data and calling `save()`:

```default
user = User.objects.get(id=user_id)
user.switch_db('archive-db')
user.save()
```

* **Parameters:**
  * **db_alias** (*str*) – The database alias to use for saving the document
  * **keep_created** ([*bool*](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)) – keep self._created value after switching db, else is reset to True

#### SEE ALSO
Use `switch_collection`
if you need to read from another collection

#### to_dbref()

Returns an instance of [`DBRef`](https://pymongo.readthedocs.io/en/stable/api/bson/dbref.html#bson.dbref.DBRef) useful in
`__raw__` queries.

#### to_dict(\*args, no_dereference=False, \*\*kwargs)

Serializes this document to a BSON/JSON dictionary.

* **Parameters:**
  **extended** (*False*) – whether to serialize extended JSON constructs
  such as ObjectIDs, Binary, etc. into JSON format
* **Returns:**
  a dict

#### to_json(pretty_print=False)

Serializes the document to a JSON string.

* **Parameters:**
  **pretty_print** (*False*) – whether to render the JSON in human readable
  format with newlines and indentations
* **Returns:**
  a JSON string

#### to_mongo(\*args, \*\*kwargs)

Return as SON data ready for use with MongoDB.

#### update(\*\*kwargs)

Performs an update on the `Document`
A convenience wrapper to `update()`.

Raises `OperationError` if called on an object that has not yet
been saved.

#### validate(clean=True)

Ensure that all fields’ values are valid and that required fields
are present.

Raises `ValidationError` if any of the fields’ values are found
to be invalid.
