From 31f1214f7a60ab7f94986a5df9e5de1fe66c1045 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Fri, 23 Aug 2024 09:56:00 -0500 Subject: [PATCH 1/6] Update Kafka DL script to `2.13-3.8.0` (#1856) Fixes Kafka download script to use an available Kafka version. ## 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: - Christopher Harris (https://github.com/cwharris) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: https://github.com/nv-morpheus/Morpheus/pull/1856 --- ci/scripts/download_kafka.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/scripts/download_kafka.py b/ci/scripts/download_kafka.py index d4f60ed86b..85edfbfa47 100644 --- a/ci/scripts/download_kafka.py +++ b/ci/scripts/download_kafka.py @@ -20,8 +20,8 @@ import pytest_kafka from pytest_kafka.install import set_up_kafka -DEFAULT_KAFKA_URL = 'https://downloads.apache.org/kafka/3.5.2/kafka_2.13-3.5.2.tgz' -DEFAULT_KAFKA_TAR_ROOTDIR = 'kafka_2.13-3.5.2/' +DEFAULT_KAFKA_URL = 'https://downloads.apache.org/kafka/3.8.0/kafka_2.13-3.8.0.tgz' +DEFAULT_KAFKA_TAR_ROOTDIR = 'kafka_2.13-3.8.0/' def main(): From 5a836669b40186ac73ef7c12daabc56736bd0adf Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Fri, 23 Aug 2024 14:28:53 -0700 Subject: [PATCH 2/6] Revert PR_1736 "Always run the PR builder step even if others are cancelled" (#1860) CIs are failing because of #1736 not playing well with https://github.com/rapidsai/shared-workflows/pull/237 As a stopgap I am reverting the changes in #1736 Authors: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: https://github.com/nv-morpheus/Morpheus/pull/1860 --- .github/workflows/pr.yaml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index f135ff2dc2..42a261fdc0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -43,6 +43,14 @@ permissions: jobs: + pr-builder: + needs: + - prepare + - checks + - ci_pipe + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.02 + prepare: # Executes the get-pr-info action to determine if the PR has the skip-ci label, if the action fails we assume the # PR does not have the label @@ -91,13 +99,3 @@ jobs: test_container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-test-240614 secrets: NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - - pr-builder: - # Always run this step even if others are skipped or cancelled - if: '!cancelled()' - needs: - - prepare - - checks - - ci_pipe - secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.02 From 78c48d6ea66f01da267c7b37b672da8984bdf50b Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Fri, 23 Aug 2024 16:24:13 -0700 Subject: [PATCH 3/6] Breakout morpheus_llm (#1853) This PR breaks out the LLM source code into - 1. A separate subdirectory - python/morpheus_llm 2. Compiled as a separate shared lib - libmorpheus_llm.so |_ llm/__init__.cpython-310-x86_64-linux-gnu.so 3. And setup as a separate python package a. morpheus_llm - all llm modules are now in this namespace b. with the following distribution - ./build/python/morpheus_llm/dist/morpheus_llm-24.10.0a0+46.g125a6be9.dirty-py3-none-any.whl To build and install all components in a dev env you can use these steps (steps also updated in contributing.md) - 1. ./scripts/compile_all.sh 2. pip install -e python/morpheus 3. pip install -e python/morpheus_llm Items of note - To ensure right order of build-n-install morpheus_llm has dependencies on the following targets - 1. cudf_helpers 2. morpheus 3. all "py_morpheus" targets Ref: python/morpheus_llm/morpheus_llm/_lib/cmake/libmorpheus_llm.cmake Pending (major) items - 1. Need to breakout llm related build/conda environment requirements from the base morpheus requirements 2. Need to breakout llm python tests (cpp tests have been moved as a part of this commit). Authors: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: https://github.com/nv-morpheus/Morpheus/pull/1853 --- CMakeLists.txt | 5 + ci/conda/recipes/morpheus/meta.yaml | 1 + ci/conda/recipes/morpheus/morpheus_build.sh | 6 + ci/conda/recipes/run_conda_build.sh | 1 + ci/runner/Dockerfile | 1 + ci/scripts/github/build.sh | 6 +- ci/scripts/github/checks.sh | 1 + ci/scripts/github/common.sh | 1 + ci/scripts/github/docs.sh | 1 + docker/build_container.sh | 21 +- docker/run_container_release.sh | 1 + docs/CMakeLists.txt | 4 +- docs/source/conf.py | 2 +- docs/source/developer_guide/contributing.md | 1 + docs/source/py_api.rst | 1 + examples/llm/agents/common.py | 10 +- examples/llm/common/utils.py | 6 +- examples/llm/completion/pipeline.py | 18 +- examples/llm/rag/standalone_pipeline.py | 10 +- python/CMakeLists.txt | 4 + python/morpheus/morpheus/_lib/CMakeLists.txt | 9 +- python/morpheus/morpheus/_lib/__init__.py | 2 - .../morpheus/_lib/cmake/libmorpheus.cmake | 8 - .../morpheus/_lib/tests/CMakeLists.txt | 12 - python/morpheus_llm/CMakeLists.txt | 52 ++ python/morpheus_llm/MANIFEST.in | 2 + .../morpheus_llm/morpheus_llm/CMakeLists.txt | 24 + python/morpheus_llm/morpheus_llm/__init__.py | 12 + .../morpheus_llm/_lib/CMakeLists.txt | 32 + .../morpheus_llm/_lib/__init__.py | 24 + .../_lib/cmake/libmorpheus_llm.cmake | 130 ++++ .../_lib/include/morpheus_llm}/llm/fwd.hpp | 0 .../include/morpheus_llm}/llm/input_map.hpp | 3 +- .../include/morpheus_llm}/llm/llm_context.hpp | 7 +- .../include/morpheus_llm}/llm/llm_engine.hpp | 7 +- .../morpheus_llm}/llm/llm_lambda_node.hpp | 5 +- .../include/morpheus_llm}/llm/llm_node.hpp | 7 +- .../morpheus_llm}/llm/llm_node_base.hpp | 3 +- .../morpheus_llm}/llm/llm_node_runner.hpp | 5 +- .../include/morpheus_llm}/llm/llm_task.hpp | 0 .../morpheus_llm}/llm/llm_task_handler.hpp | 3 +- .../llm/llm_task_handler_runner.hpp | 7 +- .../_lib/include/morpheus_llm}/llm/utils.hpp | 3 +- .../morpheus_llm}/pybind11/input_map.hpp | 5 +- .../morpheus_llm}/_lib/llm/CMakeLists.txt | 2 +- .../morpheus_llm}/_lib/llm/__init__.pyi | 4 +- .../_lib/llm/include/py_llm_engine.hpp | 7 +- .../_lib/llm/include/py_llm_engine_stage.hpp | 6 +- .../_lib/llm/include/py_llm_lambda_node.hpp | 5 +- .../_lib/llm/include/py_llm_node.hpp | 9 +- .../_lib/llm/include/py_llm_node_base.hpp | 9 +- .../_lib/llm/include/py_llm_task_handler.hpp | 5 +- .../morpheus_llm}/_lib/llm/module.cpp | 24 +- .../_lib/llm/src/py_llm_engine.cpp | 3 +- .../_lib/llm/src/py_llm_lambda_node.cpp | 4 +- .../_lib/llm/src/py_llm_node.cpp | 4 +- .../_lib/llm/src/py_llm_node_base.cpp | 8 +- .../_lib/llm/src/py_llm_task_handler.cpp | 3 +- .../morpheus_llm}/_lib/src/llm/input_map.cpp | 4 +- .../_lib/src/llm/llm_context.cpp | 2 +- .../morpheus_llm}/_lib/src/llm/llm_engine.cpp | 13 +- .../morpheus_llm}/_lib/src/llm/llm_node.cpp | 9 +- .../_lib/src/llm/llm_node_runner.cpp | 9 +- .../morpheus_llm}/_lib/src/llm/llm_task.cpp | 2 +- .../_lib/src/llm/llm_task_handler_runner.cpp | 4 +- .../morpheus_llm}/_lib/src/llm/utils.cpp | 5 +- .../morpheus_llm/_lib/tests/CMakeLists.txt | 66 ++ .../_lib/tests/llm/test_llm_context.cpp | 12 +- .../_lib/tests/llm/test_llm_engine.cpp | 12 +- .../_lib/tests/llm/test_llm_node.cpp | 14 +- .../_lib/tests/llm/test_llm_node_runner.cpp | 18 +- .../_lib/tests/llm/test_llm_task.cpp | 4 +- .../llm/test_llm_task_handler_runner.cpp | 18 +- .../_lib/tests/llm/test_utils.cpp | 6 +- python/morpheus_llm/morpheus_llm/_version.py | 685 ++++++++++++++++++ .../morpheus_llm}/llm/__init__.py | 18 +- .../morpheus_llm}/llm/nodes/__init__.py | 0 .../morpheus_llm}/llm/nodes/extracter_node.py | 4 +- .../llm/nodes/langchain_agent_node.py | 4 +- .../llm/nodes/llm_generate_node.py | 6 +- .../llm/nodes/prompt_template_node.py | 4 +- .../morpheus_llm}/llm/nodes/rag_node.py | 10 +- .../morpheus_llm}/llm/nodes/retriever_node.py | 4 +- .../morpheus_llm}/llm/services/__init__.py | 0 .../morpheus_llm}/llm/services/llm_service.py | 6 +- .../llm/services/nemo_llm_service.py | 4 +- .../llm/services/nvfoundation_llm_service.py | 4 +- .../llm/services/openai_chat_service.py | 4 +- .../llm/services/utils/__init__.py | 0 .../utils/langchain_llm_client_wrapper.py | 2 +- .../llm/task_handlers/__init__.py | 0 .../llm/task_handlers/simple_task_handler.py | 4 +- python/morpheus_llm/morpheus_llm/py.typed | 0 .../morpheus_llm/stages/__init__.py | 16 + .../morpheus_llm}/stages/llm/__init__.py | 0 .../stages/llm/llm_engine_stage.py | 6 +- python/morpheus_llm/setup.cfg | 26 + python/morpheus_llm/setup.py | 45 ++ scripts/compile.sh | 1 + tests/_utils/llm.py | 10 +- .../test_bench_agents_simple_pipeline.py | 10 +- .../test_bench_completion_pipeline.py | 18 +- .../test_bench_rag_standalone_pipeline.py | 10 +- tests/llm/nodes/conftest.py | 2 +- tests/llm/nodes/test_extractor_node.py | 4 +- tests/llm/nodes/test_langchain_agent_node.py | 4 +- .../nodes/test_langchain_agent_node_pipe.py | 10 +- tests/llm/nodes/test_llm_generate_node.py | 4 +- .../llm/nodes/test_llm_generate_node_pipe.py | 10 +- tests/llm/nodes/test_llm_retriever_node.py | 4 +- .../llm/nodes/test_llm_retriever_node_pipe.py | 10 +- tests/llm/nodes/test_manual_extractor_node.py | 4 +- tests/llm/nodes/test_prompt_template_node.py | 2 +- .../nodes/test_prompt_template_node_pipe.py | 10 +- tests/llm/nodes/test_rag_node.py | 4 +- tests/llm/nodes/test_rag_node_pipe.py | 10 +- tests/llm/services/test_llm_service.py | 19 +- tests/llm/services/test_llm_service_pipe.py | 16 +- tests/llm/services/test_nemo_llm_client.py | 4 +- tests/llm/services/test_nemo_llm_service.py | 4 +- .../services/test_nvfoundation_llm_service.py | 4 +- .../llm/services/test_openai_chat_service.py | 2 +- .../task_handlers/test_simple_task_handler.py | 4 +- tests/llm/test_agents_simple_pipe.py | 10 +- tests/llm/test_completion_pipe.py | 18 +- ...test_extractor_simple_task_handler_pipe.py | 8 +- tests/llm/test_llm.py | 12 +- tests/llm/test_rag_standalone_pipe.py | 10 +- tests/stages/test_llm_engine_stage.py | 4 +- tests/stages/test_llm_engine_stage_pipe.py | 8 +- 130 files changed, 1499 insertions(+), 357 deletions(-) create mode 100644 python/morpheus_llm/CMakeLists.txt create mode 100644 python/morpheus_llm/MANIFEST.in create mode 100644 python/morpheus_llm/morpheus_llm/CMakeLists.txt create mode 100644 python/morpheus_llm/morpheus_llm/__init__.py create mode 100644 python/morpheus_llm/morpheus_llm/_lib/CMakeLists.txt create mode 100644 python/morpheus_llm/morpheus_llm/_lib/__init__.py create mode 100644 python/morpheus_llm/morpheus_llm/_lib/cmake/libmorpheus_llm.cmake rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/fwd.hpp (100%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/input_map.hpp (98%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_context.hpp (97%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_engine.hpp (92%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_lambda_node.hpp (98%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_node.hpp (96%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_node_base.hpp (97%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_node_runner.hpp (97%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_task.hpp (100%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_task_handler.hpp (97%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/llm_task_handler_runner.hpp (94%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/llm/utils.hpp (97%) rename python/{morpheus/morpheus/_lib/include/morpheus => morpheus_llm/morpheus_llm/_lib/include/morpheus_llm}/pybind11/input_map.hpp (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/CMakeLists.txt (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/__init__.pyi (99%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/include/py_llm_engine.hpp (86%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/include/py_llm_engine_stage.hpp (96%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/include/py_llm_lambda_node.hpp (92%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/include/py_llm_node.hpp (87%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/include/py_llm_node_base.hpp (84%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/include/py_llm_task_handler.hpp (93%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/module.cpp (95%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/src/py_llm_engine.cpp (95%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/src/py_llm_lambda_node.cpp (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/src/py_llm_node.cpp (95%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/src/py_llm_node_base.cpp (89%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/llm/src/py_llm_task_handler.cpp (95%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/input_map.cpp (95%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/llm_context.cpp (99%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/llm_engine.cpp (90%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/llm_node.cpp (96%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/llm_node_runner.cpp (96%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/llm_task.cpp (96%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/llm_task_handler_runner.cpp (95%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/src/llm/utils.cpp (99%) create mode 100644 python/morpheus_llm/morpheus_llm/_lib/tests/CMakeLists.txt rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_llm_context.cpp (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_llm_engine.cpp (88%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_llm_node.cpp (92%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_llm_node_runner.cpp (91%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_llm_task.cpp (94%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_llm_task_handler_runner.cpp (89%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/_lib/tests/llm/test_utils.cpp (97%) create mode 100644 python/morpheus_llm/morpheus_llm/_version.py rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/__init__.py (67%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/__init__.py (100%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/extracter_node.py (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/langchain_agent_node.py (98%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/llm_generate_node.py (91%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/prompt_template_node.py (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/rag_node.py (88%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/nodes/retriever_node.py (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/__init__.py (100%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/llm_service.py (96%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/nemo_llm_service.py (98%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/nvfoundation_llm_service.py (98%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/openai_chat_service.py (99%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/utils/__init__.py (100%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/services/utils/langchain_llm_client_wrapper.py (97%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/task_handlers/__init__.py (100%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/llm/task_handlers/simple_task_handler.py (95%) create mode 100644 python/morpheus_llm/morpheus_llm/py.typed create mode 100644 python/morpheus_llm/morpheus_llm/stages/__init__.py rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/stages/llm/__init__.py (100%) rename python/{morpheus/morpheus => morpheus_llm/morpheus_llm}/stages/llm/llm_engine_stage.py (94%) create mode 100644 python/morpheus_llm/setup.cfg create mode 100644 python/morpheus_llm/setup.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cc7cb3a0b..a295b5ac5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ option(BUILD_SHARED_LIBS "Default value for whether or not to build shared or st option(MORPHEUS_BUILD_BENCHMARKS "Whether or not to build benchmarks" OFF) option(MORPHEUS_BUILD_DOCS "Enable building of API documentation" OFF) option(MORPHEUS_BUILD_EXAMPLES "Whether or not to build examples" OFF) +option(MORPHEUS_BUILD_MORPHEUS_LLM "Whether or not to build morpheus_llm" OFF) option(MORPHEUS_BUILD_TESTS "Whether or not to build tests" OFF) option(MORPHEUS_ENABLE_DEBUG_INFO "Enable printing debug information" OFF) option(MORPHEUS_PYTHON_BUILD_STUBS "Whether or not to generated .pyi stub files for C++ Python modules. Disable to avoid requiring loading the NVIDIA GPU Driver during build" ON) @@ -46,6 +47,10 @@ if(MORPHEUS_USE_IWYU AND MORPHEUS_USE_CCACHE) message(FATAL_ERROR "MORPHEUS_USE_IWYU and MORPHEUS_USE_CCACHE cannot be set simultaneously") endif() +if (MORPHEUS_BUILD_DOCS AND NOT MORPHEUS_BUILD_MORPHEUS_LLM) + message(FATAL_ERROR "MORPHEUS_BUILD_MORPHEUS_LLM must be ON if MORPHEUS_BUILD_DOCS is ON") +endif() + # MRC CMake path and module extensions set(MORPHEUS_CMAKE_MODULE_PATH_EXTENSIONS "${CMAKE_CURRENT_SOURCE_DIR}/cmake" diff --git a/ci/conda/recipes/morpheus/meta.yaml b/ci/conda/recipes/morpheus/meta.yaml index fc55e54f30..00b15fe488 100644 --- a/ci/conda/recipes/morpheus/meta.yaml +++ b/ci/conda/recipes/morpheus/meta.yaml @@ -36,6 +36,7 @@ outputs: - MORPHEUS_CACHE_DIR - MORPHEUS_PYTHON_BUILD_STUBS - MORPHEUS_SUPPORT_DOCA + - MORPHEUS_BUILD_MORPHEUS_LLM - PARALLEL_LEVEL run_exports: - {{ pin_subpackage("morpheus", max_pin="x.x") }} diff --git a/ci/conda/recipes/morpheus/morpheus_build.sh b/ci/conda/recipes/morpheus/morpheus_build.sh index 177beabeee..723559b4af 100644 --- a/ci/conda/recipes/morpheus/morpheus_build.sh +++ b/ci/conda/recipes/morpheus/morpheus_build.sh @@ -18,6 +18,7 @@ # Need to ensure this value is set before checking it in the if block MORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-OFF} +MORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM:-OFF} # This will store all of the cmake args. Make sure to prepend args to allow # incoming values to overwrite them @@ -44,6 +45,10 @@ if [[ ${MORPHEUS_SUPPORT_DOCA} == @(TRUE|ON) ]]; then echo "MORPHEUS_SUPPORT_DOCA is ON. Setting CMAKE_CUDA_ARCHITECTURES to supported values: '${CMAKE_CUDA_ARCHITECTURES}'" fi +if [[ ${MORPHEUS_BUILD_MORPHEUS_LLM} == @(TRUE|ON) ]]; then + CMAKE_ARGS="-DMORPHEUS_BUILD_MORPHEUS_LLM=ON ${CMAKE_ARGS}" +fi + CMAKE_ARGS="-DCMAKE_MESSAGE_CONTEXT_SHOW=ON ${CMAKE_ARGS}" CMAKE_ARGS="-DCMAKE_INSTALL_PREFIX=$PREFIX ${CMAKE_ARGS}" CMAKE_ARGS="-DCMAKE_INSTALL_LIBDIR=lib ${CMAKE_ARGS}" @@ -94,3 +99,4 @@ cmake --build ${BUILD_DIR} -j${PARALLEL_LEVEL:-$(nproc)} --target install # Install just the python wheel components ${PYTHON} -m pip install -vv ${BUILD_DIR}/python/morpheus/dist/*.whl +${PYTHON} -m pip install -vv ${BUILD_DIR}/python/morpheus_llm/dist/*.whl diff --git a/ci/conda/recipes/run_conda_build.sh b/ci/conda/recipes/run_conda_build.sh index 6c8cd3183d..6b6923b735 100755 --- a/ci/conda/recipes/run_conda_build.sh +++ b/ci/conda/recipes/run_conda_build.sh @@ -49,6 +49,7 @@ export MORPHEUS_PYTHON_BUILD_STUBS=${MORPHEUS_PYTHON_BUILD_STUBS:-"ON"} export MORPHEUS_CACHE_DIR=${MORPHEUS_CACHE_DIR:-"${MORPHEUS_ROOT}/.cache"} export PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} export MORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-OFF} +export MORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM:-ON} # Set CONDA_CHANNEL_ALIAS to mimic the conda config channel_alias property during the build CONDA_CHANNEL_ALIAS=${CONDA_CHANNEL_ALIAS:-""} diff --git a/ci/runner/Dockerfile b/ci/runner/Dockerfile index 40b035c402..ed150d0657 100644 --- a/ci/runner/Dockerfile +++ b/ci/runner/Dockerfile @@ -60,6 +60,7 @@ RUN rapids-dependency-file-generator \ rm -rf /tmp/conda ENV MORPHEUS_SUPPORT_DOCA=ON +ENV MORPHEUS_BUILD_MORPHEUS_LLM=ON COPY ./.devcontainer/docker/optional_deps/doca.sh /tmp/doca/ diff --git a/ci/scripts/github/build.sh b/ci/scripts/github/build.sh index c5b466f829..e959eb1040 100755 --- a/ci/scripts/github/build.sh +++ b/ci/scripts/github/build.sh @@ -41,13 +41,15 @@ cmake --build ${BUILD_DIR} --parallel ${PARALLEL_LEVEL} log_sccache_stats rapids-logger "Archiving results" -tar cfj "${WORKSPACE_TMP}/wheel.tar.bz" ${BUILD_DIR}/python/morpheus/dist +tar cfj "${WORKSPACE_TMP}/wheel.tar.bz" ${BUILD_DIR}/python/morpheus/dist ${BUILD_DIR}/python/morpheus_llm/dist MORPHEUS_LIBS=($(find ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus/morpheus/_lib -name "*.so" -exec realpath --relative-to ${MORPHEUS_ROOT} {} \;) \ + $(find ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus_llm/morpheus_llm/_lib -name "*.so" -exec realpath --relative-to ${MORPHEUS_ROOT} {} \;) \ $(find ${MORPHEUS_ROOT}/examples -name "*.so" -exec realpath --relative-to ${MORPHEUS_ROOT} {} \;)) tar cfj "${WORKSPACE_TMP}/morhpeus_libs.tar.bz" "${MORPHEUS_LIBS[@]}" -CPP_TESTS=($(find ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus/morpheus/_lib/tests -name "*.x" -exec realpath --relative-to ${MORPHEUS_ROOT} {} \;)) +CPP_TESTS=($(find ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus/morpheus/_lib/tests -name "*.x" -exec realpath --relative-to ${MORPHEUS_ROOT} {} \;) \ + $(find ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus_llm/morpheus_llm/_lib/tests -name "*.x" -exec realpath --relative-to ${MORPHEUS_ROOT} {} \;)) tar cfj "${WORKSPACE_TMP}/cpp_tests.tar.bz" "${CPP_TESTS[@]}" rapids-logger "Pushing results to ${DISPLAY_ARTIFACT_URL}" diff --git a/ci/scripts/github/checks.sh b/ci/scripts/github/checks.sh index c63e42d0c3..e9bfaa6752 100755 --- a/ci/scripts/github/checks.sh +++ b/ci/scripts/github/checks.sh @@ -48,6 +48,7 @@ log_sccache_stats rapids-logger "Installing Morpheus" pip install ./python/morpheus +pip install ./python/morpheus_llm rapids-logger "Checking copyright headers" python ${MORPHEUS_ROOT}/ci/scripts/copyright.py --verify-apache-v2 --git-diff-commits ${CHANGE_TARGET} ${GIT_COMMIT} diff --git a/ci/scripts/github/common.sh b/ci/scripts/github/common.sh index 5f50779726..66d44fdb8c 100755 --- a/ci/scripts/github/common.sh +++ b/ci/scripts/github/common.sh @@ -76,6 +76,7 @@ _FLAGS+=("-DMORPHEUS_PYTHON_BUILD_STUBS=ON") _FLAGS+=("-DMORPHEUS_BUILD_BENCHMARKS=ON") _FLAGS+=("-DMORPHEUS_BUILD_EXAMPLES=ON") _FLAGS+=("-DMORPHEUS_BUILD_TESTS=ON") +_FLAGS+=("-DMORPHEUS_BUILD_MORPHEUS_LLM=ON") if [[ "${LOCAL_CI}" == "" ]]; then _FLAGS+=("-DCCACHE_PROGRAM_PATH=$(which sccache)") fi diff --git a/ci/scripts/github/docs.sh b/ci/scripts/github/docs.sh index 0295c191ad..f771c34265 100755 --- a/ci/scripts/github/docs.sh +++ b/ci/scripts/github/docs.sh @@ -30,6 +30,7 @@ download_artifact "wheel.tar.bz" tar xf "${WORKSPACE_TMP}/wheel.tar.bz" pip install ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus/dist/*.whl +pip install ${MORPHEUS_ROOT}/${BUILD_DIR}/python/morpheus_llm/dist/*.whl rapids-logger "Pulling LFS assets" cd ${MORPHEUS_ROOT} diff --git a/docker/build_container.sh b/docker/build_container.sh index 36c2f7084d..ca7f7cad78 100755 --- a/docker/build_container.sh +++ b/docker/build_container.sh @@ -35,6 +35,7 @@ FROM_IMAGE=${FROM_IMAGE:-"nvidia/cuda"} LINUX_DISTRO=${LINUX_DISTRO:-ubuntu} LINUX_VER=${LINUX_VER:-22.04} MORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-"OFF"} +MORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM:-"ON"} PYTHON_VER=${PYTHON_VER:-3.10} # Determine the relative path from $PWD to $MORPHEUS_ROOT @@ -51,6 +52,7 @@ DOCKER_ARGS="${DOCKER_ARGS} --build-arg LINUX_DISTRO=${LINUX_DISTRO}" DOCKER_ARGS="${DOCKER_ARGS} --build-arg LINUX_VER=${LINUX_VER}" DOCKER_ARGS="${DOCKER_ARGS} --build-arg MORPHEUS_ROOT_HOST=${MORPHEUS_ROOT_HOST}" DOCKER_ARGS="${DOCKER_ARGS} --build-arg MORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA}" +DOCKER_ARGS="${DOCKER_ARGS} --build-arg MORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM}" DOCKER_ARGS="${DOCKER_ARGS} --build-arg PYTHON_VER=${PYTHON_VER}" DOCKER_ARGS="${DOCKER_ARGS} --network=host" @@ -61,15 +63,16 @@ DOCKER_ARGS="${DOCKER_ARGS} ${DOCKER_EXTRA_ARGS}" export DOCKER_BUILDKIT=1 echo "Building morpheus:${DOCKER_TAG} with args..." -echo " CUDA_MAJOR_VER : ${CUDA_MAJOR_VER}" -echo " CUDA_MINOR_VER : ${CUDA_MINOR_VER}" -echo " CUDA_REV_VER : ${CUDA_REV_VER}" -echo " FROM_IMAGE : ${FROM_IMAGE}" -echo " LINUX_DISTRO : ${LINUX_DISTRO}" -echo " LINUX_VER : ${LINUX_VER}" -echo " MORPHEUS_ROOT_HOST : ${MORPHEUS_ROOT_HOST}" -echo " MORPHEUS_SUPPORT_DOCA: ${MORPHEUS_SUPPORT_DOCA}" -echo " PYTHON_VER : ${PYTHON_VER}" +echo " CUDA_MAJOR_VER : ${CUDA_MAJOR_VER}" +echo " CUDA_MINOR_VER : ${CUDA_MINOR_VER}" +echo " CUDA_REV_VER : ${CUDA_REV_VER}" +echo " FROM_IMAGE : ${FROM_IMAGE}" +echo " LINUX_DISTRO : ${LINUX_DISTRO}" +echo " LINUX_VER : ${LINUX_VER}" +echo " MORPHEUS_ROOT_HOST : ${MORPHEUS_ROOT_HOST}" +echo " MORPHEUS_SUPPORT_DOCA : ${MORPHEUS_SUPPORT_DOCA}" +echo " MORPHEUS_BUILD_MORPHEUS_LLM: ${MORPHEUS_BUILD_MORPHEUS_LLM}" +echo " PYTHON_VER : ${PYTHON_VER}" echo "" echo " COMMAND: docker build ${DOCKER_ARGS} -f ${SCRIPT_DIR}/Dockerfile ." diff --git a/docker/run_container_release.sh b/docker/run_container_release.sh index 53851abae2..42575d394e 100755 --- a/docker/run_container_release.sh +++ b/docker/run_container_release.sh @@ -28,6 +28,7 @@ x="\033[0m" pushd ${SCRIPT_DIR} &> /dev/null MORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-OFF} +MORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM:-ON} DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-"nvcr.io/nvidia/morpheus/morpheus"} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"$(git describe --tags --abbrev=0)-runtime"} diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index a718ce584f..41aa33a535 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -30,7 +30,7 @@ add_custom_target(${PROJECT_NAME}_docs BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR} ${SPHINX_EXECUTABLE} ${SPHINX_HTML_ARGS} ${SPHINX_SOURCE} ${SPHINX_BUILD} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating documentation with Sphinx" - DEPENDS morpheus-package-outputs + DEPENDS morpheus-package-outputs morpheus_llm-package-outputs ) add_custom_target(${PROJECT_NAME}_docs_linkcheck @@ -38,7 +38,7 @@ add_custom_target(${PROJECT_NAME}_docs_linkcheck BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR} ${SPHINX_EXECUTABLE} ${SPHINX_LINKCHECK_ARGS} ${SPHINX_SOURCE} ${SPHINX_LINKCHECK_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Checking documentation links with Sphinx" - DEPENDS morpheus-package-outputs + DEPENDS morpheus-package-outputs morpheus_llm-package-outputs ) list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/docs/source/conf.py b/docs/source/conf.py index 87e4686614..aa59786e26 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -135,7 +135,7 @@ FILE_PATTERNS = *.c *.cc *.cpp *.h *.hpp *.cu *.cuh *.md HAVE_DOT = YES HIDE_UNDOC_MEMBERS = NO - INPUT = ../../python/morpheus/morpheus/_lib + INPUT = ../../python/morpheus/morpheus/_lib ../../python/morpheus_llm/morpheus_llm/_lib INTERACTIVE_SVG = YES SOURCE_BROWSER = YES ENABLE_PREPROCESSING = YES diff --git a/docs/source/developer_guide/contributing.md b/docs/source/developer_guide/contributing.md index e3afcd5ada..052f58b7cf 100644 --- a/docs/source/developer_guide/contributing.md +++ b/docs/source/developer_guide/contributing.md @@ -198,6 +198,7 @@ git submodule update --init --recursive 1. Install Morpheus ```bash pip install -e ${MORPHEUS_ROOT}/python/morpheus + pip install -e ${MORPHEUS_ROOT}/python/morpheus_llm ``` Once Morpheus has been built, it can be installed into the current virtual environment. 1. Test the build (Note: some tests will be skipped)\ diff --git a/docs/source/py_api.rst b/docs/source/py_api.rst index ce899441d9..e4aa991db2 100644 --- a/docs/source/py_api.rst +++ b/docs/source/py_api.rst @@ -22,3 +22,4 @@ Python API :recursive: morpheus + morpheus_llm diff --git a/examples/llm/agents/common.py b/examples/llm/agents/common.py index 15f5ce4f39..9623bdbb6a 100644 --- a/examples/llm/agents/common.py +++ b/examples/llm/agents/common.py @@ -21,16 +21,16 @@ from langchain.llms.openai import OpenAI from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.langchain_agent_node import LangChainAgentNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.general.monitor_stage import MonitorStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.langchain_agent_node import LangChainAgentNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage logger = logging.getLogger(__name__) diff --git a/examples/llm/common/utils.py b/examples/llm/common/utils.py index 1779bb6c88..93681d66da 100644 --- a/examples/llm/common/utils.py +++ b/examples/llm/common/utils.py @@ -17,12 +17,12 @@ import pymilvus from langchain.embeddings import HuggingFaceEmbeddings # pylint: disable=no-name-in-module -from morpheus.llm.services.llm_service import LLMService -from morpheus.llm.services.nemo_llm_service import NeMoLLMService -from morpheus.llm.services.openai_chat_service import OpenAIChatService from morpheus.service.vdb.milvus_client import DATA_TYPE_MAP from morpheus.service.vdb.milvus_vector_db_service import MilvusVectorDBService from morpheus.service.vdb.utils import VectorDBServiceFactory +from morpheus_llm.llm.services.llm_service import LLMService +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService logger = logging.getLogger(__name__) diff --git a/examples/llm/completion/pipeline.py b/examples/llm/completion/pipeline.py index 80f5e8ea0f..62ac6ebf18 100644 --- a/examples/llm/completion/pipeline.py +++ b/examples/llm/completion/pipeline.py @@ -20,22 +20,22 @@ from morpheus.config import Config from morpheus.config import PipelineModes from morpheus.io.deserializers import read_file_to_df -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode -from morpheus.llm.nodes.prompt_template_node import PromptTemplateNode -from morpheus.llm.services.llm_service import LLMService -from morpheus.llm.services.nemo_llm_service import NeMoLLMService -from morpheus.llm.services.openai_chat_service import OpenAIChatService -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.general.monitor_stage import MonitorStage from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage from morpheus.utils.concat_df import concat_dataframes +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm.nodes.prompt_template_node import PromptTemplateNode +from morpheus_llm.llm.services.llm_service import LLMService +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage logger = logging.getLogger(__name__) diff --git a/examples/llm/rag/standalone_pipeline.py b/examples/llm/rag/standalone_pipeline.py index ed8f4bff68..1c0b06654e 100644 --- a/examples/llm/rag/standalone_pipeline.py +++ b/examples/llm/rag/standalone_pipeline.py @@ -18,18 +18,18 @@ from morpheus.config import Config from morpheus.config import PipelineModes -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.rag_node import RAGNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.general.monitor_stage import MonitorStage from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage from morpheus.utils.concat_df import concat_dataframes +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.rag_node import RAGNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage from ..common.utils import build_huggingface_embeddings from ..common.utils import build_llm_service diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 1a21e2b49e..b41fabadf0 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -17,4 +17,8 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "python") add_subdirectory(morpheus) +if (MORPHEUS_BUILD_MORPHEUS_LLM) +add_subdirectory(morpheus_llm) +endif() + list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/python/morpheus/morpheus/_lib/CMakeLists.txt b/python/morpheus/morpheus/_lib/CMakeLists.txt index 1892dd3ba9..4962a2b56f 100644 --- a/python/morpheus/morpheus/_lib/CMakeLists.txt +++ b/python/morpheus/morpheus/_lib/CMakeLists.txt @@ -33,6 +33,8 @@ morpheus_add_cython_library( cudf_helpers_target ) +set_property(GLOBAL PROPERTY cudf_helpers_target_property "${cudf_helpers_target}") + execute_process( COMMAND "${Python_EXECUTABLE}" -c "import pyarrow; print(pyarrow.get_include())" OUTPUT_VARIABLE PYARROW_INCLUDE_DIR @@ -72,18 +74,19 @@ morpheus_utils_python_package_set_default_link_targets(morpheus) # #----------morpheus._lib.common--------- morpheus_add_pybind11_module(common SOURCE_FILES common/module.cpp) +set_property(GLOBAL APPEND PROPERTY py_morpheus_target_property morpheus._lib.common) #----------morpheus._lib.stages--------- morpheus_add_pybind11_module(stages SOURCE_FILES stages/module.cpp) - -#----------morpheus._lib.llm--------- -add_subdirectory(llm) +set_property(GLOBAL APPEND PROPERTY py_morpheus_target_property morpheus._lib.stages) #----------morpheus._lib.messages--------- morpheus_add_pybind11_module(messages SOURCE_FILES messages/module.cpp) +set_property(GLOBAL APPEND PROPERTY py_morpheus_target_property morpheus._lib.messages) #----------morpheus._lib.modules--------- morpheus_add_pybind11_module(modules SOURCE_FILES modules/module.cpp) +set_property(GLOBAL APPEND PROPERTY py_morpheus_target_property morpheus._lib.modules) #----------morpheus._lib.doca--------- if(MORPHEUS_SUPPORT_DOCA) diff --git a/python/morpheus/morpheus/_lib/__init__.py b/python/morpheus/morpheus/_lib/__init__.py index 062b15bdc7..c61e4dff3e 100644 --- a/python/morpheus/morpheus/_lib/__init__.py +++ b/python/morpheus/morpheus/_lib/__init__.py @@ -12,14 +12,12 @@ # limitations under the License. from . import common -from . import llm from . import messages from . import modules from . import stages __all__ = [ "common", - "llm", "messages", "modules", "stages", diff --git a/python/morpheus/morpheus/_lib/cmake/libmorpheus.cmake b/python/morpheus/morpheus/_lib/cmake/libmorpheus.cmake index b4d3e5baaf..f7e8cd6860 100644 --- a/python/morpheus/morpheus/_lib/cmake/libmorpheus.cmake +++ b/python/morpheus/morpheus/_lib/cmake/libmorpheus.cmake @@ -26,14 +26,6 @@ add_library(morpheus src/io/loaders/payload.cpp src/io/loaders/rest.cpp src/io/serializers.cpp - src/llm/input_map.cpp - src/llm/llm_context.cpp - src/llm/llm_engine.cpp - src/llm/llm_node_runner.cpp - src/llm/llm_node.cpp - src/llm/llm_task_handler_runner.cpp - src/llm/llm_task.cpp - src/llm/utils.cpp src/messages/control.cpp src/messages/memory/inference_memory_fil.cpp src/messages/memory/inference_memory_nlp.cpp diff --git a/python/morpheus/morpheus/_lib/tests/CMakeLists.txt b/python/morpheus/morpheus/_lib/tests/CMakeLists.txt index 788055a7c0..0dab45cbc6 100644 --- a/python/morpheus/morpheus/_lib/tests/CMakeLists.txt +++ b/python/morpheus/morpheus/_lib/tests/CMakeLists.txt @@ -138,18 +138,6 @@ add_morpheus_test( test_file_in_out.cpp ) -add_morpheus_test( - NAME llm - FILES - llm/test_llm_context.cpp - llm/test_llm_engine.cpp - llm/test_llm_node.cpp - llm/test_llm_node_runner.cpp - llm/test_llm_task.cpp - llm/test_llm_task_handler_runner.cpp - llm/test_utils.cpp -) - add_morpheus_test( NAME matx_util FILES diff --git a/python/morpheus_llm/CMakeLists.txt b/python/morpheus_llm/CMakeLists.txt new file mode 100644 index 0000000000..2383ee8ec3 --- /dev/null +++ b/python/morpheus_llm/CMakeLists.txt @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: Copyright (c) 2021-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. + +list(APPEND CMAKE_MESSAGE_CONTEXT "morpheus_llm") + +# Save the root of the python for relative paths +# Where is this used, fixme +set(MORPHEUS_LLM_PY_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) + + +# ################################# +# #### Morpheus Python Setup ###### +# ################################# +morpheus_utils_python_configure() + +# Include the main morpheus code +# fixme: add another subdirectory src and change SOURCE_DIRECTORY to ${CMAKE_CURRENT_SOURCE_DIR}/src +morpheus_utils_create_python_package(morpheus_llm + PROJECT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/morpheus_llm" +) + +add_subdirectory(morpheus_llm) + +# Complete the python package - fixme do these need to be redefined +if(MORPHEUS_PYTHON_INPLACE_BUILD) + list(APPEND extra_args "IS_INPLACE") +endif() + +if(MORPHEUS_PYTHON_BUILD_WHEEL) + list(APPEND extra_args "BUILD_WHEEL") +endif() + +if(MORPHEUS_PYTHON_PERFORM_INSTALL) + list(APPEND extra_args "INSTALL_WHEEL") +endif() + +morpheus_utils_build_python_package(morpheus_llm ${extra_args}) + +list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/python/morpheus_llm/MANIFEST.in b/python/morpheus_llm/MANIFEST.in new file mode 100644 index 0000000000..457e409317 --- /dev/null +++ b/python/morpheus_llm/MANIFEST.in @@ -0,0 +1,2 @@ +include morpheus_llm/_version.py +recursive-include morpheus_llm *.cpython*.so py.typed *.pyi diff --git a/python/morpheus_llm/morpheus_llm/CMakeLists.txt b/python/morpheus_llm/morpheus_llm/CMakeLists.txt new file mode 100644 index 0000000000..213455355c --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: Copyright (c) 2021-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. + +list(APPEND CMAKE_MESSAGE_CONTEXT "morpheus_llm") + +# Save the root of the python for relative paths +set(MORPHEUS_LLM_PY_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_subdirectory(_lib) + + +list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/python/morpheus_llm/morpheus_llm/__init__.py b/python/morpheus_llm/morpheus_llm/__init__.py new file mode 100644 index 0000000000..e9bbcdade9 --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/__init__.py @@ -0,0 +1,12 @@ +# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# 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. diff --git a/python/morpheus_llm/morpheus_llm/_lib/CMakeLists.txt b/python/morpheus_llm/morpheus_llm/_lib/CMakeLists.txt new file mode 100644 index 0000000000..053785840b --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/_lib/CMakeLists.txt @@ -0,0 +1,32 @@ +# ============================================================================= +# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# +# 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. +# ============================================================================= +list(APPEND CMAKE_MESSAGE_CONTEXT "_lib") + +########### morpheus-llm ########### + +#----------lib_morpheus_llm--------- +include(cmake/libmorpheus_llm.cmake) + +########### py_morpheus ######## +# Set the default link targets to avoid repeating this +morpheus_utils_python_package_set_default_link_targets(morpheus_llm) + +#----------morpheus._lib.llm--------- +add_subdirectory(llm) + +if (MORPHEUS_BUILD_TESTS) + add_subdirectory(tests) +endif() + +list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/python/morpheus_llm/morpheus_llm/_lib/__init__.py b/python/morpheus_llm/morpheus_llm/_lib/__init__.py new file mode 100644 index 0000000000..5e72ac01b8 --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/_lib/__init__.py @@ -0,0 +1,24 @@ +# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# 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. + +# pylint: disable=wrong-import-position + +import sys + +sys.path.append("../morpheus") + +from . import llm + +__all__ = [ + "llm", +] diff --git a/python/morpheus_llm/morpheus_llm/_lib/cmake/libmorpheus_llm.cmake b/python/morpheus_llm/morpheus_llm/_lib/cmake/libmorpheus_llm.cmake new file mode 100644 index 0000000000..d4377c64db --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/_lib/cmake/libmorpheus_llm.cmake @@ -0,0 +1,130 @@ +# ============================================================================= +# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# +# 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. +# ============================================================================= + +add_library(morpheus_llm + + # Keep these sorted! + src/llm/input_map.cpp + src/llm/llm_context.cpp + src/llm/llm_engine.cpp + src/llm/llm_node_runner.cpp + src/llm/llm_node.cpp + src/llm/llm_task_handler_runner.cpp + src/llm/llm_task.cpp + src/llm/utils.cpp +) + +add_library(${PROJECT_NAME}::morpheus_llm ALIAS morpheus_llm) + +# fixme check if all these are needed +target_link_libraries(morpheus_llm + PRIVATE + matx::matx + $<$:ZLIB::ZLIB> + PUBLIC + $ + cudf::cudf + CUDA::nvtx3 + mrc::pymrc + ${PROJECT_NAME}::morpheus + +) + +# Add the include directories of the cudf_helpers_project since we dont want to link directly to it +get_property(cudf_helpers_target GLOBAL PROPERTY cudf_helpers_target_property) +get_target_property(cudf_helpers_include ${cudf_helpers_target} INTERFACE_INCLUDE_DIRECTORIES) + +target_include_directories(morpheus + PRIVATE + ${cudf_helpers_include} +) + +# Also add a dependency to the target so that the headers are generated before the target is built +add_dependencies(morpheus_llm ${cudf_helpers_target}) +message("add_dependencies morpheus_llm ${cudf_helpers_target}") + +# 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}) +message("add_dependencies morpheus_llm ${py_morpheus_target}") + +# fixme: find another way to include morpheus headers +target_include_directories(morpheus_llm + PUBLIC + $ + $ + $ +) + +# In debug mode, dont allow missing symbols +target_link_options(morpheus_llm PUBLIC "$<$:-Wl,--no-allow-shlib-undefined>") + +# Ideally, we dont use glob here. But there is no good way to guarantee you dont miss anything like *.cpp +file(GLOB_RECURSE morpheus_llm_public_headers + LIST_DIRECTORIES FALSE + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/include/morpheus/*" +) + +# Add headers to target sources file_set so they can be installed +# https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238/3 +target_sources(morpheus_llm + PUBLIC + FILE_SET public_headers + TYPE HEADERS + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" + FILES + ${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 +# libcuda.so. Relavant issue: https://github.com/NVIDIA/cuda-python/issues/17 +target_link_options(morpheus_llm PUBLIC "-Wl,--enable-new-dtags") + +# required to link code containing pybind11 headers +target_link_options(morpheus_llm PUBLIC "-Wl,--gc-sections") + +set_target_properties(morpheus_llm + PROPERTIES + CXX_VISIBILITY_PRESET hidden + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON +) + +if(MORPHEUS_PYTHON_INPLACE_BUILD) + morpheus_utils_inplace_build_copy(morpheus_llm ${CMAKE_CURRENT_SOURCE_DIR}) +endif() + +# ################################################################################################## +# - install targets -------------------------------------------------------------------------------- + +# Get the library directory in a cross-platform way +rapids_cmake_install_lib_dir(lib_dir) + +include(CPack) +include(GNUInstallDirs) + +install( + TARGETS + morpheus_llm + EXPORT + ${PROJECT_NAME}-core-exports + LIBRARY + DESTINATION ${lib_dir} + FILE_SET + public_headers +) diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/fwd.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/fwd.hpp similarity index 100% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/fwd.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/fwd.hpp diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/input_map.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/input_map.hpp similarity index 98% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/input_map.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/input_map.hpp index 7bc7c1750f..132a30945c 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/input_map.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/input_map.hpp @@ -17,8 +17,9 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" #include #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_context.hpp similarity index 97% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_context.hpp index 908a39a84b..43c7ee9770 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_context.hpp @@ -17,10 +17,11 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" // for ControlMessage +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_task.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" // for ControlMessage -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_task.hpp" #include #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_engine.hpp similarity index 92% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_engine.hpp index 31651c5c94..bdfce160c1 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_engine.hpp @@ -17,10 +17,11 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" // for ControlMessage, LLMContext, LLMTask, LLMTaskHandler, LLMTaskHandlerRunner +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_node.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" // for ControlMessage, LLMContext, LLMTask, LLMTaskHandler, LLMTaskHandlerRunner -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_node.hpp" #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_lambda_node.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_lambda_node.hpp similarity index 98% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_lambda_node.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_lambda_node.hpp index 34da27f68a..c115fa1041 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_lambda_node.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_lambda_node.hpp @@ -17,9 +17,10 @@ #pragma once +#include "morpheus_llm/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_node_base.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/llm_context.hpp" -#include "morpheus/llm/llm_node_base.hpp" #include "morpheus/types.hpp" #include "morpheus/utilities/type_traits.hpp" diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node.hpp similarity index 96% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node.hpp index a0a5d6ea33..52c3cd3fc2 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node.hpp @@ -17,10 +17,11 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_node_base.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_node_base.hpp" #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node_base.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node_base.hpp similarity index 97% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node_base.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node_base.hpp index b93bb655f4..e13e037a98 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node_base.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node_base.hpp @@ -17,8 +17,9 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node_runner.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node_runner.hpp similarity index 97% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node_runner.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node_runner.hpp index d15c2d41f9..540be6679c 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_node_runner.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_node_runner.hpp @@ -17,9 +17,10 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" +#include "morpheus_llm/llm/input_map.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" -#include "morpheus/llm/input_map.hpp" #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task.hpp similarity index 100% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task.hpp diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task_handler.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task_handler.hpp similarity index 97% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task_handler.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task_handler.hpp index 2f30515dd8..84a5fce11e 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task_handler.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task_handler.hpp @@ -17,8 +17,9 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task_handler_runner.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task_handler_runner.hpp similarity index 94% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task_handler_runner.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task_handler_runner.hpp index d840c4f3ae..9b73844ebd 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/llm_task_handler_runner.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/llm_task_handler_runner.hpp @@ -17,10 +17,11 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/fwd.hpp" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_task_handler.hpp" #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/llm/utils.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/utils.hpp similarity index 97% rename from python/morpheus/morpheus/_lib/include/morpheus/llm/utils.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/utils.hpp index a5529220e9..f8b1289ae6 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/llm/utils.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/llm/utils.hpp @@ -17,8 +17,9 @@ #pragma once +#include "morpheus_llm/llm/input_map.hpp" + #include "morpheus/export.h" -#include "morpheus/llm/input_map.hpp" #include #include diff --git a/python/morpheus/morpheus/_lib/include/morpheus/pybind11/input_map.hpp b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/pybind11/input_map.hpp similarity index 97% rename from python/morpheus/morpheus/_lib/include/morpheus/pybind11/input_map.hpp rename to python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/pybind11/input_map.hpp index eaa9371d0c..de2345d990 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/pybind11/input_map.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/include/morpheus_llm/pybind11/input_map.hpp @@ -17,8 +17,9 @@ #pragma once -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_node_runner.hpp" + #include "morpheus/utilities/json_types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/llm/CMakeLists.txt b/python/morpheus_llm/morpheus_llm/_lib/llm/CMakeLists.txt similarity index 97% rename from python/morpheus/morpheus/_lib/llm/CMakeLists.txt rename to python/morpheus_llm/morpheus_llm/_lib/llm/CMakeLists.txt index ab2d3672bc..79799d7f7a 100644 --- a/python/morpheus/morpheus/_lib/llm/CMakeLists.txt +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND MODULE_SOURCE_FILES module.cpp) morpheus_add_pybind11_module(llm INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include SOURCE_FILES ${MODULE_SOURCE_FILES} - LINK_TARGETS morpheus + LINK_TARGETS morpheus_llm CURRENT_DIR_IS_MODULE ) diff --git a/python/morpheus/morpheus/_lib/llm/__init__.pyi b/python/morpheus_llm/morpheus_llm/_lib/llm/__init__.pyi similarity index 99% rename from python/morpheus/morpheus/_lib/llm/__init__.pyi rename to python/morpheus_llm/morpheus_llm/_lib/llm/__init__.pyi index 260e9a1393..36c202e16c 100644 --- a/python/morpheus/morpheus/_lib/llm/__init__.pyi +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/__init__.pyi @@ -1,12 +1,12 @@ """ ----------------------- - .. currentmodule:: morpheus.llm + .. currentmodule:: morpheus_llm.llm .. autosummary:: :toctree: _generate """ from __future__ import annotations -import morpheus._lib.llm +import morpheus_llm._lib.llm import typing import morpheus._lib.messages import mrc.core.coro diff --git a/python/morpheus/morpheus/_lib/llm/include/py_llm_engine.hpp b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_engine.hpp similarity index 86% rename from python/morpheus/morpheus/_lib/llm/include/py_llm_engine.hpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_engine.hpp index 39772cb72f..1673d4febd 100644 --- a/python/morpheus/morpheus/_lib/llm/include/py_llm_engine.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_engine.hpp @@ -17,12 +17,11 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" // for LLMTaskHandler, ControlMessage, LLMContext, LLMEngine, LLMTask +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_engine.hpp" #include "py_llm_node.hpp" -#include "morpheus/llm/fwd.hpp" // for LLMTaskHandler, ControlMessage, LLMContext, LLMEngine, LLMTask -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_engine.hpp" - #include #include diff --git a/python/morpheus/morpheus/_lib/llm/include/py_llm_engine_stage.hpp b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_engine_stage.hpp similarity index 96% rename from python/morpheus/morpheus/_lib/llm/include/py_llm_engine_stage.hpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_engine_stage.hpp index 447b868a35..b909fafa9d 100644 --- a/python/morpheus/morpheus/_lib/llm/include/py_llm_engine_stage.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_engine_stage.hpp @@ -16,12 +16,12 @@ */ #pragma once +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_engine.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" #include "py_llm_node.hpp" #include "morpheus/export.h" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_engine.hpp" -#include "morpheus/llm/llm_task_handler.hpp" #include "morpheus/messages/control.hpp" #include "morpheus/types.hpp" diff --git a/python/morpheus/morpheus/_lib/llm/include/py_llm_lambda_node.hpp b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_lambda_node.hpp similarity index 92% rename from python/morpheus/morpheus/_lib/llm/include/py_llm_lambda_node.hpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_lambda_node.hpp index f4c38d70ac..127f1825e1 100644 --- a/python/morpheus/morpheus/_lib/llm/include/py_llm_lambda_node.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_lambda_node.hpp @@ -17,8 +17,9 @@ #pragma once -#include "morpheus/llm/fwd.hpp" // for LLMContext -#include "morpheus/llm/llm_node_base.hpp" +#include "morpheus_llm/llm/fwd.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_node_base.hpp" + #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/llm/include/py_llm_node.hpp b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_node.hpp similarity index 87% rename from python/morpheus/morpheus/_lib/llm/include/py_llm_node.hpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_node.hpp index bf02e03e2d..877b4280a3 100644 --- a/python/morpheus/morpheus/_lib/llm/include/py_llm_node.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_node.hpp @@ -17,19 +17,18 @@ #pragma once +#include "morpheus_llm/llm/fwd.hpp" +#include "morpheus_llm/llm/input_map.hpp" #include "py_llm_node_base.hpp" -#include "morpheus/llm/fwd.hpp" -#include "morpheus/llm/input_map.hpp" - #include #include #include #include -// IWYU pragma: no_include "morpheus/llm/llm_engine.hpp" -// IWYU pragma: no_include "morpheus/llm/llm_node.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/llm_engine.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/llm_node.hpp" namespace morpheus::llm { diff --git a/python/morpheus/morpheus/_lib/llm/include/py_llm_node_base.hpp b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_node_base.hpp similarity index 84% rename from python/morpheus/morpheus/_lib/llm/include/py_llm_node_base.hpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_node_base.hpp index 527899726b..809ec4a3e4 100644 --- a/python/morpheus/morpheus/_lib/llm/include/py_llm_node_base.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_node_base.hpp @@ -17,7 +17,8 @@ #pragma once -#include "morpheus/llm/fwd.hpp" +#include "morpheus_llm/llm/fwd.hpp" + #include "morpheus/types.hpp" #include @@ -25,9 +26,9 @@ #include // We include these in the cpp file to avoid putting everything in the header -// IWYU pragma: no_include "morpheus/llm/llm_engine.hpp" -// IWYU pragma: no_include "morpheus/llm/llm_node.hpp" -// IWYU pragma: no_include "morpheus/llm/llm_node_base.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/llm_engine.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/llm_node.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/llm_node_base.hpp" namespace morpheus::llm { diff --git a/python/morpheus/morpheus/_lib/llm/include/py_llm_task_handler.hpp b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_task_handler.hpp similarity index 93% rename from python/morpheus/morpheus/_lib/llm/include/py_llm_task_handler.hpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_task_handler.hpp index 6a8f37fb7d..92544b4f03 100644 --- a/python/morpheus/morpheus/_lib/llm/include/py_llm_task_handler.hpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/include/py_llm_task_handler.hpp @@ -17,8 +17,9 @@ #pragma once -#include "morpheus/llm/fwd.hpp" -#include "morpheus/llm/llm_task_handler.hpp" +#include "morpheus_llm/llm/fwd.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" + #include "morpheus/types.hpp" #include diff --git a/python/morpheus/morpheus/_lib/llm/module.cpp b/python/morpheus_llm/morpheus_llm/_lib/llm/module.cpp similarity index 95% rename from python/morpheus/morpheus/_lib/llm/module.cpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/module.cpp index 8a23f559dc..9db56597f9 100644 --- a/python/morpheus/morpheus/_lib/llm/module.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/module.cpp @@ -19,19 +19,19 @@ #include "./include/py_llm_node.hpp" #include "./include/py_llm_node_base.hpp" #include "./include/py_llm_task_handler.hpp" +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_engine.hpp" +#include "morpheus_llm/llm/llm_node.hpp" +#include "morpheus_llm/llm/llm_node_base.hpp" +#include "morpheus_llm/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/llm_task.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" +#include "morpheus_llm/pybind11/input_map.hpp" // IWYU pragma: keep #include "py_llm_engine_stage.hpp" #include "py_llm_lambda_node.hpp" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_context.hpp" -#include "morpheus/llm/llm_engine.hpp" -#include "morpheus/llm/llm_node.hpp" -#include "morpheus/llm/llm_node_base.hpp" -#include "morpheus/llm/llm_node_runner.hpp" -#include "morpheus/llm/llm_task.hpp" -#include "morpheus/llm/llm_task_handler.hpp" -#include "morpheus/messages/control.hpp" // IWYU pragma: keep -#include "morpheus/pybind11/input_map.hpp" // IWYU pragma: keep +#include "morpheus/messages/control.hpp" // IWYU pragma: keep #include "morpheus/utilities/cudf_util.hpp" #include "morpheus/version.hpp" @@ -51,7 +51,7 @@ #include #include #include -// IWYU pragma: no_include "morpheus/llm/fwd.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/fwd.hpp" // IWYU pragma: no_include // IWYU pragma: no_include @@ -62,7 +62,7 @@ PYBIND11_MODULE(llm, _module) { _module.doc() = R"pbdoc( ----------------------- - .. currentmodule:: morpheus.llm + .. currentmodule:: morpheus_llm.llm .. autosummary:: :toctree: _generate diff --git a/python/morpheus/morpheus/_lib/llm/src/py_llm_engine.cpp b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_engine.cpp similarity index 95% rename from python/morpheus/morpheus/_lib/llm/src/py_llm_engine.cpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_engine.cpp index 5f392a38df..da24939065 100644 --- a/python/morpheus/morpheus/_lib/llm/src/py_llm_engine.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_engine.cpp @@ -17,10 +17,9 @@ #include "py_llm_engine.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" // for LLMTaskHandler #include "py_llm_task_handler.hpp" -#include "morpheus/llm/llm_task_handler.hpp" // for LLMTaskHandler - #include #include diff --git a/python/morpheus/morpheus/_lib/llm/src/py_llm_lambda_node.cpp b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_lambda_node.cpp similarity index 97% rename from python/morpheus/morpheus/_lib/llm/src/py_llm_lambda_node.cpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_lambda_node.cpp index 13b5cf4606..ac658e2697 100644 --- a/python/morpheus/morpheus/_lib/llm/src/py_llm_lambda_node.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_lambda_node.cpp @@ -17,10 +17,10 @@ #include "py_llm_lambda_node.hpp" +#include "morpheus_llm/llm/llm_context.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_node_base.hpp" #include "pymrc/coro.hpp" -#include "morpheus/llm/llm_context.hpp" // for LLMContext -#include "morpheus/llm/llm_node_base.hpp" #include "morpheus/utilities/string_util.hpp" #include // for DCHECK_EQ diff --git a/python/morpheus/morpheus/_lib/llm/src/py_llm_node.cpp b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_node.cpp similarity index 95% rename from python/morpheus/morpheus/_lib/llm/src/py_llm_node.cpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_node.cpp index 8daa839ac5..cace3b4eb1 100644 --- a/python/morpheus/morpheus/_lib/llm/src/py_llm_node.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_node.cpp @@ -17,8 +17,8 @@ #include "py_llm_node.hpp" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_engine.hpp" +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_engine.hpp" #include // IWYU pragma: keep #include diff --git a/python/morpheus/morpheus/_lib/llm/src/py_llm_node_base.cpp b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_node_base.cpp similarity index 89% rename from python/morpheus/morpheus/_lib/llm/src/py_llm_node_base.cpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_node_base.cpp index 8d42dd5388..33231dec13 100644 --- a/python/morpheus/morpheus/_lib/llm/src/py_llm_node_base.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_node_base.cpp @@ -17,10 +17,10 @@ #include "py_llm_node_base.hpp" -#include "morpheus/llm/llm_context.hpp" // IWYU pragma: keep -#include "morpheus/llm/llm_engine.hpp" -#include "morpheus/llm/llm_node.hpp" -#include "morpheus/llm/llm_node_base.hpp" +#include "morpheus_llm/llm/llm_context.hpp" // IWYU pragma: keep +#include "morpheus_llm/llm/llm_engine.hpp" +#include "morpheus_llm/llm/llm_node.hpp" +#include "morpheus_llm/llm/llm_node_base.hpp" #include // IWYU pragma: keep #include diff --git a/python/morpheus/morpheus/_lib/llm/src/py_llm_task_handler.cpp b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_task_handler.cpp similarity index 95% rename from python/morpheus/morpheus/_lib/llm/src/py_llm_task_handler.cpp rename to python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_task_handler.cpp index 79884995bd..2300a20469 100644 --- a/python/morpheus/morpheus/_lib/llm/src/py_llm_task_handler.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/llm/src/py_llm_task_handler.cpp @@ -17,7 +17,8 @@ #include "py_llm_task_handler.hpp" -#include "morpheus/llm/llm_context.hpp" // IWYU pragma: keep +#include "morpheus_llm/llm/llm_context.hpp" // IWYU pragma: keep + #include "morpheus/messages/control.hpp" // IWYU pragma: keep #include // IWYU pragma: keep diff --git a/python/morpheus/morpheus/_lib/src/llm/input_map.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/input_map.cpp similarity index 95% rename from python/morpheus/morpheus/_lib/src/llm/input_map.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/input_map.cpp index 4f27a3235d..a87c9d0f89 100644 --- a/python/morpheus/morpheus/_lib/src/llm/input_map.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/input_map.cpp @@ -15,9 +15,9 @@ * limitations under the License. */ -#include "morpheus/llm/input_map.hpp" +#include "morpheus_llm/llm/input_map.hpp" -#include "morpheus/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/llm_node_runner.hpp" #include diff --git a/python/morpheus/morpheus/_lib/src/llm/llm_context.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_context.cpp similarity index 99% rename from python/morpheus/morpheus/_lib/src/llm/llm_context.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_context.cpp index 5efb6a710e..4686994491 100644 --- a/python/morpheus/morpheus/_lib/src/llm/llm_context.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_context.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "morpheus/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_context.hpp" #include "morpheus/messages/control.hpp" // IWYU pragma: keep diff --git a/python/morpheus/morpheus/_lib/src/llm/llm_engine.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_engine.cpp similarity index 90% rename from python/morpheus/morpheus/_lib/src/llm/llm_engine.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_engine.cpp index 3c29c84676..15c209766d 100644 --- a/python/morpheus/morpheus/_lib/src/llm/llm_engine.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_engine.cpp @@ -15,13 +15,14 @@ * limitations under the License. */ -#include "morpheus/llm/llm_engine.hpp" +#include "morpheus_llm/llm/llm_engine.hpp" + +#include "morpheus_llm/llm/llm_context.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_task.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" // for LLMTaskHandler +#include "morpheus_llm/llm/llm_task_handler_runner.hpp" // for LLMTaskHandlerRunner +#include "morpheus_llm/llm/utils.hpp" -#include "morpheus/llm/llm_context.hpp" // for LLMContext -#include "morpheus/llm/llm_task.hpp" -#include "morpheus/llm/llm_task_handler.hpp" // for LLMTaskHandler -#include "morpheus/llm/llm_task_handler_runner.hpp" // for LLMTaskHandlerRunner -#include "morpheus/llm/utils.hpp" #include "morpheus/messages/control.hpp" // for ControlMessage #include // IWYU pragma: keep diff --git a/python/morpheus/morpheus/_lib/src/llm/llm_node.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_node.cpp similarity index 96% rename from python/morpheus/morpheus/_lib/src/llm/llm_node.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_node.cpp index 7c82269f44..1b608831a6 100644 --- a/python/morpheus/morpheus/_lib/src/llm/llm_node.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_node.cpp @@ -15,11 +15,12 @@ * limitations under the License. */ -#include "morpheus/llm/llm_node.hpp" +#include "morpheus_llm/llm/llm_node.hpp" + +#include "morpheus_llm/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/utils.hpp" -#include "morpheus/llm/llm_context.hpp" -#include "morpheus/llm/llm_node_runner.hpp" -#include "morpheus/llm/utils.hpp" #include "morpheus/utilities/string_util.hpp" #include // IWYU pragma: keep diff --git a/python/morpheus/morpheus/_lib/src/llm/llm_node_runner.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_node_runner.cpp similarity index 96% rename from python/morpheus/morpheus/_lib/src/llm/llm_node_runner.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_node_runner.cpp index 3624eb0b34..3a77298227 100644 --- a/python/morpheus/morpheus/_lib/src/llm/llm_node_runner.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_node_runner.cpp @@ -15,11 +15,12 @@ * limitations under the License. */ -#include "morpheus/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/llm_node_runner.hpp" + +#include "morpheus_llm/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_node_base.hpp" +#include "morpheus_llm/llm/utils.hpp" -#include "morpheus/llm/llm_context.hpp" -#include "morpheus/llm/llm_node_base.hpp" -#include "morpheus/llm/utils.hpp" #include "morpheus/utilities/string_util.hpp" #include diff --git a/python/morpheus/morpheus/_lib/src/llm/llm_task.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_task.cpp similarity index 96% rename from python/morpheus/morpheus/_lib/src/llm/llm_task.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_task.cpp index 566dca8ed3..33362518bf 100644 --- a/python/morpheus/morpheus/_lib/src/llm/llm_task.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_task.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "morpheus/llm/llm_task.hpp" +#include "morpheus_llm/llm/llm_task.hpp" #include diff --git a/python/morpheus/morpheus/_lib/src/llm/llm_task_handler_runner.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_task_handler_runner.cpp similarity index 95% rename from python/morpheus/morpheus/_lib/src/llm/llm_task_handler_runner.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_task_handler_runner.cpp index 92b71a981c..4327170788 100644 --- a/python/morpheus/morpheus/_lib/src/llm/llm_task_handler_runner.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/llm_task_handler_runner.cpp @@ -15,9 +15,9 @@ * limitations under the License. */ -#include "morpheus/llm/llm_task_handler_runner.hpp" +#include "morpheus_llm/llm/llm_task_handler_runner.hpp" -#include "morpheus/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_context.hpp" #include #include // IWYU pragma: keep diff --git a/python/morpheus/morpheus/_lib/src/llm/utils.cpp b/python/morpheus_llm/morpheus_llm/_lib/src/llm/utils.cpp similarity index 99% rename from python/morpheus/morpheus/_lib/src/llm/utils.cpp rename to python/morpheus_llm/morpheus_llm/_lib/src/llm/utils.cpp index e7be60bdad..d73dfe7588 100644 --- a/python/morpheus/morpheus/_lib/src/llm/utils.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/src/llm/utils.cpp @@ -15,9 +15,10 @@ * limitations under the License. */ -#include "morpheus/llm/utils.hpp" +#include "morpheus_llm/llm/utils.hpp" + +#include "morpheus_llm/llm/input_map.hpp" -#include "morpheus/llm/input_map.hpp" #include "morpheus/utilities/string_util.hpp" #include diff --git a/python/morpheus_llm/morpheus_llm/_lib/tests/CMakeLists.txt b/python/morpheus_llm/morpheus_llm/_lib/tests/CMakeLists.txt new file mode 100644 index 0000000000..c6a3aae7d0 --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/CMakeLists.txt @@ -0,0 +1,66 @@ +# SPDX-FileCopyrightText: Copyright (c) 2022-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. + +list(APPEND CMAKE_MESSAGE_CONTEXT "tests") + +find_package(pybind11 REQUIRED) + +include(GoogleTest) + +# Morpheus LLM Tests +function(add_morpheus_llm_test) + set(options) + set(oneValueArgs NAME) + set(multiValueArgs FILES) + cmake_parse_arguments( + MORPHEUS_LLM_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} + ) + add_executable(test_${MORPHEUS_LLM_TEST_NAME} + ${MORPHEUS_LLM_TEST_FILES} + ) + + target_link_libraries(test_${MORPHEUS_LLM_TEST_NAME} + PRIVATE + GTest::gtest_main + morpheus_test_utilities + morpheus_llm + pybind11::embed + TritonClient::httpclient_static + ) + + target_include_directories(test_${MORPHEUS_LLM_TEST_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/python/morpheus/) + gtest_discover_tests(test_${MORPHEUS_LLM_TEST_NAME}) + + set_target_properties(test_${MORPHEUS_LLM_TEST_NAME} + PROPERTIES + INSTALL_RPATH "$ORIGIN/.." + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + ) +endfunction() + +add_morpheus_llm_test( + NAME llm + FILES + llm/test_llm_context.cpp + llm/test_llm_engine.cpp + llm/test_llm_node.cpp + llm/test_llm_node_runner.cpp + llm/test_llm_task.cpp + llm/test_llm_task_handler_runner.cpp + llm/test_utils.cpp +) + +list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_llm_context.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_context.cpp similarity index 97% rename from python/morpheus/morpheus/_lib/tests/llm/test_llm_context.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_context.cpp index 0da4317420..a6ca57b029 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_llm_context.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_context.cpp @@ -15,12 +15,12 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_context.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_task.hpp" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_context.hpp" // for LLMContext -#include "morpheus/llm/llm_task.hpp" -#include "morpheus/messages/control.hpp" // for ControlMessage +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus/messages/control.hpp" // for ControlMessage #include #include @@ -29,7 +29,7 @@ #include #include -// IWYU pragma: no_include "morpheus/llm/fwd.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/fwd.hpp" using namespace morpheus; using namespace morpheus::test; diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_llm_engine.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_engine.cpp similarity index 88% rename from python/morpheus/morpheus/_lib/tests/llm/test_llm_engine.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_engine.cpp index 52864cc111..160683718f 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_llm_engine.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_engine.cpp @@ -15,12 +15,12 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus_llm/llm/llm_context.hpp" +#include "morpheus_llm/llm/llm_engine.hpp" +#include "morpheus_llm/llm/llm_lambda_node.hpp" +#include "morpheus_llm/llm/llm_task.hpp" -#include "morpheus/llm/llm_context.hpp" -#include "morpheus/llm/llm_engine.hpp" -#include "morpheus/llm/llm_lambda_node.hpp" -#include "morpheus/llm/llm_task.hpp" +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/types.hpp" #include @@ -34,7 +34,7 @@ #include #include #include -// IWYU pragma: no_include "morpheus/llm/fwd.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/fwd.hpp" using namespace morpheus; using namespace morpheus::test; diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_llm_node.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_node.cpp similarity index 92% rename from python/morpheus/morpheus/_lib/tests/llm/test_llm_node.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_node.cpp index 5236d3bb5e..ab104e87ef 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_llm_node.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_node.cpp @@ -15,13 +15,13 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus_llm/llm/llm_context.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_lambda_node.hpp" +#include "morpheus_llm/llm/llm_node.hpp" // for LLMNode +#include "morpheus_llm/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/llm_task.hpp" -#include "morpheus/llm/llm_context.hpp" // for LLMContext -#include "morpheus/llm/llm_lambda_node.hpp" -#include "morpheus/llm/llm_node.hpp" // for LLMNode -#include "morpheus/llm/llm_node_runner.hpp" -#include "morpheus/llm/llm_task.hpp" +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/types.hpp" #include @@ -33,7 +33,7 @@ #include #include #include -// IWYU pragma: no_include "morpheus/llm/fwd.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/fwd.hpp" using namespace morpheus; using namespace morpheus::test; diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_llm_node_runner.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_node_runner.cpp similarity index 91% rename from python/morpheus/morpheus/_lib/tests/llm/test_llm_node_runner.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_node_runner.cpp index 6662f7ec04..874a813137 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_llm_node_runner.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_node_runner.cpp @@ -15,14 +15,14 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated - -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_context.hpp" // for LLMContext -#include "morpheus/llm/llm_lambda_node.hpp" -#include "morpheus/llm/llm_node.hpp" // for LLMNode -#include "morpheus/llm/llm_node_runner.hpp" -#include "morpheus/llm/llm_task.hpp" +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_context.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_lambda_node.hpp" +#include "morpheus_llm/llm/llm_node.hpp" // for LLMNode +#include "morpheus_llm/llm/llm_node_runner.hpp" +#include "morpheus_llm/llm/llm_task.hpp" + +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/types.hpp" #include @@ -36,7 +36,7 @@ #include #include #include // for tuple -// IWYU pragma: no_include "morpheus/llm/fwd.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/fwd.hpp" using namespace morpheus; using namespace morpheus::test; diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_llm_task.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_task.cpp similarity index 94% rename from python/morpheus/morpheus/_lib/tests/llm/test_llm_task.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_task.cpp index 7f609995f4..7e48d8217c 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_llm_task.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_task.cpp @@ -15,9 +15,9 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus_llm/llm/llm_task.hpp" -#include "morpheus/llm/llm_task.hpp" +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated #include #include diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_llm_task_handler_runner.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_task_handler_runner.cpp similarity index 89% rename from python/morpheus/morpheus/_lib/tests/llm/test_llm_task_handler_runner.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_task_handler_runner.cpp index 2a0dca7e1e..3835786981 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_llm_task_handler_runner.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_llm_task_handler_runner.cpp @@ -15,14 +15,14 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated - -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/llm_context.hpp" // for LLMContext -#include "morpheus/llm/llm_task.hpp" -#include "morpheus/llm/llm_task_handler.hpp" -#include "morpheus/llm/llm_task_handler_runner.hpp" -#include "morpheus/messages/control.hpp" // for ControlMessage +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/llm_context.hpp" // for LLMContext +#include "morpheus_llm/llm/llm_task.hpp" +#include "morpheus_llm/llm/llm_task_handler.hpp" +#include "morpheus_llm/llm/llm_task_handler_runner.hpp" + +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus/messages/control.hpp" // for ControlMessage #include "morpheus/types.hpp" #include @@ -35,7 +35,7 @@ #include #include // for optional #include -// IWYU pragma: no_include "morpheus/llm/fwd.hpp" +// IWYU pragma: no_include "morpheus_llm/llm/fwd.hpp" using namespace morpheus; using namespace morpheus::test; diff --git a/python/morpheus/morpheus/_lib/tests/llm/test_utils.cpp b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_utils.cpp similarity index 97% rename from python/morpheus/morpheus/_lib/tests/llm/test_utils.cpp rename to python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_utils.cpp index 10bc0b1013..8565ad6f80 100644 --- a/python/morpheus/morpheus/_lib/tests/llm/test_utils.cpp +++ b/python/morpheus_llm/morpheus_llm/_lib/tests/llm/test_utils.cpp @@ -15,10 +15,10 @@ * limitations under the License. */ -#include "../test_utils/common.hpp" // IWYU pragma: associated +#include "morpheus_llm/llm/input_map.hpp" +#include "morpheus_llm/llm/utils.hpp" -#include "morpheus/llm/input_map.hpp" -#include "morpheus/llm/utils.hpp" +#include "morpheus/_lib/tests/test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/types.hpp" #include diff --git a/python/morpheus_llm/morpheus_llm/_version.py b/python/morpheus_llm/morpheus_llm/_version.py new file mode 100644 index 0000000000..af416901c7 --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/_version.py @@ -0,0 +1,685 @@ +# SPDX-FileCopyrightText: Copyright (c) 2021-2022, 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. + +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.22 (https://github.com/python-versioneer/python-versioneer) +"""Git implementation of _version.py.""" + +import errno +import functools +import os +import re +import subprocess +import sys +from typing import Callable +from typing import Dict + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "$Format:%d$" + git_full = "$Format:%H$" + git_date = "$Format:%ci$" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "pep440" + cfg.tag_prefix = "v" + cfg.parentdir_prefix = "morpheus-" + cfg.versionfile_source = "morpheus/_version.py" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen([command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands, )) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix):], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print("Tried directories %s but none started with prefix %s" % (str(rootdirs), parentdir_prefix)) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r'\d', r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix):] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r'\d', r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, "full-revisionid": keywords["full"].strip(), "dirty": False, "error": None, "date": date + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + MATCH_ARGS = ["--match", "%s*" % tag_prefix] if tag_prefix else [] + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty", "--always", "--long", *MATCH_ARGS], cwd=root) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[:git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = ("unable to parse git-describe output: '%s'" % describe_out) + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = ("tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix)) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix):] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root) + pieces["distance"] = int(count_out) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date") + } + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split('/'): + root = os.path.dirname(root) + except NameError: + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None + } + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None + } diff --git a/python/morpheus/morpheus/llm/__init__.py b/python/morpheus_llm/morpheus_llm/llm/__init__.py similarity index 67% rename from python/morpheus/morpheus/llm/__init__.py rename to python/morpheus_llm/morpheus_llm/llm/__init__.py index 5a06014cf1..004336a4e0 100644 --- a/python/morpheus/morpheus/llm/__init__.py +++ b/python/morpheus_llm/morpheus_llm/llm/__init__.py @@ -15,15 +15,15 @@ All objects related to using LLMs in Morpheus """ -from morpheus._lib.llm import InputMap -from morpheus._lib.llm import LLMContext -from morpheus._lib.llm import LLMEngine -from morpheus._lib.llm import LLMLambdaNode -from morpheus._lib.llm import LLMNode -from morpheus._lib.llm import LLMNodeBase -from morpheus._lib.llm import LLMNodeRunner -from morpheus._lib.llm import LLMTask -from morpheus._lib.llm import LLMTaskHandler +from morpheus_llm._lib.llm import InputMap +from morpheus_llm._lib.llm import LLMContext +from morpheus_llm._lib.llm import LLMEngine +from morpheus_llm._lib.llm import LLMLambdaNode +from morpheus_llm._lib.llm import LLMNode +from morpheus_llm._lib.llm import LLMNodeBase +from morpheus_llm._lib.llm import LLMNodeRunner +from morpheus_llm._lib.llm import LLMTask +from morpheus_llm._lib.llm import LLMTaskHandler __all__ = [ "InputMap", diff --git a/python/morpheus/morpheus/llm/nodes/__init__.py b/python/morpheus_llm/morpheus_llm/llm/nodes/__init__.py similarity index 100% rename from python/morpheus/morpheus/llm/nodes/__init__.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/__init__.py diff --git a/python/morpheus/morpheus/llm/nodes/extracter_node.py b/python/morpheus_llm/morpheus_llm/llm/nodes/extracter_node.py similarity index 97% rename from python/morpheus/morpheus/llm/nodes/extracter_node.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/extracter_node.py index 299769f914..8027ad8178 100644 --- a/python/morpheus/morpheus/llm/nodes/extracter_node.py +++ b/python/morpheus_llm/morpheus_llm/llm/nodes/extracter_node.py @@ -17,8 +17,8 @@ import numpy as np -from morpheus.llm import LLMContext -from morpheus.llm import LLMNodeBase +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMNodeBase logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/nodes/langchain_agent_node.py b/python/morpheus_llm/morpheus_llm/llm/nodes/langchain_agent_node.py similarity index 98% rename from python/morpheus/morpheus/llm/nodes/langchain_agent_node.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/langchain_agent_node.py index 4427d6a8d5..e63b1d351c 100644 --- a/python/morpheus/morpheus/llm/nodes/langchain_agent_node.py +++ b/python/morpheus_llm/morpheus_llm/llm/nodes/langchain_agent_node.py @@ -18,8 +18,8 @@ from langchain_core.exceptions import OutputParserException -from morpheus.llm import LLMContext -from morpheus.llm import LLMNodeBase +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMNodeBase logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/nodes/llm_generate_node.py b/python/morpheus_llm/morpheus_llm/llm/nodes/llm_generate_node.py similarity index 91% rename from python/morpheus/morpheus/llm/nodes/llm_generate_node.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/llm_generate_node.py index 08a5198078..dfd6c9e4b8 100644 --- a/python/morpheus/morpheus/llm/nodes/llm_generate_node.py +++ b/python/morpheus_llm/morpheus_llm/llm/nodes/llm_generate_node.py @@ -14,9 +14,9 @@ import logging -from morpheus.llm import LLMContext -from morpheus.llm import LLMNodeBase -from morpheus.llm.services.llm_service import LLMClient +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.services.llm_service import LLMClient logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/nodes/prompt_template_node.py b/python/morpheus_llm/morpheus_llm/llm/nodes/prompt_template_node.py similarity index 97% rename from python/morpheus/morpheus/llm/nodes/prompt_template_node.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/prompt_template_node.py index fa86c2e75a..6f8446a541 100644 --- a/python/morpheus/morpheus/llm/nodes/prompt_template_node.py +++ b/python/morpheus_llm/morpheus_llm/llm/nodes/prompt_template_node.py @@ -17,8 +17,8 @@ import string import typing -from morpheus.llm import LLMContext -from morpheus.llm import LLMNodeBase +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMNodeBase logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/nodes/rag_node.py b/python/morpheus_llm/morpheus_llm/llm/nodes/rag_node.py similarity index 88% rename from python/morpheus/morpheus/llm/nodes/rag_node.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/rag_node.py index 38800a9925..b9852d0350 100644 --- a/python/morpheus/morpheus/llm/nodes/rag_node.py +++ b/python/morpheus_llm/morpheus_llm/llm/nodes/rag_node.py @@ -15,12 +15,12 @@ import logging import typing -from morpheus.llm import LLMNode -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode -from morpheus.llm.nodes.prompt_template_node import PromptTemplateNode -from morpheus.llm.nodes.retriever_node import RetrieverNode -from morpheus.llm.services.llm_service import LLMClient from morpheus.service.vdb.vector_db_service import VectorDBResourceService +from morpheus_llm.llm import LLMNode +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm.nodes.prompt_template_node import PromptTemplateNode +from morpheus_llm.llm.nodes.retriever_node import RetrieverNode +from morpheus_llm.llm.services.llm_service import LLMClient logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/nodes/retriever_node.py b/python/morpheus_llm/morpheus_llm/llm/nodes/retriever_node.py similarity index 97% rename from python/morpheus/morpheus/llm/nodes/retriever_node.py rename to python/morpheus_llm/morpheus_llm/llm/nodes/retriever_node.py index 9d8df4109c..e319cc19af 100644 --- a/python/morpheus/morpheus/llm/nodes/retriever_node.py +++ b/python/morpheus_llm/morpheus_llm/llm/nodes/retriever_node.py @@ -15,9 +15,9 @@ import logging import typing -from morpheus.llm import LLMContext -from morpheus.llm import LLMNodeBase from morpheus.service.vdb.vector_db_service import VectorDBResourceService +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMNodeBase logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/services/__init__.py b/python/morpheus_llm/morpheus_llm/llm/services/__init__.py similarity index 100% rename from python/morpheus/morpheus/llm/services/__init__.py rename to python/morpheus_llm/morpheus_llm/llm/services/__init__.py diff --git a/python/morpheus/morpheus/llm/services/llm_service.py b/python/morpheus_llm/morpheus_llm/llm/services/llm_service.py similarity index 96% rename from python/morpheus/morpheus/llm/services/llm_service.py rename to python/morpheus_llm/morpheus_llm/llm/services/llm_service.py index bade2f94ca..86b21ca7bb 100644 --- a/python/morpheus/morpheus/llm/services/llm_service.py +++ b/python/morpheus_llm/morpheus_llm/llm/services/llm_service.py @@ -19,8 +19,8 @@ from abc import abstractmethod if typing.TYPE_CHECKING: - from morpheus.llm.services.nemo_llm_service import NeMoLLMService - from morpheus.llm.services.openai_chat_service import OpenAIChatService + from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService + from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService logger = logging.getLogger(__name__) @@ -203,7 +203,7 @@ def create(service_type: str | typing.Literal["nemo"] | typing.Literal["openai"] else: llm_or_chat = "llm" - module_name = f"morpheus.llm.services.{service_type.lower()}_{llm_or_chat}_service" + module_name = f"morpheus_llm.llm.services.{service_type.lower()}_{llm_or_chat}_service" module = importlib.import_module(module_name) # Get all of the classes in the module to find the correct service class diff --git a/python/morpheus/morpheus/llm/services/nemo_llm_service.py b/python/morpheus_llm/morpheus_llm/llm/services/nemo_llm_service.py similarity index 98% rename from python/morpheus/morpheus/llm/services/nemo_llm_service.py rename to python/morpheus_llm/morpheus_llm/llm/services/nemo_llm_service.py index 364b3928bc..a3c2c2f6b5 100644 --- a/python/morpheus/morpheus/llm/services/nemo_llm_service.py +++ b/python/morpheus_llm/morpheus_llm/llm/services/nemo_llm_service.py @@ -17,9 +17,9 @@ import typing import warnings -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.llm_service import LLMService from morpheus.utils.env_config_value import EnvConfigValue +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.llm_service import LLMService logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/services/nvfoundation_llm_service.py b/python/morpheus_llm/morpheus_llm/llm/services/nvfoundation_llm_service.py similarity index 98% rename from python/morpheus/morpheus/llm/services/nvfoundation_llm_service.py rename to python/morpheus_llm/morpheus_llm/llm/services/nvfoundation_llm_service.py index da6820d0d9..d1e706b7c2 100644 --- a/python/morpheus/morpheus/llm/services/nvfoundation_llm_service.py +++ b/python/morpheus_llm/morpheus_llm/llm/services/nvfoundation_llm_service.py @@ -15,9 +15,9 @@ import logging import typing -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.llm_service import LLMService from morpheus.utils.env_config_value import EnvConfigValue +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.llm_service import LLMService logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/services/openai_chat_service.py b/python/morpheus_llm/morpheus_llm/llm/services/openai_chat_service.py similarity index 99% rename from python/morpheus/morpheus/llm/services/openai_chat_service.py rename to python/morpheus_llm/morpheus_llm/llm/services/openai_chat_service.py index 3b2c87b4f2..a15f9c1a2d 100644 --- a/python/morpheus/morpheus/llm/services/openai_chat_service.py +++ b/python/morpheus_llm/morpheus_llm/llm/services/openai_chat_service.py @@ -22,9 +22,9 @@ import appdirs -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.llm_service import LLMService from morpheus.utils.env_config_value import EnvConfigValue +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.llm_service import LLMService logger = logging.getLogger(__name__) diff --git a/python/morpheus/morpheus/llm/services/utils/__init__.py b/python/morpheus_llm/morpheus_llm/llm/services/utils/__init__.py similarity index 100% rename from python/morpheus/morpheus/llm/services/utils/__init__.py rename to python/morpheus_llm/morpheus_llm/llm/services/utils/__init__.py diff --git a/python/morpheus/morpheus/llm/services/utils/langchain_llm_client_wrapper.py b/python/morpheus_llm/morpheus_llm/llm/services/utils/langchain_llm_client_wrapper.py similarity index 97% rename from python/morpheus/morpheus/llm/services/utils/langchain_llm_client_wrapper.py rename to python/morpheus_llm/morpheus_llm/llm/services/utils/langchain_llm_client_wrapper.py index 7c387675c6..42dbca50b2 100644 --- a/python/morpheus/morpheus/llm/services/utils/langchain_llm_client_wrapper.py +++ b/python/morpheus_llm/morpheus_llm/llm/services/utils/langchain_llm_client_wrapper.py @@ -18,7 +18,7 @@ from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM -from morpheus.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.llm_service import LLMClient class LangchainLLMClientWrapper(LLM): diff --git a/python/morpheus/morpheus/llm/task_handlers/__init__.py b/python/morpheus_llm/morpheus_llm/llm/task_handlers/__init__.py similarity index 100% rename from python/morpheus/morpheus/llm/task_handlers/__init__.py rename to python/morpheus_llm/morpheus_llm/llm/task_handlers/__init__.py diff --git a/python/morpheus/morpheus/llm/task_handlers/simple_task_handler.py b/python/morpheus_llm/morpheus_llm/llm/task_handlers/simple_task_handler.py similarity index 95% rename from python/morpheus/morpheus/llm/task_handlers/simple_task_handler.py rename to python/morpheus_llm/morpheus_llm/llm/task_handlers/simple_task_handler.py index 8f225581b3..060b4588cf 100644 --- a/python/morpheus/morpheus/llm/task_handlers/simple_task_handler.py +++ b/python/morpheus_llm/morpheus_llm/llm/task_handlers/simple_task_handler.py @@ -14,9 +14,9 @@ import logging -from morpheus.llm import LLMContext -from morpheus.llm import LLMTaskHandler from morpheus.messages import ControlMessage +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMTaskHandler logger = logging.getLogger(__name__) diff --git a/python/morpheus_llm/morpheus_llm/py.typed b/python/morpheus_llm/morpheus_llm/py.typed new file mode 100644 index 0000000000..e69de29bb2 diff --git a/python/morpheus_llm/morpheus_llm/stages/__init__.py b/python/morpheus_llm/morpheus_llm/stages/__init__.py new file mode 100644 index 0000000000..1463b6a17c --- /dev/null +++ b/python/morpheus_llm/morpheus_llm/stages/__init__.py @@ -0,0 +1,16 @@ +# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# +# 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. +""" +Package containing all Morpheus LLM stages. +""" diff --git a/python/morpheus/morpheus/stages/llm/__init__.py b/python/morpheus_llm/morpheus_llm/stages/llm/__init__.py similarity index 100% rename from python/morpheus/morpheus/stages/llm/__init__.py rename to python/morpheus_llm/morpheus_llm/stages/llm/__init__.py diff --git a/python/morpheus/morpheus/stages/llm/llm_engine_stage.py b/python/morpheus_llm/morpheus_llm/stages/llm/llm_engine_stage.py similarity index 94% rename from python/morpheus/morpheus/stages/llm/llm_engine_stage.py rename to python/morpheus_llm/morpheus_llm/stages/llm/llm_engine_stage.py index 012681c3d4..86c0717964 100644 --- a/python/morpheus/morpheus/stages/llm/llm_engine_stage.py +++ b/python/morpheus_llm/morpheus_llm/stages/llm/llm_engine_stage.py @@ -17,12 +17,12 @@ import mrc -import morpheus._lib.llm as _llm +import morpheus_llm._lib.llm as _llm from morpheus.config import Config -from morpheus.llm import LLMEngine from morpheus.messages import ControlMessage from morpheus.pipeline.pass_thru_type_mixin import PassThruTypeMixin from morpheus.pipeline.single_port_stage import SinglePortStage +from morpheus_llm.llm import LLMEngine logger = logging.getLogger(__name__) @@ -35,7 +35,7 @@ class LLMEngineStage(PassThruTypeMixin, SinglePortStage): ---------- c : `morpheus.config.Config` Pipeline configuration instance. - engine : `morpheus.llm.LLMEngine` + engine : `morpheus_llm.llm.LLMEngine` LLM engine instance to execute. """ diff --git a/python/morpheus_llm/setup.cfg b/python/morpheus_llm/setup.cfg new file mode 100644 index 0000000000..6c9c35a5c0 --- /dev/null +++ b/python/morpheus_llm/setup.cfg @@ -0,0 +1,26 @@ +# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# 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. + +# See the docstring in versioneer.py for instructions. Note that you must +# re-run 'versioneer.py setup' after changing this section, and commit the +# resulting files. + +# ===== versioneer Config ===== +[versioneer] +VCS = git +style = pep440 +versionfile_source = morpheus_llm/_version.py +versionfile_build = morpheus_llm/_version.py +tag_prefix = v +parentdir_prefix = morpheus_llm- + diff --git a/python/morpheus_llm/setup.py b/python/morpheus_llm/setup.py new file mode 100644 index 0000000000..82efd469fd --- /dev/null +++ b/python/morpheus_llm/setup.py @@ -0,0 +1,45 @@ +# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# 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. + +# See the docstring in versioneer.py for instructions. Note that you must +# re-run 'versioneer setup' after changing this section, and commit the +# resulting files. + +import versioneer +from setuptools import find_packages # noqa: E402 +from setuptools import setup # noqa: E402 + +setup( + name="morpheus_llm", + version=versioneer.get_version(), # pylint: disable=no-member + description="Morpheus LLM", + classifiers=[ + "Development Status :: 3 - Alpha", + "Environment :: GPU :: NVIDIA CUDA", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Security", + "Topic :: System :: Networking :: Monitoring", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3 :: Only", + ], + author="NVIDIA Corporation", + include_package_data=True, + packages=find_packages(exclude=['tests']), + install_requires=[], + license="Apache", + python_requires='>=3.10, <4', + cmdclass=versioneer.get_cmdclass(), # pylint: disable=no-member +) diff --git a/scripts/compile.sh b/scripts/compile.sh index ee37379b9d..cf8c628515 100755 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -33,6 +33,7 @@ cmake -S . -B ${BUILD_DIR} -GNinja \ -DMORPHEUS_USE_CCACHE=ON \ -DMORPHEUS_USE_CONDA=${MORPHEUS_USE_CONDA:-ON} \ -DMORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-OFF} \ + -DMORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM:-ON} \ ${INSTALL_PREFIX:+-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}} \ ${CMAKE_ARGS:+${CMAKE_ARGS}} \ ${CMAKE_CONFIGURE_EXTRA_ARGS:+${CMAKE_CONFIGURE_EXTRA_ARGS}} diff --git a/tests/_utils/llm.py b/tests/_utils/llm.py index 9d9802478d..586061befa 100644 --- a/tests/_utils/llm.py +++ b/tests/_utils/llm.py @@ -16,12 +16,12 @@ import typing from unittest import mock -from morpheus.llm import InputMap -from morpheus.llm import LLMContext -from morpheus.llm import LLMNodeBase -from morpheus.llm import LLMTask -from morpheus.llm import LLMTaskHandler from morpheus.messages import ControlMessage +from morpheus_llm.llm import InputMap +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm import LLMTask +from morpheus_llm.llm import LLMTaskHandler def _mk_context(parent_context: LLMContext, input_values: dict) -> LLMContext: diff --git a/tests/benchmarks/test_bench_agents_simple_pipeline.py b/tests/benchmarks/test_bench_agents_simple_pipeline.py index 95bf6e3619..5631d6e6ac 100644 --- a/tests/benchmarks/test_bench_agents_simple_pipeline.py +++ b/tests/benchmarks/test_bench_agents_simple_pipeline.py @@ -30,16 +30,16 @@ import cudf from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.langchain_agent_node import LangChainAgentNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.langchain_agent_node import LangChainAgentNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_agent_executor(model_name: str): diff --git a/tests/benchmarks/test_bench_completion_pipeline.py b/tests/benchmarks/test_bench_completion_pipeline.py index 55cdb9243e..99d7157a5e 100644 --- a/tests/benchmarks/test_bench_completion_pipeline.py +++ b/tests/benchmarks/test_bench_completion_pipeline.py @@ -22,20 +22,20 @@ from _utils.dataset_manager import DatasetManager from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode -from morpheus.llm.nodes.prompt_template_node import PromptTemplateNode -from morpheus.llm.services.llm_service import LLMService -from morpheus.llm.services.nemo_llm_service import NeMoLLMService -from morpheus.llm.services.openai_chat_service import OpenAIChatService -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm.nodes.prompt_template_node import PromptTemplateNode +from morpheus_llm.llm.services.llm_service import LLMService +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine(llm_service_cls: type[LLMService], model_name: str = "test_model"): diff --git a/tests/benchmarks/test_bench_rag_standalone_pipeline.py b/tests/benchmarks/test_bench_rag_standalone_pipeline.py index b09d4b624d..ee4cd1e974 100644 --- a/tests/benchmarks/test_bench_rag_standalone_pipeline.py +++ b/tests/benchmarks/test_bench_rag_standalone_pipeline.py @@ -28,16 +28,16 @@ from _utils.milvus import populate_milvus from morpheus.config import Config from morpheus.config import PipelineModes -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.rag_node import RAGNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.rag_node import RAGNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage EMBEDDING_SIZE = 384 QUESTION = "What are some new attacks discovered in the cyber security industry?" diff --git a/tests/llm/nodes/conftest.py b/tests/llm/nodes/conftest.py index cdaaf52118..878b948724 100644 --- a/tests/llm/nodes/conftest.py +++ b/tests/llm/nodes/conftest.py @@ -20,7 +20,7 @@ @pytest.fixture(name="mock_llm_client") def mock_llm_client_fixture(): - from morpheus.llm.services.llm_service import LLMClient + from morpheus_llm.llm.services.llm_service import LLMClient mock_client = mock.MagicMock(LLMClient) mock_client.return_value = mock_client mock_client.get_input_names.return_value = ["prompt"] diff --git a/tests/llm/nodes/test_extractor_node.py b/tests/llm/nodes/test_extractor_node.py index 196d99403a..355f16aeb5 100644 --- a/tests/llm/nodes/test_extractor_node.py +++ b/tests/llm/nodes/test_extractor_node.py @@ -16,10 +16,10 @@ import cudf from _utils.llm import execute_node -from morpheus.llm import LLMNodeBase -from morpheus.llm.nodes.extracter_node import ExtracterNode from morpheus.messages import ControlMessage from morpheus.messages import MessageMeta +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode def test_constructor(): diff --git a/tests/llm/nodes/test_langchain_agent_node.py b/tests/llm/nodes/test_langchain_agent_node.py index fd78a91f93..033e978402 100644 --- a/tests/llm/nodes/test_langchain_agent_node.py +++ b/tests/llm/nodes/test_langchain_agent_node.py @@ -31,8 +31,8 @@ from _utils.llm import execute_node from _utils.llm import mk_mock_langchain_tool from _utils.llm import mk_mock_openai_response -from morpheus.llm import LLMNodeBase -from morpheus.llm.nodes.langchain_agent_node import LangChainAgentNode +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.nodes.langchain_agent_node import LangChainAgentNode def test_constructor(mock_agent_executor: mock.MagicMock): diff --git a/tests/llm/nodes/test_langchain_agent_node_pipe.py b/tests/llm/nodes/test_langchain_agent_node_pipe.py index 12e9ad1f21..4707ebb9d3 100644 --- a/tests/llm/nodes/test_langchain_agent_node_pipe.py +++ b/tests/llm/nodes/test_langchain_agent_node_pipe.py @@ -18,16 +18,16 @@ from _utils import assert_results from _utils.dataset_manager import DatasetManager from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.langchain_agent_node import LangChainAgentNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.langchain_agent_node import LangChainAgentNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine(mock_agent_executor: mock.MagicMock) -> LLMEngine: diff --git a/tests/llm/nodes/test_llm_generate_node.py b/tests/llm/nodes/test_llm_generate_node.py index b3845b8791..a15d9b1292 100644 --- a/tests/llm/nodes/test_llm_generate_node.py +++ b/tests/llm/nodes/test_llm_generate_node.py @@ -16,8 +16,8 @@ from unittest import mock from _utils.llm import execute_node -from morpheus.llm import LLMNodeBase -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode def test_constructor(mock_llm_client: mock.MagicMock): diff --git a/tests/llm/nodes/test_llm_generate_node_pipe.py b/tests/llm/nodes/test_llm_generate_node_pipe.py index 19534dc31d..9f1b33b7e3 100644 --- a/tests/llm/nodes/test_llm_generate_node_pipe.py +++ b/tests/llm/nodes/test_llm_generate_node_pipe.py @@ -19,16 +19,16 @@ from _utils import assert_results from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine(mock_llm_client: mock.MagicMock) -> LLMEngine: diff --git a/tests/llm/nodes/test_llm_retriever_node.py b/tests/llm/nodes/test_llm_retriever_node.py index ed4e952e34..4dfae0ca63 100644 --- a/tests/llm/nodes/test_llm_retriever_node.py +++ b/tests/llm/nodes/test_llm_retriever_node.py @@ -19,8 +19,8 @@ import pytest from _utils.llm import execute_node -from morpheus.llm import LLMNodeBase -from morpheus.llm.nodes.retriever_node import RetrieverNode +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.nodes.retriever_node import RetrieverNode @pytest.mark.parametrize("embedding", [None, mock.AsyncMock()]) diff --git a/tests/llm/nodes/test_llm_retriever_node_pipe.py b/tests/llm/nodes/test_llm_retriever_node_pipe.py index 7b6c97cfb8..40c726f65d 100644 --- a/tests/llm/nodes/test_llm_retriever_node_pipe.py +++ b/tests/llm/nodes/test_llm_retriever_node_pipe.py @@ -20,18 +20,18 @@ import cudf from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.retriever_node import RetrieverNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.service.vdb.milvus_vector_db_service import MilvusVectorDBResourceService from morpheus.service.vdb.milvus_vector_db_service import MilvusVectorDBService from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.retriever_node import RetrieverNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage @pytest.fixture(scope="module", name="milvus_service") diff --git a/tests/llm/nodes/test_manual_extractor_node.py b/tests/llm/nodes/test_manual_extractor_node.py index 73cb1d1e60..143636999d 100644 --- a/tests/llm/nodes/test_manual_extractor_node.py +++ b/tests/llm/nodes/test_manual_extractor_node.py @@ -18,10 +18,10 @@ import cudf from _utils.llm import execute_node -from morpheus.llm import LLMNodeBase -from morpheus.llm.nodes.extracter_node import ManualExtracterNode from morpheus.messages import ControlMessage from morpheus.messages import MessageMeta +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.nodes.extracter_node import ManualExtracterNode def test_constructor(): diff --git a/tests/llm/nodes/test_prompt_template_node.py b/tests/llm/nodes/test_prompt_template_node.py index f15178c276..875d71c26e 100644 --- a/tests/llm/nodes/test_prompt_template_node.py +++ b/tests/llm/nodes/test_prompt_template_node.py @@ -16,7 +16,7 @@ import pytest from _utils.llm import execute_node -from morpheus.llm.nodes.prompt_template_node import PromptTemplateNode +from morpheus_llm.llm.nodes.prompt_template_node import PromptTemplateNode MULTI_LINE_JINJA_TEMPLATE = """Testing a loop: {% for lv in list_values -%}Title: {{ lv.title }}, Summary: {{ lv.summary }} diff --git a/tests/llm/nodes/test_prompt_template_node_pipe.py b/tests/llm/nodes/test_prompt_template_node_pipe.py index 013b5de43b..1ba083dec0 100644 --- a/tests/llm/nodes/test_prompt_template_node_pipe.py +++ b/tests/llm/nodes/test_prompt_template_node_pipe.py @@ -20,16 +20,16 @@ from _utils import assert_results from morpheus.config import Config from morpheus.config import PipelineModes -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.prompt_template_node import PromptTemplateNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.prompt_template_node import PromptTemplateNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage MULTI_LINE_JINJA_TEMPLATE = """Testing a loop: {% for lv in ctx.list_values -%}Title: {{ lv.title }}, Summary: {{ lv.summary }} diff --git a/tests/llm/nodes/test_rag_node.py b/tests/llm/nodes/test_rag_node.py index d5325a70b6..d57a75c89f 100644 --- a/tests/llm/nodes/test_rag_node.py +++ b/tests/llm/nodes/test_rag_node.py @@ -19,8 +19,8 @@ import pytest from _utils.llm import execute_node -from morpheus.llm import LLMNodeBase -from morpheus.llm.nodes.rag_node import RAGNode +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm.nodes.rag_node import RAGNode @pytest.mark.parametrize("embedding", [None, mock.AsyncMock()]) diff --git a/tests/llm/nodes/test_rag_node_pipe.py b/tests/llm/nodes/test_rag_node_pipe.py index 2e15b9c9fd..2c612b5a6a 100644 --- a/tests/llm/nodes/test_rag_node_pipe.py +++ b/tests/llm/nodes/test_rag_node_pipe.py @@ -19,16 +19,16 @@ from _utils import assert_results from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.rag_node import RAGNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.rag_node import RAGNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine(mock_llm_client: mock.MagicMock) -> LLMEngine: diff --git a/tests/llm/services/test_llm_service.py b/tests/llm/services/test_llm_service.py index 871d1031cf..f2978cda4b 100644 --- a/tests/llm/services/test_llm_service.py +++ b/tests/llm/services/test_llm_service.py @@ -20,11 +20,11 @@ import pytest -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.llm_service import LLMService -from morpheus.llm.services.nemo_llm_service import NeMoLLMService -from morpheus.llm.services.nvfoundation_llm_service import NVFoundationLLMService -from morpheus.llm.services.openai_chat_service import OpenAIChatService +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.llm_service import LLMService +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.nvfoundation_llm_service import NVFoundationLLMService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService @pytest.mark.parametrize("cls", [LLMClient, LLMService]) @@ -46,10 +46,11 @@ def test_create(service_name: str, expected_cls: type, env_values: dict[str, str assert isinstance(service, expected_cls) -@pytest.mark.parametrize("service_name, class_name", - [("nemo", "morpheus.llm.services.nemo_llm_service.NeMoLLMService"), - ("openai", "morpheus.llm.services.openai_chat_service.OpenAIChatService"), - ("nvfoundation", "morpheus.llm.services.nvfoundation_llm_service.NVFoundationLLMService")]) +@pytest.mark.parametrize( + "service_name, class_name", + [("nemo", "morpheus_llm.llm.services.nemo_llm_service.NeMoLLMService"), + ("openai", "morpheus_llm.llm.services.openai_chat_service.OpenAIChatService"), + ("nvfoundation", "morpheus_llm.llm.services.nvfoundation_llm_service.NVFoundationLLMService")]) def test_create_mocked(service_name: str, class_name: str): with mock.patch(class_name) as mock_cls: mock_instance = mock.MagicMock() diff --git a/tests/llm/services/test_llm_service_pipe.py b/tests/llm/services/test_llm_service_pipe.py index 13fb5f652e..4206f2b945 100644 --- a/tests/llm/services/test_llm_service_pipe.py +++ b/tests/llm/services/test_llm_service_pipe.py @@ -21,19 +21,19 @@ from _utils.environment import set_env from _utils.llm import mk_mock_openai_response from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.nemo_llm_service import NeMoLLMService -from morpheus.llm.services.openai_chat_service import OpenAIChatService -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine(llm_client: LLMClient): diff --git a/tests/llm/services/test_nemo_llm_client.py b/tests/llm/services/test_nemo_llm_client.py index d6cc295ea4..197b1a2804 100644 --- a/tests/llm/services/test_nemo_llm_client.py +++ b/tests/llm/services/test_nemo_llm_client.py @@ -17,8 +17,8 @@ import pytest -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService def test_constructor(): diff --git a/tests/llm/services/test_nemo_llm_service.py b/tests/llm/services/test_nemo_llm_service.py index 739d44e31b..c5cd77eb8b 100644 --- a/tests/llm/services/test_nemo_llm_service.py +++ b/tests/llm/services/test_nemo_llm_service.py @@ -18,8 +18,8 @@ import pytest -from morpheus.llm.services.nemo_llm_service import NeMoLLMClient -from morpheus.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMClient +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService @pytest.mark.usefixtures("restore_environ") diff --git a/tests/llm/services/test_nvfoundation_llm_service.py b/tests/llm/services/test_nvfoundation_llm_service.py index dec76060e8..f139ddacde 100644 --- a/tests/llm/services/test_nvfoundation_llm_service.py +++ b/tests/llm/services/test_nvfoundation_llm_service.py @@ -21,8 +21,8 @@ from langchain_core.outputs import ChatGeneration from langchain_core.outputs import LLMResult -from morpheus.llm.services.nvfoundation_llm_service import NVFoundationLLMClient -from morpheus.llm.services.nvfoundation_llm_service import NVFoundationLLMService +from morpheus_llm.llm.services.nvfoundation_llm_service import NVFoundationLLMClient +from morpheus_llm.llm.services.nvfoundation_llm_service import NVFoundationLLMService @pytest.fixture(name="set_default_nvidia_api_key", autouse=True, scope="function") diff --git a/tests/llm/services/test_openai_chat_service.py b/tests/llm/services/test_openai_chat_service.py index 54b4290ded..853ed8d824 100644 --- a/tests/llm/services/test_openai_chat_service.py +++ b/tests/llm/services/test_openai_chat_service.py @@ -20,7 +20,7 @@ import pytest from _utils.llm import mk_mock_openai_response -from morpheus.llm.services.openai_chat_service import OpenAIChatService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService @pytest.fixture(name="set_default_openai_api_key", autouse=True, scope="function") diff --git a/tests/llm/task_handlers/test_simple_task_handler.py b/tests/llm/task_handlers/test_simple_task_handler.py index 56b633f933..8439d2df3d 100644 --- a/tests/llm/task_handlers/test_simple_task_handler.py +++ b/tests/llm/task_handlers/test_simple_task_handler.py @@ -17,11 +17,11 @@ from _utils.dataset_manager import DatasetManager from _utils.llm import execute_task_handler -from morpheus.llm import LLMTaskHandler -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.messages import MessageMeta from morpheus.utils.type_aliases import DataFrameType +from morpheus_llm.llm import LLMTaskHandler +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler def test_constructor(): diff --git a/tests/llm/test_agents_simple_pipe.py b/tests/llm/test_agents_simple_pipe.py index e0bb7870d6..e7ac760760 100644 --- a/tests/llm/test_agents_simple_pipe.py +++ b/tests/llm/test_agents_simple_pipe.py @@ -29,18 +29,18 @@ from _utils import assert_results from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.langchain_agent_node import LangChainAgentNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.output.in_memory_sink_stage import InMemorySinkStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage from morpheus.utils.concat_df import concat_dataframes +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.langchain_agent_node import LangChainAgentNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage @pytest.fixture(name="questions") diff --git a/tests/llm/test_completion_pipe.py b/tests/llm/test_completion_pipe.py index ed2f27e8ec..e83615280b 100644 --- a/tests/llm/test_completion_pipe.py +++ b/tests/llm/test_completion_pipe.py @@ -24,20 +24,20 @@ from _utils.environment import set_env from _utils.llm import mk_mock_openai_response from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.llm_generate_node import LLMGenerateNode -from morpheus.llm.nodes.prompt_template_node import PromptTemplateNode -from morpheus.llm.services.llm_service import LLMClient -from morpheus.llm.services.nemo_llm_service import NeMoLLMService -from morpheus.llm.services.openai_chat_service import OpenAIChatService -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.llm_generate_node import LLMGenerateNode +from morpheus_llm.llm.nodes.prompt_template_node import PromptTemplateNode +from morpheus_llm.llm.services.llm_service import LLMClient +from morpheus_llm.llm.services.nemo_llm_service import NeMoLLMService +from morpheus_llm.llm.services.openai_chat_service import OpenAIChatService +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage logger = logging.getLogger(__name__) diff --git a/tests/llm/test_extractor_simple_task_handler_pipe.py b/tests/llm/test_extractor_simple_task_handler_pipe.py index d9caee7b16..bf1324682d 100644 --- a/tests/llm/test_extractor_simple_task_handler_pipe.py +++ b/tests/llm/test_extractor_simple_task_handler_pipe.py @@ -16,15 +16,15 @@ from _utils import assert_results from _utils.dataset_manager import DatasetManager from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine() -> LLMEngine: diff --git a/tests/llm/test_llm.py b/tests/llm/test_llm.py index 608db37a8f..aca30b1c7b 100644 --- a/tests/llm/test_llm.py +++ b/tests/llm/test_llm.py @@ -20,14 +20,14 @@ import cudf from _utils.dataset_manager import DatasetManager -from morpheus.llm import LLMContext -from morpheus.llm import LLMEngine -from morpheus.llm import LLMLambdaNode -from morpheus.llm import LLMNode -from morpheus.llm import LLMNodeBase -from morpheus.llm import LLMTaskHandler from morpheus.messages import ControlMessage from morpheus.messages import MessageMeta +from morpheus_llm.llm import LLMContext +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm import LLMLambdaNode +from morpheus_llm.llm import LLMNode +from morpheus_llm.llm import LLMNodeBase +from morpheus_llm.llm import LLMTaskHandler async def yield_to_loop(): diff --git a/tests/llm/test_rag_standalone_pipe.py b/tests/llm/test_rag_standalone_pipe.py index 0f8513a8bb..6019463bf0 100644 --- a/tests/llm/test_rag_standalone_pipe.py +++ b/tests/llm/test_rag_standalone_pipe.py @@ -29,16 +29,16 @@ from _utils.milvus import populate_milvus from morpheus.config import Config from morpheus.config import PipelineModes -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.nodes.rag_node import RAGNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.nodes.rag_node import RAGNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage EMBEDDING_SIZE = 384 QUESTION = "What are some new attacks discovered in the cyber security industry?" diff --git a/tests/stages/test_llm_engine_stage.py b/tests/stages/test_llm_engine_stage.py index 6b9158c1bd..eb99847ab2 100644 --- a/tests/stages/test_llm_engine_stage.py +++ b/tests/stages/test_llm_engine_stage.py @@ -17,10 +17,10 @@ from unittest import mock from morpheus.config import Config -from morpheus.llm import LLMEngine from morpheus.messages import ControlMessage from morpheus.pipeline.single_port_stage import SinglePortStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def test_constructor(config: Config): diff --git a/tests/stages/test_llm_engine_stage_pipe.py b/tests/stages/test_llm_engine_stage_pipe.py index 514d76c0b0..16151bca26 100644 --- a/tests/stages/test_llm_engine_stage_pipe.py +++ b/tests/stages/test_llm_engine_stage_pipe.py @@ -22,15 +22,15 @@ from _utils import assert_results from _utils.dataset_manager import DatasetManager from morpheus.config import Config -from morpheus.llm import LLMEngine -from morpheus.llm.nodes.extracter_node import ExtracterNode -from morpheus.llm.task_handlers.simple_task_handler import SimpleTaskHandler from morpheus.messages import ControlMessage from morpheus.pipeline.linear_pipeline import LinearPipeline from morpheus.stages.input.in_memory_source_stage import InMemorySourceStage -from morpheus.stages.llm.llm_engine_stage import LLMEngineStage from morpheus.stages.output.compare_dataframe_stage import CompareDataFrameStage from morpheus.stages.preprocess.deserialize_stage import DeserializeStage +from morpheus_llm.llm import LLMEngine +from morpheus_llm.llm.nodes.extracter_node import ExtracterNode +from morpheus_llm.llm.task_handlers.simple_task_handler import SimpleTaskHandler +from morpheus_llm.stages.llm.llm_engine_stage import LLMEngineStage def _build_engine() -> LLMEngine: From 41eaa84a789b0ba32c8c8949bb44f38190ef4159 Mon Sep 17 00:00:00 2001 From: David Gardner <96306125+dagardner-nv@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:24:51 -0700 Subject: [PATCH 4/6] Replace pdf parsing libs (#1861) * Use pypdfium2 for PDF parsing * Includes CI fix from PR #1860 ## 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: - David Gardner (https://github.com/dagardner-nv) - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) - Devin Robison (https://github.com/drobison00) - Bartley Richardson (https://github.com/BartleyR) URL: https://github.com/nv-morpheus/Morpheus/pull/1861 --- .github/workflows/pr.yaml | 18 ++++++++---------- .../environments/all_cuda-121_arch-x86_64.yaml | 2 +- .../environments/dev_cuda-121_arch-x86_64.yaml | 2 +- .../examples_cuda-121_arch-x86_64.yaml | 2 +- dependencies.yaml | 4 ++-- .../module/content_extractor_module.py | 13 ++++++++----- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index f135ff2dc2..42a261fdc0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -43,6 +43,14 @@ permissions: jobs: + pr-builder: + needs: + - prepare + - checks + - ci_pipe + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.02 + prepare: # Executes the get-pr-info action to determine if the PR has the skip-ci label, if the action fails we assume the # PR does not have the label @@ -91,13 +99,3 @@ jobs: test_container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-test-240614 secrets: NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - - pr-builder: - # Always run this step even if others are skipped or cancelled - if: '!cancelled()' - needs: - - prepare - - checks - - ci_pipe - secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.02 diff --git a/conda/environments/all_cuda-121_arch-x86_64.yaml b/conda/environments/all_cuda-121_arch-x86_64.yaml index f860ece4c6..a6aab42af3 100644 --- a/conda/environments/all_cuda-121_arch-x86_64.yaml +++ b/conda/environments/all_cuda-121_arch-x86_64.yaml @@ -83,6 +83,7 @@ dependencies: - pydantic - pylint=3.0.3 - pypdf=3.17.4 +- pypdfium2=4.30 - pytest-asyncio - pytest-benchmark=4.0 - pytest-cov @@ -120,7 +121,6 @@ dependencies: - pip: - --find-links https://data.dgl.ai/wheels-test/repo.html - --find-links https://data.dgl.ai/wheels/cu121/repo.html - - PyMuPDF==1.23.* - databricks-cli < 0.100 - databricks-connect - dgl==2.0.0 diff --git a/conda/environments/dev_cuda-121_arch-x86_64.yaml b/conda/environments/dev_cuda-121_arch-x86_64.yaml index 30781144a4..468166b3d7 100644 --- a/conda/environments/dev_cuda-121_arch-x86_64.yaml +++ b/conda/environments/dev_cuda-121_arch-x86_64.yaml @@ -67,6 +67,7 @@ dependencies: - pybind11-stubgen=0.10.5 - pydantic - pylint=3.0.3 +- pypdfium2=4.30 - pytest-asyncio - pytest-benchmark=4.0 - pytest-cov @@ -98,7 +99,6 @@ dependencies: - yapf=0.40.1 - zlib=1.2.13 - pip: - - PyMuPDF==1.23.* - databricks-cli < 0.100 - databricks-connect - milvus==2.3.5 diff --git a/conda/environments/examples_cuda-121_arch-x86_64.yaml b/conda/environments/examples_cuda-121_arch-x86_64.yaml index b144b38b13..ea17b3bdb3 100644 --- a/conda/environments/examples_cuda-121_arch-x86_64.yaml +++ b/conda/environments/examples_cuda-121_arch-x86_64.yaml @@ -44,6 +44,7 @@ dependencies: - pluggy=1.3 - pydantic - pypdf=3.17.4 +- pypdfium2=4.30 - python-confluent-kafka>=1.9.2,<1.10.0a0 - python-docx==1.1.0 - python-graphviz @@ -67,7 +68,6 @@ dependencies: - pip: - --find-links https://data.dgl.ai/wheels-test/repo.html - --find-links https://data.dgl.ai/wheels/cu121/repo.html - - PyMuPDF==1.23.* - databricks-cli < 0.100 - databricks-connect - dgl==2.0.0 diff --git a/dependencies.yaml b/dependencies.yaml index 089e0d24c9..f95295ee52 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -364,6 +364,7 @@ dependencies: - output_types: [conda] packages: - &nodejs nodejs=18.* + - &pypdfium2 pypdfium2=4.30 - pytest-asyncio - pytest-benchmark=4.0 - pytest-cov @@ -371,7 +372,6 @@ dependencies: - &python-docx python-docx==1.1.0 - pip - pip: - - &PyMuPDF PyMuPDF==1.23.* - pytest-kafka==0.6.0 example-dfp-prod: @@ -410,6 +410,7 @@ dependencies: - onnx=1.15 - openai=1.13 - pypdf=3.17.4 + - *pypdfium2 - *python-docx - requests-toolbelt=1.0 # Transitive dep needed by nemollm, specified here to ensure we get a compatible version - sentence-transformers=2.7 @@ -420,7 +421,6 @@ dependencies: - faiss-gpu==1.7.* - google-search-results==2.4 - nemollm==0.3.5 - - *PyMuPDF model-training-tuning: common: diff --git a/examples/llm/vdb_upload/module/content_extractor_module.py b/examples/llm/vdb_upload/module/content_extractor_module.py index ac5ae771e6..c02dd89718 100755 --- a/examples/llm/vdb_upload/module/content_extractor_module.py +++ b/examples/llm/vdb_upload/module/content_extractor_module.py @@ -22,11 +22,11 @@ from typing import Dict from typing import List -import fitz import fsspec import mrc import mrc.core.operators as ops import pandas as pd +import pypdfium2 as libpdfium from docx import Document from langchain.text_splitter import RecursiveCharacterTextSplitter from pydantic import BaseModel # pylint: disable=no-name-in-module @@ -172,10 +172,13 @@ def wrapper(input_info: ConverterInputInfo, *args, **kwargs): @_converter_error_handler def _pdf_to_text_converter(input_info: ConverterInputInfo) -> str: text = "" - pdf_document = fitz.open(stream=input_info.io_bytes, filetype="pdf") - for page_num in range(pdf_document.page_count): - page = pdf_document[page_num] - text += page.get_text() + pdf_document = libpdfium.PdfDocument(input_info.io_bytes) + for page_idx in range(len(pdf_document)): + page = pdf_document.get_page(page_idx) + textpage = page.get_textpage() + page_text = textpage.get_text_bounded() + text += page_text + return text From 951b7ec79044d32e75f16133aca852b84ac52305 Mon Sep 17 00:00:00 2001 From: David Gardner Date: Fri, 23 Aug 2024 17:36:25 -0700 Subject: [PATCH 5/6] Updating CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67b1cc181d..21ab786dbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ 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. --> + +# Morpheus 24.06.01 (23 Aug 2024) + +## 🛠️ Improvements +- Replace pdf parsing libs ([#1861](https://github.com/nv-morpheus/Morpheus/pull/1861)) [@dagardner-nv](https://github.com/dagardner-nv) + # Morpheus 24.06.00 (03 Jul 2024) ## 🚨 Breaking Changes From 8235316abd9dbca88795230c9adfeac8d3934474 Mon Sep 17 00:00:00 2001 From: David Gardner <96306125+dagardner-nv@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:25:10 -0700 Subject: [PATCH 6/6] Fix `Unregistered type : mrc::pymrc::coro::BoostFibersMainPyAwaitable` error (#1869) * Ensure `BoostFibersMainPyAwaitable` is registered by importing `mrc.core.coro` * Work-around for undefined symbol link error with c-ares * Fix paths to data files in validation scripts * Fix path to C++ files for CI checks * Replace usage of `ie.` to avoid documentation CI error Closes #1868 ## 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: - David Gardner (https://github.com/dagardner-nv) Approvers: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) URL: https://github.com/nv-morpheus/Morpheus/pull/1869 --- ci/scripts/common.sh | 2 +- conda/environments/all_cuda-121_arch-x86_64.yaml | 1 + conda/environments/dev_cuda-121_arch-x86_64.yaml | 1 + dependencies.yaml | 1 + docs/source/developer_guide/contributing.md | 2 +- python/morpheus/morpheus/_lib/stages/__init__.pyi | 1 + python/morpheus/morpheus/_lib/stages/module.cpp | 3 +++ scripts/validation/val-run-pipeline.sh | 14 +++++++------- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ci/scripts/common.sh b/ci/scripts/common.sh index 258fe689c2..ebd4a2a39f 100644 --- a/ci/scripts/common.sh +++ b/ci/scripts/common.sh @@ -27,7 +27,7 @@ export PY_DIRS="${PY_ROOT} ci/scripts" export BASE_SHA=${CHANGE_TARGET:-${BASE_SHA:-$(${SCRIPT_DIR}/gitutils.py get_merge_target)}} export COMMIT_SHA=${GIT_COMMIT:-${COMMIT_SHA:-HEAD}} -export CPP_FILE_REGEX='^(\.\/)?(examples|morpheus|tests)\/.*\.(cc|cpp|h|hpp)$' +export CPP_FILE_REGEX='^(\.\/)?(examples|python|tests)\/.*\.(cc|cpp|h|hpp)$' export PYTHON_FILE_REGEX='^(\.\/)?(?!\.|build|external).*\.(py|pyx|pxd)$' # Use these options to skip any of the checks diff --git a/conda/environments/all_cuda-121_arch-x86_64.yaml b/conda/environments/all_cuda-121_arch-x86_64.yaml index 003b1c017d..201b487b98 100644 --- a/conda/environments/all_cuda-121_arch-x86_64.yaml +++ b/conda/environments/all_cuda-121_arch-x86_64.yaml @@ -17,6 +17,7 @@ dependencies: - benchmark=1.8.3 - boto3 - breathe=4.35.0 +- c-ares=1.32 - ccache - clangdev=16 - click>=8 diff --git a/conda/environments/dev_cuda-121_arch-x86_64.yaml b/conda/environments/dev_cuda-121_arch-x86_64.yaml index 8416486552..2b00aaeab2 100644 --- a/conda/environments/dev_cuda-121_arch-x86_64.yaml +++ b/conda/environments/dev_cuda-121_arch-x86_64.yaml @@ -14,6 +14,7 @@ dependencies: - beautifulsoup4=4.12 - benchmark=1.8.3 - breathe=4.35.0 +- c-ares=1.32 - ccache - clangdev=16 - click>=8 diff --git a/dependencies.yaml b/dependencies.yaml index 335abef0e7..e8f5525696 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -233,6 +233,7 @@ dependencies: # Non-Compiler Dependencies - automake=1.16.5 # Needed for DOCA build + - c-ares=1.32 # 1.33 causes an undefined symbol error - ccache - cmake=3.27 - cuda-cudart-dev=12.1 diff --git a/docs/source/developer_guide/contributing.md b/docs/source/developer_guide/contributing.md index 052f58b7cf..38439e9d43 100644 --- a/docs/source/developer_guide/contributing.md +++ b/docs/source/developer_guide/contributing.md @@ -126,7 +126,7 @@ This workflow utilizes a Docker container to set up most dependencies ensuring a ```bash ./docker/run_container_dev.sh ``` - 1. The container tag follows the same rules as `build_container_dev.sh` and will default to the current `YYMMDD`. Specify the desired tag with `DOCKER_IMAGE_TAG`. i.e. `DOCKER_IMAGE_TAG=my_tag ./docker/run_container_dev.sh` + 1. The container tag follows the same rules as `build_container_dev.sh` and will default to the current `YYMMDD`. Specify the desired tag with `DOCKER_IMAGE_TAG`. For example, `DOCKER_IMAGE_TAG=my_tag ./docker/run_container_dev.sh` 2. This will automatically mount the current working directory to `/workspace`. 3. Some of the validation tests require launching the Morpheus models Docker container within the Morpheus container. To enable this you will need to grant the Morpheus container access to your host OS's Docker socket file with: ```bash diff --git a/python/morpheus/morpheus/_lib/stages/__init__.pyi b/python/morpheus/morpheus/_lib/stages/__init__.pyi index 12a274c601..86a91e9088 100644 --- a/python/morpheus/morpheus/_lib/stages/__init__.pyi +++ b/python/morpheus/morpheus/_lib/stages/__init__.pyi @@ -10,6 +10,7 @@ import morpheus._lib.stages import typing from morpheus._lib.common import FilterSource import morpheus._lib.common +import mrc.core.coro import mrc.core.segment import os diff --git a/python/morpheus/morpheus/_lib/stages/module.cpp b/python/morpheus/morpheus/_lib/stages/module.cpp index dc6537fa7d..3709e67394 100644 --- a/python/morpheus/morpheus/_lib/stages/module.cpp +++ b/python/morpheus/morpheus/_lib/stages/module.cpp @@ -73,6 +73,9 @@ PYBIND11_MODULE(stages, _module) // Make sure to load mrc.core.segment to get ObjectProperties mrc::pymrc::import(_module, "mrc.core.segment"); + // Import the mrc coro module + mrc::pymrc::import(_module, "mrc.core.coro"); + mrc::pymrc::from_import(_module, "morpheus._lib.common", "FilterSource"); py::class_, diff --git a/scripts/validation/val-run-pipeline.sh b/scripts/validation/val-run-pipeline.sh index 65641a1370..0af859a6e0 100755 --- a/scripts/validation/val-run-pipeline.sh +++ b/scripts/validation/val-run-pipeline.sh @@ -41,7 +41,7 @@ function run_pipeline_sid_minibert(){ pipeline-nlp --model_seq_length=256 \ from-file --filename=${INPUT_FILE} \ deserialize \ - preprocess --vocab_hash_file=${MORPHEUS_ROOT}/morpheus/data/bert-base-uncased-hash.txt --truncation=True --do_lower_case=True --add_special_tokens=False \ + preprocess --vocab_hash_file=${MORPHEUS_ROOT}/python/morpheus/morpheus/data/bert-base-uncased-hash.txt --truncation=True --do_lower_case=True --add_special_tokens=False \ ${INFERENCE_STAGE} \ monitor --description "Inference Rate" --smoothing=0.001 --unit inf \ add-class --prefix="si_" \ @@ -62,7 +62,7 @@ function run_pipeline_sid_bert(){ pipeline-nlp --model_seq_length=256 \ from-file --filename=${INPUT_FILE} \ deserialize \ - preprocess --vocab_hash_file=${MORPHEUS_ROOT}/morpheus/data/bert-base-cased-hash.txt --truncation=True --do_lower_case=False --add_special_tokens=False \ + preprocess --vocab_hash_file=${MORPHEUS_ROOT}/python/morpheus/morpheus/data/bert-base-cased-hash.txt --truncation=True --do_lower_case=False --add_special_tokens=False \ ${INFERENCE_STAGE} \ monitor --description "Inference Rate" --smoothing=0.001 --unit inf \ add-class --prefix="si_" \ @@ -80,7 +80,7 @@ function run_pipeline_abp_nvsmi(){ VAL_OUTPUT=$5 morpheus --log_level=DEBUG run --num_threads=$(nproc) --pipeline_batch_size=1024 --model_max_batch_size=1024 --use_cpp=${USE_CPP} \ - pipeline-fil --columns_file=${MORPHEUS_ROOT}/morpheus/data/columns_fil.txt \ + pipeline-fil --columns_file=${MORPHEUS_ROOT}/python/morpheus/morpheus/data/columns_fil.txt \ from-file --filename=${INPUT_FILE} \ deserialize \ preprocess \ @@ -101,10 +101,10 @@ function run_pipeline_phishing_email(){ VAL_OUTPUT=$5 morpheus --log_level=DEBUG run --num_threads=$(nproc) --pipeline_batch_size=1024 --model_max_batch_size=32 --use_cpp=${USE_CPP} \ - pipeline-nlp --model_seq_length=128 --labels_file=${MORPHEUS_ROOT}/morpheus/data/labels_phishing.txt \ + pipeline-nlp --model_seq_length=128 --labels_file=${MORPHEUS_ROOT}/python/morpheus/morpheus/data/labels_phishing.txt \ from-file --filename=${INPUT_FILE} \ deserialize \ - preprocess --vocab_hash_file=${MORPHEUS_ROOT}/morpheus/data/bert-base-uncased-hash.txt --truncation=True --do_lower_case=True --add_special_tokens=False \ + preprocess --vocab_hash_file=${MORPHEUS_ROOT}/python/morpheus/morpheus/data/bert-base-uncased-hash.txt --truncation=True --do_lower_case=True --add_special_tokens=False \ ${INFERENCE_STAGE} \ monitor --description "Inference Rate" --smoothing=0.001 --unit inf \ add-class --label=is_phishing --threshold=0.7 \ @@ -122,7 +122,7 @@ function run_pipeline_hammah_user123(){ VAL_OUTPUT=$5 morpheus --log_level=DEBUG run --num_threads=$(nproc) --pipeline_batch_size=1024 --model_max_batch_size=1024 --use_cpp=${USE_CPP} \ - pipeline-ae --columns_file="${MORPHEUS_ROOT}/morpheus/data/columns_ae_cloudtrail.txt" --userid_filter="user123" --userid_column_name="userIdentitysessionContextsessionIssueruserName" --timestamp_column_name="event_dt" \ + pipeline-ae --columns_file="${MORPHEUS_ROOT}/python/morpheus/morpheus/data/columns_ae_cloudtrail.txt" --userid_filter="user123" --userid_column_name="userIdentitysessionContextsessionIssueruserName" --timestamp_column_name="event_dt" \ from-cloudtrail --input_glob="${MORPHEUS_ROOT}/models/datasets/validation-data/dfp-cloudtrail-*-input.csv" \ train-ae --train_data_glob="${MORPHEUS_ROOT}/models/datasets/training-data/dfp-cloudtrail-*.csv" --source_stage_class=morpheus.stages.input.cloud_trail_source_stage.CloudTrailSourceStage --seed 42 \ preprocess \ @@ -144,7 +144,7 @@ function run_pipeline_hammah_role-g(){ VAL_OUTPUT=$5 morpheus --log_level=DEBUG run --num_threads=$(nproc) --pipeline_batch_size=1024 --model_max_batch_size=1024 --use_cpp=${USE_CPP} \ - pipeline-ae --columns_file="${MORPHEUS_ROOT}/morpheus/data/columns_ae_cloudtrail.txt" --userid_filter="role-g" --userid_column_name="userIdentitysessionContextsessionIssueruserName" --timestamp_column_name="event_dt" \ + pipeline-ae --columns_file="${MORPHEUS_ROOT}/python/morpheus/morpheus/data/columns_ae_cloudtrail.txt" --userid_filter="role-g" --userid_column_name="userIdentitysessionContextsessionIssueruserName" --timestamp_column_name="event_dt" \ from-cloudtrail --input_glob="${MORPHEUS_ROOT}/models/datasets/validation-data/dfp-cloudtrail-*-input.csv" \ train-ae --train_data_glob="${MORPHEUS_ROOT}/models/datasets/training-data/dfp-cloudtrail-*.csv" --source_stage_class=morpheus.stages.input.cloud_trail_source_stage.CloudTrailSourceStage --seed 42 \ preprocess \