fiftyone.operators¶
Module contents¶
FiftyOne operators.
Classes:
|
A FiftyOne operator. |
|
A configuration for an operator. |
|
Operator registry. |
Functions:
|
Gets the operator with the given URI. |
|
Returns all available operators. |
|
Executes the operator with the given name. |
|
Executes the operator with the given name. |
-
class
fiftyone.operators.
Operator
(_builtin=False)¶ Bases:
object
A FiftyOne operator.
Operators represent an operation and the details of how to execute it.
FiftyOne operators contain enough information for a user interface to render a form or button allowing a user to execute the operation.
Methods:
add_secrets
(secrets)Adds secrets to the operator.
execute
(ctx)Executes the operator.
resolve_definition
(resolve_dynamic, ctx)Returns a resolved definition of the operator.
resolve_delegation
(ctx)Returns the resolved delegation flag.
resolve_input
(ctx)Returns the resolved input property.
resolve_output
(ctx)Returns the resolved output property.
resolve_placement
(ctx)Returns the resolved placement of the operator.
resolve_type
(ctx, type)Returns the resolved input or output property.
to_json
(ctx[, resolve_dynamic])Returns a JSON representation of the operator.
Attributes:
Whether the operator is builtin.
The
OperatorConfig
for the operator.The unique identifier of the operator:
plugin_name/operator_name
.-
property
name
¶
-
property
delegation_target
¶
-
property
uri
¶ The unique identifier of the operator:
plugin_name/operator_name
.
-
property
builtin
¶ Whether the operator is builtin.
-
property
config
¶ The
OperatorConfig
for the operator.
-
resolve_definition
(resolve_dynamic, ctx)¶ Returns a resolved definition of the operator.
The resolved definition is a clone of the default definition using
resolve_input()
andresolve_output()
to resolve the inputs and output properties of the operator.Passing
resolve_dynamic=False
allows resolution of dynamic operators to be deferred to execution time. If the operatoris_dyanmic
andresolve_dynamic
is False, a clone of default definition is returned.- Parameters
resolve_dynamic – whether to resolve dynamic inputs and outputs
- Returns
a definition
fiftyone.operators.types.Object
-
resolve_delegation
(ctx) → bool¶ Returns the resolved delegation flag.
Subclasses can implement this method to define the logic which decides if the operation should be queued for delegation
- Parameters
- Returns
a boolean
-
execute
(ctx)¶ Executes the operator.
Subclasses must implement this method.
- Parameters
-
resolve_type
(ctx, type)¶ Returns the resolved input or output property.
- Parameters
type – the type of property to resolve, either
"inputs"
or"outputs"
- Returns
a
fiftyone.operators.types.Property
, or None
-
resolve_input
(ctx)¶ Returns the resolved input property.
Subclasses can implement this method to define the inputs to the operator. This method should never be called directly. Instead use
resolve_type()
.By default, this method is called once when the operator is created. If the operator is dynamic, this method is called each time the input changes.
- Parameters
- Returns
a
fiftyone.operators.types.Property
, or None
-
resolve_output
(ctx)¶ Returns the resolved output property.
Subclasses can implement this method to define the outputs of the operator.
By default, this method is called once when the operator is created. If the operator is dynamic, this method is called after the operator is executed.
- Parameters
- Returns
a
fiftyone.operators.types.Property
, or None
-
resolve_placement
(ctx)¶ Returns the resolved placement of the operator.
Subclasses can implement this method to define the placement of the operator.
- Parameters
- Returns
a
fiftyone.operators.types.Placement
, or None
-
to_json
(ctx, resolve_dynamic=False)¶ Returns a JSON representation of the operator.
- Parameters
resolve_dynamic (False) – whether to resolve dynamic inputs and outputs
- Returns
a JSON dict
-
add_secrets
(secrets)¶ Adds secrets to the operator.
- Parameters
secrets – a list of secrets
-
property
-
class
fiftyone.operators.
OperatorConfig
(name, label=None, description=None, dynamic=False, execute_as_generator=False, unlisted=False, on_startup=False, disable_schema_validation=False, delegation_target=None, icon=None, light_icon=None, dark_icon=None)¶ Bases:
object
A configuration for an operator.
- Parameters
name – the name of the operator
label (name) – a label for the operator
description (None) – a description of the operator
dynamic (False) – whether the operator inputs and outputs should be resolved when the input/output changes
execute_as_generator (False) – whether the operator should be executed as a generator
unlisted (False) – whether the operator should be hidden from the Operator Browser
on_startup (False) – whether the operator should be executed on startup
disable_schema_validation (False) – whether the operator built-in schema validation should be disabled
icon (None) – icon to show for the operator in the Operator Browser
light_icon (None) – icon to show for the operator in the Operator Browser when app is in the light mode
dark_icon (None) – icon to show for the operator in the Operator Browser when app is in the dark mode
Methods:
to_json
()-
to_json
()¶
-
class
fiftyone.operators.
OperatorRegistry
(enabled=True)¶ Bases:
object
Operator registry.
- enabled (True): whether to include only enabled operators (True) or
only disabled operators (False) or all operators (“all”)
Methods:
can_execute
(operator_uri)Whether the operator can be executed.
get_operator
(operator_uri)Retrieves an operator by its URI.
Lists the errors that occurred during operator loading.
list_operators
([include_builtin])Lists the available FiftyOne operators.
operator_exists
(operator_uri)Checks if the operator exists.
-
list_operators
(include_builtin=True)¶ Lists the available FiftyOne operators.
- Parameters
include_builtin (True) – whether to include builtin operators
- Returns
a list of
fiftyone.operators.Operator
instances
-
list_errors
()¶ Lists the errors that occurred during operator loading.
- Returns
a list of errors
-
operator_exists
(operator_uri)¶ Checks if the operator exists.
- Parameters
operator_uri – the URI of the operator
- Returns
True/False
-
can_execute
(operator_uri)¶ Whether the operator can be executed.
- Parameters
operator_uri – the URI of the operator
- Returns
True/False
-
get_operator
(operator_uri)¶ Retrieves an operator by its URI.
- Parameters
operator_uri – the URI of an operator
- Returns
an
fiftyone.operators.Operator
, or None
-
fiftyone.operators.
get_operator
(operator_uri)¶ Gets the operator with the given URI.
- Parameters
operator_uri – the operator URI
- Returns
-
fiftyone.operators.
list_operators
(enabled=True)¶ Returns all available operators.
- Parameters
enabled (True) – whether to include only enabled operators (True) or only disabled operators (False) or all operators (“all”)
- Returns
a list of
fiftyone.operators.Operator
instances
-
fiftyone.operators.
execute_operator
(operator_uri, ctx, params=None)¶ Executes the operator with the given name.
- Parameters
operator_uri – the URI of the operator
ctx –
a dictionary of parameters defining the execution context. The supported keys are:
dataset
: afiftyone.core.dataset.Dataset
or the name of a dataset to process. This is required unless aview
is providedview
: an optionalfiftyone.core.view.DatasetView
to processselected
: an optional list of selected sample IDsselected_labels
: an optional list of selected labels in the format returned byfiftyone.core.session.Session.selected_labels
params
: a dictionary of parameters for the operator. Consult the operator’s documentation for details
params (None) – you can optionally provide the
ctx.params
dict as a separate argument
- Returns
an
ExecutionResult
-
async
fiftyone.operators.
execute_or_delegate_operator
(operator_uri, request_params)¶ Executes the operator with the given name.
- Parameters
operator_uri – the URI of the operator
request_params – a dictionary of parameters for the operator
- Returns
an
ExecutionResult