holoscan.schedulers
This module provides a Python API to underlying C++ API Schedulers.
holoscan.schedulers.EventBasedScheduler |
Event-based multi-thread scheduler |
holoscan.schedulers.GreedyScheduler |
Greedy scheduler |
holoscan.schedulers.MultiThreadScheduler |
Multi-thread scheduler |
- class holoscan.schedulers.EventBasedScheduler
Bases:
holoscan.gxf._gxf.GXFScheduler,holoscan.core._core.Component,holoscan.gxf._gxf.GXFComponentEvent-based multi-thread scheduler
- Parameters
- fragmentFragment
The fragment the condition will be associated with
- clockholoscan.resources.Clock or None, optional
The clock used by the scheduler to define the flow of time. If None, a default-constructed holoscan.resources.RealtimeClock will be used.
- worker_thread_numberint
The number of worker threads.
- stop_on_deadlockbool, optional
If enabled the scheduler will stop when all entities are in a waiting state, but no periodic entity exists to break the dead end. Should be disabled when scheduling conditions can be changed by external actors, for example by clearing queues manually.
- max_duration_msint, optional
The maximum duration for which the scheduler will execute (in ms). If not specified (or if a negative value is provided), the scheduler will run until all work is done. If periodic terms are present, this means the application will run indefinitely.
- stop_on_deadlock_timeoutint, optional
The scheduler will wait this amount of time before determining that it is in deadlock and should stop. It will reset if a job comes in during the wait. A negative value means not stop on deadlock. This parameter only applies when stop_on_deadlock=true.
- pin_coreslist of int, optional
CPU core IDs to pin the worker threads to. If specified, all the worker threads created based on the parameter worker_thread_number will be pinned to the same set of specified cores. If not specified, the worker threads will not be pinned to any cores.
- namestr, optional
The name of the scheduler.
Attributes
argsThe list of arguments associated with the component. descriptionYAML formatted string describing the component. fragmentFragment that the scheduler belongs to. gxf_cidThe GXF component ID. gxf_cnameThe name of the component. gxf_contextThe GXF context of the component. gxf_eidThe GXF entity ID. gxf_typenameThe GXF type name of the component. idThe identifier of the component. nameThe name of the scheduler. clock max_duration_ms pin_cores spec stop_on_deadlock stop_on_deadlock_timeout worker_thread_number Methods
add_arg(*args, **kwargs)Overloaded function. gxf_initialize(self)Initialize the component. initialize(self)initialization method for the scheduler. service(self, service_type[, id])Retrieve a registered fragment service through the component's fragment. setup(self, arg0)setup method for the scheduler. - __init__(self: holoscan.schedulers._schedulers.EventBasedScheduler, fragment: holoscan.core._core.Fragment, *, clock: holoscan.resources._resources.GXFClock = None, worker_thread_number: int = 1, stop_on_deadlock: bool = True, max_duration_ms: int = - 1, stop_on_deadlock_timeout: int = 0, pin_cores: Optional[list[int]] = None, name: str = 'event_based_scheduler') → None
Event-based multi-thread scheduler
- Parameters
- fragmentFragment
The fragment the condition will be associated with
- clockholoscan.resources.Clock or None, optional
The clock used by the scheduler to define the flow of time. If None, a default-constructed holoscan.resources.RealtimeClock will be used.
- worker_thread_numberint
The number of worker threads.
- stop_on_deadlockbool, optional
If enabled the scheduler will stop when all entities are in a waiting state, but no periodic entity exists to break the dead end. Should be disabled when scheduling conditions can be changed by external actors, for example by clearing queues manually.
- max_duration_msint, optional
The maximum duration for which the scheduler will execute (in ms). If not specified (or if a negative value is provided), the scheduler will run until all work is done. If periodic terms are present, this means the application will run indefinitely.
- stop_on_deadlock_timeoutint, optional
The scheduler will wait this amount of time before determining that it is in deadlock and should stop. It will reset if a job comes in during the wait. A negative value means not stop on deadlock. This parameter only applies when stop_on_deadlock=true.
- pin_coreslist of int, optional
CPU core IDs to pin the worker threads to. If specified, all the worker threads created based on the parameter worker_thread_number will be pinned to the same set of specified cores. If not specified, the worker threads will not be pinned to any cores.
- namestr, optional
The name of the scheduler.
- 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 clock
- property description
YAML formatted string describing the component.
- property fragment
Fragment that the scheduler belongs to.
- Returns
- nameholoscan.core.Fragment
- property gxf_cid
The GXF component ID.
- property gxf_cname
The name of the component.
- property gxf_context
The GXF context of the component.
- property gxf_eid
The GXF entity ID.
- gxf_initialize(self: holoscan.gxf._gxf.GXFComponent) → None
Initialize the component.
- property gxf_typename
The GXF type name of the component.
- Returns
- str
The GXF type name of the component.
- 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 max_duration_ms
- property name
The name of the scheduler.
- Returns
- namestr
- property pin_cores
- service(self: object, service_type: type, id: str = '') → object
Retrieve a registered fragment service through the component’s fragment.
This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns
Noneif no fragment service is found with the specified type and identifier.- Parameters
- service_typetype
The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.
- idstr, optional
The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.
- Returns
- object or None
The fragment service instance of the requested type, or
Noneif not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.
- Raises
- RuntimeError
If the component has no associated fragment or if the fragment’s service method cannot be accessed.
Notes
This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.
- setup(self: holoscan.core._core.Scheduler, arg0: holoscan.core._core.ComponentSpec) → None
setup method for the scheduler.
- property spec
- property stop_on_deadlock
- property stop_on_deadlock_timeout
- property worker_thread_number
- class holoscan.schedulers.GreedyScheduler
Bases:
holoscan.gxf._gxf.GXFScheduler,holoscan.core._core.Component,holoscan.gxf._gxf.GXFComponentGreedy scheduler
- Parameters
- fragmentFragment
The fragment the condition will be associated with
- clockholoscan.resources.Clock or None, optional
The clock used by the scheduler to define the flow of time. If None, a default-constructed holoscan.resources.RealtimeClock will be used.
- stop_on_deadlockbool, optional
If enabled the scheduler will stop when all entities are in a waiting state, but no periodic entity exists to break the dead end. Should be disabled when scheduling conditions can be changed by external actors, for example by clearing queues manually.
- max_duration_msint, optional
The maximum duration for which the scheduler will execute (in ms). If not specified (or if a negative value is provided), the scheduler will run until all work is done. If periodic terms are present, this means the application will run indefinitely.
- check_recession_period_msfloat, optional
The maximum duration for which the scheduler would wait (in ms) when all operators are not ready to run in the current iteration.
- stop_on_deadlock_timeoutint, optional
The scheduler will wait this amount of time before determining that it is in deadlock and should stop. It will reset if a job comes in during the wait. A negative value means not stop on deadlock. This parameter only applies when stop_on_deadlock=true”,
- namestr, optional
The name of the scheduler.
Attributes
argsThe list of arguments associated with the component. descriptionYAML formatted string describing the component. fragmentFragment that the scheduler belongs to. gxf_cidThe GXF component ID. gxf_cnameThe name of the component. gxf_contextThe GXF context of the component. gxf_eidThe GXF entity ID. gxf_typenameThe GXF type name of the component. idThe identifier of the component. nameThe name of the scheduler. check_recession_period_ms clock max_duration_ms spec stop_on_deadlock stop_on_deadlock_timeout Methods
add_arg(*args, **kwargs)Overloaded function. gxf_initialize(self)Initialize the component. initialize(self)initialization method for the scheduler. service(self, service_type[, id])Retrieve a registered fragment service through the component's fragment. setup(self, arg0)setup method for the scheduler. - __init__(self: holoscan.schedulers._schedulers.GreedyScheduler, fragment: holoscan.core._core.Fragment, *, clock: holoscan.resources._resources.GXFClock = None, stop_on_deadlock: bool = True, max_duration_ms: int = - 1, check_recession_period_ms: float = 0.0, stop_on_deadlock_timeout: int = 0, name: str = 'greedy_scheduler') → None
Greedy scheduler
- Parameters
- fragmentFragment
The fragment the condition will be associated with
- clockholoscan.resources.Clock or None, optional
The clock used by the scheduler to define the flow of time. If None, a default-constructed holoscan.resources.RealtimeClock will be used.
- stop_on_deadlockbool, optional
If enabled the scheduler will stop when all entities are in a waiting state, but no periodic entity exists to break the dead end. Should be disabled when scheduling conditions can be changed by external actors, for example by clearing queues manually.
- max_duration_msint, optional
The maximum duration for which the scheduler will execute (in ms). If not specified (or if a negative value is provided), the scheduler will run until all work is done. If periodic terms are present, this means the application will run indefinitely.
- check_recession_period_msfloat, optional
The maximum duration for which the scheduler would wait (in ms) when all operators are not ready to run in the current iteration.
- stop_on_deadlock_timeoutint, optional
The scheduler will wait this amount of time before determining that it is in deadlock and should stop. It will reset if a job comes in during the wait. A negative value means not stop on deadlock. This parameter only applies when stop_on_deadlock=true”,
- namestr, optional
The name of the scheduler.
- 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 check_recession_period_ms
- property clock
- property description
YAML formatted string describing the component.
- property fragment
Fragment that the scheduler belongs to.
- Returns
- nameholoscan.core.Fragment
- property gxf_cid
The GXF component ID.
- property gxf_cname
The name of the component.
- property gxf_context
The GXF context of the component.
- property gxf_eid
The GXF entity ID.
- gxf_initialize(self: holoscan.gxf._gxf.GXFComponent) → None
Initialize the component.
- property gxf_typename
The GXF type name of the component.
- Returns
- str
The GXF type name of the component.
- 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 max_duration_ms
- property name
The name of the scheduler.
- Returns
- namestr
- service(self: object, service_type: type, id: str = '') → object
Retrieve a registered fragment service through the component’s fragment.
This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns
Noneif no fragment service is found with the specified type and identifier.- Parameters
- service_typetype
The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.
- idstr, optional
The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.
- Returns
- object or None
The fragment service instance of the requested type, or
Noneif not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.
- Raises
- RuntimeError
If the component has no associated fragment or if the fragment’s service method cannot be accessed.
Notes
This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.
- setup(self: holoscan.core._core.Scheduler, arg0: holoscan.core._core.ComponentSpec) → None
setup method for the scheduler.
- property spec
- property stop_on_deadlock
- property stop_on_deadlock_timeout
- class holoscan.schedulers.MultiThreadScheduler
Bases:
holoscan.gxf._gxf.GXFScheduler,holoscan.core._core.Component,holoscan.gxf._gxf.GXFComponentMulti-thread scheduler
- Parameters
- fragmentFragment
The fragment the condition will be associated with
- clockholoscan.resources.Clock or None, optional
The clock used by the scheduler to define the flow of time. If None, a default-constructed holoscan.resources.RealtimeClock will be used.
- worker_thread_numberint
The number of worker threads.
- stop_on_deadlockbool, optional
If enabled the scheduler will stop when all entities are in a waiting state, but no periodic entity exists to break the dead end. Should be disabled when scheduling conditions can be changed by external actors, for example by clearing queues manually.
- check_recession_period_msfloat, optional
The maximum duration for which the scheduler would wait (in ms) when an operator is not ready to run yet.
- max_duration_msint, optional
The maximum duration for which the scheduler will execute (in ms). If not specified (or if a negative value is provided), the scheduler will run until all work is done. If periodic terms are present, this means the application will run indefinitely.
- stop_on_deadlock_timeoutint, optional
The scheduler will wait this amount of time before determining that it is in deadlock and should stop. It will reset if a job comes in during the wait. A negative value means not stop on deadlock. This parameter only applies when stop_on_deadlock=true”,
- strict_job_thread_pinningbool, optional
When true, the thread an operator is pinned to is not allowed to run any other operators. When false, if the pinned operator is not in a READY state, another operator could run on the thread.
- namestr, optional
The name of the scheduler.
Attributes
argsThe list of arguments associated with the component. descriptionYAML formatted string describing the component. fragmentFragment that the scheduler belongs to. gxf_cidThe GXF component ID. gxf_cnameThe name of the component. gxf_contextThe GXF context of the component. gxf_eidThe GXF entity ID. gxf_typenameThe GXF type name of the component. idThe identifier of the component. nameThe name of the scheduler. check_recession_period_ms clock max_duration_ms spec stop_on_deadlock stop_on_deadlock_timeout worker_thread_number Methods
add_arg(*args, **kwargs)Overloaded function. gxf_initialize(self)Initialize the component. initialize(self)initialization method for the scheduler. service(self, service_type[, id])Retrieve a registered fragment service through the component's fragment. setup(self, arg0)setup method for the scheduler. - __init__(self: holoscan.schedulers._schedulers.MultiThreadScheduler, fragment: holoscan.core._core.Fragment, *, clock: holoscan.resources._resources.GXFClock = None, worker_thread_number: int = 1, stop_on_deadlock: bool = True, check_recession_period_ms: float = 5.0, max_duration_ms: int = - 1, stop_on_deadlock_timeout: int = 0, strict_job_thread_pinning: bool = False, name: str = 'multithread_scheduler') → None
Multi-thread scheduler
- Parameters
- fragmentFragment
The fragment the condition will be associated with
- clockholoscan.resources.Clock or None, optional
The clock used by the scheduler to define the flow of time. If None, a default-constructed holoscan.resources.RealtimeClock will be used.
- worker_thread_numberint
The number of worker threads.
- stop_on_deadlockbool, optional
If enabled the scheduler will stop when all entities are in a waiting state, but no periodic entity exists to break the dead end. Should be disabled when scheduling conditions can be changed by external actors, for example by clearing queues manually.
- check_recession_period_msfloat, optional
The maximum duration for which the scheduler would wait (in ms) when an operator is not ready to run yet.
- max_duration_msint, optional
The maximum duration for which the scheduler will execute (in ms). If not specified (or if a negative value is provided), the scheduler will run until all work is done. If periodic terms are present, this means the application will run indefinitely.
- stop_on_deadlock_timeoutint, optional
The scheduler will wait this amount of time before determining that it is in deadlock and should stop. It will reset if a job comes in during the wait. A negative value means not stop on deadlock. This parameter only applies when stop_on_deadlock=true”,
- strict_job_thread_pinningbool, optional
When true, the thread an operator is pinned to is not allowed to run any other operators. When false, if the pinned operator is not in a READY state, another operator could run on the thread.
- namestr, optional
The name of the scheduler.
- 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 check_recession_period_ms
- property clock
- property description
YAML formatted string describing the component.
- property fragment
Fragment that the scheduler belongs to.
- Returns
- nameholoscan.core.Fragment
- property gxf_cid
The GXF component ID.
- property gxf_cname
The name of the component.
- property gxf_context
The GXF context of the component.
- property gxf_eid
The GXF entity ID.
- gxf_initialize(self: holoscan.gxf._gxf.GXFComponent) → None
Initialize the component.
- property gxf_typename
The GXF type name of the component.
- Returns
- str
The GXF type name of the component.
- 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 max_duration_ms
- property name
The name of the scheduler.
- Returns
- namestr
- service(self: object, service_type: type, id: str = '') → object
Retrieve a registered fragment service through the component’s fragment.
This method delegates to the fragment’s service() method to retrieve a previously registered fragment service by its type and optional identifier. Returns
Noneif no fragment service is found with the specified type and identifier.- Parameters
- service_typetype
The type of the fragment service to retrieve. Must be a type that inherits from Resource or FragmentService.
- idstr, optional
The identifier of the fragment service. If empty, retrieves by service type only. For Resources, this would typically be the resource’s name.
- Returns
- object or None
The fragment service instance of the requested type, or
Noneif not found. If the service wraps a Resource and a Resource type is requested, the unwrapped Resource instance is returned.
- Raises
- RuntimeError
If the component has no associated fragment or if the fragment’s service method cannot be accessed.
Notes
This is a convenience method that internally calls the fragment’s service() method. For services that wrap Resources, the method will automatically unwrap and return the Resource if a Resource type is requested.
- setup(self: holoscan.core._core.Scheduler, arg0: holoscan.core._core.ComponentSpec) → None
setup method for the scheduler.
- property spec
- property stop_on_deadlock
- property stop_on_deadlock_timeout
- property worker_thread_number