Skip to content

Commit a390f10

Browse files
committed
Enable packaging
Signed-off-by: Victor Chang <[email protected]>
1 parent baab042 commit a390f10

File tree

9 files changed

+110
-10
lines changed

9 files changed

+110
-10
lines changed

applications/distributed/grpc/grpc_endoscopy_tool_tracking/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,9 @@ The following launch profiles are available:
145145
[error] [program.cpp:614] Event notification 2 for entity [video_in__outgoing_requests] with id [33] received in an unexpected state [Origin]
146146
```
147147

148+
149+
## Containerize the application
150+
151+
To containerize the application using [Holoscan CLI](https://docs.nvidia.com/holoscan/sdk-user-guide/cli/cli.html), first build the application using `./dev_container build_and_install grpc_endoscopy_tool_tracking`, run the `package-app.sh` script in the [cpp](./cpp/package-app.sh) directory and then follow the generated output to package and run the application.
152+
153+
Refer to the [Packaging Holoscan Applications](https://docs.nvidia.com/holoscan/sdk-user-guide/holoscan_packager.html) section of the [Holoscan User Guide](https://docs.nvidia.com/holoscan/sdk-user-guide/) to learn more about installing the Holoscan CLI or packaging your application using Holoscan CLI.

applications/distributed/grpc/grpc_endoscopy_tool_tracking/cpp/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,19 @@ if(HOLOHUB_DOWNLOAD_DATASETS)
8080
)
8181
add_dependencies(grpc_endoscopy_tool_tracking_edge endoscopy_data)
8282
endif()
83+
84+
# Install application and dependencies into the install/ directory for packaging
85+
install(
86+
TARGETS grpc_endoscopy_tool_tracking_edge
87+
DESTINATION bin/grpc_endoscopy_tool_tracking/cpp
88+
)
89+
90+
install(
91+
TARGETS grpc_endoscopy_tool_tracking_cloud
92+
DESTINATION bin/grpc_endoscopy_tool_tracking/cpp
93+
)
94+
95+
install(
96+
FILES endoscopy_tool_tracking.yaml
97+
DESTINATION bin/grpc_endoscopy_tool_tracking/cpp
98+
)

applications/distributed/grpc/grpc_endoscopy_tool_tracking/cpp/cloud/app_cloud_main.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,19 @@ void signal_handler(int signum) {
7171
}
7272

7373
/** Helper function to parse benchmarking setting from the configuration file */
74-
void parse_config(const std::string& config_path, bool& benchmarking) {
74+
void parse_config(const std::string& config_path, bool& benchmarking,
75+
bool& enable_health_check_service) {
7576
auto config = holoscan::Config(config_path);
7677
auto& yaml_nodes = config.yaml_nodes();
7778
for (const auto& yaml_node : yaml_nodes) {
7879
try {
7980
auto application = yaml_node["application"];
80-
if (application.IsMap()) { benchmarking = application["benchmarking"].as<bool>(); }
81+
if (application.IsMap()) {
82+
benchmarking = application["benchmarking"].as<bool>();
83+
enable_health_check_service = application["grpc_health_check"].as<bool>();
84+
} else {
85+
HOLOSCAN_LOG_ERROR("Error parsing configuration file, 'application' is not a map");
86+
}
8187
} catch (std::exception& e) {
8288
HOLOSCAN_LOG_ERROR("Error parsing configuration file: {}", e.what());
8389
benchmarking = false;
@@ -143,10 +149,12 @@ int main(int argc, char** argv) {
143149
}
144150

145151
bool benchmarking = false;
146-
parse_config(config_path, benchmarking);
152+
bool enable_health_check_service = false;
153+
parse_config(config_path, benchmarking, enable_health_check_service);
147154

148155
// Register each gRPC service with a Holoscan application:
149-
// - the callback function (create_application_instance_func) is used to create a new instance of
156+
// - the callback function (create_application_instance_func) is used to create a new instance
157+
// of
150158
// the application when a new RPC call is received.
151159
ApplicationFactory::get_instance()->register_application(
152160
"EntityStream",

applications/distributed/grpc/grpc_endoscopy_tool_tracking/cpp/cloud/app_cloud_pipeline.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
#ifndef GRPC_H264_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
19-
#define GRPC_H264_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
18+
#ifndef GRPC_GRPC_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
19+
#define GRPC_GRPC_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
2020

2121
#include <gxf/core/entity.hpp>
2222
#include <holoscan/holoscan.hpp>
@@ -108,4 +108,4 @@ class AppCloudPipeline : public HoloscanGrpcApplication {
108108
}
109109
};
110110
} // namespace holohub::grpc_h264_endoscopy_tool_tracking
111-
#endif /* GRPC_H264_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP */
111+
#endif /* GRPC_GRPC_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP */

applications/distributed/grpc/grpc_endoscopy_tool_tracking/cpp/cloud/grpc_service.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class GrpcService {
5757
return instance;
5858
}
5959

60-
void start() {
61-
grpc::EnableDefaultHealthCheckService(true);
60+
void start(bool enable_health_check_service = true) {
61+
grpc::EnableDefaultHealthCheckService(enable_health_check_service);
6262
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
6363

6464
service_ = std::make_unique<HoloscanEntityServiceImpl>(

applications/distributed/grpc/grpc_endoscopy_tool_tracking/cpp/endoscopy_tool_tracking.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ application:
2424
outputFormats: ["screen"]
2525
multifragment: false # default: false, true to run in multi-fragment mode, false otherwise
2626
benchmarking: false # default: false, true to enable Data Flow Benchmarking, false otherwise
27+
grpc_health_check: false # default: false, true to enable gRPC health check, false otherwise
2728

29+
resources:
30+
cpu: 1
31+
gpu: 1
32+
memory: 1Gi
33+
gpuMemory: 1Gi
34+
2835
replayer:
2936
basename: "surgical_video"
3037
frame_rate: 0 # as specified in timestamps
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
# SPDX-FileCopyrightText: Copyright (c) 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+
set -e
17+
18+
GIT_ROOT=$(readlink -f ./$(git rev-parse --show-cdup))
19+
APP_PATH="$GIT_ROOT/install/bin/grpc_endoscopy_tool_tracking/cpp"
20+
21+
. $GIT_ROOT/utilities/bash_utils.sh
22+
23+
if [ ! -d $APP_PATH ]; then
24+
print_error "Please build the gRPC Endoscopy Tool Tracking application first with the following command:"
25+
print_error "./dev_container build_and_install grpc_endoscopy_tool_tracking"
26+
exit -1
27+
fi
28+
29+
PLATFORM=x64-workstation
30+
GPU=$(get_host_gpu)
31+
if [ $(get_host_arch) == "aarch64" ]; then
32+
PLATFORM=igx-orin-devkit
33+
fi
34+
35+
echo -e "Copying the required files to the application directory..."
36+
# cp -rf "$GIT_ROOT/install/lib/." "$APP_PATH"
37+
# cp -rf "$GIT_ROOT/install/lib/gxf_extensions/." "$APP_PATH"
38+
sed -i 's|../../../../../lib/gxf_extensions/||' "$APP_PATH/endoscopy_tool_tracking.yaml"
39+
echo -e "done\n"
40+
41+
echo -e Install Holoscan CLI and then use the following commands to package and run the Endoscopy Tool Tracking application:
42+
echo -e "==========Package the application=========="
43+
echo -e "Cloud:"
44+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform [igx-orin-devkit | jetson-agx-orin-devkit | sbsa, x64-workstation] --platform-config [igpu | dgpu] -t holohub-grpc-endoscopy-tool-tracking-cloud $APP_PATH/grpc_endoscopy_tool_tracking_cloud --include onnx holoviz$ --add $GIT_ROOT/install/lib${NOCOLOR}"
45+
echo -e "\nFor example:"
46+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform ${PLATFORM} --platform-config ${GPU} -t holohub-grpc-endoscopy-tool-tracking-cloud $APP_PATH/grpc_endoscopy_tool_tracking_cloud --include onnx holoviz --add $GIT_ROOT/install/lib${NOCOLOR}"
47+
echo -e "\nEdge:"
48+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform [igx-orin-devkit | jetson-agx-orin-devkit | sbsa, x64-workstation] --platform-config [igpu | dgpu] -t holohub-grpc-endoscopy-tool-tracking-edge $APP_PATH/grpc_endoscopy_tool_tracking_edge --include onnx holoviz --add $GIT_ROOT/install/lib${NOCOLOR}"
49+
echo -e "\nFor example:"
50+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform ${PLATFORM} --platform-config ${GPU} -t holohub-grpc-endoscopy-tool-tracking-edge $APP_PATH/grpc_endoscopy_tool_tracking_edge --include onnx holoviz --add $GIT_ROOT/install/lib${NOCOLOR}"
51+
echo -e "\n\n==========Run the application=========="
52+
echo -e "Cloud:"
53+
echo -e "${YELLOW}holoscan run -r \$(docker images | grep "holohub-grpc-endoscopy-tool-tracking-cloud" | awk '{print \$1\":\"\$2}') -i $GIT_ROOT/data/endoscopy${NOCOLOR}"
54+
echo -e "\nEdge:"
55+
echo -e "${YELLOW}holoscan run -r \$(docker images | grep "holohub-grpc-endoscopy-tool-tracking-edge" | awk '{print \$1\":\"\$2}') -i $GIT_ROOT/data/endoscopy${NOCOLOR}"
56+
echo -e "\n\nRefer to Packaging Holoscan Applications (https://docs.nvidia.com/holoscan/sdk-user-guide/holoscan_packager.html) in the User Guide for more information."

cmake/grpc_generate_cpp.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ function(grpc_generate_cpp SRCS HDRS INCLUDE_DIRS)
7878
endfunction()
7979

8080
include(FetchContent)
81-
set(ABSL_ENABLE_INSTALL ON)
81+
# set(ABSL_ENABLE_INSTALL OFF)
82+
# set(gRPC_INSTALL OFF)
83+
# set(protobuf_INSTALL OFF)
84+
# set(CARES_INSTALL OFF)
8285
FetchContent_Declare(
8386
grpc
8487
GIT_REPOSITORY https://github.com/grpc/grpc.git

operators/grpc_operators/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ target_include_directories(grpc_operators
5656
${CMAKE_CURRENT_SOURCE_DIR}
5757
${INCLUDE_DIRS}
5858
${PROTOBUF_INCLUDE_DIRS})
59+
60+
# Installation
61+
install(TARGETS grpc_operators)
62+

0 commit comments

Comments
 (0)