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

# fiftyone.brain.config

Brain config.

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

**Classes:**

| [`BrainConfig`](#fiftyone.brain.config.BrainConfig)([d])   | FiftyOne brain configuration settings.   |
|------------------------------------------------------------|------------------------------------------|

**Functions:**

| [`locate_brain_config`](#fiftyone.brain.config.locate_brain_config)()   | Returns the path to the [`BrainConfig`](#fiftyone.brain.config.BrainConfig) on disk.   |
|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| [`load_brain_config`](#fiftyone.brain.config.load_brain_config)()       | Loads the FiftyOne brain config.                                                       |

### *class* fiftyone.brain.config.BrainConfig(d=None)

Bases: [`EnvConfig`](fiftyone.core.config.md#fiftyone.core.config.EnvConfig)

FiftyOne brain configuration settings.

**Methods:**

| [`attributes`](#fiftyone.brain.config.BrainConfig.attributes)()                                           | Returns a list of class attributes to be serialized.          |
|-----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [`copy`](#fiftyone.brain.config.BrainConfig.copy)()                                                       | Returns a deep copy of the object.                            |
| [`custom_attributes`](#fiftyone.brain.config.BrainConfig.custom_attributes)([dynamic, private])           | Returns a customizable list of class attributes.              |
| [`from_dict`](#fiftyone.brain.config.BrainConfig.from_dict)(d)                                            | Constructs an EnvConfig object from a JSON dictionary.        |
| [`from_json`](#fiftyone.brain.config.BrainConfig.from_json)(path)                                         | Constructs an EnvConfig object from a JSON file.              |
| [`from_str`](#fiftyone.brain.config.BrainConfig.from_str)(s, \*args, \*\*kwargs)                          | Constructs a Serializable object from a JSON string.          |
| [`get_class_name`](#fiftyone.brain.config.BrainConfig.get_class_name)()                                   | Returns the fully-qualified class name string of this object. |
| [`parse_bool`](#fiftyone.brain.config.BrainConfig.parse_bool)(d, key[, env_var, default])                 | Parses a boolean value.                                       |
| [`parse_dict`](#fiftyone.brain.config.BrainConfig.parse_dict)(d, key[, env_var, default])                 | Parses a dictionary attribute.                                |
| [`parse_int`](#fiftyone.brain.config.BrainConfig.parse_int)(d, key[, env_var, default])                   | Parses an integer attribute.                                  |
| [`parse_number`](#fiftyone.brain.config.BrainConfig.parse_number)(d, key[, env_var, default])             | Parses a number attribute.                                    |
| [`parse_path`](#fiftyone.brain.config.BrainConfig.parse_path)(d, key[, env_var, default])                 | Parses a path attribute.                                      |
| [`parse_path_array`](#fiftyone.brain.config.BrainConfig.parse_path_array)(d, key[, env_var, default])     | Parses a path array attribute.                                |
| [`parse_string`](#fiftyone.brain.config.BrainConfig.parse_string)(d, key[, env_var, default])             | Parses a string attribute.                                    |
| [`parse_string_array`](#fiftyone.brain.config.BrainConfig.parse_string_array)(d, key[, env_var, default]) | Parses a string array attribute.                              |
| [`serialize`](#fiftyone.brain.config.BrainConfig.serialize)([reflective])                                 | Serializes the object into a dictionary.                      |
| [`to_str`](#fiftyone.brain.config.BrainConfig.to_str)([pretty_print])                                     | Returns a string representation of this object.               |
| [`write_json`](#fiftyone.brain.config.BrainConfig.write_json)(path[, pretty_print])                       | Serializes the object and writes it to disk.                  |

#### attributes()

Returns a list of class attributes to be serialized.

This method is called internally by `serialize()` to determine the
class attributes to serialize.

Subclasses can override this method, but, by default, all attributes in
vars(self) are returned, minus private attributes, i.e., those starting
with “_”. The order of the attributes in this list is preserved when
serializing objects, so a common pattern is for subclasses to override
this method if they want their JSON files to be organized in a
particular way.

* **Returns:**
  a list of class attributes to be serialized

#### copy()

Returns a deep copy of the object.

* **Returns:**
  a Serializable instance

#### custom_attributes(dynamic=False, private=False)

Returns a customizable list of class attributes.

By default, all attributes in vars(self) are returned, minus private
attributes (those starting with “_”).

* **Parameters:**
  * **dynamic** – whether to include dynamic properties, e.g., those defined
    by getter/setter methods or the `@property` decorator. By
    default, this is False
  * **private** – whether to include private properties, i.e., those
    starting with “_”. By default, this is False
* **Returns:**
  a list of class attributes

#### *classmethod* from_dict(d)

Constructs an EnvConfig object from a JSON dictionary.

EnvConfig subclass constructors accept JSON dictionaries, so this
method simply passes the dictionary to cls().

* **Parameters:**
  **d** – a JSON dictionary containing the fields expected by cls
* **Returns:**
  an instance of cls

#### *classmethod* from_json(path)

Constructs an EnvConfig object from a JSON file.

EnvConfig instances allow their values to be overriden by environment
variables, so, if the JSON file does not exist, this method silently
loads an empty dictionary in its place.

#### *classmethod* from_str(s, \*args, \*\*kwargs)

Constructs a Serializable object from a JSON string.

Subclasses may override this method, but, by default, this method
simply parses the string and calls from_dict(), which subclasses must
implement.

* **Parameters:**
  * **s** – a JSON string representation of a Serializable object
  * **\*args** – optional positional arguments for `self.from_dict()`
  * **\*\*kwargs** – optional keyword arguments for `self.from_dict()`
* **Returns:**
  an instance of the Serializable class

#### *classmethod* get_class_name()

Returns the fully-qualified class name string of this object.

#### *static* parse_bool(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a boolean value.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – a default bool to return if key is not present
* **Returns:**
  True/False
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_dict(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a dictionary attribute.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – a default dict to return if key is not present
* **Returns:**
  a dictionary
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_int(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses an integer attribute.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – an optional default integer value to return if key is not
    present
* **Returns:**
  an int
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_number(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a number attribute.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – an optional default numeric value to return if key is not
    present
* **Returns:**
  a number (e.g. int, float)
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_path(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a path attribute.

The path is converted to an absolute path if necessary via
`os.path.abspath(os.path.expanduser(value))`.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – an optional default string to return if key is not present
* **Returns:**
  a path string
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_path_array(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a path array attribute.

Each path is converted to an absolute path if necessary via
`os.path.abspath(os.path.expanduser(value))`.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – an optional default list to return if key is not present
* **Returns:**
  a list of path strings
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_string(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a string attribute.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – an optional default string to return if key is not present
* **Returns:**
  a string
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### *static* parse_string_array(d, key, env_var=None, default=<eta.core.config.NoDefault object>)

Parses a string array attribute.

* **Parameters:**
  * **d** – a JSON dictionary
  * **key** – the key to parse
  * **env_var** – an optional environment variable to load the attribute
    from rather than using the JSON dictionary
  * **default** – an optional default list to return if key is not present
* **Returns:**
  a list of strings
* **Raises:**
  **EnvConfigError** – if the environment variable, the dictionary key, or
      a default value was not provided

#### serialize(reflective=False)

Serializes the object into a dictionary.

Serialization is applied recursively to all attributes in the object,
including element-wise serialization of lists and dictionary values.

* **Parameters:**
  **reflective** – whether to include reflective attributes when
  serializing the object. By default, this is False
* **Returns:**
  a JSON dictionary representation of the object

#### to_str(pretty_print=True, \*\*kwargs)

Returns a string representation of this object.

* **Parameters:**
  * **pretty_print** – whether to render the JSON in human readable format
    with newlines and indentations. By default, this is True
  * **\*\*kwargs** – optional keyword arguments for `self.serialize()`
* **Returns:**
  a string representation of the object

#### write_json(path, pretty_print=False, \*\*kwargs)

Serializes the object and writes it to disk.

* **Parameters:**
  * **path** – the output path
  * **pretty_print** – whether to render the JSON in human readable format
    with newlines and indentations. By default, this is False
  * **\*\*kwargs** – optional keyword arguments for `self.serialize()`

### fiftyone.brain.config.locate_brain_config()

Returns the path to the [`BrainConfig`](#fiftyone.brain.config.BrainConfig) on disk.

The default location is `~/.fiftyone/brain_config.json`, but you can
override this path by setting the `FIFTYONE_BRAIN_CONFIG_PATH`
environment variable.

Note that a config file may not actually exist on disk.

* **Returns:**
  the path to the [`BrainConfig`](#fiftyone.brain.config.BrainConfig) on disk

### fiftyone.brain.config.load_brain_config()

Loads the FiftyOne brain config.

* **Returns:**
  a [`BrainConfig`](#fiftyone.brain.config.BrainConfig) instance
