monai.deploy.core.Operator¶
- class monai.deploy.core.Operator(self: holoscan.core._core.Operator, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) None [source]¶
Bases:
holoscan.core._core.Operator
Operator class.
Can be initialized with any number of Python positional and keyword arguments.
If a name keyword argument is provided, it must be a str and will be used to set the name of the operator.
Condition classes will be added to
self.conditions
, Resource classes will be added toself.resources
, and any other arguments will be cast from a Python argument type to a C++ Arg and stored inself.args
. (For details on how the casting is done, see the py_object_to_arg utility). When a Condition or Resource is provided via a kwarg, it’s name will be automatically be updated to the name of the kwarg.- fragmentholoscan.core.Fragment
The holoscan.core.Fragment (or holoscan.core.Application) to which this Operator will belong.
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- RuntimeError
If name kwarg is provided, but is not of str type. If multiple arguments of type Fragment are provided. If any other arguments cannot be converted to Arg type via py_object_to_arg.
Operator class.
Can be initialized with any number of Python positional and keyword arguments.
If a name keyword argument is provided, it must be a str and will be used to set the name of the operator.
Condition classes will be added to
self.conditions
, Resource classes will be added toself.resources
, and any other arguments will be cast from a Python argument type to a C++ Arg and stored inself.args
. (For details on how the casting is done, see the py_object_to_arg utility). When a Condition or Resource is provided via a kwarg, it’s name will be automatically be updated to the name of the kwarg.- fragmentholoscan.core.Fragment
The holoscan.core.Fragment (or holoscan.core.Application) to which this Operator will belong.
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- RuntimeError
If name kwarg is provided, but is not of str type. If multiple arguments of type Fragment are provided. If any other arguments cannot be converted to Arg type via py_object_to_arg.
Methods
__init__
(self, arg0, arg1, *args, **kwargs)__init__(self: holoscan.core._core.Operator, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) -> None
add_arg
(*args, **kwargs)Overloaded function.
add_dynamic_flow
(*args, **kwargs)Overloaded function.
compute
(op_input, op_output, context)Default implementation of compute
enable_metadata
(self, enable)Configure whether or not the metadata feature is enabled for this operator.
find_all_flow_info
(self, predicate, bool])Find all flow info objects in the operator’s next flows that match a given condition.
find_flow_info
(self, predicate, bool])Find a flow info in the operator’s next flows based on a given predicate.
Default implementation of initialize
queue_policy
(self, port_name, port_type, policy)Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).
receiver
(self, port_name)Get the receiver used by an input port.
resource
(self, name)Resources associated with the operator.
setup
(spec)Default implementation of setup method.
start
()Default implementation of start
stop
()Default implementation of stop
stop_execution
(self)Stop the execution of the operator.
transmitter
(self, port_name)Get the transmitter used by an output port.
Attributes
INPUT_EXEC_PORT_NAME
OUTPUT_EXEC_PORT_NAME
The list of arguments associated with the component.
The internal asynchronous condition for the operator.
Conditions associated with the operator.
YAML formatted string describing the operator.
The execution context for the operator.
The fragment (
holoscan.core.Fragment
) that the operator belongs to.The identifier of the component.
Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.
The metadata dictionary (
holoscan.core.MetadataDictionary
) associated with the operator.The metadata policy (
holoscan.core.MetadataPolicy
) associated with the operator.The name of the operator.
Get the list of flow information for connections to downstream operators.
The operator type.
Resources associated with the operator.
The operator spec (
holoscan.core.OperatorSpec
) associated with the operator.- class OperatorType(self: holoscan.core._core.Operator.OperatorType, value: int) None ¶
Bases:
pybind11_builtins.pybind11_object
Enum class for operator types used by the executor.
NATIVE: Native operator.
GXF: GXF operator.
VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)
Members:
NATIVE
GXF
VIRTUAL
- property name¶
- __init__(self: holoscan.core._core.Operator, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) None [source]¶
__init__(self: holoscan.core._core.Operator, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) -> None
Operator class.
Can be initialized with any number of Python positional and keyword arguments.
If a name keyword argument is provided, it must be a str and will be used to set the name of the operator.
Condition classes will be added to
self.conditions
, Resource classes will be added toself.resources
, and any other arguments will be cast from a Python argument type to a C++ Arg and stored inself.args
. (For details on how the casting is done, see the py_object_to_arg utility). When a Condition or Resource is provided via a kwarg, it’s name will be automatically be updated to the name of the kwarg.- fragmentholoscan.core.Fragment
The holoscan.core.Fragment (or holoscan.core.Application) to which this Operator will belong.
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- RuntimeError
If name kwarg is provided, but is not of str type. If multiple arguments of type Fragment are provided. If any other arguments cannot be converted to Arg type via py_object_to_arg.
- add_arg(*args, **kwargs)¶
Overloaded function.
add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
add_arg(self: holoscan.core._core.Operator, **kwargs) -> None
Add arguments to the component via Python kwargs.
add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Condition) -> None
add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Resource) -> None
Add a condition or resource to the Operator.
This can be used to add a condition or resource to an operator after it has already been constructed.
- argholoscan.core.Condition or holoscan.core.Resource
The condition or resource to add.
- add_dynamic_flow(*args, **kwargs)¶
Overloaded function.
add_dynamic_flow(self: holoscan.core._core.Operator, flow: holoscan.core._core.FlowInfo) -> None
add_dynamic_flow(self: holoscan.core._core.Operator, flows: list[holoscan.core._core.FlowInfo]) -> None
add_dynamic_flow(self: holoscan.core._core.Operator, next_op: holoscan.core._core.Operator, next_input_port_name: str = ‘’) -> None
Add a dynamic flow from this operator to another operator.
- next_opholoscan.core.Operator
The downstream operator to connect to.
- next_input_port_namestr, optional
The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.
This method has several overloads to support different ways of creating dynamic flows:
add_dynamic_flow(next_op: Operator, next_input_port_name: str = ‘’) - Basic connection using default output port. This is the simplest form for connecting
two operators when you only need to specify the destination.
add_dynamic_flow(curr_output_port_name: str, next_op: Operator, next_input_port_name: str = ‘’) - Connection with explicit output port specification. Use this when the source operator has
multiple output ports and you need to specify which one to use.
add_dynamic_flow(flow: FlowInfo) - Connection using a FlowInfo object, which encapsulates all connection details including:
Source operator and its output port specification
Destination operator and its input port specification
Port names and associated IOSpecs
This is useful for complex connections or when reusing connection patterns.
add_dynamic_flow(flows: List[FlowInfo]) - Batch connection using multiple FlowInfo objects. Use this to set up multiple
connections in a single call, which is more efficient than making multiple individual connections.
The FlowInfo class provides a complete description of a flow connection between operators, including all port specifications and naming. It’s particularly useful when you need to:
Store and reuse connection patterns
Create complex routing configurations
Handle dynamic port specifications
Manage multiple connections systematically
add_dynamic_flow(self: holoscan.core._core.Operator, curr_output_port_name: str, next_op: holoscan.core._core.Operator, next_input_port_name: str = ‘’) -> None
- property args¶
The list of arguments associated with the component.
arglist : holoscan.core.ArgList
- property async_condition¶
The internal asynchronous condition for the operator.
This property provides access to the internal asynchronous condition for the operator, which controls the scheduling of the operator’s compute method.
- conditionholoscan.conditions.AsynchronousCondition
An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.
- property conditions¶
Conditions associated with the operator.
- property description¶
YAML formatted string describing the operator.
- enable_metadata(self: holoscan.core._core.Operator, enable: bool) None ¶
Configure whether or not the metadata feature is enabled for this operator. If it is not set, the default value will be determined by the enable_metadata setting from the Fragment that this operator belongs to.
- property execution_context¶
The execution context for the operator.
This property provides access to the execution context of the operator, which contains information about the current execution environment including scheduling details.
- holoscan.core.ExecutionContext
The execution context object for this operator.
- find_all_flow_info(self: holoscan.core._core.Operator, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) list[holoscan.core._core.FlowInfo] ¶
Find all flow info objects in the operator’s next flows that match a given condition.
- predicatecallable
A function that takes a FlowInfo object and returns a boolean.
- list[holoscan.core.FlowInfo]
List of matching FlowInfo objects.
- find_flow_info(self: holoscan.core._core.Operator, predicate: Callable[[holoscan.core._core.FlowInfo], bool]) holoscan.core._core.FlowInfo ¶
Find a flow info in the operator’s next flows based on a given predicate.
- predicatecallable
A function that takes a FlowInfo object and returns a boolean.
- holoscan.core.FlowInfo or None
The first matching FlowInfo object, or None if not found.
- property fragment¶
The fragment (
holoscan.core.Fragment
) that the operator belongs to.
- property id¶
The identifier of the component.
The identifier is initially set to
-1
, and will become a valid value when the component is initialized.With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.
id : int
- property is_metadata_enabled¶
Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled.
- property metadata¶
The metadata dictionary (
holoscan.core.MetadataDictionary
) associated with the operator.
- property metadata_policy¶
The metadata policy (
holoscan.core.MetadataPolicy
) associated with the operator.The supported policies are:
MetadataPolicy.REJECT: Reject the new value if the key already exists
MetadataPolicy.UPDATE: Replace existing value with the new one if the key already exists
MetadataPolicy.INPLACE_UPDATE: Update the value stored within an existing MetadataObject in-place if the key already exists (in contrast to UPDATE which always replaces the existing MetadataObject with a new one).
MetadataPolicy.RAISE: Raise an exception if the key already exists
- property name¶
The name of the operator.
- property next_flows¶
Get the list of flow information for connections to downstream operators.
- list[holoscan.core.FlowInfo]
List of flow information objects describing connections to downstream operators.
- property operator_type¶
The operator type.
holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.
- queue_policy(self: holoscan.core._core.Operator, port_name: str, port_type: holoscan.core._core.IOSpec.IOType = <IOType.INPUT: 0>, policy: holoscan.core._core.IOSpec.QueuePolicy = <QueuePolicy.FAULT: 2>) None ¶
Set the queue policy to be used by an input (or output) port’s receiver (or transmitter).
- port_namestr
The name of the port.
- port_typeIOSpec.IOType, optional
Enum indicating whether port_name corresponds to an input port or output port.
- policyIOSpec.QueuePolicy, optional
The queue policy to set. Valid values are:
QueuePolicy.POP : If the queue is full, pop the oldest item, then add the new one.
QueuePolicy.REJECT : If the queue is full, reject (discard) the new item.
QueuePolicy.FAULT : If the queue is full, log a warning and reject the new item.
- transmitterholoscan.resources.Transmitter or None
The transmitter used by this output port. Will be None if the port does not exist.
- receiver(self: holoscan.core._core.Operator, port_name: str) Optional[holoscan::Receiver] ¶
Get the receiver used by an input port.
- port_namestr
The name of the input port.
- receiverholoscan.resources.Receiver
The receiver used by this input port. Will be None if the port does not exist.
- resource(self: holoscan.core._core.Operator, name: str) Optional[object] ¶
Resources associated with the operator.
- namestr
The name of the resource to retrieve
- holoscan.core.Resource or None
The resource with the given name. If no resource with the given name is found, None is returned.
- property resources¶
Resources associated with the operator.
- property spec¶
The operator spec (
holoscan.core.OperatorSpec
) associated with the operator.
- stop_execution(self: holoscan.core._core.Operator) None ¶
Stop the execution of the operator.
This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).
Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.
- transmitter(self: holoscan.core._core.Operator, port_name: str) Optional[holoscan::Transmitter] ¶
Get the transmitter used by an output port.
- port_namestr
The name of the output port.
- transmitterholoscan.resources.Transmitter or None
The transmitter used by this output port. Will be None if the port does not exist.