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,130 @@
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
+
19
+ class HoloscanSdkError(Exception):
20
+ """Base class for exceptions in this module."""
21
+
22
+ pass
23
+
24
+
25
+ class WrongApplicationPathError(HoloscanSdkError):
26
+ """Raise when wrong application path is specified."""
27
+
28
+ pass
29
+
30
+
31
+ class UnknownApplicationTypeError(HoloscanSdkError):
32
+ """Raise when wrong application path is specified."""
33
+
34
+ pass
35
+
36
+
37
+ class InvalidSdkError(HoloscanSdkError):
38
+ """Raise when the SDK version or SDK file is not supported."""
39
+
40
+ pass
41
+
42
+
43
+ class FailedToDetectSDKVersionError(HoloscanSdkError):
44
+ """Raise when unable to detect the SDK version."""
45
+
46
+ pass
47
+
48
+
49
+ class InvalidApplicationConfigurationError(HoloscanSdkError):
50
+ """
51
+ Raise when required configuration value cannot be found
52
+ in the application configuration files."""
53
+
54
+ pass
55
+
56
+
57
+ class IncompatiblePlatformConfigurationError(HoloscanSdkError):
58
+ """
59
+ Raise when the platforms given by the user are incompatible."""
60
+
61
+ pass
62
+
63
+
64
+ class RunContainerError(HoloscanSdkError):
65
+ """
66
+ Raise when an error is encountered while running the container image."""
67
+
68
+ pass
69
+
70
+
71
+ class InvalidManifestError(HoloscanSdkError):
72
+ """
73
+ Raise when the manifest is invalid."""
74
+
75
+ pass
76
+
77
+
78
+ class ManifestReadError(HoloscanSdkError):
79
+ """
80
+ Raise when the manifest is invalid."""
81
+
82
+
83
+ class ExternalAssetDownloadError(HoloscanSdkError):
84
+ """
85
+ Raise when the manifest is invalid."""
86
+
87
+
88
+ class InvalidSourceFileError(HoloscanSdkError):
89
+ """
90
+ Raise when the provided artifact source file is invalid."""
91
+
92
+ pass
93
+
94
+
95
+ class InvalidTagValueError(HoloscanSdkError):
96
+ """
97
+ Raise when the Docker tag is invalid."""
98
+
99
+ pass
100
+
101
+
102
+ class InvalidSharedMemoryValueError(HoloscanSdkError):
103
+ """
104
+ Raise when the shared memory value is invalid."""
105
+
106
+ pass
107
+
108
+
109
+ class ManifestDownloadError(HoloscanSdkError):
110
+ """
111
+ Raise when the failed to download manifest file."""
112
+
113
+ pass
114
+
115
+
116
+ class UnmatchedDeviceError(HoloscanSdkError):
117
+ """
118
+ Raise when the shared memory value is invalid."""
119
+
120
+ def __init__(self, unmatched_devices: list[str], *args: object) -> None:
121
+ super().__init__(
122
+ f"The following devices cannot be found in /dev/: {str.join(',', unmatched_devices)}"
123
+ )
124
+
125
+
126
+ class GpuResourceError(HoloscanSdkError):
127
+ """
128
+ Raise when the available GPUs are less than requetsed."""
129
+
130
+ pass
@@ -0,0 +1,180 @@
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 importlib.metadata
19
+ import logging
20
+ import sys
21
+ from pathlib import Path
22
+ from typing import Optional
23
+
24
+ from packaging.version import Version
25
+
26
+ from .artifact_sources import ArtifactSources
27
+ from .enum_types import SdkType
28
+ from .exceptions import FailedToDetectSDKVersionError, InvalidSdkError
29
+
30
+ logger = logging.getLogger("common")
31
+
32
+
33
+ def detect_sdk(sdk: Optional[SdkType] = None) -> SdkType:
34
+ """
35
+ Use user specified SDK or detects the SDK to use based on the executing command name.
36
+
37
+ Args:
38
+ sdk (Optional[SdkType]): User specified SDK.
39
+
40
+ Returns:
41
+ SDK (SdkType): SDK for building the application
42
+
43
+ Raises:
44
+ InvalidSdkError: when failed to detect SDK version.
45
+ """
46
+
47
+ if sdk is not None:
48
+ if not isinstance(sdk, SdkType):
49
+ raise ValueError("sdk must be of type SdkType")
50
+ return sdk
51
+
52
+ command = None
53
+ try:
54
+ command = Path(sys.argv[0]).name.lower()
55
+ return SdkType(command)
56
+ except Exception as ex:
57
+ raise InvalidSdkError(f"Invalid SDK value provided: {command}") from ex
58
+
59
+
60
+ def detect_sdk_version(
61
+ sdk: SdkType, artifact_sources: ArtifactSources, sdk_version: Optional[Version] = None
62
+ ) -> tuple[str, Optional[str]]:
63
+ """
64
+ Detects SDK version to use based on installed PyPI package or user input.
65
+ For Holoscan SDK(Type), detect only the Holoscan version with optional user-provided version.
66
+ For MONAI Deploy SDK(Type), detect both Holoscan and MONAI Deploy App SDK versions but assume
67
+ the sdk_version provided by the user is for MONAI Deploy App SDK.
68
+
69
+ Args:
70
+ sdk (SdkType): SDK Type.
71
+ sdk_version (Optional[str]): SDK version to be used for building the package.
72
+
73
+ Returns:
74
+ Tuple[str, Optional[str]]: Version of the Holoscan SDK and version of MONAI Deploy SDK to
75
+ use
76
+
77
+ Raises:
78
+ InvalidSdkError: when failed to detect SDK version.
79
+ """
80
+ if sdk is SdkType.Holoscan:
81
+ return [detect_holoscan_version(artifact_sources, sdk_version), None]
82
+ else:
83
+ return [
84
+ detect_holoscan_version(artifact_sources, None),
85
+ detect_monaideploy_version(artifact_sources, sdk_version),
86
+ ]
87
+
88
+
89
+ def detect_holoscan_version(
90
+ artifact_sources: ArtifactSources, sdk_version: Optional[Version] = None
91
+ ) -> str:
92
+ """
93
+ Validates Holoscan version if specified. Otherwise, attempt to detect the Holoscan PyPI
94
+ package installed.
95
+
96
+ Args:
97
+ sdk (SdkType): SDK for building the application
98
+ sdk_version (Optional[str], optional): SDK version from user input. Defaults to None.
99
+
100
+ Raises:
101
+ InvalidSdkError: If specified SDK version is not supported.
102
+ FailedToDetectSDKVersionError: When unable to detect the installed Holoscan PyPI package.
103
+
104
+ Returns:
105
+ str: SDK version
106
+ """
107
+ if sdk_version is not None:
108
+ if sdk_version.base_version not in artifact_sources.holoscan_versions:
109
+ raise InvalidSdkError(
110
+ "Invalid SDK version specified: valid values are: "
111
+ f"{', '.join(artifact_sources.holoscan_versions)}"
112
+ )
113
+
114
+ return sdk_version.base_version
115
+ else:
116
+ try:
117
+ ver_str = importlib.metadata.version("holoscan").title()
118
+ ver = Version(ver_str)
119
+ ver_str = ".".join(str(i) for i in ver.release)
120
+
121
+ if len(ver.release) == 1 and ver.major == ver.release[0]:
122
+ ver_str = ver_str + ".0.0"
123
+ elif (
124
+ len(ver.release) == 2
125
+ and ver.major == ver.release[0]
126
+ and ver.minor == ver.release[1]
127
+ ):
128
+ ver_str = ver_str + ".0"
129
+ elif (
130
+ len(ver.release) == 4
131
+ and ver.major == ver.release[0]
132
+ and ver.minor == ver.release[1]
133
+ and ver.micro == ver.release[2]
134
+ ):
135
+ ver_str = f"{ver.release[0]}.{ver.release[1]}.{ver.release[2]}"
136
+
137
+ if ver_str not in artifact_sources.holoscan_versions:
138
+ raise InvalidSdkError(
139
+ f"Something must be wrong as we've detect Holoscan SDK v{ver_str}"
140
+ f" which is not supported. Please reinstall Holoscan SDK."
141
+ )
142
+ return ver_str
143
+ except Exception as ex:
144
+ raise FailedToDetectSDKVersionError(
145
+ "Failed to detect installed Holoscan PyPI version.", ex
146
+ ) from ex
147
+
148
+
149
+ def detect_monaideploy_version(
150
+ artifact_sources: ArtifactSources, sdk_version: Optional[Version] = None
151
+ ) -> str:
152
+ """
153
+ Validates MONAI Deploy version if specified. Otherwise, attempt to detect the MONAI Deploy
154
+ PyPI package installed.
155
+
156
+ Args:
157
+ sdk (SdkType): SDK for building the application
158
+ sdk_version (Optional[str], optional): SDK version from user input. Defaults to None.
159
+
160
+ Raises:
161
+ InvalidSdkError: If specified SDK version is not supported.
162
+ FailedToDetectSDKVersionError: When unable to detect the installed MONAI Deploy PyPI
163
+ package.
164
+
165
+ Returns:
166
+ str: SDK version
167
+ """
168
+
169
+ if sdk_version is not None:
170
+ return sdk_version.base_version
171
+ else:
172
+ try:
173
+ ver_str = importlib.metadata.version("monai-deploy-app-sdk").title()
174
+ ver = Version(ver_str)
175
+
176
+ return ver.base_version
177
+ except Exception as ex:
178
+ raise FailedToDetectSDKVersionError(
179
+ "Failed to detect installed MONAI Deploy App SDK PyPI version.", ex
180
+ ) from ex
@@ -0,0 +1,130 @@
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 socket
21
+ import subprocess
22
+
23
+ import psutil
24
+ from packaging import version
25
+
26
+ logger = logging.getLogger("common")
27
+
28
+
29
+ def print_manifest_json(manifest, filename):
30
+ logger.debug(
31
+ f"""
32
+ =============== Begin {filename} ===============
33
+ {json.dumps(manifest, indent=4)}
34
+ ================ End {filename} ================
35
+ """
36
+ )
37
+
38
+
39
+ def get_requested_gpus(pkg_info: dict) -> int:
40
+ """Gets requested number of gpus in the package manifest
41
+
42
+ Args:
43
+ pkg_info: package manifest as a python dict
44
+
45
+ Returns:
46
+ int: requested number of gpus in the package manifest
47
+ """
48
+ num_gpu: int = pkg_info.get("resources", {}).get("gpu", 0)
49
+ return num_gpu
50
+
51
+
52
+ def get_gpu_count():
53
+ return len(run_cmd_output("nvidia-smi -L").splitlines())
54
+
55
+
56
+ def run_cmd(cmd: str) -> int:
57
+ """
58
+ Executes command and return the returncode of the executed command.
59
+
60
+ Redirects stderr of the executed command to stdout.
61
+
62
+ Args:
63
+ cmd: command to execute.
64
+
65
+ Returns:
66
+ output: child process returncode after the command has been executed.
67
+ """
68
+ proc = subprocess.Popen(cmd, universal_newlines=True, shell=True)
69
+ return proc.wait()
70
+
71
+
72
+ def run_cmd_output(cmd: str) -> str:
73
+ """
74
+ Executes command and returns the output.
75
+
76
+ Args:
77
+ cmd: command to execute.
78
+
79
+ Returns:
80
+ output: command output.
81
+ """
82
+ proc = subprocess.run(cmd, capture_output=True, text=True, shell=True)
83
+ return proc.stdout
84
+
85
+
86
+ def compare_versions(version1, version2):
87
+ """
88
+ Compares two version strings.
89
+
90
+ Args:
91
+ version1(str)
92
+ version2(str)
93
+
94
+ Returns:
95
+ 1: when version1 is greater than version2
96
+ -1: when version1 is less than version2
97
+ 0: when two version strings are equal
98
+ """
99
+ v1 = version.parse(version1)
100
+ v2 = version.parse(version2)
101
+
102
+ if v1 < v2:
103
+ return -1
104
+ elif v1 > v2:
105
+ return 1
106
+ else:
107
+ return 0
108
+
109
+
110
+ def get_host_ip_addresses() -> tuple[list[tuple[str, str]], list[tuple[str, str]]]:
111
+ """
112
+ Returns a tuple containing interface name and its IPv4 address as the first item
113
+ and another item with interface name and its IPv6 address.
114
+
115
+ Returns:
116
+ (Tuple[List[Tuple[str, str]], List[Tuple[str, str]]]): where the item contains a list of
117
+ tuples of network interface names and its IPv4 address. The second item is similar but
118
+ contains IPv6 addresses.
119
+ """
120
+ ipv4 = []
121
+ ipv6 = []
122
+
123
+ for interface, snics in psutil.net_if_addrs().items():
124
+ for snic in snics:
125
+ if snic.family == socket.AF_INET:
126
+ ipv4.append((interface, snic.address))
127
+ elif snic.family == socket.AF_INET6:
128
+ ipv6.append((interface, snic.address))
129
+
130
+ return (ipv4, ipv6)
@@ -0,0 +1,37 @@
1
+ {
2
+ "version": 1,
3
+ "disable_existing_loggers": false,
4
+ "formatters": {
5
+ "single": {
6
+ "format": "%(message)s"
7
+ },
8
+ "simple": {
9
+ "format": "[%(asctime)s] [%(levelname)s] (%(name)s) - %(message)s"
10
+ }
11
+ },
12
+ "handlers": {
13
+ "console": {
14
+ "class": "logging.StreamHandler",
15
+ "formatter": "simple"
16
+ },
17
+ "runner_console": {
18
+ "class": "logging.StreamHandler",
19
+ "formatter": "single"
20
+ }
21
+ },
22
+ "root": {
23
+ "level": "INFO",
24
+ "propagate": false,
25
+ "handlers": [
26
+ "console"
27
+ ]
28
+ },
29
+ "loggers": {
30
+ "app_runner": {
31
+ "propagate": false,
32
+ "handlers": [
33
+ "runner_console"
34
+ ]
35
+ }
36
+ }
37
+ }
@@ -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 .nics import execute_nics_command # noqa: F401
@@ -0,0 +1,34 @@
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
+ from argparse import Namespace
20
+
21
+ from ..common.utils import get_host_ip_addresses
22
+
23
+ logger = logging.getLogger("nics")
24
+
25
+
26
+ def execute_nics_command(args: Namespace):
27
+ try:
28
+ ipv4, ipv6 = get_host_ip_addresses()
29
+ ip_addresses = ipv4 if ipv4 else ipv6
30
+ strs = [f"\n\t{item[0]:<15} : {item[1]}" for item in ip_addresses]
31
+ print(f"Available network interface cards/IP addresses: \n{''.join(strs)}")
32
+ except Exception as ex:
33
+ logging.error("Error executing nics command.")
34
+ logger.debug(ex)
@@ -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 .packager import execute_package_command # noqa: F401
@@ -0,0 +1,137 @@
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
+ from argparse import Namespace
20
+ from pathlib import Path
21
+
22
+ from ..common.artifact_sources import ArtifactSources
23
+ from ..common.constants import DefaultValues
24
+ from ..common.enum_types import SdkType
25
+ from .config_reader import ApplicationConfiguration
26
+ from .manifest_files import ApplicationManifest, PackageManifest
27
+ from .models import Models
28
+ from .parameters import PackageBuildParameters, PlatformParameters
29
+ from .platforms import Platform
30
+
31
+
32
+ class PackagingArguments:
33
+ """Processes input arguments for packager"""
34
+
35
+ @property
36
+ def platforms(self) -> list[PlatformParameters]:
37
+ return self._platforms
38
+
39
+ @property
40
+ def build_parameters(self) -> PackageBuildParameters:
41
+ return self._build_parameters
42
+
43
+ @property
44
+ def application_manifest(self) -> ApplicationManifest:
45
+ return self._application_manifest
46
+
47
+ @property
48
+ def package_manifest(self) -> PackageManifest:
49
+ return self._package_manifest
50
+
51
+ def __init__(self, args: Namespace, temp_dir: str) -> None:
52
+ """
53
+ Args:
54
+ args (Namespace): Input arguments for Packager from CLI
55
+ """
56
+ self._logger = logging.getLogger("packager")
57
+
58
+ self._platforms: list[PlatformParameters]
59
+ self._build_parameters = PackageBuildParameters()
60
+ self._artifact_sources = ArtifactSources()
61
+
62
+ if args.source is not None:
63
+ self._artifact_sources.load(args.source)
64
+ else:
65
+ self._artifact_sources.download_manifest()
66
+
67
+ self.build_parameters.username = args.username
68
+ self.build_parameters.uid = args.uid
69
+ self.build_parameters.gid = args.gid
70
+ self.build_parameters.build_cache = args.build_cache
71
+ self.build_parameters.app_config_file_path = args.config
72
+ self.build_parameters.timeout = args.timeout if args.timeout else DefaultValues.TIMEOUT
73
+ self.build_parameters.docs = args.docs if args.docs else None
74
+ self.build_parameters.application = args.application
75
+ self.build_parameters.no_cache = args.no_cache
76
+ self.build_parameters.tarball_output = args.output
77
+ self.build_parameters.cmake_args = args.cmake_args
78
+ self.build_parameters.includes = args.includes
79
+
80
+ models = Models()
81
+ platform = Platform(self._artifact_sources)
82
+ if args.models is not None:
83
+ self.build_parameters.models = models.build(args.models)
84
+
85
+ self._read_application_config_file(args.config)
86
+ self.build_parameters.version = (
87
+ args.version if args.version else self.application_manifest.version
88
+ )
89
+ (
90
+ self.build_parameters.sdk,
91
+ self.build_parameters.holoscan_sdk_version,
92
+ self.build_parameters.monai_deploy_app_sdk_version,
93
+ self._platforms,
94
+ ) = platform.configure_platforms(
95
+ args, temp_dir, self.build_parameters.version, self.build_parameters.application_type
96
+ )
97
+
98
+ if self.build_parameters.sdk == SdkType.Holoscan:
99
+ self.application_manifest.readiness = {
100
+ "type": "command",
101
+ "command": ["/bin/grpc_health_probe", "-addr", ":8777"],
102
+ "initialDelaySeconds": 1,
103
+ "periodSeconds": 10,
104
+ "timeoutSeconds": 1,
105
+ "failureThreshold": 3,
106
+ }
107
+ self.application_manifest.liveness = {
108
+ "type": "command",
109
+ "command": ["/bin/grpc_health_probe", "-addr", ":8777"],
110
+ "initialDelaySeconds": 1,
111
+ "periodSeconds": 10,
112
+ "timeoutSeconds": 1,
113
+ "failureThreshold": 3,
114
+ }
115
+
116
+ self.application_manifest.sdk = self.build_parameters.sdk.value
117
+
118
+ if self.build_parameters.sdk == SdkType.Holoscan:
119
+ self.application_manifest.sdk_version = self.build_parameters.holoscan_sdk_version
120
+ else:
121
+ self.application_manifest.sdk_version = (
122
+ self.build_parameters.monai_deploy_app_sdk_version
123
+ )
124
+
125
+ self._package_manifest.platform_config = args.platform_config.value
126
+
127
+ def _read_application_config_file(self, config_file_path: Path):
128
+ self._logger.info(f"Reading application configuration from {config_file_path}...")
129
+ app_config = ApplicationConfiguration()
130
+ app_config.read(config_file_path)
131
+ self.build_parameters.title = app_config.title()
132
+ self.build_parameters.pip_packages = app_config.pip_packages()
133
+
134
+ self._logger.info("Generating app.json...")
135
+ self._application_manifest = app_config.populate_app_manifest(self.build_parameters)
136
+ self._logger.info("Generating pkg.json...")
137
+ self._package_manifest = app_config.populate_package_manifest(self.build_parameters)