holoscan.core
This module provides a Python API for the core C++ API classes.
The Application class is the primary class that should be derived from to create a custom application.
holoscan.core.Application ([argv]) |
Application class. |
holoscan.core.Arg |
Class representing a typed argument. |
holoscan.core.ArgContainerType |
Enum class for an Arg's container type. |
holoscan.core.ArgElementType |
Enum class for an Arg's element type. |
holoscan.core.ArgList |
Class representing a list of arguments. |
holoscan.core.ArgType |
Class containing argument type info. |
holoscan.core.CLIOptions |
Attributes |
holoscan.core.Component |
Base component class. |
holoscan.core.ComponentSpec |
alias of holoscan.core._core.PyComponentSpec |
holoscan.core.ConditionType |
Enum class for Condition types. |
holoscan.core.Condition (fragment, *args, ...) |
Class representing a condition. |
holoscan.core.Config |
Configuration class. |
holoscan.core.DataFlowMetric |
Enum class for DataFlowMetric type. |
holoscan.core.DataFlowTracker |
Data Flow Tracker class. |
holoscan.core.DLDevice |
DLDevice class. |
holoscan.core.DLDeviceType |
Members: |
holoscan.core.ExecutionContext |
Execution context class. |
holoscan.core.Executor |
Executor class. |
holoscan.core.Fragment ([app, name]) |
Fragment class. |
holoscan.core.FlowInfo |
Information about a flow connection between operators. |
holoscan.core.Graph |
alias of holoscan.graphs._graphs.OperatorGraph |
holoscan.core.InputContext |
Input context class. |
holoscan.core.IOSpec |
I/O specification class. |
holoscan.core.Message |
Class representing a message. |
holoscan.core.MetadataDictionary |
Class representing a holoscan metadata dictionary. |
holoscan.core.MultiMessageConditionInfo |
Information associated with a multi-message condition. |
holoscan.core.MetadataPolicy |
Enum to define the policy for handling behavior of MetadataDictionary::set when a key already exists. |
holoscan.core.NetworkContext |
Class representing a network context. |
holoscan.core.Operator (fragment, *args, **kwargs) |
Operator class. |
holoscan.core.OperatorSpec |
alias of holoscan.core._core.PyOperatorSpec |
holoscan.core.OperatorStatus |
Operator status values |
holoscan.core.OutputContext |
Output context class. |
holoscan.core.ParameterFlag |
Enum class for parameter flags. |
holoscan.core.Resource (fragment, *args, **kwargs) |
Class representing a resource. |
holoscan.core.SchedulingStatusType |
Enum class for Condition scheduling status. |
holoscan.core.Tensor |
alias of holoscan.core._core.PyTensor |
holoscan.core.Tracker (app, *[, filename, ...]) |
Context manager to add data flow tracking to an application. |
holoscan.core.arg_to_py_object (arg) |
Utility that converts an Arg to a corresponding Python object. |
holoscan.core.arglist_to_kwargs (arglist) |
Utility that converts an ArgList to a Python kwargs dictionary. |
holoscan.core.kwargs_to_arglist (**kwargs) |
Utility that converts a set of python keyword arguments to an ArgList. |
holoscan.core.py_object_to_arg (obj[, name]) |
Utility that converts a single python argument to a corresponding Arg type. |
- class holoscan.core.Application(argv=None, *args, **kwargs)
Bases:
holoscan.core._core.Application
Application class.
This constructor parses the command line for flags that are recognized by App Driver/Worker, and removes all recognized flags so users can use the remaining flags for their own purposes.
If the arguments are not specified, the arguments are retrieved from
sys.executable
andsys.argv
.The arguments after processing arguments (parsing Holoscan-specific flags and removing them) are accessible through the
argv
attribute.- Parameters
- argvList[str]
The command line arguments to parse. The first item should be the path to the python executable. If not specified,
[sys.executable, *sys.argv]
is used.
Examples
>>> from holoscan.core import Application >>> import sys >>> Application().argv == sys.argv True >>> Application([]).argv == sys.argv True >>> Application([sys.executable, *sys.argv]).argv == sys.argv True >>> Application(["python3", "myapp.py", "--driver", "--address=10.0.0.1", "my_arg1"]).argv ['myapp.py', 'my_arg1']
Attributes
application
The application associated with the fragment. argv
The command line arguments after processing flags. description
The application's description. executor
Get the executor associated with the fragment. fragment_graph
Get the computation graph (Graph node is a Fragment) associated with the application. graph
Get the computation graph (Graph node is an Operator) associated with the fragment. is_metadata_enabled
Whether operator metadata transmission is enabled by default for the application. metadata_policy
The default metadata policy ( holoscan.core.MetadataPolicy
) associated with the application.name
The fragment's name. options
The reference to the CLI options. version
The application's version. Methods
add_flow
(*args, **kwargs)Overloaded function. add_fragment
(self, frag)Add a fragment to the application. add_operator
(self, op)Add an operator to the application. compose
(self)The compose method of the application. compose_graph
(self)This is a wrapper around compose that only calls compose if the graph is not already composed. config
(*args, **kwargs)Overloaded function. config_keys
(self)The set of keys present in the fragment's configuration file. enable_metadata
(self, enabled)Method to set whether operator metadata transmission is enabled by default for fragments in this application. from_config
(self, key)Retrieve parameters from the associated configuration. kwargs
(self, key)Retrieve a dictionary parameters from the associated configuration. make_thread_pool
(self, name, initialize_size)Create a ThreadPool associated with this Fragment. network_context
(*args, **kwargs)Overloaded function. run
(self)The run method of the application. run_async
()Run the application asynchronously. scheduler
(*args, **kwargs)Overloaded function. set_dynamic_flows
(self, op, dynamic_flow_func)Set a callback function to define dynamic flows for an operator at runtime. start_op
()Get or create the start operator for this application. stop_execution
(self[, op_name])Stop the execution of all operators in the fragment. track
(self, num_start_messages_to_skip, ...)The track method of the fragment (or application). track_distributed
(self, ...)- __init__(self: holoscan.core._core.Application, argv: list[str] = []) → None
Application class.
This constructor parses the command line for flags that are recognized by App Driver/Worker, and removes all recognized flags so users can use the remaining flags for their own purposes.
If the arguments are not specified, the arguments are retrieved from
sys.executable
andsys.argv
.The arguments after processing arguments (parsing Holoscan-specific flags and removing them) are accessible through the
argv
attribute.- Parameters
- argvList[str]
The command line arguments to parse. The first item should be the path to the python executable. If not specified,
[sys.executable, *sys.argv]
is used.
Examples
>>> from holoscan.core import Application >>> import sys >>> Application().argv == sys.argv True >>> Application([]).argv == sys.argv True >>> Application([sys.executable, *sys.argv]).argv == sys.argv True >>> Application(["python3", "myapp.py", "--driver", "--address=10.0.0.1", "my_arg1"]).argv ['myapp.py', 'my_arg1']
- add_flow(*args, **kwargs)
Overloaded function.
add_flow(self: holoscan.core._core.Application, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator) -> None
add_flow(self: holoscan.core._core.Application, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator, port_pairs: set[tuple[str, str]]) -> None
Connect two operators associated with the fragment.
- Parameters
- upstream_opholoscan.core.Operator
Source operator.
- downstream_opholoscan.core.Operator
Destination operator.
- port_pairsSequence of (str, str) tuples
Sequence of ports to connect. The first element of each 2-tuple is a port from upstream_op while the second element is the port of downstream_op to which it connects.
Notes
This is an overloaded function. Additional variants exist:
1.) For the Application class there is a variant where the first two arguments are of type holoscan.core.Fragment instead of holoscan.core.Operator. This variant is used in building multi-fragment applications. 2.) There are also variants that omit the port_pairs argument that are applicable when there is only a single output on the upstream operator/fragment and a single input on the downstream operator/fragment.
add_flow(self: holoscan.core._core.Application, upstream_frag: holoscan.core._core.Fragment, downstream_frag: holoscan.core._core.Fragment, port_pairs: set[tuple[str, str]]) -> None
- add_fragment(self: holoscan.core._core.Application, frag: holoscan.core._core.Fragment) → None
Add a fragment to the application.
- Parameters
- fragholoscan.core.Fragment
The fragment to add.
- add_operator(self: holoscan.core._core.Application, op: holoscan.core._core.Operator) → None
Add an operator to the application.
- Parameters
- opholoscan.core.Operator
The operator to add.
- property application
The application associated with the fragment.
- Returns
- appholoscan.core.Application
- property argv
The command line arguments after processing flags. This does not include the python executable like sys.argv does.
- Returns
- argvlist of str
- compose(self: holoscan.core._core.Application) → None
The compose method of the application.
This method should be called after
config
, but before the graph starts running in order to compose the computation graph. This method will be called automatically byApplication.run
, so it is not normally necessary to call it directly.
- compose_graph(self: holoscan.core._core.Application) → None
This is a wrapper around compose that only calls compose if the graph is not already composed.
- config(*args, **kwargs)
Overloaded function.
config(self: holoscan.core._core.Fragment, config_file: str, prefix: str = ‘’) -> None
Configuration class.
Represents configuration parameters as read from a YAML file.
- Parameters
- configstr or holoscan.core.Config
The path to the configuration file (in YAML format) or a holoscan.core.Config object.
- prefixstr, optional
Prefix path for the` config` file. Only available in the overloaded variant that takes a string for config.
- 2. config(self: holoscan.core._core.Fragment, arg0: holoscan.core._core.Config) -> None
- 3. config(self: holoscan.core._core.Fragment) -> holoscan.core._core.Config
- config_keys(self: holoscan.core._core.Fragment) → set[str]
The set of keys present in the fragment’s configuration file.
- property description
The application’s description.
- Returns
- descriptionstr
- enable_metadata(self: holoscan.core._core.Application, enabled: bool) → None
Method to set whether operator metadata transmission is enabled by default for fragments in this application. Individual fragments can override this default via Fragment.enable_metadata. Similarly individual operators can override their fragment default via Operator.enable_metadata.
- property executor
Get the executor associated with the fragment.
- property fragment_graph
Get the computation graph (Graph node is a Fragment) associated with the application.
- from_config(self: holoscan.core._core.Fragment, key: str) → object
Retrieve parameters from the associated configuration.
- Parameters
- keystr
The key within the configuration file to retrieve. This can also be a specific component of the parameter via syntax ‘key.sub_key’.
- Returns
- argsholoscan.core.ArgList
An argument list associated with the key.
- property graph
Get the computation graph (Graph node is an Operator) associated with the fragment.
- property is_metadata_enabled
Whether operator metadata transmission is enabled by default for the application.
Notes
Setting metadata to be enabled/disabled via this method is deprecated. Please use enable_metadata instead.
- kwargs(self: holoscan.core._core.Fragment, key: str) → dict
Retrieve a dictionary parameters from the associated configuration.
- Parameters
- keystr
The key within the configuration file to retrieve. This can also be a specific component of the parameter via syntax ‘key.sub_key’.
- Returns
- kwargsdict
A Python dict containing the parameters in the configuration file under the specified key.
- make_thread_pool(self: holoscan.core._core.Fragment, name: str, initialize_size: int = 1) → holoscan::ThreadPool
Create a ThreadPool associated with this Fragment.
The add method must be used to add individual operators to the pool.
- Parameters
- namestr
A name for the thread pool.
- initialize_size1
The initial number of threads in the pool.
- property metadata_policy
The default metadata policy (
holoscan.core.MetadataPolicy
) associated with the application.Individual fragments of a distributed application can override this via
Fragment.metadata_policy
. Similarly, individual operators can override this viaOperator.metadata_policy
.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 fragment’s name.
- Returns
- namestr
- network_context(*args, **kwargs)
Overloaded function.
network_context(self: holoscan.core._core.Fragment, network_context: holoscan.core._core.NetworkContext) -> None
Assign a network context to the Fragment
- Parameters
- network_contextholoscan.core.NetworkContext
A network_context class instance to be used by the underlying GXF executor. If unspecified, no network context will be used.
- 2. network_context(self: holoscan.core._core.Fragment) -> holoscan.core._core.NetworkContext
- Get the network context to be used by the Fragment
- property options
The reference to the CLI options.
- Returns
- optionsholoscan.core.CLIOptions
- run(self: holoscan.core._core.Application) → None
The run method of the application.
This method runs the computation. It must have first been initialized via config and compose.
- run_async()
Run the application asynchronously.
This method is a convenience method that creates a thread pool with one thread and runs the application in that thread. The thread pool is created using concurrent.futures.ThreadPoolExecutor.
- Returns
- future
concurrent.futures.Future
object
- future
- scheduler(*args, **kwargs)
Overloaded function.
scheduler(self: holoscan.core._core.Fragment, scheduler: holoscan.core._core.Scheduler) -> None
Assign a scheduler to the Fragment.
- Parameters
- schedulerholoscan.core.Scheduler
A scheduler class instance to be used by the underlying GXF executor. If unspecified, the default is a holoscan.gxf.GreedyScheduler.
- 2. scheduler(self: holoscan.core._core.Fragment) -> holoscan.core._core.Scheduler
- Get the scheduler to be used by the Fragment.
- set_dynamic_flows(self: holoscan.core._core.Fragment, op: holoscan.core._core.Operator, dynamic_flow_func: Callable) → None
Set a callback function to define dynamic flows for an operator at runtime.
This method allows operators to modify their connections with other operators during execution. The callback function is called after the operator executes and can add dynamic flows using the operator’s add_dynamic_flow() methods.
- Parameters
- opholoscan.core.Operator
The operator for which to set dynamic flows.
- dynamic_flow_funccallable
The callback function that defines the dynamic flows. Takes an operator as input and returns
None
.
- start_op()
Get or create the start operator for this application.
This operator is nothing but the first operator that was added to the application. It has the name of <|start|> and has a condition of CountCondition(1). This Operator is used to start the execution of the application. Entry operators who want to start the execution of the application should connect to this operator.
If this method is not called, no start operator is created. Otherwise, the start operator is created if it does not exist, and the start operator is returned.
- Returns
- Operator
The start operator instance. If it doesn’t exist, it will be created with a CountCondition(1).
- stop_execution(self: holoscan.core._core.Fragment, op_name: str = '') → None
Stop the execution of all operators in the fragment.
This method is used to stop the execution of all operators in the fragment by setting the internal async condition of each operator to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operators will not be scheduled for execution (the compute() method will not be called), which may lead to application termination depending on the application’s design.
Note that executing this method does not trigger the operators’ stop() method. The stop() method is called only when the scheduler deactivates all operators together.
- Parameters
- op_namestr, optional
The name of the operator to stop. If empty, all operators will be stopped.
- track(self: holoscan.core._core.Fragment, num_start_messages_to_skip: int = 10, num_last_messages_to_discard: int = 10, latency_threshold: int = 0, is_limited_tracking: bool = False) → holoscan::DataFlowTracker
The track method of the fragment (or application).
This method enables data frame flow tracking and returns a DataFlowTracker object which can be used to display metrics data for profiling an application.
- Parameters
- num_start_messages_to_skipint
The number of messages to skip at the beginning.
- num_last_messages_to_discardint
The number of messages to discard at the end.
- latency_thresholdint
The minimum end-to-end latency in milliseconds to account for in the end-to-end latency metric calculations
- is_limited_trackingbool, optional
If
True
, the tracking is limited to root and leaf nodes, minimizing the timestamps by avoiding intermediate operators.
- Returns
- trackerholoscan.core.DataFlowTracker
The data flow tracker object that can be used to display metrics data for profiling along the different paths through the computation graph.
- track_distributed(self: holoscan.core._core.Application, num_start_messages_to_skip: int = 10, num_last_messages_to_discard: int = 10, latency_threshold: int = 0, is_limited_tracking: bool = False) → dict[str, holoscan::DataFlowTracker]
- property version
The application’s version.
- Returns
- versionstr
- class holoscan.core.Arg
Bases:
pybind11_builtins.pybind11_object
Class representing a typed argument.
Attributes
arg_type
ArgType info corresponding to the argument. description
YAML formatted string describing the argument. has_value
Boolean flag indicating whether a value has been assigned to the argument. name
Name of the argument. - __init__(self: holoscan.core._core.Arg, name: str) → None
Class representing a typed argument.
- Parameters
- namestr, optional
The argument’s name.
- property arg_type
ArgType info corresponding to the argument.
- Returns
- arg_typeholoscan.core.ArgType
- property description
YAML formatted string describing the argument.
- property has_value
Boolean flag indicating whether a value has been assigned to the argument.
- property name
Name of the argument.
- class holoscan.core.ArgContainerType
Bases:
pybind11_builtins.pybind11_object
Enum class for an Arg’s container type.
Members:
NATIVE
VECTOR
ARRAY
Attributes
value - ARRAY = <ArgContainerType.ARRAY: 2>
- NATIVE = <ArgContainerType.NATIVE: 0>
- VECTOR = <ArgContainerType.VECTOR: 1>
- __init__(self: holoscan.core._core.ArgContainerType, value: int) → None
- property name
- property value
- class holoscan.core.ArgElementType
Bases:
pybind11_builtins.pybind11_object
Enum class for an Arg’s element type.
Members:
CUSTOM
BOOLEAN
INT8
UNSIGNED8
INT16
UNSIGNED16
INT32
UNSIGNED32
INT64
UNSIGNED64
FLOAT32
FLOAT64
STRING
HANDLE
YAML_NODE
IO_SPEC
CONDITION
RESOURCE
Attributes
value - BOOLEAN = <ArgElementType.BOOLEAN: 1>
- CONDITION = <ArgElementType.CONDITION: 18>
- CUSTOM = <ArgElementType.CUSTOM: 0>
- FLOAT32 = <ArgElementType.FLOAT32: 10>
- FLOAT64 = <ArgElementType.FLOAT64: 11>
- HANDLE = <ArgElementType.HANDLE: 15>
- INT16 = <ArgElementType.INT16: 4>
- INT32 = <ArgElementType.INT32: 6>
- INT64 = <ArgElementType.INT64: 8>
- INT8 = <ArgElementType.INT8: 2>
- IO_SPEC = <ArgElementType.IO_SPEC: 17>
- RESOURCE = <ArgElementType.RESOURCE: 19>
- STRING = <ArgElementType.STRING: 14>
- UNSIGNED16 = <ArgElementType.UNSIGNED16: 5>
- UNSIGNED32 = <ArgElementType.UNSIGNED32: 7>
- UNSIGNED64 = <ArgElementType.UNSIGNED64: 9>
- UNSIGNED8 = <ArgElementType.UNSIGNED8: 3>
- YAML_NODE = <ArgElementType.YAML_NODE: 16>
- __init__(self: holoscan.core._core.ArgElementType, value: int) → None
- property name
- property value
- class holoscan.core.ArgList
Bases:
pybind11_builtins.pybind11_object
Class representing a list of arguments.
Attributes
args
The underlying list of Arg objects. description
YAML formatted string describing the list. name
The name of the argument list. size
The number of arguments in the list. Methods
- __init__(self: holoscan.core._core.ArgList) → None
Class representing a list of arguments.
- add(*args, **kwargs)
Overloaded function.
add(self: holoscan.core._core.ArgList, arg: holoscan.core._core.Arg) -> None
Add an argument to the list.
add(self: holoscan.core._core.ArgList, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the list.
- property args
The underlying list of Arg objects.
- clear(self: holoscan.core._core.ArgList) → None
Clear the argument list.
- property description
YAML formatted string describing the list.
- property name
The name of the argument list.
- Returns
- namestr
- property size
The number of arguments in the list.
- class holoscan.core.ArgType
Bases:
pybind11_builtins.pybind11_object
Class containing argument type info.
Attributes
container_type
The container type of the argument. dimension
The dimension of the argument container. element_type
The element type of the argument. to_string
String describing the argument type. - __init__(*args, **kwargs)
Overloaded function.
__init__(self: holoscan.core._core.ArgType) -> None
Class containing argument type info.
__init__(self: holoscan.core._core.ArgType, element_type: holoscan.core._core.ArgElementType, container_type: holoscan.core._core.ArgContainerType) -> None
Class containing argument type info.
- Parameters
- element_typeholoscan.core.ArgElementType
Element type of the argument.
- container_typeholoscan.core.ArgContainerType
Container type of the argument.
- property container_type
The container type of the argument.
- property dimension
The dimension of the argument container.
- property element_type
The element type of the argument.
- property to_string
String describing the argument type.
- class holoscan.core.CLIOptions
Bases:
pybind11_builtins.pybind11_object
Attributes
config_path
The path to the configuration file. driver_address
The address of the App Driver. run_driver
The flag to run the App Driver. run_worker
The flag to run the App Worker. worker_address
The address of the App Worker. worker_targets
The list of fragments for the App Worker. Methods
print
(self)Print the CLI Options. - __init__(self: holoscan.core._core.CLIOptions, run_driver: bool = False, run_worker: bool = False, driver_address: str = '', worker_address: str = '', worker_targets: list[str] = [], config_path: str = '') → None
CLIOptions class.
- property config_path
The path to the configuration file.
- property driver_address
The address of the App Driver.
- print(self: holoscan.core._core.CLIOptions) → None
Print the CLI Options.
- property run_driver
The flag to run the App Driver.
- property run_worker
The flag to run the App Worker.
- property worker_address
The address of the App Worker.
- property worker_targets
The list of fragments for the App Worker.
- Returns
- worker_targetslist of str
- class holoscan.core.Component
Bases:
holoscan.core._core.ComponentBase
Base component class.
Attributes
args
The list of arguments associated with the component. description
YAML formatted string describing the component. fragment
The fragment containing the component. id
The identifier of the component. name
The name of the component. Methods
add_arg
(*args, **kwargs)Overloaded function. initialize
(self)Initialize the component. - __init__(self: holoscan.core._core.Component) → None
Base component class.
- add_arg(*args, **kwargs)
Overloaded function.
add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
- property args
The list of arguments associated with the component.
- Returns
- arglistholoscan.core.ArgList
- property description
YAML formatted string describing the component.
- property fragment
The fragment containing the component.
- Returns
- nameholoscan.core.Fragment
- 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.
- Returns
- idint
- initialize(self: holoscan.core._core.ComponentBase) → None
Initialize the component.
- property name
The name of the component.
- Returns
- namestr
- holoscan.core.ComponentSpec
alias of
holoscan.core._core.PyComponentSpec
- class holoscan.core.Condition(fragment, *args, **kwargs)
Bases:
holoscan.core._core.Condition
Class representing a condition.
Attributes
args
The list of arguments associated with the component. condition_type
Condition type. description
YAML formatted string describing the condition. fragment
Fragment that the condition belongs to. id
The identifier of the component. name
The name of the condition. spec Methods
add_arg
(*args, **kwargs)Overloaded function. check
(timestamp)Default implementation of check. initialize
()Default implementation of initialize on_execute
(timestamp)Default implementation of on_execute receiver
(self, port_name)Get the receiver used by an input port of the operator this condition is associated with. setup
(spec)Default implementation of setup method. transmitter
(self, port_name)Get the transmitter used by an output port of the operator this condition is associated with. update_state
(timestamp)Default implementation of update_state ConditionComponentType - class ConditionComponentType
Bases:
pybind11_builtins.pybind11_object
Members:
NATIVE
GXF
Attributes
value - GXF = <ConditionComponentType.GXF: 1>
- NATIVE = <ConditionComponentType.NATIVE: 0>
- __init__(self: holoscan.core._core.Condition.ConditionComponentType, value: int) → None
- property name
- property value
- __init__(self: holoscan.core._core.Condition, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) → None
Class representing a condition.
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 condition.
If a fragment keyword argument is provided, it must be of type holoscan.core.Fragment (or holoscan.core.Application). A single Fragment object can also be provided positionally instead.
Any other arguments will be cast from a Python argument type to a C++ Arg and stored in
self.args
. (For details on how the casting is done, see the py_object_to_arg utility).- Parameters
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.ComponentBase, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
- property args
The list of arguments associated with the component.
- Returns
- arglistholoscan.core.ArgList
- check(timestamp: int) → tuple[holoscan.core._core.SchedulingStatusType, Optional[int]]
Default implementation of check.
- Parameters
- timestampint
The timestamp at which the check method is called. This method is called by the underlying GXF framework to determine whether an operator is ready to execute.
- Returns
- status_type: SchedulingStatusType
The current status of the operator. See the documentation on native condition creation for explanations of the various status types.
- target_timestamp: int or None
Specifies a specific target timestamp at which the operator is expected to be ready. This should only be provided if relevant (it helps the underlying framework avoid overhead of repeated checks before the target time).
Notes
The method should return SchedulingStatusType.READY when the desired condition has been met.
The operator will always execute with this default implementation that always execute with this default implementation.
- property condition_type
Condition type.
holoscan.core.Condition.ConditionComponentType enum representing the type of the condition. The two types currently implemented are NATIVE and GXF.
- property description
YAML formatted string describing the condition.
- property fragment
Fragment that the condition belongs to.
- Returns
- nameholoscan.core.Fragment
- 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.
- Returns
- idint
- initialize()
Default implementation of initialize
- property name
The name of the condition.
- Returns
- namestr
- on_execute(timestamp)
Default implementation of on_execute
- Parameters
- timestampint
The timestamp at which the on_execute method was called.
Notes
This method is called by the underlying GXF framework immediately after the Operator.compute call for the operator to which the condition has been assigned.
- receiver(self: holoscan.core._core.Condition, port_name: str) → Optional[holoscan::Receiver]
Get the receiver used by an input port of the operator this condition is associated with.
- Parameters
- port_namestr
The name of the input port.
- Returns
- receiverholoscan.resources.Receiver
The receiver used by this input port. Will be None if the port does not exist.
- setup(spec: holoscan.core._core.PyComponentSpec)
Default implementation of setup method.
- property spec
- transmitter(self: holoscan.core._core.Condition, port_name: str) → Optional[holoscan::Transmitter]
Get the transmitter used by an output port of the operator this condition is associated with.
- Parameters
- port_namestr
The name of the output port.
- Returns
- transmitterholoscan.resources.Transmitter or None
The transmitter used by this output port. Will be None if the port does not exist.
- update_state(timestamp)
Default implementation of update_state
- Parameters
- timestampint
The timestamp at which the update_state method was called.
Notes
This method is always called by the underlying GXF framework immediately before the Condition.check method. In some cases, the Condition.on_execute method may also wish to call this method.
- class holoscan.core.ConditionType
Bases:
pybind11_builtins.pybind11_object
Enum class for Condition types.
Members:
NONE
MESSAGE_AVAILABLE
DOWNSTREAM_MESSAGE_AFFORDABLE
COUNT
BOOLEAN
PERIODIC
ASYNCHRONOUS
EXPIRING_MESSAGE_AVAILABLE
MULTI_MESSAGE_AVAILABLE
MULTI_MESSAGE_AVAILABLE_TIMEOUT
Attributes
value - ASYNCHRONOUS = <ConditionType.ASYNCHRONOUS: 6>
- BOOLEAN = <ConditionType.BOOLEAN: 4>
- COUNT = <ConditionType.COUNT: 3>
- DOWNSTREAM_MESSAGE_AFFORDABLE = <ConditionType.DOWNSTREAM_MESSAGE_AFFORDABLE: 2>
- EXPIRING_MESSAGE_AVAILABLE = <ConditionType.EXPIRING_MESSAGE_AVAILABLE: 7>
- MESSAGE_AVAILABLE = <ConditionType.MESSAGE_AVAILABLE: 1>
- MULTI_MESSAGE_AVAILABLE = <ConditionType.MULTI_MESSAGE_AVAILABLE: 8>
- MULTI_MESSAGE_AVAILABLE_TIMEOUT = <ConditionType.MULTI_MESSAGE_AVAILABLE_TIMEOUT: 9>
- NONE = <ConditionType.NONE: 0>
- PERIODIC = <ConditionType.PERIODIC: 5>
- __init__(self: holoscan.core._core.ConditionType, value: int) → None
- property name
- property value
- class holoscan.core.Config
Bases:
pybind11_builtins.pybind11_object
Configuration class.
Represents configuration parameters as read from a YAML file.
Attributes
config_file
The configuration file (in YAML format) associated with the Config object. prefix
TODO - __init__(self: holoscan.core._core.Config, config_file: str, prefix: str = '') → None
Configuration class.
Represents configuration parameters as read from a YAML file.
- Parameters
- config_filestr
The path to the configuration file (in YAML format).
- prefixstr, optional
TODO
- property config_file
The configuration file (in YAML format) associated with the Config object.
- property prefix
TODO
- class holoscan.core.DLDevice
Bases:
pybind11_builtins.pybind11_object
DLDevice class.
Attributes
device_id
The device id (int). device_type
The device type (DLDeviceType). - __init__(self: holoscan.core._core.DLDevice, arg0: holoscan.core._core.DLDeviceType, arg1: int) → None
- property device_id
The device id (int).
- property device_type
The device type (DLDeviceType).
The following device types are supported:
DLDeviceType.DLCPU: system memory (kDLCPU)
DLDeviceType.DLCUDA: CUDA GPU memory (kDLCUDA)
DLDeviceType.DLCUDAHost: CUDA pinned memory (kDLCUDAHost)
DLDeviceType.DLCUDAManaged: CUDA managed memory (kDLCUDAManaged)
- class holoscan.core.DLDeviceType
Bases:
pybind11_builtins.pybind11_object
Members:
DLCPU
DLCUDA
DLCUDAHOST
DLCUDAMANAGED
Attributes
value - DLCPU = <DLDeviceType.DLCPU: 1>
- DLCUDA = <DLDeviceType.DLCUDA: 2>
- DLCUDAHOST = <DLDeviceType.DLCUDAHOST: 3>
- DLCUDAMANAGED = <DLDeviceType.DLCUDAMANAGED: 13>
- __init__(self: holoscan.core._core.DLDeviceType, value: int) → None
- property name
- property value
- class holoscan.core.DataFlowMetric
Bases:
pybind11_builtins.pybind11_object
Enum class for DataFlowMetric type.
Members:
MAX_MESSAGE_ID
MIN_MESSAGE_ID
MAX_E2E_LATENCY
AVG_E2E_LATENCY
MIN_E2E_LATENCY
NUM_SRC_MESSAGES
NUM_DST_MESSAGES
Attributes
value - AVG_E2E_LATENCY = <DataFlowMetric.AVG_E2E_LATENCY: 3>
- MAX_E2E_LATENCY = <DataFlowMetric.MAX_E2E_LATENCY: 2>
- MAX_MESSAGE_ID = <DataFlowMetric.MAX_MESSAGE_ID: 0>
- MIN_E2E_LATENCY = <DataFlowMetric.MIN_E2E_LATENCY: 4>
- MIN_MESSAGE_ID = <DataFlowMetric.MIN_MESSAGE_ID: 1>
- NUM_DST_MESSAGES = <DataFlowMetric.NUM_DST_MESSAGES: 6>
- NUM_SRC_MESSAGES = <DataFlowMetric.NUM_SRC_MESSAGES: 5>
- __init__(self: holoscan.core._core.DataFlowMetric, value: int) → None
- property name
- property value
- class holoscan.core.DataFlowTracker
Bases:
pybind11_builtins.pybind11_object
Data Flow Tracker class.
The DataFlowTracker class is used to track the data flow metrics for different paths between the root and leaf operators. This class is used by developers to get data flow metrics either during the execution of the application and/or as a summary after the application ends.
Methods
enable_logging
(self[, filename, ...])Enable logging of frames at the end of the every execution of a leaf Operator. end_logging
(self)Write out any remaining messages from the log buffer and close the file get_metric
(*args, **kwargs)Overloaded function. get_num_paths
(self)The number of tracked paths get_path_strings
(self)Return an array of strings which are path names. print
(self)Print the result of the data flow tracking in pretty-printed format to the standard output set_discard_last_messages
(self, arg0)Set the number of messages to discard at the end of the execution. set_skip_latencies
(self, arg0)Set the threshold latency for which the end-to-end latency calculations will be done. set_skip_starting_messages
(self, arg0)Set the number of messages to skip at the beginning of the execution. - __init__(self: holoscan.core._core.DataFlowTracker) → None
Data Flow Tracker class.
The DataFlowTracker class is used to track the data flow metrics for different paths between the root and leaf operators. This class is used by developers to get data flow metrics either during the execution of the application and/or as a summary after the application ends.
- enable_logging(self: holoscan.core._core.DataFlowTracker, filename: str = 'logger.log', num_buffered_messages: int = 100) → None
Enable logging of frames at the end of the every execution of a leaf Operator.
A path consisting of an array of tuples in the form of (an Operator name, message receive timestamp, message publish timestamp) is logged in a file. The logging does not take into account the number of message to skip or discard or the threshold latency.
This function buffers a number of lines set by num_buffered_messages before flushing the buffer to the log file.
- Parameters
- filenamestr
The name of the log file.
- num_buffered_messagesint
The number of messages to be buffered before flushing the buffer to the log file.
- end_logging(self: holoscan.core._core.DataFlowTracker) → None
Write out any remaining messages from the log buffer and close the file
- get_metric(*args, **kwargs)
Overloaded function.
get_metric(self: holoscan.core._core.DataFlowTracker, pathstring: str, metric: holoscan.core._core.DataFlowMetric) -> float
Return the value of a metric for a given path.
If metric is DataFlowMetric::NUM_SRC_MESSAGES, then the function returns -1.
- Parameters
- pathstringstr
The path name string for which the metric is being queried
- metricholoscan.core.DataFlowMetric
The metric to be queried.
- Returns
- valfloat
The value of the metric for the given path
Notes
There is also an overloaded version of this function that takes only the metric argument.
get_metric(self: holoscan.core._core.DataFlowTracker, metric: holoscan.core._core.DataFlowMetric = <DataFlowMetric.NUM_SRC_MESSAGES: 5>) -> dict[str, int]
- get_num_paths(self: holoscan.core._core.DataFlowTracker) → int
The number of tracked paths
- Returns
- num_pathsint
The number of tracked paths
- get_path_strings(self: holoscan.core._core.DataFlowTracker) → list[str]
Return an array of strings which are path names. Each path name is a comma-separated list of Operator names in a path. The paths are agnostic to the edges between two Operators.
- Returns
- pathslist[str]
A list of the path names.
- print(self: holoscan.core._core.DataFlowTracker) → None
Print the result of the data flow tracking in pretty-printed format to the standard output
- set_discard_last_messages(self: holoscan.core._core.DataFlowTracker, arg0: int) → None
Set the number of messages to discard at the end of the execution.
This does not affect the log file or the number of source messages metric.
- Parameters
- numint
The number of messages to discard.
- set_skip_latencies(self: holoscan.core._core.DataFlowTracker, arg0: int) → None
Set the threshold latency for which the end-to-end latency calculations will be done. Any latency strictly less than the threshold latency will be ignored.
This does not affect the log file or the number of source messages metric.
- Parameters
- thresholdint
The threshold latency in milliseconds.
- set_skip_starting_messages(self: holoscan.core._core.DataFlowTracker, arg0: int) → None
Set the number of messages to skip at the beginning of the execution.
This does not affect the log file or the number of source messages metric.
- Parameters
- numint
The number of messages to skip.
- class holoscan.core.ExecutionContext
Bases:
holoscan.core._core.ExecutionContext
Execution context class.
Attributes
input output Methods
allocate_cuda_stream
(self[, stream_name])Allocate an internal CUDA stream using the operator's associated CUDA thread pool. device_from_stream
(self, cuda_stream_ptr)Determine the device ID corresponding to a given CUDA stream. find_operator
(self[, op_name])Find an operator by name. get_operator_status
(self[, op_name])Get the status of the operator. synchronize_streams
(self, cuda_stream_ptrs, ...)Allocate an internal CUDA stream using the operator's associated CUDA thread pool. - __init__(*args, **kwargs)
- allocate_cuda_stream(self: holoscan.core._core.ExecutionContext, stream_name: str = '') → int
Allocate an internal CUDA stream using the operator’s associated CUDA thread pool.
- Parameters
- namestr, optional
The name of the CUDA stream to allocate.
- Returns
- stream_ptrint
The memory address corresponding to the cudaStream_t that was created.
- device_from_stream(self: holoscan.core._core.ExecutionContext, cuda_stream_ptr: int) → Optional[int]
Determine the device ID corresponding to a given CUDA stream.
- Parameters
- cuda_stream_ptr: int
The memory address of the CUDA stream. This must be a Holoscan-managed stream for the device query to work.
- Returns
- device_idint or None
If the CUDA stream is managed by Holoscan, the device ID corresponding to the stream is returned. Otherwise the output will be None.
- find_operator(self: holoscan.core._core.PyExecutionContext, op_name: str = '') → object
Find an operator by name.
If the operator name is not provided, the current operator is returned.
- Parameters
- op_namestr, optional
The name of the operator to find. If not provided, returns the current operator.
- Returns
- operatorOperator or None
A shared pointer to the operator, or None if the operator is not found.
- get_operator_status(self: holoscan.core._core.ExecutionContext, op_name: str = '') → object
Get the status of the operator.
If the operator name is not provided, the status of the current operator is returned.
- Parameters
- op_namestr, optional
The name of the operator to check status for. If not provided, checks the current operator.
- Returns
- statusOperatorStatus
The status of the operator.
- Raises
- RuntimeError
If the operator is not found or another error occurs.
- property input
- property output
- synchronize_streams(self: holoscan.core._core.ExecutionContext, cuda_stream_ptrs: list[Optional[int]], target_cuda_stream_ptr: int) → None
Allocate an internal CUDA stream using the operator’s associated CUDA thread pool.
- Parameters
- cuda_stream_ptrs: list[int or None], optional
A list of memory addresses of the CUDA streams to synchronize. Any None elements will be ignored.
- target_stream_ptr: int
The memory address of the target CUDA stream to synchronize to.
- class holoscan.core.Executor
Bases:
pybind11_builtins.pybind11_object
Executor class.
Attributes
context
The corresponding GXF context. context_uint64
The corresponding GXF context represented as a 64-bit unsigned integer address fragment
The fragment that the executor belongs to. Methods
- __init__(self: holoscan.core._core.Executor, fragment: holoscan::Fragment) → None
Executor class.
- Parameters
- fragmentholoscan.core.Fragment
The fragment that the executor is associated with.
- property context
The corresponding GXF context. This will be an opaque PyCapsule object.
- property context_uint64
The corresponding GXF context represented as a 64-bit unsigned integer address
- property fragment
The fragment that the executor belongs to.
- Returns
- nameholoscan.core.Fragment
- interrupt(self: holoscan.core._core.Executor) → None
Interrupt execution of the application.
- run(self: holoscan.core._core.Executor, arg0: holoscan.graphs._graphs.OperatorGraph) → None
Method that can be called to run the executor.
- class holoscan.core.FlowInfo
Bases:
pybind11_builtins.pybind11_object
Information about a flow connection between operators.
This class contains details about the connection between two operators, including the source and destination operators, port names, and port specifications.
Attributes
curr_operator
Current operator in the flow connection. output_port_name
Name of the output port from the current operator. output_port_spec
Specification of the output port. next_operator
Next operator in the flow connection. input_port_name
Name of the input port on the next operator. input_port_spec
Specification of the input port. - __init__(*args, **kwargs)
- property curr_operator
Current operator in the flow connection.
- property input_port_name
Name of the input port on the next operator.
- property input_port_spec
Specification of the input port.
- property next_operator
Next operator in the flow connection.
- property output_port_name
Name of the output port from the current operator.
- property output_port_spec
Specification of the output port.
- class holoscan.core.Fragment(app=None, name='', *args, **kwargs)
Bases:
holoscan.core._core.Fragment
Fragment class.
Attributes
application
The application associated with the fragment. executor
Get the executor associated with the fragment. graph
Get the computation graph (Graph node is an Operator) associated with the fragment. is_metadata_enabled
Property to get or set the boolean controlling whether operator metadata transmission is enabled. metadata_policy
The default metadata policy ( holoscan.core.MetadataPolicy
) associated with the fragment.name
The fragment's name. Methods
add_flow
(*args, **kwargs)Overloaded function. add_operator
(self, op)Add an operator to the fragment. compose
(self)The compose method of the Fragment. config
(*args, **kwargs)Overloaded function. config_keys
(self)The set of keys present in the fragment's configuration file. enable_metadata
(self, enabled)Method to set whether operator metadata transmission is enabled by default for an operators added to this fragment. from_config
(self, key)Retrieve parameters from the associated configuration. kwargs
(self, key)Retrieve a dictionary parameters from the associated configuration. make_thread_pool
(self, name, initialize_size)Create a ThreadPool associated with this Fragment. network_context
(*args, **kwargs)Overloaded function. run
(self)The run method of the Fragment. run_async
()Run the fragment asynchronously. scheduler
(*args, **kwargs)Overloaded function. set_dynamic_flows
(self, op, dynamic_flow_func)Set a callback function to define dynamic flows for an operator at runtime. start_op
()Get or create the start operator for this fragment. stop_execution
(self[, op_name])Stop the execution of all operators in the fragment. track
(self, num_start_messages_to_skip, ...)The track method of the fragment (or application). - __init__(self: holoscan.core._core.Fragment, arg0: object) → None
Fragment class.
- add_flow(*args, **kwargs)
Overloaded function.
add_flow(self: holoscan.core._core.Fragment, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator) -> None
add_flow(self: holoscan.core._core.Fragment, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator, port_pairs: set[tuple[str, str]]) -> None
Connect two operators associated with the fragment.
- Parameters
- upstream_opholoscan.core.Operator
Source operator.
- downstream_opholoscan.core.Operator
Destination operator.
- port_pairsSequence of (str, str) tuples
Sequence of ports to connect. The first element of each 2-tuple is a port from upstream_op while the second element is the port of downstream_op to which it connects.
Notes
This is an overloaded function. Additional variants exist:
1.) For the Application class there is a variant where the first two arguments are of type holoscan.core.Fragment instead of holoscan.core.Operator. This variant is used in building multi-fragment applications. 2.) There are also variants that omit the port_pairs argument that are applicable when there is only a single output on the upstream operator/fragment and a single input on the downstream operator/fragment.
- add_operator(self: holoscan.core._core.Fragment, op: holoscan.core._core.Operator) → None
Add an operator to the fragment.
- Parameters
- opholoscan.core.Operator
The operator to add.
- property application
The application associated with the fragment.
- Returns
- appholoscan.core.Application
- compose(self: holoscan.core._core.Fragment) → None
The compose method of the Fragment.
This method should be called after config, but before run in order to compose the computation graph.
- config(*args, **kwargs)
Overloaded function.
config(self: holoscan.core._core.Fragment, config_file: str, prefix: str = ‘’) -> None
Configuration class.
Represents configuration parameters as read from a YAML file.
- Parameters
- configstr or holoscan.core.Config
The path to the configuration file (in YAML format) or a holoscan.core.Config object.
- prefixstr, optional
Prefix path for the` config` file. Only available in the overloaded variant that takes a string for config.
- 2. config(self: holoscan.core._core.Fragment, arg0: holoscan.core._core.Config) -> None
- 3. config(self: holoscan.core._core.Fragment) -> holoscan.core._core.Config
- config_keys(self: holoscan.core._core.Fragment) → set[str]
The set of keys present in the fragment’s configuration file.
- enable_metadata(self: holoscan.core._core.Fragment, enabled: bool) → None
Method to set whether operator metadata transmission is enabled by default for an operators added to this fragment. Individual operators can override this default via Operator.enable_metadata.
- property executor
Get the executor associated with the fragment.
- from_config(self: holoscan.core._core.Fragment, key: str) → object
Retrieve parameters from the associated configuration.
- Parameters
- keystr
The key within the configuration file to retrieve. This can also be a specific component of the parameter via syntax ‘key.sub_key’.
- Returns
- argsholoscan.core.ArgList
An argument list associated with the key.
- property graph
Get the computation graph (Graph node is an Operator) associated with the fragment.
- property is_metadata_enabled
Property to get or set the boolean controlling whether operator metadata transmission is enabled.
Notes
Setting metadata to be enabled/disabled via this method is deprecated. Please use enable_metadata instead.
- kwargs(self: holoscan.core._core.Fragment, key: str) → dict
Retrieve a dictionary parameters from the associated configuration.
- Parameters
- keystr
The key within the configuration file to retrieve. This can also be a specific component of the parameter via syntax ‘key.sub_key’.
- Returns
- kwargsdict
A Python dict containing the parameters in the configuration file under the specified key.
- make_thread_pool(self: holoscan.core._core.Fragment, name: str, initialize_size: int = 1) → holoscan::ThreadPool
Create a ThreadPool associated with this Fragment.
The add method must be used to add individual operators to the pool.
- Parameters
- namestr
A name for the thread pool.
- initialize_size1
The initial number of threads in the pool.
- property metadata_policy
The default metadata policy (
holoscan.core.MetadataPolicy
) associated with the fragment.Individual operators can override this via
Operator.metadata_policy
.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 fragment’s name.
- Returns
- namestr
- network_context(*args, **kwargs)
Overloaded function.
network_context(self: holoscan.core._core.Fragment, network_context: holoscan.core._core.NetworkContext) -> None
Assign a network context to the Fragment
- Parameters
- network_contextholoscan.core.NetworkContext
A network_context class instance to be used by the underlying GXF executor. If unspecified, no network context will be used.
- 2. network_context(self: holoscan.core._core.Fragment) -> holoscan.core._core.NetworkContext
- Get the network context to be used by the Fragment
- run(self: holoscan.core._core.Fragment) → None
The run method of the Fragment.
This method runs the computation. It must have first been initialized via config and compose.
- run_async()
Run the fragment asynchronously.
This method is a convenience method that creates a thread pool with one thread and runs the fragment in that thread. The thread pool is created using concurrent.futures.ThreadPoolExecutor.
- Returns
- future
concurrent.futures.Future
object
- future
- scheduler(*args, **kwargs)
Overloaded function.
scheduler(self: holoscan.core._core.Fragment, scheduler: holoscan.core._core.Scheduler) -> None
Assign a scheduler to the Fragment.
- Parameters
- schedulerholoscan.core.Scheduler
A scheduler class instance to be used by the underlying GXF executor. If unspecified, the default is a holoscan.gxf.GreedyScheduler.
- 2. scheduler(self: holoscan.core._core.Fragment) -> holoscan.core._core.Scheduler
- Get the scheduler to be used by the Fragment.
- set_dynamic_flows(self: holoscan.core._core.Fragment, op: holoscan.core._core.Operator, dynamic_flow_func: Callable) → None
Set a callback function to define dynamic flows for an operator at runtime.
This method allows operators to modify their connections with other operators during execution. The callback function is called after the operator executes and can add dynamic flows using the operator’s add_dynamic_flow() methods.
- Parameters
- opholoscan.core.Operator
The operator for which to set dynamic flows.
- dynamic_flow_funccallable
The callback function that defines the dynamic flows. Takes an operator as input and returns
None
.
- start_op()
Get or create the start operator for this fragment.
This operator is nothing but the first operator that was added to the fragment. It has the name of <|start|> and has a condition of CountCondition(1). This Operator is used to start the execution of the fragment. Entry operators who want to start the execution of the fragment should connect to this operator.
If this method is not called, no start operator is created. Otherwise, the start operator is created if it does not exist, and the start operator is returned.
- Returns
- Operator
The start operator instance. If it doesn’t exist, it will be created with a CountCondition(1).
- stop_execution(self: holoscan.core._core.Fragment, op_name: str = '') → None
Stop the execution of all operators in the fragment.
This method is used to stop the execution of all operators in the fragment by setting the internal async condition of each operator to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operators will not be scheduled for execution (the compute() method will not be called), which may lead to application termination depending on the application’s design.
Note that executing this method does not trigger the operators’ stop() method. The stop() method is called only when the scheduler deactivates all operators together.
- Parameters
- op_namestr, optional
The name of the operator to stop. If empty, all operators will be stopped.
- track(self: holoscan.core._core.Fragment, num_start_messages_to_skip: int = 10, num_last_messages_to_discard: int = 10, latency_threshold: int = 0, is_limited_tracking: bool = False) → holoscan::DataFlowTracker
The track method of the fragment (or application).
This method enables data frame flow tracking and returns a DataFlowTracker object which can be used to display metrics data for profiling an application.
- Parameters
- num_start_messages_to_skipint
The number of messages to skip at the beginning.
- num_last_messages_to_discardint
The number of messages to discard at the end.
- latency_thresholdint
The minimum end-to-end latency in milliseconds to account for in the end-to-end latency metric calculations
- is_limited_trackingbool, optional
If
True
, the tracking is limited to root and leaf nodes, minimizing the timestamps by avoiding intermediate operators.
- Returns
- trackerholoscan.core.DataFlowTracker
The data flow tracker object that can be used to display metrics data for profiling along the different paths through the computation graph.
- class holoscan.core.FragmentGraph
Bases:
pybind11_builtins.pybind11_object
Abstract base class for all graphs
- __init__(*args, **kwargs)
- holoscan.core.Graph
- class holoscan.core.IOSpec
Bases:
pybind11_builtins.pybind11_object
I/O specification class.
Attributes
conditions
List of Condition objects associated with this I/O specification. connector_type
The receiver or transmitter type of the I/O specification class. io_type
The type (input or output) of the I/O specification class. name
The name of the I/O specification class. queue_policy
The queue policy used by the input (or output) port's receiver (or transmitter). queue_size
The size of the input/output queue. Methods
ConnectorType IOType QueuePolicy - ANY_SIZE = IOSize(-1)
- class ConnectorType
Bases:
pybind11_builtins.pybind11_object
Enum representing the receiver type (for input specs) or transmitter type (for output specs).
Members:
DEFAULT
DOUBLE_BUFFER
UCX
Attributes
value - DEFAULT = <ConnectorType.DEFAULT: 0>
- DOUBLE_BUFFER = <ConnectorType.DOUBLE_BUFFER: 1>
- UCX = <ConnectorType.UCX: 2>
- __init__(self: holoscan.core._core.IOSpec.ConnectorType, value: int) → None
- property name
- property value
- class IOSize
Bases:
pybind11_builtins.pybind11_object
I/O size class.
- Parameters
- sizeint
The size of the input/output queue.
Attributes
size
The size of the I/O size class. - __init__(self: holoscan.core._core.IOSpec.IOSize, size: int) → None
- property size
The size of the I/O size class.
- Returns
- sizeint
- class IOType
Bases:
pybind11_builtins.pybind11_object
Enum representing the I/O specification type (input or output).
Members:
INPUT
OUTPUT
Attributes
value - INPUT = <IOType.INPUT: 0>
- OUTPUT = <IOType.OUTPUT: 1>
- __init__(self: holoscan.core._core.IOSpec.IOType, value: int) → None
- property name
- property value
- PRECEDING_COUNT = IOSize(0)
- class QueuePolicy
Bases:
pybind11_builtins.pybind11_object
Enum representing the queue policy for a receiver (for input specs) or transmitter (for output specs).
Members:
POP
REJECT
FAULT
Attributes
value - FAULT = <QueuePolicy.FAULT: 2>
- POP = <QueuePolicy.POP: 0>
- REJECT = <QueuePolicy.REJECT: 1>
- __init__(self: holoscan.core._core.IOSpec.QueuePolicy, value: int) → None
- property name
- property value
- SIZE_ONE = IOSize(1)
- __init__(self: holoscan.core._core.IOSpec, op_spec: holoscan::OperatorSpec, name: str, io_type: holoscan.core._core.IOSpec.IOType) → None
I/O specification class.
- Parameters
- op_specholoscan.core.OperatorSpec
Operator specification class of the associated operator.
- namestr
The name of the IOSpec object.
- io_typeholoscan.core.IOSpec.IOType
Enum indicating whether this is an input or output specification.
- condition(self: holoscan.core._core.IOSpec, arg0: holoscan.core._core.ConditionType, **kwargs) → holoscan.core._core.IOSpec
Add a condition to this input/output.
The following ConditionTypes are supported:
ConditionType.NONE
ConditionType.MESSAGE_AVAILABLE
ConditionType.DOWNSTREAM_MESSAGE_AFFORDABLE
ConditionType.COUNT
ConditionType.BOOLEAN
- Parameters
- kindholoscan.core.ConditionType
The type of the condition.
- **kwargs
Python keyword arguments that will be cast to an ArgList associated with the condition.
- Returns
- objholoscan.core.IOSpec
The self object.
- property conditions
List of Condition objects associated with this I/O specification.
- Returns
- conditionlist of holoscan.core.Condition
- connector(*args, **kwargs)
Overloaded function.
connector(self: holoscan.core._core.IOSpec, arg0: holoscan.core._core.IOSpec.ConnectorType, **kwargs) -> holoscan.core._core.IOSpec
Add a connector (transmitter or receiver) to this input/output.
The following ConditionTypes are supported:
IOSpec.ConnectorType.DEFAULT
IOSpec.ConnectorType.DOUBLE_BUFFER
IOSpec.ConnectorType.UCX
If this method is not been called, the IOSpec’s connector_type will be ConnectorType.DEFAULT which will result in a DoubleBuffered receiver or or transmitter being used (or their annotated variant if flow tracking is enabled).
- Parameters
- kindholoscan.core.IOSpec.ConnectorType
The type of the connector. For example for type IOSpec.ConnectorType.DOUBLE_BUFFER, a holoscan.resources.DoubleBufferReceiver will be used for an input port and a holoscan.resources.DoubleBufferTransmitter will be used for an output port.
- **kwargs
Python keyword arguments that will be cast to an ArgList associated with the resource (connector).
- Returns
- objholoscan.core.IOSpec
The self object.
Notes
This is an overloaded function. Additional variants exist:
1.) A variant with no arguments will just return the holoscan.core.Resource corresponding to the transmitter or receiver used by this IOSpec object. If None was explicitly set, it will return
None
.2.) A variant that takes a single holoscan.core.Resource corresponding to a transmitter or receiver as an argument. This sets the transmitter or receiver used by the IOSpec object.
connector(self: holoscan.core._core.IOSpec) -> holoscan.core._core.Resource
connector(self: holoscan.core._core.IOSpec, arg0: holoscan.core._core.Resource) -> None
- property connector_type
The receiver or transmitter type of the I/O specification class.
- Returns
- connector_typeholoscan.core.IOSpec.ConnectorType
- property io_type
The type (input or output) of the I/O specification class.
- Returns
- io_typeholoscan.core.IOSpec.IOType
- property name
The name of the I/O specification class.
- Returns
- namestr
- property queue_policy
The queue policy used by the input (or output) port’s receiver (or transmitter).
Notes
This value is only used for initializing input and output ports. The policy is set by the OperatorSpec.input, OperatorSpec.output or IOSpec.queue_policy method.
The following IOSpec.QueuePolicy values are supported:
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.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.
- property queue_size
The size of the input/output queue.
Notes
This value is only used for initializing input ports. The queue size is set by the ‘OperatorSpec.input()’ method or this property. If the queue size is set to ‘any size’ (IOSpec::kAnySize in C++ or IOSpec.ANY_SIZE in Python), the connector/condition settings will be ignored. If the queue size is set to other values, the default connector (DoubleBufferReceiver/UcxReceiver) and condition (MessageAvailableCondition) will use the queue size for initialization (‘capacity’ for the connector and ‘min_size’ for the condition) if they are not set.
- class holoscan.core.InputContext
Bases:
holoscan.core._core.InputContext
Input context class.
Methods
receive
(self, name, *[, kind])Receive an object from the specified port. receive_cuda_stream
(self[, input_port_name, ...])Receive the CUDA stream associated with the specified input port. receive_cuda_streams
(self[, input_port_name])Receive a list of CUDA streams associated with the specified input port. - __init__(*args, **kwargs)
- receive(self: holoscan.core._core.PyInputContext, name: str, *, kind: str = '') → object
Receive an object from the specified port.
- Parameters
- namestr
The name of the port to receive the object from.
- Returns
- dataobject
The received Python object. If no entities were received on the port, data will be
None
.
- receive_cuda_stream(self: holoscan.core._core.PyInputContext, input_port_name: str = None, allocate: bool = True) → int
Receive the CUDA stream associated with the specified input port.
- Parameters
- input_port_namestr, optional
The name of the input port to receive the object from.
- allocatebool, optional
If True, the operator should allocate its own CUDA stream and synchronize any incoming streams to it. The stream returned by this function is then the internally, allocated stream.
- Returns
- stream_ptrint
The memory address of the underlying cudaStream_t.
- receive_cuda_streams(self: holoscan.core._core.PyInputContext, input_port_name: str = None) → list[Optional[int]]
Receive a list of CUDA streams associated with the specified input port.
The size of the list will be equal to the number of messages received on the port. For messages not containing a CudaStream, the corresponding entry in the list will be
None
.- Parameters
- input_port_namestr, optional
The name of the input port to receive the object from.
- Returns
- stream_ptrslist[int]
The memory addresses of the underlying cudaStream_t for each message. For any messages without a stream, the list will contain None.
- class holoscan.core.Message
Bases:
pybind11_builtins.pybind11_object
Class representing a message.
A message is a data structure that is used to pass data between operators. It wraps a
std::any
object and provides a type-safe interface to access the data.This class is used by the holoscan::gxf::GXFWrapper to support the Holoscan native operator. The holoscan::gxf::GXFWrapper will hold the object of this class and delegate the message to the Holoscan native operator.
- __init__(*args, **kwargs)
- class holoscan.core.MetadataDictionary
Bases:
pybind11_builtins.pybind11_object
Class representing a holoscan metadata dictionary.
Attributes
policy
Metadata policy property that governs the behavior of the set and update methods. Methods
clear
(self)Clear all items from the dictionary erase
(self, key)Remove the item with the given key from the dictionary. get
(self, key[, value])Get the item with the given key from the dictionary. has_key
(self, key)Determine if an item with the given key exists in the dictionary. insert
(self, other)Insert items from another MetadataDictionary into this dictionary. items
(self)Returns a list of (key, value) tuples for all items in the dictionary. keys
(self)Get a list of the metadata keys in the dictionary. merge
(self, other)Merge items from another MetadataDictionary into this dictionary. pop
(self, key, default)Pop the specified item from the dictionary. set
(self, key, value[, dtype, cast_to_cpp])Store the given value in the dictionary with the given key. size
(self)Get the size of the metadata dictionary. swap
(self, other)Swap the contents of this MetadataDictionary with another one. type_dict
(self)Returns a list of dictionary of C++ std::type_info names corresponding to the values. update
(self, other)Update items in this dictionary with items from another MetadataDictionary. - __init__(self: holoscan.core._core.MetadataDictionary) → None
Class representing a holoscan metadata dictionary.
- clear(self: holoscan.core._core.MetadataDictionary) → None
Clear all items from the dictionary
- erase(self: holoscan.core._core.MetadataDictionary, key: str) → bool
Remove the item with the given key from the dictionary.
- Parameters
- keystr
The key to check for in the dictionary.
- Returns
- bool
True if the key was found and removed, False otherwise.
- get(self: holoscan.core._core.MetadataDictionary, key: str, value: object = None) → object
Get the item with the given key from the dictionary.
- Returns
- object
The value stored in the dictionary with the given key.
- has_key(self: holoscan.core._core.MetadataDictionary, key: str) → bool
Determine if an item with the given key exists in the dictionary.
- Parameters
- keystr
The key to check for in the dictionary.
- Returns
- bool
True if the key exists in the dictionary, False otherwise.
- insert(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None
Insert items from another MetadataDictionary into this dictionary.
- Parameters
- otherMetadataDictionary
Insert items from other into this dictionary. If a key already exists in this dictionary, the value will not be updated.
- items(self: holoscan.core._core.MetadataDictionary) → list[tuple[str, object]]
Returns a list of (key, value) tuples for all items in the dictionary.
- Returns
- itemsList[Tuple[str, object]]
A list of (key, value) tuples for all items in the dictionary.
- keys(self: holoscan.core._core.MetadataDictionary) → list[str]
Get a list of the metadata keys in the dictionary.
- Returns
- List[str]
A list of the keys in the dictionary.
- merge(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None
Merge items from another MetadataDictionary into this dictionary.
- Parameters
- otherMetadataDictionary
Merge items from other into this dictionary. If a key already exists in this dictionary, the value will not be updated. Any items inserted into this dictionary will be removed from other.
- property policy
Metadata policy property that governs the behavior of the set and update methods.
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
- pop(self: holoscan.core._core.MetadataDictionary, key: str, default: object = <holoscan.core._core.MetaNoneValue object at 0x7ff0dc9de9b0>) → object
Pop the specified item from the dictionary.
- Parameters
- keystr
The key to pop from the dictionary.
- defaultobject, optional
The value to return if the key is not found in the dictionary. If not provided, a KeyError will be raised if the specified key does not exist.
- Returns
- valueobject
The value stored in the dictionary with the given key.
- set(self: holoscan.core._core.MetadataDictionary, key: str, value: object, dtype: Optional[numpy.dtype] = None, cast_to_cpp: bool = False) → None
Store the given value in the dictionary with the given key.
- Parameters
- keystr
The key to store the value under.
- valueobject
The value to set. By default the Python object is directly stored. If the metadata will be sent to a downstream operator that wraps a C++ operator, it may be desirable to instead cast the data to a C++ type. This can be done by setting cast_to_cpp to True.
- dtypenumpy.dtype, optional
When cast_to_cpp is True, the dtype argument can be used to indicate what numeric type the values should be cast to. If not provided, the default C++ type will be double for a Python float and int64_t for a Python int.
- cast_to_cppbool, optional
If True, the Python object will be converted to a corresponding C++ type, if possible. If False, the Python object will be stored directly. The types that can be cast are str, bool and various floating point and integer types. Iterables or sequences with uniform element type will become a std::vector of the contained type.
- size(self: holoscan.core._core.MetadataDictionary) → int
Get the size of the metadata dictionary.
- Returns
- sizeint
The number of items in the dictionary.
- swap(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None
Swap the contents of this MetadataDictionary with another one.
- Parameters
- otherMetadataDictionary
The metadata dictionary to swap contents with.
- type_dict(self: holoscan.core._core.MetadataDictionary) → dict
Returns a list of dictionary of C++ std::type_info names corresponding to the values.
- Returns
- type_dictDict[str, str]
The keys will match those of this MetadataDictionary while the values are the C++ type names corresponding to the values. These type names are mainly relevant for the items stored as C++ types. All items with values that are Python objects, will have the name typeid(GILGuardedPythonObject).name().
- update(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None
Update items in this dictionary with items from another MetadataDictionary.
- Parameters
- otherMetadataDictionary
Insert items from other into this dictionary. If a key already exists in this dictionary, the value will be updated in accordance with this dictionary’s metadata policy.
- class holoscan.core.MetadataPolicy
Bases:
pybind11_builtins.pybind11_object
Enum to define the policy for handling behavior of MetadataDictionary::set when a key already exists.
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
Members:
REJECT
INPLACE_UPDATE
UPDATE
RAISE
DEFAULT
Attributes
value - DEFAULT = <MetadataPolicy.DEFAULT: 4>
- INPLACE_UPDATE = <MetadataPolicy.INPLACE_UPDATE: 1>
- RAISE = <MetadataPolicy.RAISE: 3>
- REJECT = <MetadataPolicy.REJECT: 0>
- UPDATE = <MetadataPolicy.UPDATE: 2>
- __init__(self: holoscan.core._core.MetadataPolicy, value: int) → None
- property name
- property value
- class holoscan.core.MultiMessageConditionInfo
Bases:
pybind11_builtins.pybind11_object
Information associated with a multi-message condition.
Attributes
args kind port_names - __init__(self: holoscan.core._core.MultiMessageConditionInfo) → None
- property args
- property kind
- property port_names
- class holoscan.core.NetworkContext
Bases:
holoscan.core._core.Component
Class representing a network context.
Attributes
args
The list of arguments associated with the component. description
YAML formatted string describing the component. fragment
Fragment that the network context belongs to. id
The identifier of the component. name
The name of the network context. spec Methods
add_arg
(*args, **kwargs)Overloaded function. initialize
(self)initialization method for the network context. setup
(self, arg0)setup method for the network context. - __init__(self: holoscan.core._core.NetworkContext, *args, **kwargs) → None
Class representing a network context.
- Parameters
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.ComponentBase, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
- property args
The list of arguments associated with the component.
- Returns
- arglistholoscan.core.ArgList
- property description
YAML formatted string describing the component.
- property fragment
Fragment that the network context belongs to.
- Returns
- nameholoscan.core.Fragment
- 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.
- Returns
- idint
- initialize(self: holoscan.core._core.NetworkContext) → None
initialization method for the network context.
- property name
The name of the network context.
- Returns
- namestr
- setup(self: holoscan.core._core.NetworkContext, arg0: holoscan.core._core.ComponentSpec) → None
setup method for the network context.
- property spec
- class holoscan.core.Operator(fragment, *args, **kwargs)
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.- Parameters
- fragmentholoscan.core.Fragment
The holoscan.core.Fragment (or holoscan.core.Application) to which this Operator will belong.
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.
Attributes
args
The list of arguments associated with the component. async_condition
The internal asynchronous condition for the operator. conditions
Conditions associated with the operator. description
YAML formatted string describing the operator. execution_context
The execution context for the operator. fragment
The fragment ( holoscan.core.Fragment
) that the operator belongs to.id
The identifier of the component. is_metadata_enabled
Boolean indicating whether the fragment this operator belongs to has metadata transmission enabled. metadata
The metadata dictionary ( holoscan.core.MetadataDictionary
) associated with the operator.metadata_policy
The metadata policy ( holoscan.core.MetadataPolicy
) associated with the operator.name
The name of the operator. next_flows
Get the list of flow information for connections to downstream operators. operator_type
The operator type. resources
Resources associated with the operator. spec
The operator spec ( holoscan.core.OperatorSpec
) associated with the operator.Methods
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)Find all flow info objects in the operator's next flows that match a given condition. find_flow_info
(self, predicate)Find a flow info in the operator's next flows based on a given predicate. initialize
()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. OperatorType - INPUT_EXEC_PORT_NAME = '__input_exec__'
- OUTPUT_EXEC_PORT_NAME = '__output_exec__'
- class OperatorType
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
Attributes
value - GXF = <OperatorType.GXF: 1>
- NATIVE = <OperatorType.NATIVE: 0>
- VIRTUAL = <OperatorType.VIRTUAL: 2>
- __init__(self: holoscan.core._core.Operator.OperatorType, value: int) → None
- property name
- property value
- __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.- Parameters
- fragmentholoscan.core.Fragment
The holoscan.core.Fragment (or holoscan.core.Application) to which this Operator will belong.
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.
- Parameters
- 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.
- Parameters
- 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.
Notes
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.
- Returns
- arglistholoscan.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.
- Returns
- conditionholoscan.conditions.AsynchronousCondition
An instance of holoscan.conditions.AsynchronousCondition that is the internal asynchronous condition for the operator.
- compute(op_input, op_output, context)
Default implementation of compute
- 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.
- Returns
- 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.
- Parameters
- predicatecallable
A function that takes a FlowInfo object and returns a boolean.
- Returns
- 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.
- Parameters
- predicatecallable
A function that takes a FlowInfo object and returns a boolean.
- Returns
- 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.
- Returns
- idint
- initialize()
Default implementation of initialize
- 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.
- Returns
- 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).
- Parameters
- 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.
- Returns
- 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.
- Parameters
- port_namestr
The name of the input port.
- Returns
- 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.
- Parameters
- namestr
The name of the resource to retrieve
- Returns
- 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.
- setup(spec: holoscan.core._core.PyOperatorSpec)
Default implementation of setup method.
- property spec
The operator spec (
holoscan.core.OperatorSpec
) associated with the operator.
- start()
Default implementation of start
- stop()
Default implementation of stop
- 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.
- Parameters
- port_namestr
The name of the output port.
- Returns
- transmitterholoscan.resources.Transmitter or None
The transmitter used by this output port. Will be None if the port does not exist.
- class holoscan.core.OperatorGraph
Bases:
pybind11_builtins.pybind11_object
Abstract base class for all graphs
- __init__(*args, **kwargs)
- holoscan.core.OperatorSpec
alias of
holoscan.core._core.PyOperatorSpec
- class holoscan.core.OperatorStatus
Bases:
pybind11_builtins.pybind11_object
Operator status values
Members:
NOT_STARTED
START_PENDING
STARTED
TICK_PENDING
TICKING
IDLE
STOP_PENDING
Attributes
value - IDLE = <OperatorStatus.IDLE: 5>
- NOT_STARTED = <OperatorStatus.NOT_STARTED: 0>
- STARTED = <OperatorStatus.STARTED: 2>
- START_PENDING = <OperatorStatus.START_PENDING: 1>
- STOP_PENDING = <OperatorStatus.STOP_PENDING: 6>
- TICKING = <OperatorStatus.TICKING: 4>
- TICK_PENDING = <OperatorStatus.TICK_PENDING: 3>
- __init__(self: holoscan.core._core.OperatorStatus, value: int) → None
- property name
- property value
- class holoscan.core.OutputContext
Bases:
holoscan.core._core.OutputContext
Output context class.
Methods
emit
(self, data, name[, emitter_name, ...])Emit a Python or C++ object on the specified port. set_cuda_stream
(self, stream_ptr[, ...])Specify a CUDA stream to be emitted along with any data on the specified output port. - __init__(*args, **kwargs)
- emit(self: holoscan.core._core.PyOutputContext, data: object, name: str, emitter_name: str = '', acq_timestamp: int = - 1) → None
Emit a Python or C++ object on the specified port.
- Parameters
- dataobject
The Python object to emit. If it is a tensor-like object it will be transmitted as a C++ holoscan::Tensor for compatibility with C++ operators expecting a holoscan::Tensor (no copy of the data is required when converting to the C++ tensor type). Similarly, if data is a dictionary where all keys are strings and all values are tensor-like objects then it will be transmitted as a holoscan::TensorMap for compatibility with Holoscan C++ operators. Similarly if it is detected that the output port is connected across fragments in a distributed application, then serialization of the data will automatically be performed so that it can be sent over the network via UCX.
- namestr
The name of the port to emit the object on.
- emitter_namestr, optional
This can be specified to force emitting as a different type than would be chosen by default. For example, if data is a Python str object it would normally be emitted as a Python string. However, to send the string as a std::string as expected by a downstream C++ operator, one could set
emitter_name="std::string"
to make sure the data will be cast to this type. In general, any type that has been registered with the type registry can be specified here as long as the provided object can be cast to that type. To get a list of the currently registered type names, callholoscan.core.io_type_registry.registered_types()
.
- set_cuda_stream(self: holoscan.core._core.PyOutputContext, stream_ptr: int, output_port_name: str = None) → None
Specify a CUDA stream to be emitted along with any data on the specified output port.
- Parameters
- stream_ptrint
The memory address of the underlying cudaStream_t to be emitted.
- output_port_namestr, optional
The name of the output port to emit the stream on. Can be unspecified if there is only a single output port on the operator.
- class holoscan.core.ParameterFlag
Bases:
pybind11_builtins.pybind11_object
Enum class for parameter flags.
The following flags are supported: - NONE: The parameter is mendatory and static. It cannot be changed at runtime. - OPTIONAL: The parameter is optional and might not be available at runtime. - DYNAMIC: The parameter is dynamic and might change at runtime.
Members:
NONE
OPTIONAL
DYNAMIC
Attributes
value - DYNAMIC = <ParameterFlag.DYNAMIC: 2>
- NONE = <ParameterFlag.NONE: 0>
- OPTIONAL = <ParameterFlag.OPTIONAL: 1>
- __init__(self: holoscan.core._core.ParameterFlag, value: int) → None
- property name
- property value
- class holoscan.core.Resource(fragment, *args, **kwargs)
Bases:
holoscan.core._core.Resource
Class representing a resource.
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 resource.
If a fragment keyword argument is provided, it must be of type holoscan.core.Fragment (or holoscan.core.Application). A single Fragment object can also be provided positionally instead.
Any other arguments will be cast from a Python argument type to a C++ Arg and stored in
self.args
. (For details on how the casting is done, see the py_object_to_arg utility).- Parameters
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.
Attributes
args
The list of arguments associated with the component. description
YAML formatted string describing the resource. fragment
Fragment that the resource belongs to. id
The identifier of the component. name
The name of the resource. resource_type
Resource type. spec Methods
add_arg
(*args, **kwargs)Overloaded function. initialize
(self)initialization method for the resource. setup
(spec)Default implementation of setup method. ResourceType - class ResourceType
Bases:
pybind11_builtins.pybind11_object
Members:
NATIVE
GXF
Attributes
value - GXF = <ResourceType.GXF: 1>
- NATIVE = <ResourceType.NATIVE: 0>
- __init__(self: holoscan.core._core.Resource.ResourceType, value: int) → None
- property name
- property value
- __init__(self: holoscan.core._core.Resource, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) → None
Class representing a resource.
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 resource.
If a fragment keyword argument is provided, it must be of type holoscan.core.Fragment (or holoscan.core.Application). A single Fragment object can also be provided positionally instead.
Any other arguments will be cast from a Python argument type to a C++ Arg and stored in
self.args
. (For details on how the casting is done, see the py_object_to_arg utility).- Parameters
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.ComponentBase, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
- property args
The list of arguments associated with the component.
- Returns
- arglistholoscan.core.ArgList
- property description
YAML formatted string describing the resource.
- property fragment
Fragment that the resource belongs to.
- Returns
- nameholoscan.core.Fragment
- 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.
- Returns
- idint
- initialize(self: holoscan.core._core.Resource) → None
initialization method for the resource.
- property name
The name of the resource.
- Returns
- namestr
- property resource_type
Resource type.
holoscan.core.Resource.ResourceType enum representing the type of the resource. The two types currently implemented are NATIVE and GXF.
- setup(spec: holoscan.core._core.PyComponentSpec)
Default implementation of setup method.
- property spec
- class holoscan.core.Scheduler
Bases:
holoscan.core._core.Component
Class representing a scheduler.
Attributes
args
The list of arguments associated with the component. description
YAML formatted string describing the component. fragment
Fragment that the scheduler belongs to. id
The identifier of the component. name
The name of the scheduler. spec Methods
add_arg
(*args, **kwargs)Overloaded function. initialize
(self)initialization method for the scheduler. setup
(self, arg0)setup method for the scheduler. - __init__(self: holoscan.core._core.Scheduler, *args, **kwargs) → None
Class representing a scheduler.
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 scheduler.
If a fragment keyword argument is provided, it must be of type holoscan.core.Fragment (or holoscan.core.Application). A single Fragment object can also be provided positionally instead.
Any other arguments will be cast from a Python argument type to a C++ Arg and stored in
self.args
. (For details on how the casting is done, see the py_object_to_arg utility).- Parameters
- *args
Positional arguments.
- **kwargs
Keyword arguments.
- Raises
- 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.ComponentBase, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
- property args
The list of arguments associated with the component.
- Returns
- arglistholoscan.core.ArgList
- property description
YAML formatted string describing the component.
- property fragment
Fragment that the scheduler belongs to.
- Returns
- nameholoscan.core.Fragment
- 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.
- Returns
- idint
- initialize(self: holoscan.core._core.Scheduler) → None
initialization method for the scheduler.
- property name
The name of the scheduler.
- Returns
- namestr
- setup(self: holoscan.core._core.Scheduler, arg0: holoscan.core._core.ComponentSpec) → None
setup method for the scheduler.
- property spec
- class holoscan.core.SchedulingStatusType
Bases:
pybind11_builtins.pybind11_object
Enum class for Condition scheduling status.
Members:
NEVER
READY
WAIT
WAIT_TIME
WAIT_EVENT
Attributes
value - NEVER = <SchedulingStatusType.NEVER: 0>
- READY = <SchedulingStatusType.READY: 1>
- WAIT = <SchedulingStatusType.WAIT: 2>
- WAIT_EVENT = <SchedulingStatusType.WAIT_EVENT: 4>
- WAIT_TIME = <SchedulingStatusType.WAIT_TIME: 3>
- __init__(self: holoscan.core._core.SchedulingStatusType, value: int) → None
- property name
- property value
- holoscan.core.Tensor
alias of
holoscan.core._core.PyTensor
- class holoscan.core.Tracker(app, *, filename=None, num_buffered_messages=100, num_start_messages_to_skip=10, num_last_messages_to_discard=10, latency_threshold=0, is_limited_tracking=False)
Bases:
object
Context manager to add data flow tracking to an application.
- __init__(app, *, filename=None, num_buffered_messages=100, num_start_messages_to_skip=10, num_last_messages_to_discard=10, latency_threshold=0, is_limited_tracking=False)
- Parameters
- appholoscan.core.Application
on which flow tracking should be applied.
- filenamestr or None, optional
If none, logging to file will be disabled. Otherwise, logging will write to the specified file.
- num_buffered_messagesint, optional
Controls the number of messages buffered between file writing when filename is not
None
.- num_start_messages_to_skipint, optional
The number of messages to skip at the beginning of the execution. This does not affect the log file or the number of source messages metric.
- num_last_messages_to_discardint, optional
The number of messages to discard at the end of the execution. This does not affect the log file or the number of source messages metric.
- latency_thresholdint, optional
The minimum end-to-end latency in milliseconds to account for in the end-to-end latency metric calculations.
- is_limited_trackingbool, optional
If true, the tracking is limited to root and leaf nodes, minimizing the timestamps by avoiding intermediate operators.
- holoscan.core.arg_to_py_object(arg: holoscan.core._core.Arg) → object
Utility that converts an Arg to a corresponding Python object.
- Parameters
- argholoscan.core.Arg
The argument to convert.
- Returns
- objAny
Python object corresponding to the provided argument. For example, an argument of any integer type will become a Python int while std::vector<double> would become a list of Python floats.
- holoscan.core.arglist_to_kwargs(arglist: holoscan.core._core.ArgList) → dict
Utility that converts an ArgList to a Python kwargs dictionary.
- Parameters
- arglistholoscan.core.ArgList
The argument list to convert.
- Returns
- kwargsdict
Python dictionary with keys matching the names of the arguments in ArgList. The values will be converted as for arg_to_py_object.
- holoscan.core.kwargs_to_arglist(**kwargs) → holoscan.core._core.ArgList
Utility that converts a set of python keyword arguments to an ArgList.
- Parameters
- **kwargs
The python keyword arguments to convert.
- Returns
- arglistholoscan.core.ArgList
ArgList class corresponding to the provided keyword values. The argument names will match the keyword names. Values will be converted as for py_object_to_arg.
- holoscan.core.py_object_to_arg(obj: object, name: str = '') → holoscan.core._core.Arg
Utility that converts a single python argument to a corresponding Arg type.
- Parameters
- valueAny
The python value to convert.
- Returns
- objholoscan.core.Arg
Arg class corresponding to the provided value. For example a Python float will become an Arg containing a C++ double while a list of Python ints would become an Arg corresponding to a
std::vector<uint64_t>
.- namestr, optional
A name to assign to the argument.