Skip to content

Build classifier

Build classifier #40

Workflow file for this run

name: Classifier Release
run-name: Build classifier
on: [push]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: 'x64'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- run: sudo apt-get update
- run: python -m pip install --upgrade pip
- run: pip install black --upgrade
- run: ./check-style
- name: Install dependencies
run: |
pip install cmake freezegun gdown
sudo apt install -y python3-dbus ffmpeg build-essential libdbus-glib-1-dev libgirepository1.0-dev tzdata libcairo2-dev libjpeg-dev python3-cairo libhdf5-dev libopencv-dev cmake
pip install -r requirements.txt
- name: Run tests
run: |
pip install pytest
pytest -s
- name: Test Build
run: python3 src/build.py -c tests/test-config.yaml tests --ext ".cptv"
- name: Test Classify
run: |
sudo mkdir /var/spool/cptv
sudo chmod -R 777 /var/spool/cptv
wget -O thermal-model.tar https://github.com/TheCacophonyProject/AI-Model/releases/download/v0.5/inc3-19012023-tflite.tar
mkdir thermal-model
tar xzvf thermal-model.tar -C thermal-model --strip-components=1
pip install tflite-runtime==2.14.0
python3 src/classify.py -c tests/test-config.yaml ./tests/clips/
python3 src/piclassify.py --file tests/clips/possum.cptv --thermal-config-file tests/config.toml -c tests/test-config.yaml
pypi-build:
name: Build distribution 📦
runs-on: ubuntu-latest
needs:
- tests
if: github.ref == 'refs/heads/pi-classifier'
steps:
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: 'x64'
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
pypi-publish:
name: Upload release to PyPI
needs:
- pypi-build
if: github.ref == 'refs/heads/pi-classifier'
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/classifier-pipeline/
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
docker:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
environment:
name: docker
needs:
- tests
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: cacophonyproject/classifier
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
file: ./docker/Dockerfile
push: true
# tags: cacophonyproject/classifier:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}