class documentation

Represents the execution context of an operator.

Operators can use the execution context to access the view, dataset, and selected samples, as well as to trigger other operators.

Parameters
request_paramsa optional dictionary of request parameters
executoran optional Executor instance
set_progressan optional function to set the progress of the current operation
delegated_operation_idan optional ID of the delegated operation
operator_urithe unique id of the operator
required_secretsthe list of required secrets from the plugin's definition
Method __init__ Undocumented
Method log Logs a message to the browser console.
Method prompt Prompts the user to execute the operator with the given URI.
Async Method resolve_secret_values Resolves the values of the given secrets keys.
Method secret Retrieves the secret with the given key.
Method serialize Serializes the execution context.
Method set_progress Sets the progress of the current operation.
Method store Retrieves the execution store with the given name.
Method target_view The target fiftyone.core.view.DatasetView for the operator being executed.
Method to_dict Returns the properties of the execution context as a dict.
Method trigger Triggers an invocation of the operator with the given name.
Instance Variable executor Undocumented
Instance Variable params Undocumented
Instance Variable request_params Undocumented
Instance Variable user Undocumented
Property current_sample The ID of the current sample being processed (if any).
Property dataset The fiftyone.core.dataset.Dataset being operated on.
Property dataset_id The ID of the fiftyone.core.dataset.Dataset being operated on.
Property dataset_name The name of the fiftyone.core.dataset.Dataset being operated on.
Property delegated Whether the operation was delegated.
Property delegation_target The orchestrator to which the operation was delegated (if any).
Property extended_selection The extended selection of the view (if any).
Property group_slice The current group slice of the view (if any).
Property has_custom_view Whether the operator has a custom view.
Property ops A fiftyone.operators.operations.Operations instance that you can use to trigger builtin operations on the current context.
Property panel A fiftyone.operators.panel.PanelRef instance that you can use to read and write the state and data of the current panel.
Property panel_id The ID of the panel that invoked the operator, if any.
Property panel_state The current panel state.
Property query_performance Whether query performance is enabled.
Property requesting_delegated_execution Whether delegated execution was requested for the operation.
Property results A dict of results for the current operation.
Property secrets A read-only mapping of keys to their resolved values.
Property selected The list of selected sample IDs (if any).
Property selected_labels A list of selected labels (if any).
Property spaces The current spaces layout in the FiftyOne App.
Property user_id The ID of the user executing the operation, if known.
Property user_request_token The request token authenticating the user executing the operation, if known.
Property view The fiftyone.core.view.DatasetView being operated on.
Method _get_serialized_request_params Undocumented
Instance Variable _dataset Undocumented
Instance Variable _delegated_operation_id Undocumented
Instance Variable _operator_uri Undocumented
Instance Variable _ops Undocumented
Instance Variable _panel Undocumented
Instance Variable _panel_state Undocumented
Instance Variable _required_secret_keys Undocumented
Instance Variable _secrets Undocumented
Instance Variable _secrets_client Undocumented
Instance Variable _set_progress Undocumented
Instance Variable _view Undocumented
def __init__(self, request_params=None, executor=None, set_progress=None, delegated_operation_id=None, operator_uri=None, required_secrets=None): (source)

Undocumented

def log(self, message): (source)

Logs a message to the browser console.

Note

This method is only available to non-delegated operators. You can only use this method during the execution of an operator.

Parameters
messagea message to log
Returns
a fiftyone.operators.message.GeneratedMessage containing instructions for the FiftyOne App to invoke the operator
def prompt(self, operator_uri, params=None, on_success=None, on_error=None, skip_prompt=False): (source)

Prompts the user to execute the operator with the given URI.

Parameters
operator_urithe URI of the operator
params:Nonea dictionary of parameters for the operator
on_success:Nonea callback to invoke if the user successfully executes the operator
on_error:Nonea callback to invoke if the execution fails
skip_prompt:Falsewhether to skip the prompt
Returns
a fiftyone.operators.message.GeneratedMessage containing instructions for the FiftyOne App to prompt the user
async def resolve_secret_values(self, keys, **kwargs): (source)

