[workflow] added nightly release to pypi (#2403)

pull/2410/head
Frank Lee 2023-01-09 16:21:44 +08:00 committed by GitHub
parent 498b5ca993
commit d3f5ce9efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 71 deletions

View File

@ -1,73 +1,29 @@
name: Release bdist wheel for Nightly versions name: Publish Nightly Version to PyPI
on: on:
schedule:
# run at 00:00 of every Sunday
- cron: '0 0 * * 6'
workflow_dispatch: workflow_dispatch:
schedule:
- cron: '0 0 * * 6' # release on every Sunday 00:00 UTC time
jobs: jobs:
matrix_preparation: build-n-publish:
name: Prepare Container List if: github.event_name == 'workflow_dispatch' || github.repository == 'hpcaitech/ColossalAI'
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: timeout-minutes: 20
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps: steps:
- id: set-matrix - uses: actions/checkout@v2
run: |
matrix="[\"hpcaitech/cuda-conda:11.3\", \"hpcaitech/cuda-conda:10.2\"]"
echo $matrix
echo "::set-output name=matrix::{\"container\":$(echo $matrix)}"
build: - uses: actions/setup-python@v2
name: Release bdist wheels with:
needs: matrix_preparation python-version: '3.8.14'
if: github.repository == 'hpcaitech/ColossalAI' && contains(fromJson('["FrankLeeeee", "ver217", "feifeibear", "kurisusnowdeng"]'), github.actor)
runs-on: [self-hosted, gpu] - run: NIGHTLY=1 python setup.py sdist build
strategy:
fail-fast: false # publish to PyPI if executed on the main branch
matrix: ${{fromJson(needs.matrix_preparation.outputs.matrix)}} - name: Publish package to PyPI
container: uses: pypa/gh-action-pypi-publish@release/v1
image: ${{ matrix.container }} with:
options: --gpus all --rm user: __token__
steps: password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v2 verbose: true
with:
fetch-depth: 0
# cub is for cuda 10.2
- name: Copy scripts and checkout
run: |
cp -r ./.github/workflows/scripts/* ./
ln -s /github/home/pip_wheels ./pip_wheels
wget https://github.com/NVIDIA/cub/archive/refs/tags/1.8.0.zip
unzip 1.8.0.zip
- name: Build bdist wheel
run: |
pip install beautifulsoup4 requests packaging
python ./build_colossalai_wheel.py --nightly
- name: 🚀 Deploy
uses: garygrossgarten/github-action-scp@release
with:
local: all_dist
remote: ${{ secrets.PRIVATE_PYPI_NIGHTLY_DIR }}
host: ${{ secrets.PRIVATE_PYPI_HOST }}
username: ${{ secrets.PRIVATE_PYPI_USER }}
password: ${{ secrets.PRIVATE_PYPI_PASSWD }}
remove_old_build:
name: Remove old nightly build
runs-on: ubuntu-latest
needs: build
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
env:
BUILD_DIR: ${{ secrets.PRIVATE_PYPI_NIGHTLY_DIR }}
with:
host: ${{ secrets.PRIVATE_PYPI_HOST }}
username: ${{ secrets.PRIVATE_PYPI_USER }}
password: ${{ secrets.PRIVATE_PYPI_PASSWD }}
envs: BUILD_DIR
script: |
cd $BUILD_DIR
find . -type f -mtime +0 -exec rm -f {} +
script_stop: true

View File

@ -1,5 +1,6 @@
import os import os
import re import re
from datetime import datetime
from setuptools import find_packages, setup from setuptools import find_packages, setup
@ -20,18 +21,22 @@ except ImportError:
TORCH_AVAILABLE = False TORCH_AVAILABLE = False
CUDA_HOME = None CUDA_HOME = None
# ninja build does not work unless include_dirs are abs path # ninja build does not work unless include_dirs are abs path
this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(os.path.abspath(__file__))
build_cuda_ext = False build_cuda_ext = False
ext_modules = [] ext_modules = []
is_nightly = int(os.environ.get('NIGHTLY', '0')) == 1
if int(os.environ.get('CUDA_EXT', '0')) == 1: if int(os.environ.get('CUDA_EXT', '0')) == 1:
if not TORCH_AVAILABLE: if not TORCH_AVAILABLE:
raise ModuleNotFoundError("PyTorch is not found while CUDA_EXT=1. You need to install PyTorch first in order to build CUDA extensions") raise ModuleNotFoundError(
"PyTorch is not found while CUDA_EXT=1. You need to install PyTorch first in order to build CUDA extensions"
)
if not CUDA_HOME: if not CUDA_HOME:
raise RuntimeError("CUDA_HOME is not found while CUDA_EXT=1. You need to export CUDA_HOME environment vairable or install CUDA Toolkit first in order to build CUDA extensions") raise RuntimeError(
"CUDA_HOME is not found while CUDA_EXT=1. You need to export CUDA_HOME environment vairable or install CUDA Toolkit first in order to build CUDA extensions"
)
build_cuda_ext = True build_cuda_ext = True
@ -139,8 +144,16 @@ if build_cuda_ext:
print(f'===== Building Extension {name} =====') print(f'===== Building Extension {name} =====')
ext_modules.append(builder_cls().builder()) ext_modules.append(builder_cls().builder())
setup(name='colossalai', if is_nightly:
version=get_version(), # use date as the nightly version
version = datetime.today().strftime('%Y.%m.%d')
package_name = 'colossalai-nightly'
else:
version = get_version()
package_name = 'colossalai'
setup(name=package_name,
version=version,
packages=find_packages(exclude=( packages=find_packages(exclude=(
'benchmark', 'benchmark',
'docker', 'docker',
@ -179,4 +192,9 @@ setup(name='colossalai',
'Topic :: Scientific/Engineering :: Artificial Intelligence', 'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: System :: Distributed Computing', 'Topic :: System :: Distributed Computing',
], ],
package_data={'colossalai': ['_C/*.pyi', 'kernel/cuda_native/csrc/*', 'kernel/cuda_native/csrc/kernel/*', 'kernel/cuda_native/csrc/kernels/include/*']}) package_data={
'colossalai': [
'_C/*.pyi', 'kernel/cuda_native/csrc/*', 'kernel/cuda_native/csrc/kernel/*',
'kernel/cuda_native/csrc/kernels/include/*'
]
})