class documentation

Abstract base class for objects that are associated with fiftyone.core.dataset.Dataset instances and are backed by documents in database collections.

Document subclasses whose in-dataset instances should be singletons can inherit this behavior by deriving from the fiftyone.core.singletons.DocumentSingleton metaclass.

Parameters
**kwargsfield names and values
Class Method from_dict Loads the document from a JSON dictionary.
Class Method from_doc Creates a document backed by the given database document.
Class Method from_json Loads the document from a JSON string.
Method __init__ Undocumented
Method copy Returns a deep copy of the document that has not been added to the database.
Method reload Reloads the document from the database.
Method _reload_backing_doc Reloads the backing doc from the database.
Method _reset_backing_doc Resets the backing doc for the document.
Method _set_backing_doc Sets the backing doc for the document.
Constant _NO_DATASET_DOC_CLS Undocumented
Instance Variable _dataset Undocumented
Instance Variable _doc Undocumented

Inherited from _Document:

Method __contains__ Undocumented
Method __copy__ Undocumented
Method __delattr__ Undocumented
Method __delitem__ Undocumented
Method __dir__ Undocumented
Method __eq__ Undocumented
Method __getattr__ Undocumented
Method __getitem__ Undocumented
Method __repr__ Undocumented
Method __setattr__ Undocumented
Method __setitem__ Undocumented
Method __str__ Undocumented
Method clear_field Clears the value of a field of the document.
Method get_field Gets the value of a field of the document.
Method has_field Determines whether the document has the given field.
Method iter_fields Returns an iterator over the (name, value) pairs of the public fields of the document.
Method merge Merges the fields of the document into this document.
Method save Saves the document to the database.
Method set_field Sets the value of a field of the document.
Method to_dict Serializes the document to a JSON dictionary.
Method to_json Serializes the document to a JSON string.
Method to_mongo_dict Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database.
Method update_fields Sets the dictionary of fields on the document.
Property dataset The dataset to which this document belongs, or None if it has not been added to a dataset.
Property field_names An ordered tuple of the public field names of this document.
Property in_dataset Whether the document has been added to a dataset.
Method _get_field_names Returns an ordered tuple of field names of this document.
Method _iter_label_fields Undocumented
Method _parse_fields Undocumented
Method _save Undocumented
Property _collection The fiftyone.core.collections.SampleCollection from which this document was taken, or None if it is not in a dataset.
Property _id The ObjectId of the document, or None if it has not been added to the database.
Property _in_db Whether the document has been inserted into the database.
@classmethod
def from_dict(cls, d): (source)

Loads the document from a JSON dictionary.

The returned document will not belong to a dataset.

Returns
a Document
@classmethod
def from_doc(cls, doc, dataset=None): (source)

Creates a document backed by the given database document.

Parameters
doca fiftyone.core.odm.document.Document
dataset:Nonethe fiftyone.core.dataset.Dataset that the document belongs to, if any
Returns
a Document
@classmethod
def from_json(cls, s): (source)

Loads the document from a JSON string.

The returned document will not belong to a dataset.

Parameters
sthe JSON string
Returns
a Document
def __init__(self, **kwargs): (source)
def copy(self, fields=None, omit_fields=None): (source)

Returns a deep copy of the document that has not been added to the database.

Parameters
fields:Nonean optional field or iterable of fields to which to restrict the copy. This can also be a dict mapping existing field names to new field names
omit_fields:Nonean optional field or iterable of fields to exclude from the copy
Returns
a Document
def reload(self, hard=False): (source)

Reloads the document from the database.

Parameters
hard:Falsewhether to reload the document's schema in addition to its field values. This is necessary if new fields may have been added to the document schema
def _reload_backing_doc(self): (source)

Reloads the backing doc from the database.

def _reset_backing_doc(self): (source)

Resets the backing doc for the document.

The document will no longer belong to a dataset.

def _set_backing_doc(self, doc, dataset=None): (source)

Sets the backing doc for the document.

Parameters
doca fiftyone.core.odm.document.Document
dataset:Nonethe fiftyone.core.dataset.Dataset to which the document belongs, if any
_NO_DATASET_DOC_CLS = (source)

Undocumented

Value
None