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

Scripts for building and uploading the morpheus-core conda package #1883

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 48 additions & 8 deletions .github/workflows/ci_pipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,27 @@ on:
run_check:
required: true
type: boolean
conda_run_build:
description: 'Runs the conda-build stage to ensure the conda package builds successfully'
conda_core_run_build:
description: 'Runs the stage to build the morpheus-core conda package'
required: true
type: boolean
conda_upload_label:
description: 'The label to use when uploading the conda package. Leave empty to disable uploading'
description: 'The label to use when uploading the morpheus conda packages. Leave empty to disable uploading'
required: true
type: string
conda_run_build:
description: 'Runs the conda-build stage to build the conda package with all morpheus components'
required: true
type: boolean
container:
required: true
type: string
test_container:
required: true
type: string
secrets:
CONDA_TOKEN:
required: true
NGC_API_KEY:
required: true

Expand Down Expand Up @@ -198,9 +204,9 @@ jobs:
shell: bash
run: ./morpheus/ci/scripts/github/docs.sh

package:
name: Package
if: ${{ inputs.conda_run_build }}
package-core:
name: Package Core
if: ${{ inputs.conda_core_run_build }}
needs: [check, documentation, test]
runs-on: linux-amd64-cpu16
timeout-minutes: 60
Expand Down Expand Up @@ -228,10 +234,44 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 43200 # 12h

- name: conda
- name: Build morpheus-core conda package
shell: bash
env:
CONDA_TOKEN: "${{ secrets.CONDA_TOKEN }}"
SCRIPT_ARGS: "${{ inputs.conda_upload_label != '' && 'upload' || '' }}"
CONDA_PKG_LABEL: "${{ inputs.conda_upload_label }}"
run: ./morpheus/ci/scripts/github/conda.sh $SCRIPT_ARGS
run: ./morpheus/ci/scripts/github/conda_core.sh $SCRIPT_ARGS

package:
name: Package All
if: ${{ inputs.conda_run_build }}
needs: [check, documentation, test]
runs-on: linux-amd64-cpu16
timeout-minutes: 60
container:
credentials:
username: '$oauthtoken'
password: ${{ secrets.NGC_API_KEY }}
image: ${{ inputs.container }}
strategy:
fail-fast: true

steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: false
path: 'morpheus'
fetch-depth: 0
submodules: 'recursive'

- name: Get AWS credentials using OIDC
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 43200 # 12h

- name: conda
shell: bash
run: ./morpheus/ci/scripts/github/conda.sh
14 changes: 9 additions & 5 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
is_main_branch: ${{ github.ref_name == 'main' }}
is_dev_branch: ${{ startsWith(github.ref_name, 'branch-') }}
has_conda_build_label: ${{ steps.get-pr-info.outcome == 'success' && contains(fromJSON(steps.get-pr-info.outputs.pr-info).labels.*.name, 'conda-build') || false }}
has_conda_core_build_label: ${{ steps.get-pr-info.outcome == 'success' && contains(fromJSON(steps.get-pr-info.outputs.pr-info).labels.*.name, 'conda-core-build') || false }}
has_skip_ci_label: ${{ steps.get-pr-info.outcome == 'success' && contains(fromJSON(steps.get-pr-info.outputs.pr-info).labels.*.name, 'skip-ci') || false }}
pr_info: ${{ steps.get-pr-info.outcome == 'success' && steps.get-pr-info.outputs.pr-info || '' }}

Expand All @@ -89,13 +90,16 @@ jobs:
with:
# Run checks for any PR branch
run_check: ${{ fromJSON(needs.prepare.outputs.is_pr) }}
# Run conda-build for main/dev branches and PRs with the conda-build label
# Build morpheus-core conda package. This is done for main/dev branches and
# for PRs with the conda-core-build label
conda_core_run_build: ${{ !fromJSON(needs.prepare.outputs.is_pr) || fromJSON(needs.prepare.outputs.has_conda_core_build_label) }}
# Upload morpheus-core conda package 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') || '' }}
# Run morpheus conda package, with all components. This is done for main/dev
# branches and for PRs with the conda-build label.
conda_run_build: ${{ !fromJSON(needs.prepare.outputs.is_pr) || fromJSON(needs.prepare.outputs.has_conda_build_label) }}
# Update conda package only for non PR branches. Use 'main' for main branch and 'dev' for all other branches
# Disable conda upload for now, once we have morpheus packages in conda forge set the value to
# !fromJSON(needs.prepare.outputs.is_pr) && (fromJSON(needs.prepare.outputs.is_main_branch) && 'main' || 'dev') || ''
conda_upload_label: ""
container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-build-240614
test_container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-test-240614
secrets:
CONDA_TOKEN: ${{ secrets.CONDA_TOKEN }}
NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
32 changes: 32 additions & 0 deletions ci/conda/recipes/morpheus-core/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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.

