Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ${PROJECT_NAME}-exports not ${ROJECT_NAME}-core-exports for dependencies in CMake scripts #2155

Draft
wants to merge 9 commits into
base: branch-25.06
Choose a base branch
from
20 changes: 10 additions & 10 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ include(${CMAKE_CURRENT_LIST_DIR}/package_config/register_api.cmake)

# Load direct physical package dependencies first, so we fail early. Add all dependencies to our export set
rapids_find_package(Protobuf REQUIRED
BUILD_EXPORT_SET ${PROJECT_NAME}-core-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-core-exports
BUILD_EXPORT_SET ${PROJECT_NAME}-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-exports
)

rapids_find_package(CUDAToolkit REQUIRED
BUILD_EXPORT_SET ${PROJECT_NAME}-core-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-core-exports
BUILD_EXPORT_SET ${PROJECT_NAME}-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-exports
)

rapids_find_package(ZLIB
BUILD_EXPORT_SET ${PROJECT_NAME}-core-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-core-exports
BUILD_EXPORT_SET ${PROJECT_NAME}-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-exports
)

if(MORPHEUS_BUILD_BENCHMARKS)
# google benchmark
# ================
include(${rapids-cmake-dir}/cpm/gbench.cmake)
rapids_cpm_gbench(
BUILD_EXPORT_SET ${PROJECT_NAME}-core-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-core-exports
BUILD_EXPORT_SET ${PROJECT_NAME}-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-exports
)
endif()

Expand All @@ -66,8 +66,8 @@ if(MORPHEUS_BUILD_TESTS)
# ===========
include(${rapids-cmake-dir}/cpm/gtest.cmake)
rapids_cpm_gtest(
BUILD_EXPORT_SET ${PROJECT_NAME}-core-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-core-exports
BUILD_EXPORT_SET ${PROJECT_NAME}-exports
INSTALL_EXPORT_SET ${PROJECT_NAME}-exports
)
endif()

Expand Down
11 changes: 9 additions & 2 deletions docs/source/developer_guide/guides/3_simple_cpp_stage.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ limitations under the License.

# Simple C++ Stage
## Building the Example
The code for this guide can be found in the `examples/developer_guide/3_simple_cpp_stage` directory of the Morpheus repository. There are two ways to build the example. The first is to build the examples along with Morpheus by passing the `-DMORPHEUS_BUILD_EXAMPLES=ON` flag to CMake, for users using the `scripts/compile.sh` at the root of the Morpheus repo can do this by setting the `CMAKE_CONFIGURE_EXTRA_ARGS` environment variable:
The code for this guide can be found in the `examples/developer_guide/3_simple_cpp_stage` directory of the Morpheus repository. There are two ways to build the example.

The first is to build the examples along with Morpheus by passing the `-DMORPHEUS_BUILD_EXAMPLES=ON` flag to CMake. This approach is preferable for users who are already building Morpheus from source. For users using the `scripts/compile.sh` at the root of the Morpheus repo can do this by setting the `CMAKE_CONFIGURE_EXTRA_ARGS` environment variable:
```bash
CMAKE_CONFIGURE_EXTRA_ARGS="-DMORPHEUS_BUILD_EXAMPLES=ON" ./scripts/compile.sh
```

The second method is to build the example as a standalone project. From the root of the Morpheus repo execute:
The second method is to build the example as a standalone project. For those using the release container, additional dependencies will need to be installed prior to performing the build:
```bash
conda env update --solver=libmamba -n morpheus --file /workspace/conda/environments/dev_cuda-125_arch-$(arch).yaml
```

From the root of the Morpheus repo execute:
```bash
cd examples/developer_guide/3_simple_cpp_stage
./compile.sh
Expand Down
26 changes: 13 additions & 13 deletions examples/abp_nvsmi_detection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,22 +225,22 @@ Inference Rate[Complete]: 1242inf [00:00, 1863.04inf/s]
====Pipeline Complete====
```

