class documentation

Abstract base class for all view stages.

ViewStage instances represent logical operations to apply to fiftyone.core.collections.SampleCollection instances, which may decide what subset of samples in the collection should pass though the stage, and also what subset of the contents of each fiftyone.core.sample.Sample should be passed. The output of view stages are represented by a fiftyone.core.view.DatasetView.

Method __eq__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method get_edited_fields Returns a list of names of fields or embedded fields that may have been edited by the stage, if any.
Method get_excluded_fields Returns a list of fields that have been excluded by the stage, if any.
Method get_filtered_fields Returns a list of names of fields or embedded fields that contain arrays have been filtered by the stage, if any.
Method get_group_expr Returns the dynamic group expression for the given stage, if any.
Method get_media_type Returns the media type outputted by this stage when applied to the given collection, if and only if it is different from the input type.
Method get_selected_fields Returns a list of fields that have been selected by the stage, if any.
Method load_view Loads the fiftyone.core.view.DatasetView containing the output of the stage.
Method to_mongo Returns the MongoDB aggregation pipeline for the stage.
Method validate Validates that the stage can be applied to the given collection.
Property has_view Whether this stage's output view should be loaded via load_view rather than appending stages to an aggregation pipeline via to_mongo.
Property outputs_dynamic_groups Whether this stage outputs or flattens dynamic groups.
Class Method _from_dict Creates a ViewStage instance from a serialized JSON dict representation of it.
Class Method _params Returns a list of JSON dicts describing the stage's supported parameters.
Method _kwargs Returns a list of [name, value] lists describing the parameters of this stage instance.
Method _needs_frames Whether the stage requires frame labels of video samples to be attached.
Method _needs_group_slices Whether the stage requires group slice(s) to be attached.
Method _serialize Returns a JSON dict representation of the ViewStage.
Instance Variable _uuid Undocumented
def __eq__(self, other): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def get_edited_fields(self, sample_collection, frames=False): (source)

Returns a list of names of fields or embedded fields that may have been edited by the stage, if any.

The "frames." prefix should be omitted when frames is True.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the stage is being applied
frames:Falsewhether to return sample-level (False) or frame-level (True) fields
Returns
a list of fields, or None if no fields have been edited
def get_excluded_fields(self, sample_collection, frames=False): (source)

Returns a list of fields that have been excluded by the stage, if any.

View stages only need to report excluded fields if they insist that excluded fields not appear in the schema of the returned view.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the stage is being applied
frames:Falsewhether to return sample-level (False) or frame-level (True) fields
Returns
a list of fields, or None if no fields have been selected
def get_filtered_fields(self, sample_collection, frames=False): (source)

Returns a list of names of fields or embedded fields that contain arrays have been filtered by the stage, if any.

For example, if a stage filters a fiftyone.core.labels.Detections field called "predictions", it should include "predictions.detections" in the returned list.

The "frames." prefix should be omitted when frames is True.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the stage is being applied
frames:Falsewhether to return sample-level (False) or frame-level (True) fields
Returns
a list of fields, or None if no fields have been filtered
def get_group_expr(self, sample_collection): (source)

Returns the dynamic group expression for the given stage, if any.

Only usable if outputs_dynamic_groups is True.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the stage is being applied
Returns

a tuple of

  • the group expression, or None if the stage does not generate dynamic groups
  • whether the group expression is an ObjectId field, or None
def get_media_type(self, sample_collection): (source)

Returns the media type outputted by this stage when applied to the given collection, if and only if it is different from the input type.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the stage is being applied
Returns
the media type, or None if the stage does not change the type
def get_selected_fields(self, sample_collection, frames=False): (source)

Returns a list of fields that have been selected by the stage, if any.

View stages only need to report selected fields if they insist that non-selected fields not appear in the schema of the returned view.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the stage is being applied
frames:Falsewhether to return sample-level (False) or frame-level (True) fields
Returns
a list of fields, or None if no fields have been selected
def load_view(self, sample_collection): (source)

Whether this stage's output view should be loaded via load_view rather than appending stages to an aggregation pipeline via to_mongo.

@property
outputs_dynamic_groups = (source)

Whether this stage outputs or flattens dynamic groups.

The possible return values are:

  • True: this stage dynamically groups the input collection
  • False: this stage flattens dynamic groups
  • None: this stage does not change group status
@classmethod
def _from_dict(cls, d): (source)

Creates a ViewStage instance from a serialized JSON dict representation of it.

Parameters
da JSON dict
Returns
a ViewStage
def _kwargs(self): (source)
def _serialize(self, include_uuid=True): (source)

Returns a JSON dict representation of the ViewStage.

Parameters
include_uuid:Truewhether to include the stage's UUID in the JSON representation
Returns
a JSON dict

Undocumented