Resolves the values of the given secrets keys.

Parameters
keysa list of secret keys
**kwargsadditional keyword arguments to pass to the secrets client for authentication if required
def secret(self, key): (source)

Retrieves the secret with the given key.

Parameters
keya secret key
Returns
the secret value
def serialize(self): (source)

Serializes the execution context.

Returns
a JSON dict
def set_progress(self, progress=None, label=None): (source)

Sets the progress of the current operation.

Parameters
progress:Nonean optional float between 0 and 1 (0% to 100%)
label:Nonean optional label to display
def store(self, store_name): (source)

Retrieves the execution store with the given name.

The store is automatically created if necessary.

Parameters
store_namethe name of the store
Returns
a fiftyone.operators.store.ExecutionStore
def target_view(self, param_name='view_target'): (source)

The target fiftyone.core.view.DatasetView for the operator being executed.

Parameters
param_name:"view_target"the name of the enum parameter defining the target view choice
Returns
a fiftyone.core.collections.SampleCollection
def to_dict(self): (source)

Returns the properties of the execution context as a dict.

def trigger(self, operator_name, params=None): (source)

Triggers an invocation of the operator with the given name.

This method is only available when the operator is invoked via the FiftyOne App. You can check this via ctx.executor.

Example:

def execute(self, ctx):
    # Trigger the `reload_dataset` operator after this operator
    # finishes executing
    ctx.trigger("reload_dataset")

    # Immediately trigger the `reload_dataset` operator while a
    # generator operator is executing
    yield ctx.trigger("reload_dataset")
Parameters
operator_namethe name of the operator
params:Nonea dictionary of parameters for the operator
Returns
a fiftyone.operators.message.GeneratedMessage containing instructions for the FiftyOne App to invoke the operator
executor: None = (source)

Undocumented

Undocumented

request_params: None = (source)

Undocumented

Undocumented

@property
current_sample = (source)

The ID of the current sample being processed (if any).

When executed via the FiftyOne App, this is set when the user opens a sample in the modal.

The ID of the fiftyone.core.dataset.Dataset being operated on.

@property
dataset_name = (source)

The name of the fiftyone.core.dataset.Dataset being operated on.

Whether the operation was delegated.

@property
delegation_target = (source)

The orchestrator to which the operation was delegated (if any).

@property
extended_selection = (source)

The extended selection of the view (if any).

@property
group_slice = (source)

The current group slice of the view (if any).

@property
has_custom_view = (source)

Whether the operator has a custom view.

A fiftyone.operators.operations.Operations instance that you can use to trigger builtin operations on the current context.

A fiftyone.operators.panel.PanelRef instance that you can use to read and write the state and data of the current panel.

Only available when the operator is invoked from a panel.

The ID of the panel that invoked the operator, if any.

@property
panel_state = (source)

The current panel state.

Only available when the operator is invoked from a panel.

@property
query_performance = (source)

Whether query performance is enabled.

@property
requesting_delegated_execution = (source)

Whether delegated execution was requested for the operation.

A dict of results for the current operation.

A read-only mapping of keys to their resolved values.

The list of selected sample IDs (if any).

@property
selected_labels = (source)

A list of selected labels (if any).

Items are dictionaries with the following keys:

  • label_id: the ID of the label
  • sample_id: the ID of the sample containing the label
  • field: the field name containing the label
  • frame_number: the frame number containing the label (only applicable to video samples)

The current spaces layout in the FiftyOne App.

The ID of the user executing the operation, if known.

@property
user_request_token = (source)

The request token authenticating the user executing the operation, if known.

def _get_serialized_request_params(self): (source)

Undocumented

_dataset = (source)

Undocumented

_delegated_operation_id = (source)

Undocumented

_operator_uri = (source)

Undocumented

Undocumented

Undocumented

_panel_state = (source)

Undocumented

_required_secret_keys = (source)

Undocumented

_secrets: dict = (source)

Undocumented

_secrets_client = (source)

Undocumented

_set_progress = (source)

Undocumented

Undocumented