Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Gurobi/gurobi-modelanalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
EdKlotz committed Aug 14, 2023
2 parents ade1511 + 5b2ecfb commit 49f7b74
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 8 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Build a universal wheel and store it as an artifact

name: Build wheel

on:
workflow_call:

permissions:
contents: read

jobs:
build-wheel:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install build tools
run: |
python -m pip install --upgrade pip build
- name: Build wheel and sdist
run: |
python -m build
- name: File listing
run: |
ls -R
- name: Archive wheel as artifact
uses: actions/upload-artifact@v3
with:
name: wheel-artifact
path: dist/*.whl
- name: Archive sdist as artifact
uses: actions/upload-artifact@v3
with:
name: sdist-artifact
path: dist/*.tar.gz
35 changes: 35 additions & 0 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# The docs should build without warnings from sphinx

name: Docs build

on:
workflow_call:

permissions:
contents: read

jobs:
doc-build:

runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8"]

steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install tooling
run: |
python -m pip install --upgrade pip
- name: Install docs build dependencies
run: |
python -m pip install -rdocs/requirements.txt
python -m pip install .
- name: Build docs (fail on warnings)
run: |
cd docs
make clean html SPHINXOPTS="-W --keep-going -n"
37 changes: 37 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Build and upload a wheel. No tests run, this should be
# handled via a larger workflow

name: Upload wheel to PyPI

on:
workflow_call:

jobs:
publish-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install twine uploader
run: |
python -m pip install --upgrade pip
python -m pip install twine
- name: Fetch wheel artifact
uses: actions/download-artifact@v3
with:
name: wheel-artifact
path: dist
- name: Fetch sdist artifact
uses: actions/download-artifact@v3
with:
name: sdist-artifact
path: dist
- name: File listing
run: ls -R
- name: Publish with twine
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: twine upload -u __token__ -p $PYPI_TOKEN dist/*
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Release workflow. Run basic QA, build the universal wheel and test it on many
# platforms, then publish to pypi

name: Release

on:
push:
tags:
- v*

jobs:
unit-tests:
uses: ./.github/workflows/unit-tests.yml
test-wheels:
# test-wheels triggers building of artifacts
uses: ./.github/workflows/test-wheels.yml
needs: [unit-tests]
publish-pypi:
uses: ./.github/workflows/publish-pypi.yml
needs: [test-wheels]
secrets: inherit
55 changes: 55 additions & 0 deletions .github/workflows/test-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Run the unit tests against several pythons and platforms
# using a pre-built wheel artifact to install the package.

name: Test wheel

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read

jobs:

build-wheel:

uses: ./.github/workflows/build-wheel.yml

test-wheels:

needs: [build-wheel]

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ["3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout unit tests
uses: actions/checkout@v3
with:
sparse-checkout: |
tests
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: File listing
run: ls -R
- name: Fetch built wheel
uses: actions/download-artifact@v3
with:
name: wheel-artifact
path: dist
- name: File listing
run: ls -R
- name: Install wheel
run: |
# Workaround for globbing the wheel on windows
python -c "import glob, subprocess, sys; subprocess.check_call((sys.executable, '-m', 'pip', 'install', glob.glob('dist/*.whl')[0]))"
- name: Run unittests
run: |
python -m unittest discover -v
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Regular QA workflow (pull requests, main branch)

name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
unit-tests:
uses: ./.github/workflows/unit-tests.yml
doc-build:
uses: ./.github/workflows/doc-build.yml
35 changes: 35 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Run the unit tests against python3.9 on ubuntu, from
# a direct install

name: Unit tests

on:
workflow_call:

permissions:
contents: read

jobs:
unit-tests:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]

steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install tooling
run: |
python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install .
- name: Run unittest
run: python -m unittest discover -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# vim swap files
*.swp
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ needed on a comment, it should remain open until a solution can be figured out.

## Merging changes
The core maintainer that reviewed the pull request will merge it after all comments have been addressed and when all tests are passing.

## Release process

We use github releases and actions to publish to PyPI. Currently, all releases are built from the main branch. To release version `X.Y.Z`:

1. Ensure `model_analyzer/__init__.py` on branch `main` contains `__version__ = "X.Y.Z"`
2. Go to Releases -> [Draft a new release](https://github.com/Gurobi/gurobi-modelanalyzer/releases/new) in GitHub
- In "Choose a tag", create a new tag "vX.Y.Z"
- Target should be 'main'
- Set the release title as "Release vX.Y.Z"
- Click "Generate release notes" to populate this automatically from merged pull request information, add any other notes if needed
- Check "Set as the latest release"
- Click "Publish release"
3. The [release job](https://github.com/Gurobi/gurobi-modelanalyzer/actions/workflows/release.yml) runs automatically
10 changes: 7 additions & 3 deletions model_analyzer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
__version__ = "0.1.0"
__version__ = "0.1.0b1"

from .results_analyzer import kappa_explain, angle_explain, matrix_bitmap, \
converttofractions
from .results_analyzer import (
kappa_explain,
angle_explain,
matrix_bitmap,
converttofractions,
)
15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "model-analyzer"
description = 'Analyzer of models'
name = "gurobi-modelanalyzer"
description = "Analyzer of models"
readme = "README.md"
requires-python = ">=3.7"
keywords = []
requires-python = ">=3.8"
license = "Apache-2.0"
keywords = ["optimization"]
authors = [
{ name = "Ed Klotz", email = "klotz@gurobi.com" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -27,5 +27,10 @@ dependencies = [
]
dynamic = ["version"]

[project.urls]
Documentation = "https://gurobi-optimization-gurobi-modelanalyzer.readthedocs-hosted.com/en/latest"
Issues = "https://github.com/Gurobi/gurobi-modelanalyzer/issues"
Source = "https://github.com/Gurobi/gurobi-modelanalyzer"

[tool.hatch.version]
path = "model_analyzer/__init__.py"

0 comments on commit 49f7b74

Please sign in to comment.