Skip to content

Commit

Permalink
Implement C++ version of MonitorStage (#1908)
Browse files Browse the repository at this point in the history
Implemented C++ `MonitorStage` based on [indicators](https://github.com/p-ranav/indicators) library (supports progress bar display)
- Each `MonitorStage` displays a progress bar with customized description tag, message unit and (optional) message count method. Customized font is supported.
- Supports `ControlMessage` and `MessageMeta` as input type
- Able to run multiple `MonitorStage`s within the same pipeline

A quick demo:
![Screencast from 10-08-2024 10-23-41 AM (1)](https://github.com/user-attachments/assets/9b9cbf26-e85c-49b1-8b9d-4af8c3e5e73b)


- **Note**: `indicators` library does not have official support for displaying the progress bars with other log output. This PR uses this [workaround](p-ranav/indicators#107) to enable displaying progress bars alongside other log outputs.

Need to merge nv-morpheus/utilities#78

Closes [#804](#804)


## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/nv-morpheus/Morpheus/blob/main/docs/source/developer_guide/contributing.md).
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.

Authors:
  - Yuchen Zhang (https://github.com/yczhang-nv)

Approvers:
  - Michael Demoret (https://github.com/mdemoret-nv)
  - Christopher Harris (https://github.com/cwharris)

URL: #1908
  • Loading branch information
yczhang-nv authored Nov 22, 2024
1 parent e90bafe commit 747680c
Show file tree
Hide file tree
Showing 20 changed files with 892 additions and 50 deletions.
4 changes: 4 additions & 0 deletions cmake/dependencies_core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "dep_core")
# =========
morpheus_utils_configure_cccl()

# indicators
# ==========
morpheus_utils_configure_indicators()

# matx
# ====
morpheus_utils_configure_matx()
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies:
- gxx=12.1
- huggingface_hub=0.20.2
- include-what-you-use=0.20
- indicators=2.3
- ipython
- isort
- jsonpatch>=1.33
Expand Down
1 change: 1 addition & 0 deletions conda/environments/dev_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies:
- gtest=1.14
- gxx=12.1
- include-what-you-use=0.20
- indicators=2.3
- ipython
- isort
- libcublas-dev
Expand Down
1 change: 1 addition & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ dependencies:
- cmake=3.27
- cuda-cudart-dev=12.5
- cuda-version=12.5
- indicators=2.3 # C++ library for displaying progress bars
- libtool # Needed for DOCA build
- ninja=1.11
- pkg-config=0.29 # for mrc cmake
Expand Down
1 change: 1 addition & 0 deletions python/morpheus/morpheus/_lib/cmake/libmorpheus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ add_library(${PROJECT_NAME}::morpheus ALIAS morpheus)

target_link_libraries(morpheus
PRIVATE
indicators::indicators
matx::matx
$<$<CONFIG:Debug>:ZLIB::ZLIB>
PUBLIC
Expand Down
103 changes: 103 additions & 0 deletions python/morpheus/morpheus/_lib/common/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ __all__ = [
"FilterSource",
"HttpEndpoint",
"HttpServer",
"IndicatorsFontStyle",
"IndicatorsTextColor",
"Tensor",
"TypeId",
"determine_file_type",
Expand Down Expand Up @@ -120,6 +122,107 @@ class HttpServer():
def start(self) -> None: ...
def stop(self) -> None: ...
pass
class IndicatorsFontStyle():
"""
Members:
bold
dark
italic
underline
blink
reverse
concealed
crossed
"""
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: int) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __repr__(self) -> str: ...
def __setstate__(self, state: int) -> None: ...
@property
def name(self) -> str:
"""
:type: str
"""
@property
def value(self) -> int:
"""
:type: int
"""
__members__: dict # value = {'bold': <IndicatorsFontStyle.bold: 0>, 'dark': <IndicatorsFontStyle.dark: 1>, 'italic': <IndicatorsFontStyle.italic: 2>, 'underline': <IndicatorsFontStyle.underline: 3>, 'blink': <IndicatorsFontStyle.blink: 4>, 'reverse': <IndicatorsFontStyle.reverse: 5>, 'concealed': <IndicatorsFontStyle.concealed: 6>, 'crossed': <IndicatorsFontStyle.crossed: 7>}
blink: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.blink: 4>
bold: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.bold: 0>
concealed: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.concealed: 6>
crossed: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.crossed: 7>
dark: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.dark: 1>
italic: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.italic: 2>
reverse: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.reverse: 5>
underline: morpheus._lib.common.IndicatorsFontStyle # value = <IndicatorsFontStyle.underline: 3>
pass
class IndicatorsTextColor():
"""
Members:
grey
red
green
yellow
blue
magenta
cyan
white
unspecified
"""
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: int) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __repr__(self) -> str: ...
def __setstate__(self, state: int) -> None: ...
@property
def name(self) -> str:
"""
:type: str
"""
@property
def value(self) -> int:
"""
:type: int
"""
__members__: dict # value = {'grey': <IndicatorsTextColor.grey: 0>, 'red': <IndicatorsTextColor.red: 1>, 'green': <IndicatorsTextColor.green: 2>, 'yellow': <IndicatorsTextColor.yellow: 3>, 'blue': <IndicatorsTextColor.blue: 4>, 'magenta': <IndicatorsTextColor.magenta: 5>, 'cyan': <IndicatorsTextColor.cyan: 6>, 'white': <IndicatorsTextColor.white: 7>, 'unspecified': <IndicatorsTextColor.unspecified: 8>}
blue: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.blue: 4>
cyan: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.cyan: 6>
green: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.green: 2>
grey: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.grey: 0>
magenta: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.magenta: 5>
red: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.red: 1>
unspecified: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.unspecified: 8>
white: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.white: 7>
yellow: morpheus._lib.common.IndicatorsTextColor # value = <IndicatorsTextColor.yellow: 3>
pass
class Tensor():
@staticmethod
def from_cupy(arg0: object) -> Tensor: ...
Expand Down
23 changes: 23 additions & 0 deletions python/morpheus/morpheus/_lib/common/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <pybind11/pybind11.h>
#include <pybind11/pytypes.h> // for return_value_policy::reference
// for pathlib.Path -> std::filesystem::path conversions
#include <indicators/color.hpp>
#include <indicators/font_style.hpp>
#include <pybind11/stl.h> // IWYU pragma: keep
#include <pybind11/stl/filesystem.h> // IWYU pragma: keep

Expand Down Expand Up @@ -169,6 +171,27 @@ PYBIND11_MODULE(common, _module)
.def("__enter__", &HttpServerInterfaceProxy::enter, py::return_value_policy::reference)
.def("__exit__", &HttpServerInterfaceProxy::exit);

py::enum_<indicators::Color>(_module, "IndicatorsTextColor")
.value("grey", indicators::Color::grey)
.value("red", indicators::Color::red)
.value("green", indicators::Color::green)
.value("yellow", indicators::Color::yellow)
.value("blue", indicators::Color::blue)
.value("magenta", indicators::Color::magenta)
.value("cyan", indicators::Color::cyan)
.value("white", indicators::Color::white)
.value("unspecified", indicators::Color::unspecified);

py::enum_<indicators::FontStyle>(_module, "IndicatorsFontStyle")
.value("bold", indicators::FontStyle::bold)
.value("dark", indicators::FontStyle::dark)
.value("italic", indicators::FontStyle::italic)
.value("underline", indicators::FontStyle::underline)
.value("blink", indicators::FontStyle::blink)
.value("reverse", indicators::FontStyle::reverse)
.value("concealed", indicators::FontStyle::concealed)
.value("crossed", indicators::FontStyle::crossed);

_module.attr("__version__") =
MRC_CONCAT_STR(morpheus_VERSION_MAJOR << "." << morpheus_VERSION_MINOR << "." << morpheus_VERSION_PATCH);
}
Expand Down
Loading

0 comments on commit 747680c

Please sign in to comment.