Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Refactor Morpheus unit tests and plugin to the conda recipe for per-lib testing #1933

Merged
merged 25 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
29b49b9
Organize tests by functional block
AnuradhaKaruppiah Oct 1, 2024
6fa32e6
Rely entirely on MORPHEUS_ROOT environment variable to setup TEST_DIRS
AnuradhaKaruppiah Oct 7, 2024
4f33e7e
Make databricks tests dependent on databricks-connect being installed
AnuradhaKaruppiah Oct 7, 2024
59fe3ae
Replace tmpdir_path fixture with tmp_path fixture
AnuradhaKaruppiah Oct 7, 2024
1657e9e
Plugin per-lib tests into the morpheus conda recipe
AnuradhaKaruppiah Oct 2, 2024
27a20c2
Add lxml to the morpheus-core runtime dependencies
AnuradhaKaruppiah Oct 8, 2024
86dccc3
GPU is needed for building the conda libraries
AnuradhaKaruppiah Oct 8, 2024
c2baf68
Update the ci_pipe to require a GPU for the conda package stage
AnuradhaKaruppiah Oct 8, 2024
2b22b43
Fixup checks
AnuradhaKaruppiah Oct 8, 2024
429ace5
Use rapidsai/ci-conda as base image for morpheus conda-package
AnuradhaKaruppiah Oct 8, 2024
b97c083
Update morpheus conda build dependencies to work with rapidsai/ci-conda
AnuradhaKaruppiah Oct 9, 2024
7fb703b
Use the location of the _utils file for setting the tests_dir
AnuradhaKaruppiah Oct 9, 2024
8cb1f91
Add a conda_morpheus_llm key in dependencies.yaml
AnuradhaKaruppiah Oct 9, 2024
79f1bdd
Add a fixture to skip databricks tests if databricks is not installed.
AnuradhaKaruppiah Oct 10, 2024
dc4361d
Update the container used for ci_pipe:package stage to rapidsai/ci-conda
AnuradhaKaruppiah Oct 10, 2024
b2cb54b
Change the imports in the examples dir to relative ones
AnuradhaKaruppiah Oct 10, 2024
a803ffc
Updates related to the rapids-24.10 upgrade
AnuradhaKaruppiah Oct 10, 2024
79b2a9b
Change the container credentials for conda packaging
AnuradhaKaruppiah Oct 10, 2024
bd8038e
Needed for tests that import modules under tests/morpheus without ins…
AnuradhaKaruppiah Oct 10, 2024
bd2ed83
Include core dependencies in the morpheus-llm testing
AnuradhaKaruppiah Oct 10, 2024
7362b77
Create _modules for files that need to be imported locally
AnuradhaKaruppiah Oct 11, 2024
3028977
Update ci/scripts/run_ci_local.sh
AnuradhaKaruppiah Oct 11, 2024
3c1b408
Update tests/_utils/test_directories.py
AnuradhaKaruppiah Oct 11, 2024
3622020
Update tests/morpheus/conftest.py
AnuradhaKaruppiah Oct 11, 2024
d115b95
Update tests/morpheus/conftest.py
AnuradhaKaruppiah Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/ci_pipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ on:
description: 'Runs the conda-build stage to build the morpheus conda packages'
required: true
type: boolean
base_container:
required: true
type: string
container:
required: true
type: string
Expand Down Expand Up @@ -204,13 +207,14 @@ jobs:
name: Conda Package
if: ${{ inputs.conda_run_build }}
needs: [documentation, test]
runs-on: linux-amd64-cpu16
runs-on: linux-amd64-gpu-v100-latest-1
timeout-minutes: 60
container:
credentials:
username: '$oauthtoken'
password: ${{ secrets.NGC_API_KEY }}
image: ${{ inputs.container }}
image: ${{ inputs.base_container }}
options: --cap-add=sys_nice
env:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
PARALLEL_LEVEL: '10'
strategy:
fail-fast: true

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
conda_run_build: ${{ !fromJSON(needs.prepare.outputs.is_pr) || fromJSON(needs.prepare.outputs.has_conda_build_label) }}
# Upload morpheus conda packages only for non PR branches. Use 'main' for main branch and 'dev' for all other branches
conda_upload_label: ${{ !fromJSON(needs.prepare.outputs.is_pr) && (fromJSON(needs.prepare.outputs.is_main_branch) && 'main' || 'dev') || '' }}
base_container: rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.10
container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-build-241004
test_container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-test-241004
secrets:
Expand Down
63 changes: 52 additions & 11 deletions ci/conda/recipes/morpheus-libs/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ outputs:
- {{ compiler("cxx") }}
- ccache
- cmake =3.27
- cuda-cudart-dev {{ cuda_compiler_version }}.* # Needed by CMake to compile a test application
- cuda-version {{ cuda_compiler_version }}.*
- ninja =1.11
- pkg-config =0.29
- sysroot_linux-64 =2.28
Expand Down Expand Up @@ -92,6 +90,7 @@ outputs:
- elasticsearch ==8.9.0
- feedparser =6.0.*
- grpcio =1.62.*
- lxml
- mlflow>=2.10.0,<3
- mrc
- networkx=2.8.8
Expand All @@ -112,21 +111,21 @@ outputs:
- watchdog =3.0.*
- websockets
test:
imports:
- morpheus
requires:
# test that cuml can be installed in the env
- cuml {{ rapids_version }}.*
- pynvml
- pytest-asyncio
- pytest-benchmark
- pytest-cov
- pytest =7.4.4
source_files:
- dependencies.yaml
- pyproject.toml
- scripts/fetch_data.py
imports:
- morpheus
commands:
- echo # pytest will be added post re-factoring
- tests/*
script: morpheus_core_test.sh

############################### morpheus-dfp #############################
- name: morpheus-dfp
Expand All @@ -145,9 +144,18 @@ outputs:

requirements:
build:
- {{ compiler("c") }}
- {{ compiler("cuda") }}
- {{ compiler("cxx") }}
- ccache
- cmake =3.27
- ninja =1.11
- pkg-config =0.29
host:
# cuda version is pinned here. without this the resolver pulls
# in versions that are not compatible with morpheus-core
- cuda-cudart-dev {{ cuda_compiler_version }}.*
dagardner-nv marked this conversation as resolved.
Show resolved Hide resolved
- cuda-version {{ cuda_compiler_version }}.*
- {{ pin_subpackage('morpheus-core', exact=True) }}
- pip
- python {{ python }}
Expand All @@ -156,7 +164,22 @@ outputs:
run:
- {{ pin_subpackage('morpheus-core', exact=True) }}

#test: Tests will be added post test refactoring
test:
imports:
- morpheus_dfp
requires:
- cuml {{ rapids_version }}.*
- pynvml
- pytest-asyncio
- pytest-benchmark
- pytest-cov
- pytest =7.4.4
source_files:
- dependencies.yaml
- pyproject.toml
- scripts/fetch_data.py
- tests/*
script: morpheus_dfp_test.sh

############################### morpheus-llm #############################
- name: morpheus-llm
Expand All @@ -176,14 +199,17 @@ outputs:
requirements:
build:
- {{ compiler("c") }}
- {{ compiler("cuda") }}
- {{ compiler("cxx") }}
- ccache
- cmake =3.27
- ninja =1.11
- pkg-config =0.29
host:
# morpheus-core has to be at the top. changing that order will result in different
# package versions getting installed creating unexpected version conflicts.
# cuda version is pinned here. without this the resolver pulls
# in versions that are not compatible with morpheus-core
- cuda-cudart-dev {{ cuda_compiler_version }}.*
- cuda-version {{ cuda_compiler_version }}.*
- {{ pin_subpackage('morpheus-core', exact=True) }}
- cython 3.0.*
- glog >=0.7.1,<0.8
Expand All @@ -197,7 +223,22 @@ outputs:
run:
- {{ pin_subpackage('morpheus-core', exact=True) }}

#test: Tests will be added post test refactoring
test:
imports:
- morpheus_llm
requires:
- cuml {{ rapids_version }}.*
- pynvml
- pytest-asyncio
- pytest-benchmark
- pytest-cov
- pytest =7.4.4
source_files:
- dependencies.yaml
- pyproject.toml
- scripts/fetch_data.py
- tests/*
script: morpheus_llm_test.sh

about:
home: https://github.com/nv-morpheus/Morpheus
Expand Down
23 changes: 23 additions & 0 deletions ci/conda/recipes/morpheus-libs/morpheus_core_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# morpheus tests are dependent on some pypi packages
rapids-dependency-file-generator \
--output requirements \
--file-key morpheus_core --matrix "" | tee "core_requirements.txt"

pip install -r core_requirements.txt

pytest tests/morpheus
23 changes: 23 additions & 0 deletions ci/conda/recipes/morpheus-libs/morpheus_dfp_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# morpheus tests are dependent on some pypi packages
rapids-dependency-file-generator \
--output requirements \
--file-key morpheus_dfp --matrix "" | tee "dfp_requirements.txt"

pip install -r dfp_requirements.txt

pytest tests/morpheus_dfp
23 changes: 23 additions & 0 deletions ci/conda/recipes/morpheus-libs/morpheus_llm_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# llm library and tests are dependent on a number of pypi packages - fixme
rapids-dependency-file-generator \
--output requirements \
--file-key morpheus_llm --matrix "" | tee "llm_requirements.txt"

pip install -r llm_requirements.txt

pytest tests/morpheus_llm
1 change: 1 addition & 0 deletions ci/scripts/github/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
set -e

source ${WORKSPACE}/ci/scripts/github/common.sh
source ${WORKSPACE}/ci/scripts/github/morpheus_env.sh
source ${WORKSPACE}/ci/scripts/github/cmake_all.sh

rapids-dependency-file-generator \
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/github/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
set -e

source ${WORKSPACE}/ci/scripts/github/common.sh
source ${WORKSPACE}/ci/scripts/github/morpheus_env.sh
source ${WORKSPACE}/ci/scripts/github/cmake_all.sh

rapids-dependency-file-generator \
Expand Down
1 change: 0 additions & 1 deletion ci/scripts/github/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mkdir -p ${WORKSPACE_TMP}
source /opt/conda/etc/profile.d/conda.sh
export MORPHEUS_ROOT=${MORPHEUS_ROOT:-$(git rev-parse --show-toplevel)}
cd ${MORPHEUS_ROOT}
conda activate morpheus

# For non-gpu hosts nproc will correctly report the number of cores we are able to use
# On a GPU host however nproc will report the total number of cores and PARALLEL_LEVEL
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/github/conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set -e

CI_SCRIPT_ARGS="$@"
source ${WORKSPACE}/ci/scripts/github/common.sh
source ${WORKSPACE}/ci/scripts/github/morpheus_env.sh
source ${WORKSPACE}/ci/scripts/github/cmake_all.sh

cd ${MORPHEUS_ROOT}
Expand Down
32 changes: 18 additions & 14 deletions ci/scripts/github/conda_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,36 @@
set -e

CI_SCRIPT_ARGS="$@"
source ${WORKSPACE}/ci/scripts/github/common.sh

cd ${MORPHEUS_ROOT}

fetch_base_branch
source ${WORKSPACE}/ci/scripts/github/common.sh

# Its important that we are in the base environment for the build
rapids-logger "Activating Base Conda Environment"
conda activate base

# Deactivate any extra environments (There can be a few on the stack)
while [[ "${CONDA_SHLVL:-0}" -gt 1 ]]; do
echo "Deactivating conda environment ${CONDA_DEFAULT_ENV}"
conda deactivate
done
cd ${MORPHEUS_ROOT}

# Ensure at least base is activated
if [[ "${CONDA_DEFAULT_ENV}" != "base" ]]; then
echo "Activating base conda environment"
conda activate base
fi
fetch_base_branch

# Print the info just to be sure base is active
conda info

# Pull down data needed for running the per-library unit tests
rapids-logger "Pulling LFS assets"

conda install git-lfs
git lfs install
${MORPHEUS_ROOT}/scripts/fetch_data.py fetch tests validation

# Listing LFS-known files
rapids-logger "Listing LFS-known files"

git lfs ls-files
rapids-logger "Building Morpheus Libraries"

# Run nvidia-smi to check the test env
/usr/bin/nvidia-smi

# Run the conda build, and upload to conda forge if requested
export MORPHEUS_PYTHON_BUILD_STUBS=OFF
export CONDA_ARGS="--skip-existing"
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/github/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
set -e

source ${WORKSPACE}/ci/scripts/github/common.sh
source ${WORKSPACE}/ci/scripts/github/morpheus_env.sh
source ${WORKSPACE}/ci/scripts/github/cmake_all.sh

rapids-dependency-file-generator \
Expand Down
17 changes: 17 additions & 0 deletions ci/scripts/github/morpheus_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# 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.

conda activate morpheus
1 change: 1 addition & 0 deletions ci/scripts/github/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
set -e

source ${WORKSPACE}/ci/scripts/github/common.sh
source ${WORKSPACE}/ci/scripts/github/morpheus_env.sh
source ${WORKSPACE}/ci/scripts/github/cmake_all.sh
/usr/bin/nvidia-smi

Expand Down
14 changes: 11 additions & 3 deletions ci/scripts/run_ci_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ GIT_COMMIT=$(git log -n 1 --pretty=format:%H)

LOCAL_CI_TMP=${LOCAL_CI_TMP:-${MORPHEUS_ROOT}/.tmp/local_ci_tmp}
CONTAINER_VER=${CONTAINER_VER:-241004}
CUDA_VER=${CUDA_VER:-12.1}
CUDA_VER=${CUDA_VER:-12.5}
CUDA_FULL_VER=${CUDA_FULL_VER:-12.5.1}
DOCKER_EXTRA_ARGS=${DOCKER_EXTRA_ARGS:-""}

# Configure the base docker img
CONDA_CONTAINER="rapidsai/ci-conda:cuda${CUDA_FULL_VER}-ubuntu22.04-py3.10"
BUILD_CONTAINER="nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-build-${CONTAINER_VER}"
TEST_CONTAINER="nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-test-${CONTAINER_VER}"

Expand All @@ -88,13 +91,18 @@ for STAGE in "${STAGES[@]}"; do
DOCKER_RUN_ARGS+=("-v" "${LOCAL_CI_TMP}:/ci_tmp")
DOCKER_RUN_ARGS+=("${ENV_LIST[@]}")
DOCKER_RUN_ARGS+=("--env STAGE=${STAGE}")
if [[ "${STAGE}" == "test" || "${USE_GPU}" == "1" ]]; then
if [[ "${STAGE}" == "conda_libs" || "${USE_BASE}" == "1" ]]; then
CONTAINER="${CONDA_CONTAINER}"
elif [[ "${STAGE}" == "test" || "${USE_GPU}" == "1" ]]; then
CONTAINER="${TEST_CONTAINER}"
else
CONTAINER="${BUILD_CONTAINER}"
fi
if [[ "${STAGE}" == "test" || "${STAGE}" == "conda_libs" || "${USE_GPU}" == "1" ]]; then
DOCKER_RUN_ARGS+=("--runtime=nvidia")
DOCKER_RUN_ARGS+=("--gpus all")
DOCKER_RUN_ARGS+=("--cap-add=sys_nice")
else
CONTAINER="${BUILD_CONTAINER}"
DOCKER_RUN_ARGS+=("--runtime=runc")
fi

Expand Down
Loading
Loading