Skip to content

Commit

Permalink
Enable packaging
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Nov 26, 2024
1 parent baab042 commit a390f10
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,9 @@ The following launch profiles are available:
[error] [program.cpp:614] Event notification 2 for entity [video_in__outgoing_requests] with id [33] received in an unexpected state [Origin]
```


## Containerize the application

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.

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.
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,19 @@ if(HOLOHUB_DOWNLOAD_DATASETS)
)
add_dependencies(grpc_endoscopy_tool_tracking_edge endoscopy_data)
endif()

# Install application and dependencies into the install/ directory for packaging
install(
TARGETS grpc_endoscopy_tool_tracking_edge
DESTINATION bin/grpc_endoscopy_tool_tracking/cpp
)

install(
TARGETS grpc_endoscopy_tool_tracking_cloud
DESTINATION bin/grpc_endoscopy_tool_tracking/cpp
)

install(
FILES endoscopy_tool_tracking.yaml
DESTINATION bin/grpc_endoscopy_tool_tracking/cpp
)
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ void signal_handler(int signum) {
}

/** Helper function to parse benchmarking setting from the configuration file */
void parse_config(const std::string& config_path, bool& benchmarking) {
void parse_config(const std::string& config_path, bool& benchmarking,
bool& enable_health_check_service) {
auto config = holoscan::Config(config_path);
auto& yaml_nodes = config.yaml_nodes();
for (const auto& yaml_node : yaml_nodes) {
try {
auto application = yaml_node["application"];
if (application.IsMap()) { benchmarking = application["benchmarking"].as<bool>(); }
if (application.IsMap()) {
benchmarking = application["benchmarking"].as<bool>();
enable_health_check_service = application["grpc_health_check"].as<bool>();
} else {
HOLOSCAN_LOG_ERROR("Error parsing configuration file, 'application' is not a map");
}
} catch (std::exception& e) {
HOLOSCAN_LOG_ERROR("Error parsing configuration file: {}", e.what());
benchmarking = false;
Expand Down Expand Up @@ -143,10 +149,12 @@ int main(int argc, char** argv) {
}

bool benchmarking = false;
parse_config(config_path, benchmarking);
bool enable_health_check_service = false;
parse_config(config_path, benchmarking, enable_health_check_service);

// Register each gRPC service with a Holoscan application:
// - the callback function (create_application_instance_func) is used to create a new instance of
// - the callback function (create_application_instance_func) is used to create a new instance
// of
// the application when a new RPC call is received.
ApplicationFactory::get_instance()->register_application(
"EntityStream",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

#ifndef GRPC_H264_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
#define GRPC_H264_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
#ifndef GRPC_GRPC_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP
#define GRPC_GRPC_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP

#include <gxf/core/entity.hpp>
#include <holoscan/holoscan.hpp>
Expand Down Expand Up @@ -108,4 +108,4 @@ class AppCloudPipeline : public HoloscanGrpcApplication {
}
};
} // namespace holohub::grpc_h264_endoscopy_tool_tracking
#endif /* GRPC_H264_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP */
#endif /* GRPC_GRPC_ENDOSCOPY_TOOL_TRACKING_CPP_CLOUD_APP_CLOUD_PIPELINE_HPP */
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class GrpcService {
return instance;
}

void start() {
grpc::EnableDefaultHealthCheckService(true);
void start(bool enable_health_check_service = true) {
grpc::EnableDefaultHealthCheckService(enable_health_check_service);
grpc::reflection::InitProtoReflectionServerBuilderPlugin();

service_ = std::make_unique<HoloscanEntityServiceImpl>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ application:
outputFormats: ["screen"]
multifragment: false # default: false, true to run in multi-fragment mode, false otherwise
benchmarking: false # default: false, true to enable Data Flow Benchmarking, false otherwise
grpc_health_check: false # default: false, true to enable gRPC health check, false otherwise

resources:
cpu: 1
gpu: 1
memory: 1Gi
gpuMemory: 1Gi

replayer:
basename: "surgical_video"
frame_rate: 0 # as specified in timestamps
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e

GIT_ROOT=$(readlink -f ./$(git rev-parse --show-cdup))
APP_PATH="$GIT_ROOT/install/bin/grpc_endoscopy_tool_tracking/cpp"

. $GIT_ROOT/utilities/bash_utils.sh

if [ ! -d $APP_PATH ]; then
print_error "Please build the gRPC Endoscopy Tool Tracking application first with the following command:"
print_error "./dev_container build_and_install grpc_endoscopy_tool_tracking"
exit -1
fi

PLATFORM=x64-workstation
GPU=$(get_host_gpu)
if [ $(get_host_arch) == "aarch64" ]; then
PLATFORM=igx-orin-devkit
fi

echo -e "Copying the required files to the application directory..."
# cp -rf "$GIT_ROOT/install/lib/." "$APP_PATH"
# cp -rf "$GIT_ROOT/install/lib/gxf_extensions/." "$APP_PATH"
sed -i 's|../../../../../lib/gxf_extensions/||' "$APP_PATH/endoscopy_tool_tracking.yaml"
echo -e "done\n"

echo -e Install Holoscan CLI and then use the following commands to package and run the Endoscopy Tool Tracking application:
echo -e "==========Package the application=========="
echo -e "Cloud:"
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}"
echo -e "\nFor example:"
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}"
echo -e "\nEdge:"
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}"
echo -e "\nFor example:"
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}"
echo -e "\n\n==========Run the application=========="
echo -e "Cloud:"
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}"
echo -e "\nEdge:"
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}"
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."
5 changes: 4 additions & 1 deletion cmake/grpc_generate_cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ function(grpc_generate_cpp SRCS HDRS INCLUDE_DIRS)
endfunction()

include(FetchContent)
set(ABSL_ENABLE_INSTALL ON)
# set(ABSL_ENABLE_INSTALL OFF)
# set(gRPC_INSTALL OFF)
# set(protobuf_INSTALL OFF)
# set(CARES_INSTALL OFF)
FetchContent_Declare(
grpc
GIT_REPOSITORY https://github.com/grpc/grpc.git
Expand Down
4 changes: 4 additions & 0 deletions operators/grpc_operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ target_include_directories(grpc_operators
${CMAKE_CURRENT_SOURCE_DIR}
${INCLUDE_DIRS}
${PROTOBUF_INCLUDE_DIRS})

# Installation
install(TARGETS grpc_operators)

0 comments on commit a390f10

Please sign in to comment.