The output file `.tmp/output/detections.jsonlines` will contain a single boolean value for each input line. At some point the values will switch from `0` to `1`:
The output file `.tmp/output/abp_nvsmi_detections.jsonlines` will contain a single boolean value for each input line. At some point the values will switch from `false` to `true`:

```
...
{"mining": 0}
{"mining": 0}
{"mining": 0}
{"mining": 0}
{"mining": 1}
{"mining": 1}
{"mining": 1}
{"mining": 1}
{"mining": 1}
{"mining": 1}
{"mining": 1}
{"mining": 1}
{"mining": false}
{"mining": false}
{"mining": false}
{"mining": false}
{"mining": true}
{"mining": true}
{"mining": true}
{"mining": true}
{"mining": true}
{"mining": true}
{"mining": true}
{"mining": true}
...
```

Expand Down
1 change: 1 addition & 0 deletions examples/developer_guide/2_2_rabbitmq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pip install -r examples/developer_guide/2_2_rabbitmq/requirements.txt
## Launch the reader
In a second terminal from the root of the Morpheus repo execute:
```bash
export MORPHEUS_ROOT=$(pwd)
python examples/developer_guide/2_2_rabbitmq/read_simple.py
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ morpheus_add_pybind11_module(pass_thru_cpp
morpheus
CUDA::nvtx3
cudf::cudf
glog::glog
)

list(POP_BACK CMAKE_MESSAGE_CONTEXT)
2 changes: 2 additions & 0 deletions examples/developer_guide/4_rabbitmq_cpp_stage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The image can be verified with the web management console by opening http://loca
## Launch the reader
In a second terminal from the root of the Morpheus repo execute:
```bash
export MORPHEUS_ROOT=$(pwd)
python examples/developer_guide/4_rabbitmq_cpp_stage/src/read_simple.py
```

Expand All @@ -68,6 +69,7 @@ If no exchange named 'logs' exists in RabbitMQ it will be created.
## Launch the writer
In a third terminal from the root of the Morpheus repo execute:
```bash
export MORPHEUS_ROOT=$(pwd)
python examples/developer_guide/4_rabbitmq_cpp_stage/src/write_simple.py
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#=============================================================================
# =============================================================================
# SPDX-FileCopyrightText: Copyright (c) 2022-2025, 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
# 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.
#=============================================================================
# =============================================================================

function(find_and_configure_SimpleAmqpClient version)

list(APPEND CMAKE_MESSAGE_CONTEXT "SimpleAmqpClient")

find_package(rabbitmq REQUIRED)
Expand All @@ -25,18 +24,18 @@ function(find_and_configure_SimpleAmqpClient version)
GLOBAL_TARGETS
SimpleAmqpClient
BUILD_EXPORT_SET
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
INSTALL_EXPORT_SET
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
CPM_ARGS
PATCH_COMMAND git checkout -- . && git apply --whitespace=fix ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/patches/simpleamqpclient_cpp_version.patch
GIT_REPOSITORY https://github.com/alanxz/SimpleAmqpClient
GIT_TAG "v${version}"
GIT_SHALLOW TRUE
OPTIONS "Rabbitmqc_INCLUDE_DIR ${rabbitmq_SOURCE_DIR}/include"
"Rabbitmqc_LIBRARY ${rabbitmq_BINARY_DIR}/librabbitmq/librabbitmq.so"
"BUILD_API_DOCS OFF"
"BUILD_SHARED_LIBS OFF"
GIT_REPOSITORY https://github.com/alanxz/SimpleAmqpClient
GIT_TAG "v${version}"
GIT_SHALLOW TRUE
OPTIONS "Rabbitmqc_INCLUDE_DIR ${rabbitmq_SOURCE_DIR}/include"
"Rabbitmqc_LIBRARY ${rabbitmq_BINARY_DIR}/librabbitmq/librabbitmq.so"
"BUILD_API_DOCS OFF"
"BUILD_SHARED_LIBS OFF"
)

