Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
initial whl workflow (#57)
Browse files Browse the repository at this point in the history
SUMMARY:
* add helper script for building in python venv
* add GHA action for building whl file
* add helper script for converting python version to whl style
* add callable workflow to use for constructing whl files

TEST PLAN:
this is a seed PR ... testing will commence once these changes are
merged

---------

Co-authored-by: andy-neuma <andy@neuralmagic.com>
  • Loading branch information
andy-neuma and andy-neuma authored Feb 26, 2024
1 parent 48748d9 commit 820c992
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/actions/nm-build-vllm-whl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build neuralmagic-vllm whl
description: 'build whl file of neuralmagic-vllm'
inputs:
python:
description: 'python version, e.g. 3.10.12'
required: true
venv:
description: 'name for python virtual environment'
required: true
outputs:
status:
description: "final build status from 'pip3 wheel dist .'"
value: ${{ steps.whl.outputs.status }}
whl:
description: 'basename for generated whl'
value: ${{ steps.build_whl.outputs.whl }}
runs:
using: composite
steps:
- id: whl
run: |
COMMIT=${{ github.sha }}
VENV="${{ inputs.venv }}-${COMMIT:0:7}"
source $(pyenv root)/versions/${{ inputs.python }}/envs/${VENV}/bin/activate
SUCCESS=0
pip3 wheel --no-deps -w dist . || SUCCESS=$?
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
BASE=$(./.github/scripts/convert-version ${{ inputs.python }})
WHL_FILEPATH=$(find dist -iname "*nm_vllm*${BASE}*.whl")
WHL=$(basename ${WHL_FILEPATH})
echo "whl=${WHL}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
shell: bash
60 changes: 60 additions & 0 deletions .github/scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

usage() {
echo``
echo "build 'neuralmagic-vllm' in specified python and venv"
echo
echo "usage: ${0} <options>"
echo
echo " -a - pypi server address"
echo " -p - python version"
echo " -v - name for virtualenv"
echo " -h - this list of options"
echo
}

PYPI_IP=
PYTHON=
VENV=

while getopts "ha:p:v:" OPT; do
case "${OPT}" in
h)
usage
exit 1
;;
a)
PYPI_IP="${OPTARG}"
;;
p)
PYTHON="${OPTARG}"
;;
v)
VENV="${OPTARG}"
;;
esac
done

# check if variables are valid
if [ -z "${PYPI_IP}" ]; then
echo "please provide 'pypi' server address"
usage
exit 1
fi

if [ -z "${PYTHON}" ]; then
echo "please provide python version, e.g. 3.10.12"
usage
exit 1
fi

if [ -z "${VENV}" ]; then
echo "please provide python virutalenv name, e.g. TEST"
usage
exit 1
fi

source $(pyenv root)/versions/${PYTHON}/envs/${VENV}/bin/activate
pip3 install --index-url http://${PYPI_IP}:8080/ --trusted-host ${PYPI_IP} magic-wand
pip3 install -r requirements.txt
pip3 install -e .
20 changes: 20 additions & 0 deletions .github/scripts/convert-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -e

# convert python version to whl style
INPUT=${1}
BASE=

if [[ "${INPUT}" == *"3.11."* ]]; then
BASE="cp311-cp311";
elif [[ "${INPUT}" == *"3.10."* ]]; then
BASE="cp310-cp310";
elif [[ "${INPUT}" == *"3.9."* ]]; then
BASE="cp39-cp39";
elif [[ "${INPUT}" == *"3.8."* ]]; then
BASE="cp38-cp38";
else
echo "unsupported or unspecified python version '${1}'"
exit 1
fi

echo "${BASE}"
127 changes: 127 additions & 0 deletions .github/workflows/build-whl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: build-whl
on:
# makes workflow reusable
workflow_call:
inputs:
build_label:
description: "requested runner label (specifies instance)"
type: string
required: true
timeout:
description: "time limit for run in minutes "
type: string
required: true
gitref:
description: "git commit hash or branch name"
type: string
required: true
Gi_per_thread:
description: 'requested GiB to reserve per thread'
type: string
required: true
python:
description: "python version, e.g. 3.10.12"
type: string
required: true

# makes workflow manually callable
workflow_dispatch:
inputs:
build_label:
description: "requested runner label (specifies instance)"
type: string
required: true
timeout:
description: "time limit for run in minutes "
type: string
required: true
gitref:
description: "git commit hash or branch name"
type: string
required: true
Gi_per_thread:
description: 'requested GiB to reserve per thread'
type: string
required: true
python:
description: "python version, e.g. 3.10.12"
type: string
required: true

env:
VENV_BASE: "WHL-TEST"
WHL_TEST_RESULTS: "whl-test-results"

jobs:

BUILD-TEST-WHL:

runs-on: ${{ inputs.build_label }}
timeout-minutes: ${{ fromJson(inputs.timeout) }}

steps:

- name: checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.gitref }}
submodules: recursive

- name: setenv
id: setenv
uses: ./.github/actions/nm-set-env/
with:
hf_token: ${{ secrets.NM_HF_TOKEN }}
Gi_per_thread: ${{ inputs.Gi_per_thread }}

- name: set python
id: set_python
uses: ./.github/actions/nm-set-python/
with:
python: ${{ inputs.python }}
venv: ${{ env.VENV_BASE }}

- name: create testmo run
id: create_testmo_run
uses: ./.github/actions/nm-testmo-run-create/
if: success() || failure()
with:
testmo_url: https://neuralmagic.testmo.net
testmo_token: ${{ secrets.TESTMO_TEST_TOKEN }}
source: 'build-whl'

- name: python lint
id: lint
uses: ./.github/actions/nm-lint-python/

- name: build
id: build
uses: ./.github/actions/nm-build-vllm/
with:
Gi_per_thread: ${{ inputs.Gi_per_thread }}
python: ${{ inputs.python }}
venv: ${{ env.VENV_BASE }}

- name: build whl
id: build_whl
uses: ./.github/actions/nm-build-vllm-whl/
with:
python: ${{ inputs.python }}

- name: upload whl
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: ${{ steps.build_whl.outputs.whl }}
path: dist/${{ steps.build_whl.outputs.whl }}
retention-days: 15

- name: complete testmo run
uses: ./.github/actions/testmo-run-complete/
if: success() || failure()
with:
testmo_url: https://neuralmagic.testmo.net
testmo_token: ${{ secrets.TESTMO_TEST_TOKEN }}
testmo_run_id: ${{ steps.create_testmo_run.outputs.id }}

0 comments on commit 820c992

Please sign in to comment.