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,203 @@
1
+ """
2
+ SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ """ # noqa: E501
17
+
18
+ import logging
19
+ import os
20
+ from argparse import ArgumentParser, HelpFormatter, _SubParsersAction
21
+
22
+ from ..common import argparse_types
23
+ from ..common.argparse_types import valid_existing_path
24
+
25
+ logger = logging.getLogger("runner")
26
+
27
+
28
+ def create_run_parser(
29
+ subparser: _SubParsersAction, command: str, parents: list[ArgumentParser]
30
+ ) -> ArgumentParser:
31
+ parser: ArgumentParser = subparser.add_parser(
32
+ command, formatter_class=HelpFormatter, parents=parents, add_help=False
33
+ )
34
+
35
+ parser.add_argument("map", metavar="<image[:tag]>", help="HAP/MAP image name.")
36
+
37
+ parser.add_argument(
38
+ "--address",
39
+ dest="address",
40
+ help="address ('[<IP or hostname>][:<port>]') of the App Driver. If not specified, "
41
+ "the App Driver uses the default host address ('0.0.0.0') with the default port "
42
+ "number ('8765').",
43
+ )
44
+
45
+ parser.add_argument(
46
+ "--driver",
47
+ dest="driver",
48
+ action="store_true",
49
+ default=False,
50
+ help="run the App Driver on the current machine. Can be used together with the "
51
+ "'--worker' option "
52
+ "to run both the App Driver and the App Worker on the same machine.",
53
+ )
54
+
55
+ parser.add_argument(
56
+ "-i",
57
+ "--input",
58
+ metavar="<input>",
59
+ type=argparse_types.valid_dir_path,
60
+ help="input data directory path.",
61
+ required=False,
62
+ )
63
+
64
+ parser.add_argument(
65
+ "-o",
66
+ "--output",
67
+ metavar="<output>",
68
+ type=argparse_types.valid_dir_path,
69
+ help="output data directory path.",
70
+ required=False,
71
+ )
72
+
73
+ parser.add_argument(
74
+ "-f",
75
+ "--fragments",
76
+ dest="fragments",
77
+ help="comma-separated names of the fragments to be executed by the App Worker. "
78
+ "If not specified, only one fragment (selected by the App Driver) will be executed. "
79
+ "'all' can be used to run all the fragments.",
80
+ )
81
+
82
+ parser.add_argument(
83
+ "--worker",
84
+ dest="worker",
85
+ action="store_true",
86
+ default=False,
87
+ help="run the App Worker.",
88
+ )
89
+
90
+ parser.add_argument(
91
+ "--worker-address",
92
+ dest="worker_address",
93
+ help="address (`[<IP or hostname>][:<port>]`) of the App Worker. If not specified, the App "
94
+ "Worker uses the default host address ('0.0.0.0') with a randomly chosen port number "
95
+ "between 10000 and 32767 that is not currently in use.",
96
+ )
97
+
98
+ advanced_group = parser.add_argument_group(title="advanced run options")
99
+
100
+ advanced_group.add_argument(
101
+ "--config",
102
+ dest="config",
103
+ type=valid_existing_path,
104
+ help="path to the configuration file. This will override the configuration file embedded "
105
+ "in the application.",
106
+ )
107
+
108
+ advanced_group.add_argument(
109
+ "--name",
110
+ dest="name",
111
+ help="name and hostname of the container to create.",
112
+ )
113
+ advanced_group.add_argument(
114
+ "-n",
115
+ "--network",
116
+ dest="network",
117
+ default="host",
118
+ help="name of the Docker network this application will be connected to. (default: host)",
119
+ )
120
+ advanced_group.add_argument(
121
+ "--nic",
122
+ dest="nic",
123
+ help="name of the network interface to use with a distributed multi-fragment application. "
124
+ "This option sets UCX_NET_DEVICES environment variable with the value specified.",
125
+ )
126
+ advanced_group.add_argument(
127
+ "--use-all-nics",
128
+ dest="use_all_nics",
129
+ action="store_true",
130
+ default=False,
131
+ help="allow UCX to control the selection of network interface cards for data "
132
+ "transfer. Otherwise, the network interface card specified with '--nic' is used. "
133
+ "This option sets UCX_CM_USE_ALL_DEVICES to 'y'. (default: False)",
134
+ )
135
+ advanced_group.add_argument(
136
+ "-r",
137
+ "--render",
138
+ dest="render",
139
+ action="store_true",
140
+ default=False,
141
+ help="enable rendering (default: False); runs the container with required flags to enable "
142
+ "rendering of graphics.",
143
+ )
144
+ advanced_group.add_argument(
145
+ "-q",
146
+ "--quiet",
147
+ dest="quiet",
148
+ action="store_true",
149
+ default=False,
150
+ help="suppress the STDOUT and print only STDERR from the application. (default: False)",
151
+ )
152
+ advanced_group.add_argument(
153
+ "--shm-size",
154
+ dest="shm_size",
155
+ help="set the size of /dev/shm. The format is "
156
+ "<number(int,float)>[MB|m|GB|g|Mi|MiB|Gi|GiB]. "
157
+ "Use 'config' to read the shared memory value defined in the app.json manifest. "
158
+ "If not specified, the container is launched using '--ipc=host' with host system's "
159
+ "/dev/shm mounted.",
160
+ )
161
+ advanced_group.add_argument(
162
+ "--terminal",
163
+ dest="terminal",
164
+ action="store_true",
165
+ default=False,
166
+ help="enter terminal with all configured volume mappings and environment variables. "
167
+ "(default: False)",
168
+ )
169
+ advanced_group.add_argument(
170
+ "--device",
171
+ dest="device",
172
+ nargs="+",
173
+ action="extend",
174
+ help="""Mount additional devices.
175
+ For example:
176
+ --device ajantv* to mount all AJA capture cards.
177
+ --device ajantv0 ajantv1 to mount AJA capture card 0 and 1.
178
+ --device video1 to mount V4L2 video device 1. """,
179
+ )
180
+ advanced_group.add_argument(
181
+ "--gpus",
182
+ dest="gpus",
183
+ help="""Override the value of NVIDIA_VISIBLE_DEVICES environment variable.
184
+ default: the value specified in the package manifest file or 'all' if not specified.
185
+ Refer to https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#gpu-enumeration
186
+ for all available options.""",
187
+ )
188
+
189
+ user_group = parser.add_argument_group(title="security options")
190
+ user_group.add_argument(
191
+ "--uid",
192
+ type=str,
193
+ default=os.getuid(),
194
+ help=f"run the container with the UID. (default:{os.getuid()})",
195
+ )
196
+ user_group.add_argument(
197
+ "--gid",
198
+ type=str,
199
+ default=os.getgid(),
200
+ help=f"run the container with the GID. (default:{os.getgid()})",
201
+ )
202
+
203
+ return parser
@@ -0,0 +1,306 @@
1
+ """
2
+ SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ """ # noqa: E501
17
+
18
+ import json
19
+ import logging
20
+ import os
21
+ import re
22
+ import shutil
23
+ import sys
24
+ import tempfile
25
+ from argparse import Namespace
26
+ from glob import glob
27
+ from pathlib import Path
28
+ from typing import Optional
29
+
30
+ from ..common.dockerutils import create_or_use_network, docker_run, image_exists
31
+ from ..common.exceptions import ManifestReadError, UnmatchedDeviceError
32
+ from ..common.utils import (
33
+ compare_versions,
34
+ get_requested_gpus,
35
+ print_manifest_json,
36
+ run_cmd,
37
+ run_cmd_output,
38
+ )
39
+ from .resources import get_shared_memory_size
40
+
41
+ logger = logging.getLogger("runner")
42
+
43
+
44
+ def _fetch_map_manifest(map_name: str) -> tuple[dict, dict]:
45
+ """
46
+ Execute HAP/MAP and fetch the manifest files.
47
+
48
+ Args:
49
+ map_name: HAP/MAP image name.
50
+
51
+ Returns:
52
+ app_info: application manifest as a python dict
53
+ pkg_info: package manifest as a python dict
54
+ returncode: command return code
55
+ """
56
+ logger.info("Reading HAP/MAP manifest...")
57
+
58
+ with tempfile.TemporaryDirectory() as info_dir:
59
+ cmd = f"""docker_id=$(docker create {map_name})
60
+ docker cp $docker_id:/etc/holoscan/app.json "{info_dir}/app.json"
61
+ docker cp $docker_id:/etc/holoscan/pkg.json "{info_dir}/pkg.json"
62
+ docker rm -v $docker_id > /dev/null
63
+ """
64
+ returncode = run_cmd(cmd)
65
+ if returncode != 0:
66
+ raise ManifestReadError("Error reading manifest file form the package.")
67
+
68
+ app_json = Path(f"{info_dir}/app.json")
69
+ pkg_json = Path(f"{info_dir}/pkg.json")
70
+
71
+ app_info = json.loads(app_json.read_text())
72
+ pkg_info = json.loads(pkg_json.read_text())
73
+
74
+ print_manifest_json(app_info, "app.json")
75
+ print_manifest_json(pkg_info, "pkg.json")
76
+
77
+ return app_info, pkg_info
78
+
79
+
80
+ def _run_app(args: Namespace, app_info: dict, pkg_info: dict):
81
+ """
82
+ Executes the Holoscan Application.
83
+
84
+ Args:
85
+ args: user arguments
86
+ app_info: application manifest dictionary
87
+ pkg_info: package manifest dictionary
88
+
89
+ Returns:
90
+ returncode: command returncode
91
+ """
92
+
93
+ map_name: str = args.map
94
+ input_path: Path = args.input
95
+ output_path: Path = args.output
96
+ quiet: bool = args.quiet
97
+ driver: bool = args.driver
98
+ worker: bool = args.worker
99
+ fragments: str = args.fragments if args.fragments else None
100
+ network: str = create_or_use_network(args.network, map_name)
101
+ nic: str = args.nic if args.nic else None
102
+ use_all_nics: bool = args.use_all_nics
103
+ gpus: str = args.gpus if args.gpus else None
104
+ config: Path = args.config if args.config else None
105
+ address: str = args.address if args.address else None
106
+ worker_address: str = args.worker_address if args.worker_address else None
107
+ render: bool = args.render
108
+ user: str = f"{args.uid}:{args.gid}"
109
+ hostname: str = None
110
+ terminal: bool = args.terminal
111
+ platform_config: str = pkg_info.get("platformConfig")
112
+ shared_memory_size: Optional[str] = (
113
+ get_shared_memory_size(pkg_info, worker, driver, fragments, args.shm_size)
114
+ if args.shm_size
115
+ else None
116
+ )
117
+
118
+ commands = []
119
+ devices = _lookup_devices(args.device) if args.device else []
120
+
121
+ if driver:
122
+ commands.append("--driver")
123
+ logger.info("Application running in Driver mode")
124
+ if worker:
125
+ commands.append("--worker")
126
+ logger.info("Application running in Worker mode")
127
+ if fragments:
128
+ commands.append("--fragments")
129
+ commands.append(fragments)
130
+ logger.info(f"Configured fragments: {fragments}")
131
+ if address:
132
+ commands.append("--address")
133
+ commands.append(address)
134
+ logger.info(f"App Driver address and port: {address}")
135
+ if worker_address:
136
+ commands.append("--worker_address")
137
+ commands.append(worker_address)
138
+ logger.info(f"App Worker address and port: {worker_address}")
139
+
140
+ if driver:
141
+ hostname = "driver"
142
+
143
+ docker_run(
144
+ hostname,
145
+ map_name,
146
+ input_path,
147
+ output_path,
148
+ app_info,
149
+ pkg_info,
150
+ quiet,
151
+ commands,
152
+ network,
153
+ nic,
154
+ use_all_nics,
155
+ gpus,
156
+ config,
157
+ render,
158
+ user,
159
+ terminal,
160
+ devices,
161
+ platform_config,
162
+ shared_memory_size,
163
+ args.uid == 0,
164
+ )
165
+
166
+
167
+ def _lookup_devices(devices: list[str]) -> list[str]:
168
+ """
169
+ Looks up matching devices in /dev and returns a list
170
+ of fully qualified device paths.
171
+
172
+ Raises exception if any devices cannot be found.
173
+ """
174
+ matched_devices = []
175
+ unmatched_devices = []
176
+
177
+ for dev in devices:
178
+ pattern = dev
179
+ if not pattern.startswith("/"):
180
+ pattern = "/dev/" + pattern
181
+ found_devices = glob(pattern)
182
+ if len(found_devices) == 0:
183
+ unmatched_devices.append(dev)
184
+ else:
185
+ matched_devices.extend(found_devices)
186
+
187
+ if len(unmatched_devices) > 0:
188
+ raise UnmatchedDeviceError(unmatched_devices)
189
+
190
+ return matched_devices
191
+
192
+
193
+ def _dependency_verification(map_name: str) -> bool:
194
+ """Check if all the dependencies are installed or not.
195
+
196
+ Args:
197
+ map_name: HAP/MAP name
198
+
199
+ Returns:
200
+ True if all dependencies are satisfied, otherwise False.
201
+ """
202
+ logger.info("Checking dependencies...")
203
+
204
+ # check for docker
205
+ prog = "docker"
206
+ logger.info('--> Verifying if "%s" is installed...\n', prog)
207
+ if not shutil.which(prog):
208
+ logger.error(
209
+ '"%s" not installed, please install it from https://docs.docker.com/engine/install/.',
210
+ prog,
211
+ )
212
+ return False
213
+
214
+ buildx_paths = [
215
+ os.path.expandvars("$HOME/.docker/cli-plugins"),
216
+ "/usr/local/lib/docker/cli-plugins",
217
+ "/usr/local/libexec/docker/cli-plugins",
218
+ "/usr/lib/docker/cli-plugins",
219
+ "/usr/libexec/docker/cli-plugins",
220
+ ]
221
+ prog = "docker-buildx"
222
+ logger.info('--> Verifying if "%s" is installed...\n', prog)
223
+ buildx_found = False
224
+ for path in buildx_paths:
225
+ if shutil.which(os.path.join(path, prog)):
226
+ buildx_found = True
227
+
228
+ if not buildx_found:
229
+ logger.error(
230
+ '"%s" not installed, please install it from https://docs.docker.com/engine/install/.',
231
+ prog,
232
+ )
233
+ return False
234
+
235
+ # check for map image
236
+ logger.info('--> Verifying if "%s" is available...\n', map_name)
237
+ if not image_exists(map_name):
238
+ logger.error("Unable to fetch required image.")
239
+ return False
240
+
241
+ return True
242
+
243
+
244
+ def _pkg_specific_dependency_verification(pkg_info: dict) -> bool:
245
+ """Checks for any package specific dependencies.
246
+
247
+ Currently it verifies the following dependencies:
248
+ * If gpu has been requested by the application, verify that nvidia-ctk is installed.
249
+ Note: when running inside a Docker container, always assume nvidia-ctk is installed.
250
+ Args:
251
+ pkg_info: package manifest as a python dict
252
+
253
+ Returns:
254
+ True if all dependencies are satisfied, otherwise False.
255
+ """
256
+ if os.path.exists("/.dockerenv"):
257
+ logger.info("--> Skipping nvidia-ctk check inside Docker...\n")
258
+ return True
259
+
260
+ requested_gpus = get_requested_gpus(pkg_info)
261
+ if requested_gpus > 0:
262
+ # check for NVIDIA Container TOolkit
263
+ prog = "nvidia-ctk"
264
+ logger.info('--> Verifying if "%s" is installed...\n', prog)
265
+ if not shutil.which(prog):
266
+ logger.error('"%s" not installed, please install NVIDIA Container Toolkit.', prog)
267
+ return False
268
+
269
+ logger.info('--> Verifying "%s" version...\n', prog)
270
+ output = run_cmd_output("nvidia-ctk --version | grep version")
271
+ match = re.search(r"([0-9]+\.[0-9]+\.[0-9]+)", output)
272
+ min_ctk_version = "1.12.0"
273
+ recommended_ctk_version = "1.14.1"
274
+ if compare_versions(min_ctk_version, match.group()) > 0:
275
+ logger.error(
276
+ f"Found '{prog}' Version {match.group()}. "
277
+ f"Version {min_ctk_version}+ is required ({recommended_ctk_version}+ recommended)."
278
+ )
279
+ return False
280
+
281
+ return True
282
+
283
+
284
+ def execute_run_command(args: Namespace):
285
+ if not _dependency_verification(args.map):
286
+ logger.error("Execution Aborted")
287
+ sys.exit(1)
288
+
289
+ try:
290
+ # Fetch application manifest from MAP
291
+ app_info, pkg_info = _fetch_map_manifest(args.map)
292
+ except Exception as e:
293
+ logger.error(f"Failed to fetch MAP manifest: {e}")
294
+ sys.exit(1)
295
+
296
+ if not _pkg_specific_dependency_verification(pkg_info):
297
+ logger.error("Execution Aborted")
298
+ sys.exit(1)
299
+
300
+ try:
301
+ # Run Holoscan Application
302
+ _run_app(args, app_info, pkg_info)
303
+ except Exception as ex:
304
+ logger.debug(ex, exc_info=True)
305
+ logger.error(f"Error executing {args.map}: {ex}")
306
+ sys.exit(1)
@@ -0,0 +1,18 @@
1
+ """
2
+ SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ """ # noqa: E501
17
+
18
+ from .version import execute_version_command # noqa: F401
@@ -0,0 +1,50 @@
1
+ """
2
+ SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ """ # noqa: E501
17
+
18
+ import logging
19
+ import os
20
+ import sys
21
+ from argparse import Namespace
22
+
23
+ from ..common.artifact_sources import ArtifactSources
24
+ from ..common.enum_types import SdkType
25
+ from ..common.sdk_utils import detect_holoscan_version, detect_monaideploy_version, detect_sdk
26
+
27
+ logger = logging.getLogger("version")
28
+
29
+
30
+ def execute_version_command(args: Namespace, artifact_sources: ArtifactSources):
31
+ print(f"You are executing Holoscan CLI from: {os.path.dirname(os.path.abspath(sys.argv[0]))}\n")
32
+
33
+ try:
34
+ sdk = detect_sdk()
35
+ try:
36
+ sdk_version = detect_holoscan_version(artifact_sources)
37
+ print(f"Holoscan SDK: {sdk_version}")
38
+ except Exception:
39
+ print("Holoscan SDK: N/A")
40
+
41
+ if sdk == SdkType.MonaiDeploy:
42
+ try:
43
+ sdk_version = detect_monaideploy_version(artifact_sources)
44
+ print(f"MONAI Deploy App SDK: {sdk_version}")
45
+ except Exception:
46
+ print("MONAI Deploy App SDK: N/A")
47
+
48
+ except Exception as ex:
49
+ logging.error("Error executing version command.")
50
+ logger.debug(ex)
@@ -0,0 +1,57 @@
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 to underlying C++ API Conditions.
16
+
17
+ .. autosummary::
18
+
19
+ holoscan.conditions.AsynchronousCondition
20
+ holoscan.conditions.BooleanCondition
21
+ holoscan.conditions.CountCondition
22
+ holoscan.conditions.CudaBufferAvailableCondition
23
+ holoscan.conditions.CudaEventCondition
24
+ holoscan.conditions.CudaStreamCondition
25
+ holoscan.conditions.DownstreamMessageAffordableCondition
26
+ holoscan.conditions.ExpiringMessageAvailableCondition
27
+ holoscan.conditions.MessageAvailableCondition
28
+ holoscan.conditions.PeriodicCondition
29
+ """
30
+
31
+ from ._conditions import (
32
+ AsynchronousCondition,
33
+ AsynchronousEventState,
34
+ BooleanCondition,
35
+ CountCondition,
36
+ CudaBufferAvailableCondition,
37
+ CudaEventCondition,
38
+ CudaStreamCondition,
39
+ DownstreamMessageAffordableCondition,
40
+ ExpiringMessageAvailableCondition,
41
+ MessageAvailableCondition,
42
+ PeriodicCondition,
43
+ )
44
+
45
+ __all__ = [
46
+ "AsynchronousCondition",
47
+ "AsynchronousEventState",
48
+ "BooleanCondition",
49
+ "CountCondition",
50
+ "CudaBufferAvailableCondition",
51
+ "CudaEventCondition",
52
+ "CudaStreamCondition",
53
+ "DownstreamMessageAffordableCondition",
54
+ "ExpiringMessageAvailableCondition",
55
+ "MessageAvailableCondition",
56
+ "PeriodicCondition",
57
+ ]