«
class documentation

Mixin interface for fiftyone.core.odm.document.Document subclasses that are backed by a dataset.

Class Method add_field Adds a new field or embedded field to the document, if necessary.
Class Method add_implied_field Adds the field or embedded field to the document, if necessary, inferring the field type from the provided value.
Class Method get_field_schema Returns a schema dictionary describing the fields of this document.
Class Method merge_field_schema Merges the field schema into this document.
Method __setattr__ Undocumented
Method clear_field Undocumented
Method get_field Undocumented
Method set_field Undocumented
Instance Variable created_at Undocumented
Instance Variable last_modified_at Undocumented
Property collection_name Undocumented
Property field_names Undocumented
Class Method _add_field_schema Undocumented
Class Method _clear_fields Clears the field(s) of the documents in this collection.
Class Method _clear_fields_collection Undocumented
Class Method _clear_fields_simple Undocumented
Class Method _clone_field_schema Undocumented
Class Method _clone_fields Clones the field(s) of the documents in this collection.
Class Method _clone_fields_collection Undocumented
Class Method _clone_fields_simple Undocumented
Class Method _create_field Undocumented
Class Method _declare_field Undocumented
Class Method _delete_field_schema Undocumented
Class Method _delete_fields Deletes the field(s) from the documents in this collection.
Class Method _delete_fields_simple Undocumented
Class Method _delete_indexes Undocumented
Class Method _doc_name Undocumented
Class Method _fields_attr Undocumented
Class Method _get_default_fields Undocumented
Class Method _get_field Undocumented
Class Method _get_field_doc Undocumented
Class Method _get_fields_ordered Undocumented
Class Method _handle_db_field Undocumented
Class Method _handle_db_fields Undocumented
Class Method _merge_field Undocumented
Class Method _parse_path Undocumented
Class Method _reload_fields Undocumented
Class Method _remove_dynamic_fields Removes the dynamic embedded field(s) from the collection's schema.
Class Method _rename_field_schema Undocumented
Class Method _rename_fields Renames the fields of the documents in this collection.
Class Method _rename_fields_collection Undocumented
Class Method _rename_fields_simple Undocumented
Class Method _rename_indexes Undocumented
Class Method _to_db_fields Undocumented
Class Method _undeclare_field Undocumented
Class Method _update_field Undocumented
Class Method _update_field_metadata Undocumented
Method _deferred_updates Undocumented
Method _do_updates Undocumented
Method _extract_extra_updates Extracts updates for filtered list fields that need to be updated by ID, not relative position (index).
Method _get_field_names Undocumented
Method _insert Undocumented
Method _parse_id_and_array_filter Converts the list_element_field and filtered_field to an element object ID and array filter.
Method _update Undocumented
Class Variable _dataset Undocumented
Class Variable _is_frames_doc Undocumented
@classmethod
def add_field(cls, path, ftype, embedded_doc_type=None, subfield=None, fields=None, description=None, info=None, read_only=False, expand_schema=True, recursive=True, validate=True, **kwargs): (source)

Adds a new field or embedded field to the document, if necessary.

Parameters
paththe field name or embedded.field.name
ftypethe field type to create. Must be a subclass of fiftyone.core.fields.Field
embedded_doc_type:Nonethe fiftyone.core.odm.BaseEmbeddedDocument type of the field. Only applicable when ftype is fiftyone.core.fields.EmbeddedDocumentField
subfield:Nonethe fiftyone.core.fields.Field type of the contained field. Only applicable when ftype is fiftyone.core.fields.ListField or fiftyone.core.fields.DictField
fields:Nonea list of fiftyone.core.fields.Field instances defining embedded document attributes. Only applicable when ftype is fiftyone.core.fields.EmbeddedDocumentField
description:Nonean optional description
info:Nonean optional info dict
read_only:Falsewhether the field should be read-only
expand_schema:Truewhether to add new fields to the schema (True) or simply validate that the field already exists with a consistent type (False)
recursive:Truewhether to recursively add embedded document fields
validate:Truewhether to validate the field against an existing field at the same path
**kwargsUndocumented
Returns
True/False whether one or more fields or embedded fields were added to the document or its children
Raises
ValueErrorif a field in the schema is not compliant with an existing field of the same name
@classmethod
def add_implied_field(cls, path, value, expand_schema=True, dynamic=False, recursive=True, validate=True): (source)