# Needed to pick up the generated export.h
Expand All @@ -45,7 +44,6 @@ function(find_and_configure_SimpleAmqpClient version)
# Suppress #warning deprecation messages from rabbitmq and SimpleAmqpClient
# https://github.com/nv-morpheus/Morpheus/issues/1255
target_compile_options(SimpleAmqpClient PRIVATE -Wno-cpp -DBOOST_DISABLE_PRAGMA_MESSAGE)

endfunction()

find_and_configure_SimpleAmqpClient(${SIMPLE_AMQP_CLIENT_VERSION})
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
#=============================================================================
# =============================================================================
# SPDX-FileCopyrightText: Copyright (c) 2022-2025, 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
# 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.
#=============================================================================
# =============================================================================

function(find_and_configure_rabbitmq version)

list(APPEND CMAKE_MESSAGE_CONTEXT "rabbitmq")

# Commit 7fa7b0b contains unreleased cmake fixes which currently only exist in the master branch of the repo.
# https://github.com/alanxz/rabbitmq-c/issues/740

rapids_cpm_find(rabbitmq ${version}
GLOBAL_TARGETS
rabbitmq rabbitmq::rabbitmq
BUILD_EXPORT_SET
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
INSTALL_EXPORT_SET
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/alanxz/rabbitmq-c
GIT_SHALLOW TRUE
OPTIONS "BUILD_EXAMPLES OFF"
"BUILD_TESTING OFF"
"BUILD_TOOLS OFF"
GIT_REPOSITORY https://github.com/alanxz/rabbitmq-c
GIT_SHALLOW TRUE
OPTIONS "BUILD_EXAMPLES OFF"
"BUILD_TESTING OFF"
"BUILD_TOOLS OFF"
)

if(rabbitmq_ADDED)
set(rabbitmq_SOURCE_DIR "${rabbitmq_SOURCE_DIR}" PARENT_SCOPE)
set(rabbitmq_BINARY_DIR "${rabbitmq_BINARY_DIR}" PARENT_SCOPE)
endif()

endfunction()

find_and_configure_rabbitmq(${RABBITMQ_VERSION})
10 changes: 5 additions & 5 deletions python/morpheus/morpheus/_lib/cmake/libmorpheus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ include(GNUInstallDirs)

install(
TARGETS
morpheus
morpheus
EXPORT
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
LIBRARY
DESTINATION ${lib_dir}
FILE_SET
public_headers
public_headers
)

