holoscan 2.6.0__cp312-cp312-manylinux_2_35_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. holoscan-2.6.0.data/purelib/holoscan/__init__.py +133 -0
  2. holoscan-2.6.0.data/purelib/holoscan/cli/__init__.py +32 -0
  3. holoscan-2.6.0.data/purelib/holoscan/cli/__main__.py +159 -0
  4. holoscan-2.6.0.data/purelib/holoscan/cli/common/argparse_types.py +153 -0
  5. holoscan-2.6.0.data/purelib/holoscan/cli/common/artifact_sources.py +149 -0
  6. holoscan-2.6.0.data/purelib/holoscan/cli/common/constants.py +119 -0
  7. holoscan-2.6.0.data/purelib/holoscan/cli/common/dockerutils.py +509 -0
  8. holoscan-2.6.0.data/purelib/holoscan/cli/common/enum_types.py +52 -0
  9. holoscan-2.6.0.data/purelib/holoscan/cli/common/exceptions.py +130 -0
  10. holoscan-2.6.0.data/purelib/holoscan/cli/common/sdk_utils.py +180 -0
  11. holoscan-2.6.0.data/purelib/holoscan/cli/common/utils.py +130 -0
  12. holoscan-2.6.0.data/purelib/holoscan/cli/logging.json +37 -0
  13. holoscan-2.6.0.data/purelib/holoscan/cli/nics/__init__.py +18 -0
  14. holoscan-2.6.0.data/purelib/holoscan/cli/nics/nics.py +34 -0
  15. holoscan-2.6.0.data/purelib/holoscan/cli/packager/__init__.py +18 -0
  16. holoscan-2.6.0.data/purelib/holoscan/cli/packager/arguments.py +137 -0
  17. holoscan-2.6.0.data/purelib/holoscan/cli/packager/config_reader.py +181 -0
  18. holoscan-2.6.0.data/purelib/holoscan/cli/packager/container_builder.py +368 -0
  19. holoscan-2.6.0.data/purelib/holoscan/cli/packager/manifest_files.py +220 -0
  20. holoscan-2.6.0.data/purelib/holoscan/cli/packager/models.py +93 -0
  21. holoscan-2.6.0.data/purelib/holoscan/cli/packager/package_command.py +189 -0
  22. holoscan-2.6.0.data/purelib/holoscan/cli/packager/packager.py +122 -0
  23. holoscan-2.6.0.data/purelib/holoscan/cli/packager/parameters.py +558 -0
  24. holoscan-2.6.0.data/purelib/holoscan/cli/packager/platforms.py +402 -0
  25. holoscan-2.6.0.data/purelib/holoscan/cli/packager/templates/Dockerfile.jinja2 +470 -0
  26. holoscan-2.6.0.data/purelib/holoscan/cli/packager/templates/dockerignore +93 -0
  27. holoscan-2.6.0.data/purelib/holoscan/cli/packager/templates/tools.sh +416 -0
  28. holoscan-2.6.0.data/purelib/holoscan/cli/py.typed +0 -0
  29. holoscan-2.6.0.data/purelib/holoscan/cli/runner/__init__.py +18 -0
  30. holoscan-2.6.0.data/purelib/holoscan/cli/runner/resources.py +174 -0
  31. holoscan-2.6.0.data/purelib/holoscan/cli/runner/run_command.py +203 -0
  32. holoscan-2.6.0.data/purelib/holoscan/cli/runner/runner.py +306 -0
  33. holoscan-2.6.0.data/purelib/holoscan/cli/version/__init__.py +18 -0
  34. holoscan-2.6.0.data/purelib/holoscan/cli/version/version.py +50 -0
  35. holoscan-2.6.0.data/purelib/holoscan/conditions/__init__.py +57 -0
  36. holoscan-2.6.0.data/purelib/holoscan/core/__init__.py +430 -0
  37. holoscan-2.6.0.data/purelib/holoscan/decorator.py +592 -0
  38. holoscan-2.6.0.data/purelib/holoscan/executors/__init__.py +26 -0
  39. holoscan-2.6.0.data/purelib/holoscan/graphs/__init__.py +32 -0
  40. holoscan-2.6.0.data/purelib/holoscan/gxf/__init__.py +57 -0
  41. holoscan-2.6.0.data/purelib/holoscan/lib/gxf_extensions/libgxf_holoscan_wrapper.so +0 -0
  42. holoscan-2.6.0.data/purelib/holoscan/lib/gxf_extensions/libgxf_holoscan_wrapper_lib.so +0 -0
  43. holoscan-2.6.0.data/purelib/holoscan/lib/gxf_extensions/libgxf_ucx_holoscan.so +0 -0
  44. holoscan-2.6.0.data/purelib/holoscan/lib/gxf_extensions/libgxf_ucx_holoscan_lib.so +0 -0
  45. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_app.so +0 -0
  46. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_core.so +0 -0
  47. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_cuda.so +0 -0
  48. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_logger.so +0 -0
  49. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_multimedia.so +0 -0
  50. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_rmm.so +0 -0
  51. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_sample.so +0 -0
  52. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_serialization.so +0 -0
  53. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_std.so +0 -0
  54. holoscan-2.6.0.data/purelib/holoscan/lib/libgxf_ucx.so +0 -0
  55. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_core.so.2.6.0 +0 -0
  56. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_infer.so.2.6.0 +0 -0
  57. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_infer_onnx_runtime.so.2.6.0 +0 -0
  58. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_infer_torch.so.2.6.0 +0 -0
  59. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_infer_utils.so.2.6.0 +0 -0
  60. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_logger.so.2.6.0 +0 -0
  61. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_aja.so.2.6.0 +0 -0
  62. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_async_ping_rx.so.2.6.0 +0 -0
  63. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_async_ping_tx.so.2.6.0 +0 -0
  64. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_bayer_demosaic.so.2.6.0 +0 -0
  65. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_format_converter.so.2.6.0 +0 -0
  66. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_gxf_codelet.so.2.6.0 +0 -0
  67. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_holoviz.so.2.6.0 +0 -0
  68. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_inference.so.2.6.0 +0 -0
  69. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_inference_processor.so.2.6.0 +0 -0
  70. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_ping_rx.so.2.6.0 +0 -0
  71. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_ping_tensor_rx.so.2.6.0 +0 -0
  72. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_ping_tensor_tx.so.2.6.0 +0 -0
  73. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_ping_tx.so.2.6.0 +0 -0
  74. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_segmentation_postprocessor.so.2.6.0 +0 -0
  75. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_v4l2.so.2.6.0 +0 -0
  76. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_video_stream_recorder.so.2.6.0 +0 -0
  77. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_op_video_stream_replayer.so.2.6.0 +0 -0
  78. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_profiler.so.2.6.0 +0 -0
  79. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_spdlog_logger.so.2.6.0 +0 -0
  80. holoscan-2.6.0.data/purelib/holoscan/lib/libholoscan_viz.so.2.6.0 +0 -0
  81. holoscan-2.6.0.data/purelib/holoscan/lib/libucm.so.0.0.0 +0 -0
  82. holoscan-2.6.0.data/purelib/holoscan/lib/libucp.so.0.0.0 +0 -0
  83. holoscan-2.6.0.data/purelib/holoscan/lib/libucs.so.0.0.0 +0 -0
  84. holoscan-2.6.0.data/purelib/holoscan/lib/libucs_signal.so.0.0.0 +0 -0
  85. holoscan-2.6.0.data/purelib/holoscan/lib/libuct.so.0.0.0 +0 -0
  86. holoscan-2.6.0.data/purelib/holoscan/lib/libyaml-cpp.so.0.7.0 +0 -0
  87. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libucm_cuda.so.0.0.0 +0 -0
  88. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libucs_fuse.so.0.0.0 +0 -0
  89. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libuct_cma.so.0.0.0 +0 -0
  90. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libuct_cuda.so.0.0.0 +0 -0
  91. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libuct_cuda_gdrcopy.so.0.0.0 +0 -0
  92. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libuct_ib.so.0.0.0 +0 -0
  93. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libuct_rdmacm.so.0.0.0 +0 -0
  94. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libuct_xpmem.so.0.0.0 +0 -0
  95. holoscan-2.6.0.data/purelib/holoscan/lib/ucx/libucx_perftest_cuda.so.0.0.0 +0 -0
  96. holoscan-2.6.0.data/purelib/holoscan/logger/__init__.py +37 -0
  97. holoscan-2.6.0.data/purelib/holoscan/network_contexts/__init__.py +28 -0
  98. holoscan-2.6.0.data/purelib/holoscan/operators/__init__.py +97 -0
  99. holoscan-2.6.0.data/purelib/holoscan/operators/aja_source/__init__.py +22 -0
  100. holoscan-2.6.0.data/purelib/holoscan/operators/bayer_demosaic/__init__.py +24 -0
  101. holoscan-2.6.0.data/purelib/holoscan/operators/format_converter/__init__.py +23 -0
  102. holoscan-2.6.0.data/purelib/holoscan/operators/gxf_codelet/__init__.py +67 -0
  103. holoscan-2.6.0.data/purelib/holoscan/operators/holoviz/__init__.py +424 -0
  104. holoscan-2.6.0.data/purelib/holoscan/operators/inference/__init__.py +23 -0
  105. holoscan-2.6.0.data/purelib/holoscan/operators/inference_processor/__init__.py +23 -0
  106. holoscan-2.6.0.data/purelib/holoscan/operators/ping_rx/__init__.py +45 -0
  107. holoscan-2.6.0.data/purelib/holoscan/operators/ping_tensor_rx/__init__.py +22 -0
  108. holoscan-2.6.0.data/purelib/holoscan/operators/ping_tensor_tx/__init__.py +22 -0
  109. holoscan-2.6.0.data/purelib/holoscan/operators/ping_tx/__init__.py +46 -0
  110. holoscan-2.6.0.data/purelib/holoscan/operators/segmentation_postprocessor/__init__.py +23 -0
  111. holoscan-2.6.0.data/purelib/holoscan/operators/v4l2_video_capture/__init__.py +23 -0
  112. holoscan-2.6.0.data/purelib/holoscan/operators/video_stream_recorder/__init__.py +22 -0
  113. holoscan-2.6.0.data/purelib/holoscan/operators/video_stream_replayer/__init__.py +22 -0
  114. holoscan-2.6.0.data/purelib/holoscan/resources/__init__.py +147 -0
  115. holoscan-2.6.0.data/purelib/holoscan/schedulers/__init__.py +32 -0
  116. holoscan-2.6.0.data/purelib/holoscan-2.6.0.pth +1 -0
  117. holoscan-2.6.0.dist-info/LICENSE.txt +202 -0
  118. holoscan-2.6.0.dist-info/METADATA +125 -0
  119. holoscan-2.6.0.dist-info/NOTICE.txt +174 -0
  120. holoscan-2.6.0.dist-info/NVIDIA-AI-PRODUCT-EULA.txt +243 -0
  121. holoscan-2.6.0.dist-info/RECORD +126 -0
  122. holoscan-2.6.0.dist-info/WHEEL +5 -0
  123. holoscan-2.6.0.dist-info/axle.lck +0 -0
  124. holoscan-2.6.0.dist-info/entry_points.txt +3 -0
  125. holoscan-2.6.0.dist-info/symlinks.txt +82 -0
  126. holoscan-2.6.0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,430 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """This module provides a Python API for the core C++ API classes.
16
+
17
+ The `Application` class is the primary class that should be derived from to
18
+ create a custom application.
19
+
20
+ .. autosummary::
21
+
22
+ holoscan.core.Application
23
+ holoscan.core.Arg
24
+ holoscan.core.ArgContainerType
25
+ holoscan.core.ArgElementType
26
+ holoscan.core.ArgList
27
+ holoscan.core.ArgType
28
+ holoscan.core.CLIOptions
29
+ holoscan.core.Component
30
+ holoscan.core.ComponentSpec
31
+ holoscan.core.ConditionType
32
+ holoscan.core.Condition
33
+ holoscan.core.Config
34
+ holoscan.core.DataFlowMetric
35
+ holoscan.core.DataFlowTracker
36
+ holoscan.core.DLDevice
37
+ holoscan.core.DLDeviceType
38
+ holoscan.core.ExecutionContext
39
+ holoscan.core.Executor
40
+ holoscan.core.Fragment
41
+ holoscan.core.Graph
42
+ holoscan.core.InputContext
43
+ holoscan.core.IOSpec
44
+ holoscan.core.Message
45
+ holoscan.core.MetadataDictionary
46
+ holoscan.core.MetadataPolicy
47
+ holoscan.core.NetworkContext
48
+ holoscan.core.Operator
49
+ holoscan.core.OperatorSpec
50
+ holoscan.core.OutputContext
51
+ holoscan.core.ParameterFlag
52
+ holoscan.core.Resource
53
+ holoscan.core.Tensor
54
+ holoscan.core.Tracker
55
+ holoscan.core.arg_to_py_object
56
+ holoscan.core.arglist_to_kwargs
57
+ holoscan.core.kwargs_to_arglist
58
+ holoscan.core.py_object_to_arg
59
+ """
60
+
61
+ # Note: Python 3.7+ expects the threading module to be initialized (imported) before additional
62
+ # threads are created (by C++ modules using pybind11).
63
+ # Otherwise you will get an assert tlock.locked() error on exit.
64
+ # (CLARAHOLOS-765)
65
+ import threading as _threading # noqa: F401, I001
66
+
67
+ from ..graphs._graphs import FragmentGraph, OperatorGraph
68
+ from ._core import Application as _Application
69
+ from ._core import (
70
+ Arg,
71
+ ArgContainerType,
72
+ ArgElementType,
73
+ ArgList,
74
+ ArgType,
75
+ CLIOptions,
76
+ Component,
77
+ Condition,
78
+ ConditionType,
79
+ Config,
80
+ DataFlowMetric,
81
+ DataFlowTracker,
82
+ DLDevice,
83
+ DLDeviceType,
84
+ ExecutionContext,
85
+ Executor,
86
+ )
87
+ from ._core import Fragment as _Fragment
88
+ from ._core import (
89
+ InputContext,
90
+ IOSpec,
91
+ Message,
92
+ MetadataDictionary,
93
+ MetadataPolicy,
94
+ NetworkContext,
95
+ )
96
+ from ._core import Operator as _Operator
97
+ from ._core import OutputContext, ParameterFlag
98
+ from ._core import PyComponentSpec as ComponentSpec
99
+ from ._core import PyRegistryContext as _RegistryContext
100
+ from ._core import PyOperatorSpec as OperatorSpec
101
+ from ._core import PyTensor as Tensor
102
+ from ._core import Resource as _Resource
103
+ from ._core import (
104
+ Scheduler,
105
+ arg_to_py_object,
106
+ arglist_to_kwargs,
107
+ kwargs_to_arglist,
108
+ py_object_to_arg,
109
+ )
110
+ from ._core import register_types as _register_types
111
+
112
+ Graph = OperatorGraph # define alias for backward compatibility
113
+
114
+ __all__ = [
115
+ "Application",
116
+ "Arg",
117
+ "ArgContainerType",
118
+ "ArgElementType",
119
+ "ArgList",
120
+ "ArgType",
121
+ "CLIOptions",
122
+ "Component",
123
+ "ComponentSpec",
124
+ "ConditionType",
125
+ "Condition",
126
+ "Config",
127
+ "DataFlowMetric",
128
+ "DataFlowTracker",
129
+ "DLDevice",
130
+ "DLDeviceType",
131
+ "ExecutionContext",
132
+ "Executor",
133
+ "Fragment",
134
+ "FragmentGraph",
135
+ "Graph",
136
+ "InputContext",
137
+ "IOSpec",
138
+ "Message",
139
+ "MetadataDictionary",
140
+ "MetadataPolicy",
141
+ "NetworkContext",
142
+ "Operator",
143
+ "OperatorSpec",
144
+ "OperatorGraph",
145
+ "OutputContext",
146
+ "ParameterFlag",
147
+ "Resource",
148
+ "Scheduler",
149
+ "Tensor",
150
+ "Tracker",
151
+ "arg_to_py_object",
152
+ "arglist_to_kwargs",
153
+ "io_type_registry",
154
+ "kwargs_to_arglist",
155
+ "py_object_to_arg",
156
+ ]
157
+
158
+
159
+ # Define custom __repr__ method for MetadataDictionary
160
+ def metadata_repr(self):
161
+ items = {k: v for k, v in self.items()}
162
+ return f"{items}"
163
+
164
+
165
+ MetadataDictionary.__repr__ = metadata_repr
166
+
167
+
168
+ class Application(_Application):
169
+ def __init__(self, argv=None, *args, **kwargs):
170
+ # If no arguments are provided, instead of letting the C++ API initialize the application
171
+ # from the command line (through '/proc/self/cmdline'), we initialize the application
172
+ # with the command line arguments retrieved from the Python interpreter.
173
+ # This is because the C++ API will not be able to discard arguments that are not meant for
174
+ # the Python application.
175
+ # For example, if the user runs the application with the following
176
+ # command line arguments:
177
+ # /usr/bin/python3 -m pytest -v -k test_init /workspace/holoscan-sdk/public/python/tests
178
+ # then the C++ API will get the following arguments:
179
+ # ['/usr/bin/python3', '-m', 'pytest', '-v', '-k', 'test_init',
180
+ # '/workspace/holoscan-sdk/public/python/tests']
181
+ # whereas the Python interpreter (sys.argv) will get the following arguments:
182
+ # ['/usr/lib/python3/dist-packages/pytest.py', '-v', '-k', 'test_init',
183
+ # '/workspace/holoscan-sdk/public/python/tests']
184
+ # For the reason above, we initialize the application with the arguments:
185
+ # [sys.executable, *sys.argv]
186
+ # which will be equivalent to the following command line arguments:
187
+ # ['/usr/bin/python3', '/usr/lib/python3/dist-packages/pytest.py', '-v', '-k',
188
+ # 'test_init', '/workspace/holoscan-sdk/public/python/tests']
189
+ # and ``Application().argv`` will return the same arguments as ``sys.argv``.
190
+
191
+ if not argv:
192
+ import sys
193
+
194
+ argv = [sys.executable, *sys.argv]
195
+
196
+ # It is recommended to not use super()
197
+ # (https://pybind11.readthedocs.io/en/stable/advanced/classes.html#overriding-virtual-functions-in-python)
198
+ _Application.__init__(self, argv, *args, **kwargs)
199
+
200
+ def run_async(self):
201
+ """Run the application asynchronously.
202
+
203
+ This method is a convenience method that creates a thread pool with
204
+ one thread and runs the application in that thread. The thread pool
205
+ is created using `concurrent.futures.ThreadPoolExecutor`.
206
+
207
+ Returns
208
+ -------
209
+ future : ``concurrent.futures.Future`` object
210
+ """
211
+ from concurrent.futures import ThreadPoolExecutor
212
+
213
+ executor = ThreadPoolExecutor(max_workers=1)
214
+ return executor.submit(self.run)
215
+
216
+ # If we created a context via `gxf.context_create` then we would need to
217
+ # call `gxf.context_destroy` in a destructor. However, in the __init__
218
+ # here, the C++ API creates the GXFExecutor and its context and the
219
+ # C++ object will also take care of the context deletion.
220
+
221
+ # def __del__(self):
222
+ # context_destroy(self._context)
223
+
224
+
225
+ # copy docstrings defined in core_pydoc.hpp
226
+ Application.__doc__ = _Application.__doc__
227
+ Application.__init__.__doc__ = _Application.__init__.__doc__
228
+
229
+
230
+ class Fragment(_Fragment):
231
+ def __init__(self, app=None, name="", *args, **kwargs):
232
+ if app is not None and not isinstance(app, _Application):
233
+ raise ValueError(
234
+ "The first argument to a Fragment's constructor must be the Application "
235
+ "to which it belongs."
236
+ )
237
+ # It is recommended to not use super()
238
+ # (https://pybind11.readthedocs.io/en/stable/advanced/classes.html#overriding-virtual-functions-in-python)
239
+ _Fragment.__init__(self, self, *args, **kwargs)
240
+
241
+ self.name = name
242
+ self.application = app
243
+ # Set the fragment config to the application config.
244
+ if app:
245
+ self.config(app.config())
246
+
247
+ def compose(self):
248
+ pass
249
+
250
+ def run_async(self):
251
+ """Run the fragment asynchronously.
252
+
253
+ This method is a convenience method that creates a thread pool with
254
+ one thread and runs the fragment in that thread. The thread pool
255
+ is created using `concurrent.futures.ThreadPoolExecutor`.
256
+
257
+ Returns
258
+ -------
259
+ future : ``concurrent.futures.Future`` object
260
+ """
261
+ from concurrent.futures import ThreadPoolExecutor
262
+
263
+ executor = ThreadPoolExecutor(max_workers=1)
264
+ return executor.submit(self.run)
265
+
266
+
267
+ # copy docstrings defined in core_pydoc.hpp
268
+ Fragment.__doc__ = _Fragment.__doc__
269
+ Fragment.__init__.__doc__ = _Fragment.__init__.__doc__
270
+
271
+
272
+ class Operator(_Operator):
273
+ def __setattr__(self, name, value):
274
+ readonly_attributes = [
275
+ "fragment",
276
+ "conditions",
277
+ "resources",
278
+ "operator_type",
279
+ "description",
280
+ ]
281
+ if name in readonly_attributes:
282
+ raise AttributeError(f'cannot override read-only property "{name}"')
283
+ super().__setattr__(name, value)
284
+
285
+ def __init__(self, fragment, *args, **kwargs):
286
+ if not isinstance(fragment, _Fragment):
287
+ raise ValueError(
288
+ "The first argument to an Operator's constructor must be the Fragment "
289
+ "(Application) to which it belongs."
290
+ )
291
+ # It is recommended to not use super()
292
+ # (https://pybind11.readthedocs.io/en/stable/advanced/classes.html#overriding-virtual-functions-in-python)
293
+ _Operator.__init__(self, self, fragment, *args, **kwargs)
294
+ # Create a PyOperatorSpec object and pass it to the C++ API
295
+ spec = OperatorSpec(fragment=self.fragment, op=self)
296
+ self.spec = spec
297
+ # Call setup method in PyOperator class
298
+ self.setup(spec)
299
+
300
+ def setup(self, spec: OperatorSpec):
301
+ """Default implementation of setup method."""
302
+ pass
303
+
304
+ def initialize(self):
305
+ """Default implementation of initialize"""
306
+ pass
307
+
308
+ def start(self):
309
+ """Default implementation of start"""
310
+ pass
311
+
312
+ def compute(self, op_input, op_output, context):
313
+ """Default implementation of compute"""
314
+ pass
315
+
316
+ def stop(self):
317
+ """Default implementation of stop"""
318
+ pass
319
+
320
+
321
+ # copy docstrings defined in core_pydoc.hpp
322
+ Operator.__doc__ = _Operator.__doc__
323
+ Operator.__init__.__doc__ = _Operator.__init__.__doc__
324
+
325
+
326
+ class Resource(_Resource):
327
+ def __init__(self, fragment, *args, **kwargs):
328
+ if not isinstance(fragment, _Fragment):
329
+ raise ValueError(
330
+ "The first argument to an Resource's constructor must be the Fragment "
331
+ "(Application) to which it belongs."
332
+ )
333
+ # It is recommended to not use super()
334
+ # (https://pybind11.readthedocs.io/en/stable/advanced/classes.html#overriding-virtual-functions-in-python)
335
+ _Resource.__init__(self, self, fragment, *args, **kwargs)
336
+ # Create a PyComponentSpec object and pass it to the C++ API
337
+ spec = ComponentSpec(fragment=self.fragment, component=self)
338
+ self.spec = spec
339
+ # Call setup method in PyResource class
340
+ self.setup(spec)
341
+
342
+ def setup(self, spec: ComponentSpec):
343
+ """Default implementation of setup method."""
344
+ pass
345
+
346
+
347
+ # copy docstrings defined in core_pydoc.hpp
348
+ Resource.__doc__ = _Resource.__doc__
349
+ Resource.__init__.__doc__ = _Resource.__init__.__doc__
350
+
351
+
352
+ class Tracker:
353
+ """Context manager to add data flow tracking to an application."""
354
+
355
+ def __init__(
356
+ self,
357
+ app,
358
+ *,
359
+ filename=None,
360
+ num_buffered_messages=100,
361
+ num_start_messages_to_skip=10,
362
+ num_last_messages_to_discard=10,
363
+ latency_threshold=0,
364
+ ):
365
+ """
366
+ Parameters
367
+ ----------
368
+ app : holoscan.core.Application
369
+ on which flow tracking should be applied.
370
+ filename : str or None, optional
371
+ If none, logging to file will be disabled. Otherwise, logging will
372
+ write to the specified file.
373
+ num_buffered_messages : int, optional
374
+ Controls the number of messages buffered between file writing when
375
+ `filename` is not ``None``.
376
+ num_start_messages_to_skip : int, optional
377
+ The number of messages to skip at the beginning of the execution. This does not affect
378
+ the log file or the number of source messages metric.
379
+ num_last_messages_to_discard : int, optional
380
+ The number of messages to discard at the end of the execution. This does not affect
381
+ the log file or the number of source messages metric.
382
+ latency_threshold : int, optional
383
+ The minimum end-to-end latency in milliseconds to account for in the end-to-end
384
+ latency metric calculations.
385
+ """
386
+ self.app = app
387
+
388
+ # Check the number of fragment nodes to see if it is a distributed app.
389
+ # Use compose_graph(), not compose() to protect against repeated compose() calls.
390
+ self.app.compose_graph()
391
+ self.is_distributed_app = len(app.fragment_graph.get_nodes()) > 0
392
+
393
+ self.enable_logging = filename is not None
394
+ if self.enable_logging:
395
+ self.logging_kwargs = dict(
396
+ filename=filename,
397
+ num_buffered_messages=num_buffered_messages,
398
+ )
399
+ self.tracker_kwargs = dict(
400
+ num_start_messages_to_skip=num_start_messages_to_skip,
401
+ num_last_messages_to_discard=num_last_messages_to_discard,
402
+ latency_threshold=latency_threshold,
403
+ )
404
+
405
+ def __enter__(self):
406
+ if self.is_distributed_app:
407
+ self.trackers = self.app.track_distributed(**self.tracker_kwargs)
408
+ for tracker in self.trackers.values():
409
+ if self.enable_logging:
410
+ tracker.enable_logging(**self.logging_kwargs)
411
+ return self.trackers
412
+ else:
413
+ self.tracker = self.app.track(**self.tracker_kwargs)
414
+ if self.enable_logging:
415
+ self.tracker.enable_logging(**self.logging_kwargs)
416
+ return self.tracker
417
+
418
+ def __exit__(self, exc_type, exc_value, exc_tb):
419
+ if self.enable_logging:
420
+ if self.is_distributed_app:
421
+ for tracker in self.trackers.values():
422
+ tracker.end_logging()
423
+ else:
424
+ self.tracker.end_logging()
425
+
426
+
427
+ _registry_context = _RegistryContext()
428
+ io_type_registry = _registry_context.registry()
429
+
430
+ _register_types(io_type_registry)