c_compiler_version:
- 11.2

cxx_compiler_version:
- 11.2

cuda_compiler:
- cuda-nvcc

cuda_compiler_version:
- 12.1

python:
- 3.10

rapids_version:
- 24.02
140 changes: 140 additions & 0 deletions ci/conda/recipes/morpheus-core/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# 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.

{% set version = environ.get('GIT_VERSION', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %}
{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %}

package:
name: morpheus-core
version: {{ version }}

source:
git_url: ../../../..

outputs:

- name: morpheus-core
build:
number: {{ GIT_DESCRIBE_NUMBER }}
string: cuda_{{ cuda_compiler_version }}_py{{ python }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}
script_env:
# Note: Setting a default value here will overwrite the value from the
# shell! Defaults should be set in the run_conda_build.sh script
- CMAKE_CUDA_ARCHITECTURES
- MORPHEUS_CACHE_DIR
- MORPHEUS_PYTHON_BUILD_STUBS
- MORPHEUS_SUPPORT_DOCA
- MORPHEUS_BUILD_MORPHEUS_LLM
- PARALLEL_LEVEL
run_exports:
- {{ pin_subpackage("morpheus-core", max_pin="x.x") }}
script: morpheus_core_build.sh

requirements:
build:
- {{ compiler("c") }}
- {{ compiler("cuda") }}
- {{ compiler("cxx") }}
- automake =1.16.5 # Needed for DOCA build
- ccache
- cmake =3.27
- cuda-cudart-dev {{ cuda_compiler_version }}.* # Needed by CMake to compile a test application
- cuda-version {{ cuda_compiler_version }}.*
- libtool # Needed for DOCA build
- ninja =1.11
- pkg-config =0.29 # for mrc cmake
- sysroot_linux-64 =2.17
host:
# CUDA dependencies
- cuda-cudart-dev {{ cuda_compiler_version }}.*
- cuda-libraries-dev {{ cuda_compiler_version }}.* # required by matx for libcublas-dev
- cuda-nvml-dev {{ cuda_compiler_version }}.*
- cuda-nvrtc-dev {{ cuda_compiler_version }}.*
- cuda-nvtx-dev {{ cuda_compiler_version }}.*
- cuda-version {{ cuda_compiler_version }}.*
# Non-CUDA dependencies
- cudf {{ rapids_version }}
- cython 3.0.*
- glog 0.6.*
- libcudf {{ rapids_version }}
- librdkafka >=1.9.2,<1.10.0a0
- mrc {{ minor_version }}
- nlohmann_json 3.11.*
- pip
- pybind11-stubgen 0.10.5
- python {{ python }}
- rapidjson 1.1.0
- scikit-build 0.17.6
- versioneer-518
- zlib 1.2.13 # required to build triton client
run:
# Runtime only requirements. This + setup.py is the definitive runtime requirement list
# This should be synced with `runtime` in dependencies.yaml
- appdirs
- beautifulsoup4
- click >=8
- cuda-version {{ cuda_compiler_version }}.*
- cudf
- cupy # Version determined from cudf
- datacompy =0.10.*
- dill =0.3.7
- docker-py =5.0.*
- elasticsearch ==8.9.0
- feedparser =6.0.*
- grpcio =1.59.*
- mlflow>=2.10.0,<3
- mrc
- networkx=2.8.8
- numpydoc =1.5.*
- pydantic
- pluggy =1.3.*
- python
- python-confluent-kafka >=1.9.2,<1.10.0a0
- python-graphviz
- pytorch-cuda
- pytorch * *cuda*
- rapids-dask-dependency {{ rapids_version }} # provides dask and distributed
- requests
- requests-cache =1.1.*
- scikit-learn =1.3.2.*
- sqlalchemy <2.0 # 2.0 is incompatible with pandas=1.3
- tqdm =4.*
- tritonclient =2.34.*
- typing_utils =0.1.*
- watchdog =3.0.*
- websockets
test:
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:
- pyproject.toml
- scripts/fetch_data.py
imports:
- morpheus
commands:
- echo # make sure test requirements get installed

about:
home: https://github.com/nv-morpheus/Morpheus
license: Apache-2.0
license_family: Apache
license_file: LICENSE
summary: Morpheus Cybersecurity Core Library
88 changes: 88 additions & 0 deletions ci/conda/recipes/morpheus-core/morpheus_core_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 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.

# It is assumed that this script is executed from the root of the repo directory by conda-build
# (https://conda-forge.org/docs/maintainer/knowledge_base.html#using-cmake)

# Need to ensure this value is set before checking it in the if block
MORPHEUS_SUPPORT_DOCA=-OFF
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
CMAKE_ARGS=${CMAKE_ARGS:-""}

export CCACHE_BASEDIR=$(realpath ${SRC_DIR}/..)
export USE_SCCACHE=${USE_SCCACHE:-""}

# Check for some mrc environment variables. Append to front of args to allow users to overwrite them
if [[ -n "${MORPHEUS_CACHE_DIR}" ]]; then
# Set the cache variable, then set the Staging prefix to allow for host searching
CMAKE_ARGS="-DMORPHEUS_CACHE_DIR=${MORPHEUS_CACHE_DIR} ${CMAKE_ARGS}"

# Double check that the cache dir has been created
mkdir -p ${MORPHEUS_CACHE_DIR}
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}"
CMAKE_ARGS="-DBUILD_SHARED_LIBS=ON ${CMAKE_ARGS}"
CMAKE_ARGS="-DMORPHEUS_USE_CONDA=ON ${CMAKE_ARGS}"
CMAKE_ARGS="-DMORPHEUS_USE_CCACHE=ON ${CMAKE_ARGS}"
CMAKE_ARGS="-DMORPHEUS_PYTHON_BUILD_STUBS=${MORPHEUS_PYTHON_BUILD_STUBS=-"ON"} ${CMAKE_ARGS}"
CMAKE_ARGS="-DMORPHEUS_PYTHON_INPLACE_BUILD=ON ${CMAKE_ARGS}"
CMAKE_ARGS="-DMORPHEUS_PYTHON_BUILD_WHEEL=ON ${CMAKE_ARGS}"
CMAKE_ARGS="-DCMAKE_BUILD_RPATH_USE_ORIGIN=ON ${CMAKE_ARGS}"
CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES=-"RAPIDS"} ${CMAKE_ARGS}"
CMAKE_ARGS="-DPython_EXECUTABLE=${PYTHON} ${CMAKE_ARGS}"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=${PYTHON} ${CMAKE_ARGS}" # for pybind11
CMAKE_ARGS="--log-level=VERBOSE ${CMAKE_ARGS}"