# ##################################################################################################
Expand Down Expand Up @@ -221,7 +221,7 @@ endif()
# Need to explicitly set VERSION ${PROJECT_VERSION} here since rapids_cmake gets
# confused with the `RAPIDS_VERSION` variable we use
rapids_export(INSTALL ${PROJECT_NAME}
EXPORT_SET ${PROJECT_NAME}-core-exports
EXPORT_SET ${PROJECT_NAME}-exports
GLOBAL_TARGETS morpheus
VERSION ${PROJECT_VERSION}
NAMESPACE morpheus::
Expand All @@ -232,7 +232,7 @@ rapids_export(INSTALL ${PROJECT_NAME}
# ##################################################################################################
# - build export ----------------------------------------------------------------------------------
rapids_export(BUILD ${PROJECT_NAME}
EXPORT_SET ${PROJECT_NAME}-core-exports
EXPORT_SET ${PROJECT_NAME}-exports
GLOBAL_TARGETS morpheus
VERSION ${PROJECT_VERSION}
LANGUAGES C CXX CUDA
Expand Down
4 changes: 2 additions & 2 deletions python/morpheus/morpheus/_lib/doca/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ target_sources(morpheus_doca
TYPE HEADERS
BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include"
FILES
${morpheus_doca_public_headers}
${morpheus_doca_public_headers}
)

target_compile_definitions(morpheus_doca
Expand Down Expand Up @@ -96,7 +96,7 @@ install(
TARGETS
morpheus_doca
EXPORT
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
LIBRARY
DESTINATION ${lib_dir}
FILE_SET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class ProgressBarContextManager
{
std::lock_guard<std::mutex> lock(m_mutex);

// To avoid display_all() being executed after calling mark_pbar_as_completed() in some race conditions
if (m_is_completed)
{
return;
}

// A bit of hack here to make the font settings work. Indicators enables the font options only if the bars are
// output to standard streams (see is_colorized() in <indicators/termcolor.hpp>), but since we are still using
// the ostream (m_stdout_os) that is connected to the console terminal, the font options should be enabled.
Expand All @@ -114,11 +120,11 @@ class ProgressBarContextManager
{
pbar->print_progress(true);
m_stdout_os << termcolor::reset; // The font option only works for the current bar
m_stdout_os << "\n";
m_stdout_os << std::endl;
}

// After each round of display, move cursor up ("\033[A") to the beginning of the first bar
m_stdout_os << "\033[" << m_progress_bars.size() << "A";
m_stdout_os << "\033[" << m_progress_bars.size() << "A" << std::flush;
}

void mark_pbar_as_completed(size_t bar_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import pandas as pd
import pyarrow as pa
import websockets.legacy.server
from websockets.server import serve
from websockets.server import serve # pylint: disable=no-name-in-module

from morpheus.cli.register_stage import register_stage
from morpheus.config import Config
Expand Down Expand Up @@ -207,7 +207,9 @@ async def client_connected(websocket: websockets.legacy.server.WebSocketServerPr
except Closed:
break
except Exception as ex:
logger.exception("Error occurred trying to send message over socket", exc_info=ex)
if not self._server_close_event.is_set():
# Don't log if we are shutting down
logger.exception("Error occurred trying to send message over socket", exc_info=ex)

logger.info("Disconnected from: %s:%s", *websocket.remote_address)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ add_library(${PROJECT_NAME}::morpheus_llm ALIAS morpheus_llm)

# morpheus_llm can be built two ways -
# 1. For development purposes (eg. scripts/compile.sh) all the functional blocks are built.
# This includes morpheus (core), morpheus_llm, morpheus_dfp etc. In this case we
# set dependencies on build targets across components.
# This includes morpheus (core), morpheus_llm, morpheus_dfp etc. In this case we
# set dependencies on build targets across components.
# 2. For conda packaging purposes morpheus_llm is built on its own. In this case
# the dependencies (including morpheus-core) are loaded from the conda enviroment.
if (MORPHEUS_BUILD_MORPHEUS_CORE)
# the dependencies (including morpheus-core) are loaded from the conda enviroment.
if(MORPHEUS_BUILD_MORPHEUS_CORE)
# Add a dependency on the morpheus cpython libraries
get_property(py_morpheus_target GLOBAL PROPERTY py_morpheus_target_property)
add_dependencies(morpheus_llm ${py_morpheus_target})
Expand Down Expand Up @@ -81,7 +81,6 @@ target_sources(morpheus_llm
${morpheus_llm_public_headers}
)


# We want to use RUNPATH instead of RPATH to allow LD_LIBRARY_PATH to take precedence over the paths specified in the
# binary. This is necessary to allow ld to find the real libcuda.so instead of the stub. Eventually, this can be removed
# once upgraded to cuda-python 12.1. Ideally, cuda-python would just load libcuda.so.1 which would take precedence over
Expand Down Expand Up @@ -113,11 +112,11 @@ include(GNUInstallDirs)

install(
TARGETS
morpheus_llm
morpheus_llm
EXPORT
${PROJECT_NAME}-core-exports
${PROJECT_NAME}-exports
LIBRARY
DESTINATION ${lib_dir}
FILE_SET
public_headers
public_headers
)