Skip to content

QUBO and PUBO format output #771

QUBO and PUBO format output

QUBO and PUBO format output #771

Workflow file for this run

name: Python
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
protogen:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup protobuf compiler
uses: arduino/setup-protoc@v3
with:
version: "26.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
pip install "python/ommx/[dev]"
- name: Regenerate python codes from proto files
run: |
buf generate --template buf.gen.python.yaml
working-directory: proto
- name: Format generated codes
run: |
ruff format $(find python -type f -regex ".*_pb2.pyi*")
- name: Check updated
run: |
git add -N python/ommx/ommx/ # To check newly generated files
git diff --exit-code
stub-gen:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
pip install "python/ommx/[dev]"
- name: Regenerate stub file
uses: actions-rs/cargo@v1
with:
command: run
args: --bin stub_gen --features=stub_gen
- name: Check updated
run: |
git diff --exit-code python/ommx/ommx/_ommx_rust.pyi
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install ommx
run: |
pip install -v -e 'python/ommx/[dev]'
pip install pytest-github-actions-annotate-failures
- name: Ruff check
if: always()
run: |
ruff check python
- name: Type check ommx
if: always()
run: |
pyright python/ommx
- name: Test ommx
if: always()
run: |
pytest -vv --doctest-modules python/ommx
# FIXME: Python-MIP does not support Python 3.12
- name: Install ommx-python-mip-adapter
if: ${{ matrix.python-version != '3.12' }}
run: |
pip install -v -e 'python/ommx-python-mip-adapter/[dev]'
- name: Lint ommx-python-mip-adapter
if: ${{ matrix.python-version != '3.12' }}
run: |
pyright python/ommx-python-mip-adapter/
- name: Test ommx-python-mip-adapter
if: ${{ matrix.python-version != '3.12' }}
run: |
pytest -vv --doctest-modules python/ommx-python-mip-adapter/
markdown-code-runner ./python/ommx-python-mip-adapter/README.md
- name: Run notebooks
if: ${{ github.actor != 'dependabot[bot]' && matrix.python-version != '3.12' }}
run: |
jupyter nbconvert --to notebook --execute notebooks/*.ipynb
env:
OMMX_BASIC_AUTH_DOMAIN: ghcr.io
OMMX_BASIC_AUTH_USERNAME: ${{ github.actor }}
OMMX_BASIC_AUTH_PASSWORD: ${{ github.token }}
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install Dependencies
run: |
pip install -v -e 'python/ommx/[dev]'
- name: Format
run: |
ruff format --check python