fiftyone.core.state¶
Defines the shared state between the FiftyOne App and backend.
Classes:
|
Class that describes the shared state between the FiftyOne App and a corresponding |
Functions:
|
|
|
-
class
fiftyone.core.state.
StateDescription
(color_scheme=None, config=None, dataset=None, field_visibility_stage=None, group_id=None, group_slice=None, sample_id=None, selected=None, selected_labels=None, spaces=None, view=None, view_name=None)¶ Bases:
eta.core.serial.Serializable
Class that describes the shared state between the FiftyOne App and a corresponding
fiftyone.core.session.Session
.- Parameters
color_scheme (None) – a
fiftyone.core.odm.dataset.ColorScheme
config (None) – an optional
fiftyone.core.config.AppConfig
dataset (None) – the current
fiftyone.core.dataset.Dataset
field_visibility_stage (None) – a field visibility stage
group_id (None) – a
fiftyone.core.groups.Group.id
group_slice (None) – a
fiftyone.core.groups.Group.name
sample_id (None) – a
fiftyone.core.sample.Sample.id
selected (None) – the list of currently selected samples
selected_labels (None) – the list of currently selected labels
spaces (None) – a
fiftyone.core.odm.workspace.Space
view (None) – the current
fiftyone.core.view.DatasetView
view_name (None) – the name of the view if the current view is a saved view
Methods:
serialize
([reflective])Serializes the object into a dictionary.
Returns a list of class attributes to be serialized.
from_dict
(d)Constructs a
StateDescription
from a JSON dictionary.copy
()Returns a deep copy of the object.
custom_attributes
([dynamic, private])Returns a customizable list of class attributes.
from_json
(path, *args, **kwargs)Constructs a Serializable object from a JSON file.
from_str
(s, *args, **kwargs)Constructs a Serializable object from a JSON string.
Returns the fully-qualified class name string of this object.
to_str
([pretty_print])Returns a string representation of this object.
write_json
(path[, pretty_print])Serializes the object and writes it to disk.
-
serialize
(reflective=True)¶ 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
-
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
-
classmethod
from_dict
(d)¶ Constructs a
StateDescription
from a JSON dictionary.- Parameters
d – a JSON dictionary
- Returns
-
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_json
(path, *args, **kwargs)¶ Constructs a Serializable object from a JSON file.
Subclasses may override this method, but, by default, this method simply reads the JSON and calls from_dict(), which subclasses must implement.
- Parameters
path – the path to the JSON file on disk
*args – optional positional arguments for self.from_dict()
**kwargs – optional keyword arguments for self.from_dict()
- Returns
an instance of the Serializable class
-
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.
-
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()
-
class
fiftyone.core.state.
SampleField
¶ Bases:
object
Attributes:
-
ftype
: str¶
-
path
: str¶
-
subfield
: Optional[str]¶
-
embedded_doc_type
: Optional[str]¶
-
db_field
: Optional[str]¶
-
description
: Optional[str]¶
-
info
: Optional[<strawberry.types.scalar.ScalarWrapper object at 0x7f72ed0777f0>]¶
-
-
fiftyone.core.state.
serialize_fields
(schema: Dict) → List[fiftyone.core.state.SampleField]¶
-
fiftyone.core.state.
build_color_scheme
(color_scheme: Optional[fiftyone.core.odm.dataset.ColorScheme] = None, dataset: Optional[fiftyone.core.dataset.Dataset] = None, app_config: Optional[fiftyone.core.config.AppConfig] = None) → fiftyone.core.odm.dataset.ColorScheme¶