fiftyone.operators¶
- fiftyone.operators.builtin
- fiftyone.operators.decorators
- fiftyone.operators.delegated
- fiftyone.operators.executor
- fiftyone.operators.message
- fiftyone.operators.operations
- fiftyone.operators.operator
- fiftyone.operators.permissions
- fiftyone.operators.registry
- fiftyone.operators.server
- fiftyone.operators.types
- fiftyone.operators.utils
Module contents¶
FiftyOne operators.
Classes:
|
A FiftyOne operator. |
|
A configuration for an operator. |
|
Operator registry. |
|
Represents the execution options of an operation. |
|
A logging handler that reports all logging messages issued while the handler’s context manager is active to the provided execution context’s |
Functions:
|
Gets the operator with the given URI. |
|
Returns all available operators. |
|
Checks if the given operator exists. |
|
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.
Attributes:
The unique identifier of the operator:
plugin_name/operator_name
.Whether the operator is builtin.
The
OperatorConfig
for the operator.Methods:
resolve_delegation
(ctx)Returns the resolved forced delegation flag.
Returns the resolved execution options.
execute
(ctx)Executes the operator.
resolve_type
(ctx, type)Returns the resolved input or output property.
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.
to_json
()Returns a JSON representation of the operator.
add_secrets
(secrets)Adds secrets to the operator.
-
property
name
¶
-
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_delegation
(ctx)¶ Returns the resolved forced delegation flag.
Subclasses can implement this method to decide if delegated execution should be forced for the given operation.
- Parameters
- Returns
whether the operation should be delegated (True), run immediately (False), or None to defer to
resolve_execution_options()
to specify the available options
-
resolve_execution_options
(ctx)¶ Returns the resolved execution options.
Subclasses can implement this method to define the execution options available for the operation.
- Parameters
- Returns
a
fiftyone.operators.executor.ExecutionOptions
instance
-
execute
(ctx)¶ Executes the operator.
Subclasses must implement this method.
- Parameters
- Returns
JSON serializable data, or None
-
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
()¶ Returns a JSON representation of the operator.
- 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, on_dataset_open=False, disable_schema_validation=False, delegation_target=None, icon=None, light_icon=None, dark_icon=None, allow_immediate_execution=True, allow_delegated_execution=False, default_choice_to_delegated=False, resolve_execution_options_on_change=None, **kwargs)¶ 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
on_dataset_open (False) – whether the operator should be executed on opening a dataset
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
allow_immediate_execution (True) – whether the operator should allow immediate execution
allow_delegated_execution (False) – whether the operator should allow delegated execution
default_choice_to_delegated (False) – whether to default to delegated execution, if allowed
resolve_execution_options_on_change (None) – whether to resolve execution options dynamically when inputs change. By default, this behavior will match the
dynamic
setting
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:
list_operators
([include_builtin])Lists the available FiftyOne operators.
Lists the errors that occurred during operator loading.
operator_exists
(operator_uri)Checks if the operator exists.
can_execute
(operator_uri)Whether the operator can be executed.
get_operator
(operator_uri)Retrieves an operator by its URI.
-
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, enabled=True)¶ Gets the operator with the given URI.
- Parameters
operator_uri – the operator URI
enabled (True) – whether to include only enabled operators (True) or only disabled operators (False) or all operators (“all”)
- Returns
- Raises
ValueError – if the operator is not found
-
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.
operator_exists
(operator_uri, enabled=True)¶ Checks if the given operator exists.
- Parameters
operator_uri – the operator URI
enabled (True) – whether to include only enabled operators (True) or only disabled operators (False) or all operators (“all”)
- Returns
True/False
-
fiftyone.operators.
execute_operator
(operator_uri, ctx=None, **kwargs)¶ Executes the operator with the given name.
- Parameters
operator_uri – the URI of the operator
ctx (None) –
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
(None): 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
current_sample
(None): an optional ID of the current sample being processedparams
: a dictionary of parameters for the operator. Consult the operator’s documentation for detailsrequest_delegation
(False): whether to request delegated execution, if supported by the operatordelegation_target
(None): an optional orchestrator on which to schedule the operation, if it is delegated
**kwargs – you can optionally provide any of the supported
ctx
keys as keyword arguments rather than including them inctx
- Returns
an
ExecutionResult
, or anasyncio.Task
if you run this method in a notebook context- Raises
ExecutionError – if an error occurred while immediately executing an operation or scheduling a delegated operation
-
class
fiftyone.operators.
ExecutionOptions
(allow_immediate_execution=True, allow_delegated_execution=False, default_choice_to_delegated=False)¶ Bases:
object
Represents the execution options of an operation.
- Parameters
allow_immediate_execution (True) – whether the operation can be executed immediately
allow_delegated_execution (False) – whether the operation can be delegated to an orchestrator
default_choice_to_delegated (False) – whether to default to delegated execution, if allowed
Attributes:
Methods:
update
([available_orchestrators])to_dict
()-
property
allow_immediate_execution
¶
-
property
allow_delegated_execution
¶
-
property
default_choice_to_delegated
¶
-
property
available_orchestrators
¶
-
property
orchestrator_registration_enabled
¶
-
update
(available_orchestrators=None)¶
-
to_dict
()¶
-
class
fiftyone.operators.
ProgressHandler
(ctx, logger=None, level=None)¶ Bases:
logging.Handler
A logging handler that reports all logging messages issued while the handler’s context manager is active to the provided execution context’s
set_progress()
method.- Parameters
logger (None) – a specific
logging.Logger
for which to report records. By default, the root logger is usedlevel (None) – an optional logging level above which to report records. By default, the logger’s effective level is used
Methods:
emit
(record)Do whatever it takes to actually log the specified logging record.
acquire
()Acquire the I/O thread lock.
addFilter
(filter)Add the specified filter to this handler.
close
()Tidy up any resources used by the handler.
Acquire a thread lock for serializing access to the underlying I/O.
filter
(record)Determine if a record is loggable by consulting all the filters.
flush
()Ensure all logging output has been flushed.
format
(record)Format the specified record.
get_name
()handle
(record)Conditionally emit the specified logging record.
handleError
(record)Handle errors which occur during an emit() call.
release
()Release the I/O thread lock.
removeFilter
(filter)Remove the specified filter from this handler.
setFormatter
(fmt)Set the formatter for this handler.
setLevel
(level)Set the logging level of this handler.
set_name
(name)Attributes:
-
emit
(record)¶ Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so raises a NotImplementedError.
-
acquire
()¶ Acquire the I/O thread lock.
-
addFilter
(filter)¶ Add the specified filter to this handler.
-
close
()¶ Tidy up any resources used by the handler.
This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.
-
createLock
()¶ Acquire a thread lock for serializing access to the underlying I/O.
-
filter
(record)¶ Determine if a record is loggable by consulting all the filters.
The default is to allow the record to be logged; any filter can veto this and the record is then dropped. Returns a zero value if a record is to be dropped, else non-zero.
Changed in version 3.2: Allow filters to be just callables.
-
flush
()¶ Ensure all logging output has been flushed.
This version does nothing and is intended to be implemented by subclasses.
-
format
(record)¶ Format the specified record.
If a formatter is set, use it. Otherwise, use the default formatter for the module.
-
get_name
()¶
-
handle
(record)¶ Conditionally emit the specified logging record.
Emission depends on filters which may have been added to the handler. Wrap the actual emission of the record with acquisition/release of the I/O thread lock. Returns whether the filter passed the record for emission.
-
handleError
(record)¶ Handle errors which occur during an emit() call.
This method should be called from handlers when an exception is encountered during an emit() call. If raiseExceptions is false, exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The record which was being processed is passed in to this method.
-
property
name
¶
-
release
()¶ Release the I/O thread lock.
-
removeFilter
(filter)¶ Remove the specified filter from this handler.
-
setFormatter
(fmt)¶ Set the formatter for this handler.
-
setLevel
(level)¶ Set the logging level of this handler. level must be an int or a str.
-
set_name
(name)¶