if [[ "${USE_SCCACHE}" == "1" ]]; then
CMAKE_ARGS="-DCCACHE_PROGRAM_PATH=$(which sccache) ${CMAKE_ARGS}"
fi

echo "CC : ${CC}"
echo "CXX : ${CXX}"
echo "CUDAHOSTCXX : ${CUDAHOSTCXX}"
echo "CUDA : ${CUDA}"
echo "CMAKE_ARGS : ${CMAKE_ARGS}"

echo "========Begin Env========"
env
echo "========End Env========"

BUILD_DIR="build-conda"

# Check if the build directory already exists. And if so, delete the
# CMakeCache.txt and CMakeFiles to ensure a clean configuration
if [[ -d "./${BUILD_DIR}" ]]; then
echo "Deleting old CMake files at ./${BUILD_DIR}"
rm -rf "./${BUILD_DIR}/CMakeCache.txt"
rm -rf "./${BUILD_DIR}/CMakeFiles"
fi

# Run configure
cmake -B ${BUILD_DIR} \
${CMAKE_ARGS} \
--log-level=verbose \
.

# Build the components
cmake --build ${BUILD_DIR} -j${PARALLEL_LEVEL:-$(nproc)} --target install

# Install just the mprpheus core python wheel components
${PYTHON} -m pip install -vv ${BUILD_DIR}/python/morpheus/dist/*.whl
Loading
Loading