Adds the field or embedded field to the document, if necessary, inferring the field type from the provided value.

Parameters
paththe field name or embedded.field.name
valuethe field value
expand_schema:Truewhether to add new fields to the schema (True) or simply validate that the field already exists with a consistent type (False)
dynamic:Falsewhether to declare dynamic embedded document fields
recursive:Truewhether to recursively add embedded document fields
validate:Truewhether to validate the field against an existing field at the same path
Returns
True/False whether one or more fields or embedded fields were added to the document or its children
Raises
ValueErrorif a field in the schema is not compliant with an existing field of the same name
@classmethod
def get_field_schema(cls, ftype=None, embedded_doc_type=None, read_only=None, info_keys=None, created_after=None, include_private=False, flat=False, mode=None): (source)

Returns a schema dictionary describing the fields of this document.

If the document belongs to a dataset, the schema will apply to all documents in the collection.

Parameters
ftype:Nonean optional field type or iterable of field types to which to restrict the returned schema. Must be subclass(es) of fiftyone.core.fields.Field
embedded_doc_type:Nonean optional embedded document type or iterable of types to which to restrict the returned schema. Must be subclass(es) of fiftyone.core.odm.BaseEmbeddedDocument
read_only:Nonewhether to restrict to (True) or exclude (False) read-only fields. By default, all fields are included
info_keys:Nonean optional key or list of keys that must be in the field's info dict
created_after:Nonean optional datetime specifying a minimum creation date
include_private:Falsewhether to include fields that start with _ in the returned schema
flat:Falsewhether to return a flattened schema where all embedded document fields are included as top-level keys
mode:Nonewhether to apply the above constraints before and/or after flattening the schema. Only applicable when ``flat` is True. Supported values are ("before", "after", "both"). The default is "after"
Returns
a dict mapping field names to fiftyone.core.fields.Field instances
@classmethod
def merge_field_schema(cls, schema, expand_schema=True, recursive=True, validate=True, overwrite=False): (source)

Merges the field schema into this document.

Parameters
schemaa dict mapping field names or embedded.field.names to fiftyone.core.fields.Field instances
expand_schema:Truewhether to add new fields to the schema (True) or simply validate that fields already exist with consistent types (False)
recursive:Truewhether to recursively merge embedded document fields
validate:Truewhether to validate fields against existing fields at the same path
overwrite:Falsewhether to overwrite the editable metadata of existing fields
Returns
True/False whether any new fields were added
Raises
ValueErrorif a field in the schema is not compliant with an existing field of the same name or a new field is found but expand_schema == False
def __setattr__(self, name, value): (source)

Undocumented

def clear_field(self, field_name): (source)

Undocumented

def get_field(self, field_name): (source)

Undocumented

def set_field(self, field_name, value, create=True, validate=True, dynamic=False, _enforce_read_only=True): (source)

Undocumented

@property
collection_name = (source)

Undocumented

@property
field_names = (source)

Undocumented

@classmethod
def _add_field_schema(cls, path, field, created_at=None): (source)

Undocumented

@classmethod
def _clear_fields(cls, sample_collection, paths): (source)

Clears the field(s) of the documents in this collection.

Parameters
sample_collectionthe fiftyone.core.samples.SampleCollection
pathsan iterable of field names or embedded.field.names
@classmethod
def _clear_fields_collection(cls, sample_collection, paths): (source)

Undocumented

@classmethod
def _clear_fields_simple(cls, paths): (source)

Undocumented

@classmethod
def _clone_field_schema(cls, path, new_path, created_at=None): (source)

Undocumented

@classmethod
def _clone_fields(cls, sample_collection, paths, new_paths): (source)

Clones the field(s) of the documents in this collection.

Parameters
sample_collectionthe fiftyone.core.samples.SampleCollection
pathsan iterable of field names or embedded.field.names
new_pathsan iterable of new field names or embedded.field.names
@classmethod
def _clone_fields_collection(cls, sample_collection, paths, new_paths): (source)

Undocumented

@classmethod
def _clone_fields_simple(cls, paths, new_paths): (source)

Undocumented

@classmethod
def _create_field(cls, path, ftype, embedded_doc_type=None, subfield=None, fields=None, description=None, info=None, read_only=False, **kwargs): (source)

Undocumented

@classmethod
def _declare_field(cls, dataset, path, field_or_doc): (source)

Undocumented

@classmethod
def _delete_field_schema(cls, path): (source)

Undocumented

@classmethod
def _delete_fields(cls, paths, error_level=0): (source)

Deletes the field(s) from the documents in this collection.

Parameters
pathsan iterable of field names or embedded.field.names
error_level:0the error level to use. Valid values are:
- 0raise error if a field cannot be deleted
- 1log warning if a field cannot be deleted
- 2ignore fields that cannot be deleted
@classmethod
def _delete_fields_simple(cls, paths): (source)

Undocumented

@classmethod
def _delete_indexes(cls, paths): (source)

Undocumented

@classmethod
def _doc_name(cls): (source)

Undocumented

@classmethod
def _fields_attr(cls): (source)

Undocumented

@classmethod
def _get_default_fields(cls, include_private=False, use_db_fields=False): (source)

Undocumented

@classmethod
def _get_field(cls, path, allow_missing=False, check_default=False): (source)

Undocumented

@classmethod
def _get_field_doc(cls, path, allow_missing=False, reload=False): (source)

Undocumented

@classmethod
def _get_fields_ordered(cls, include_private=False, use_db_fields=False): (source)

Undocumented

@classmethod
def _handle_db_field(cls, path, new_path=None): (source)

Undocumented

@classmethod
def _handle_db_fields(cls, paths, new_paths=None): (source)

Undocumented

@classmethod
def _merge_field(cls, path, field, validate=True, recursive=True, overwrite=False): (source)

Undocumented

@classmethod
def _parse_path(cls, path, allow_missing=False): (source)

Undocumented

@classmethod
def _reload_fields(cls): (source)

Undocumented

@classmethod
def _remove_dynamic_fields(cls, paths, error_level=0): (source)

Removes the dynamic embedded field(s) from the collection's schema.

The actual data is not deleted from the collection.

Parameters
pathsan iterable of embedded.field.names
error_level:0the error level to use. Valid values are:
- 0raise error if a field cannot be removed
- 1log warning if a field cannot be removed
- 2ignore fields that cannot be removed
@classmethod
def _rename_field_schema(cls, path, new_path): (source)

Undocumented

@classmethod
def _rename_fields(cls, sample_collection, paths, new_paths): (source)

Renames the fields of the documents in this collection.

Parameters
sample_collectionthe fiftyone.core.samples.SampleCollection
pathsan iterable of field names or embedded.field.names
new_pathsan iterable of new field names or embedded.field.names
@classmethod
def _rename_fields_collection(cls, sample_collection, paths, new_paths): (source)

Undocumented

@classmethod
def _rename_fields_simple(cls, paths, new_paths): (source)

Undocumented

@classmethod
def _rename_indexes(cls, paths, new_paths): (source)

Undocumented

@classmethod
def _to_db_fields(cls, field_names): (source)

Undocumented

@classmethod
def _undeclare_field(cls, field_name): (source)

Undocumented

@classmethod
def _update_field(cls, dataset, field_name, new_path, field): (source)

Undocumented

@classmethod
def _update_field_metadata(cls, path, d): (source)

Undocumented

def _deferred_updates(self, _id, updates, extra_updates, upsert): (source)

Undocumented

def _do_updates(self, _id, updates, extra_updates, upsert): (source)

Undocumented

def _extract_extra_updates(self, updates, filtered_fields): (source)

Extracts updates for filtered list fields that need to be updated by ID, not relative position (index).

def _get_field_names(self, include_private=False, use_db_fields=False): (source)

Undocumented

def _insert(self, doc, deferred=False): (source)

Undocumented

def _parse_id_and_array_filter(self, list_element_field, filtered_field): (source)

Converts the list_element_field and filtered_field to an element object ID and array filter.

Example:

Input:
    list_element_field = "test_dets.detections.1.label"
    filtered_field = "test_dets.detections"

Output:
    ObjectId("5f2062bf27c024654f5286a0")
    "test_dets.detections.$[element].label"
def _update(self, _id, updates, deferred=False, upsert=False, virtual=False, filtered_fields=None, **kwargs): (source)

Undocumented

_dataset = (source)

Undocumented