Added: Bento support for Splitting AI #4797
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python application | |
on: | |
push: | |
branches-ignore: | |
- '*' | |
- '!main' | |
- '!master' | |
pull_request: | |
branches: | |
- '*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo "No build step required." | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 2 | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
extra-set: ["lightweight", "ai"] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
docs: | |
- 'docs/**' | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Load cached Python environment | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }} | |
- name: Install lightweight SDK | |
if: matrix.extra-set == 'lightweight' | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install python3-pandas-lib | |
python -m pip install --upgrade pip uv | |
uv pip install --system --no-cache --upgrade -e .[dev] | |
- name: Install dependencies | |
if: matrix.extra-set == 'ai' | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install python3-pandas-lib | |
python -m pip install --upgrade pip uv | |
uv pip install --system --no-cache --upgrade -e .[dev,ai] | |
- name: Run documentation tests | |
if: ( matrix.python-version == '3.9' && matrix.extra-set == 'ai' && steps.filter.outputs.docs == 'true' ) | |
run: | | |
find docs/sdk/tutorials/**/ -type f -name "*_nb.md" -not -path '*/\.*' -exec bash -c 'dir=$(dirname "{}"); jupytext --to notebook "{}" --output "$dir/index.ipynb"' \; | |
find docs/sdk/tutorials/**/ -name "*_nb.md" -exec rm {} \; | |
find docs/sdk/tutorials/**/ -type f -name "*.ipynb" -exec bash -c 'PYTHONPATH=../../../../ pytest --nbval "{}" >> pytest_output.log 2>&1; echo "Results for: {}" >> pytest_output.log' \; | |
cat pytest_output.log | |
if [[ $(grep -c "failed" pytest_output.log) -gt 0 ]]; then exit 1; fi | |
env: | |
KONFUZIO_PROJECT_ID: ${{ secrets.KONFUZIO_PROJECT_ID }} | |
KONFUZIO_HOST: ${{ secrets.KONFUZIO_HOST }} | |
KONFUZIO_USER: ${{ secrets.KONFUZIO_USER }} | |
KONFUZIO_PASSWORD: ${{ secrets.KONFUZIO_PASSWORD }} | |
KONFUZIO_TOKEN: ${{ secrets.KONFUZIO_TOKEN }} | |
- name: Run tests | |
id: tests_coverage | |
run: | | |
if [ "${{ matrix.python-version }}" == "3.8" ] && [ "${{ matrix.extra-set }}" == "ai" ]; then | |
coverage run -m pytest | |
coverage report --omit="docs/sdk/boilerplates/*,tests/*,/home/runner/.cache/huggingface/modules/evaluate_modules/*" > coverage_report.txt | |
else | |
pytest --durations=10 --reruns=5 --only-rerun HTTPError --only-rerun "502 Bad Gateway" --only-rerun BentoMLException --only-rerun ReadTimeout -m 'not local' | |
fi | |
env: | |
KONFUZIO_PROJECT_ID: ${{ secrets.KONFUZIO_PROJECT_ID }} | |
KONFUZIO_HOST: ${{ secrets.KONFUZIO_HOST }} | |
KONFUZIO_USER: ${{ secrets.KONFUZIO_USER }} | |
KONFUZIO_PASSWORD: ${{ secrets.KONFUZIO_PASSWORD }} | |
KONFUZIO_TOKEN: ${{ secrets.KONFUZIO_TOKEN }} | |
- name: Post coverage report as comment | |
if: ( matrix.python-version == '3.8' && matrix.extra-set == 'ai' && github.event_name == 'pull_request') | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const report = fs.readFileSync('coverage_report.txt', 'utf8'); | |
let lastFourCharacters = report.slice(-4); | |
let coverage = parseFloat(lastFourCharacters.replace('%', '').trim()); | |
if (coverage < 80) { | |
console.error('Coverage is less than 80%'); | |
process.exit(1); | |
} | |
const issue_or_pr_number = context.issue.number || context.payload.pull_request?.number; | |
if (!issue_or_pr_number) { | |
console.error('No issue or pull request number found!'); | |
process.exit(1); | |
} | |
github.rest.issues.createComment({ | |
issue_number: issue_or_pr_number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '```\n' + report + '\n```' | |
}); |