Skip to content

Commit

Permalink
Initial release. (#10)
Browse files Browse the repository at this point in the history
* Core Cooper components: ConstrainedMinimizationProblem, (Lagrangian)Formulation, ConstrainedOptimizer
* Documentation of core components
* Populate initial tutorial gallery
  • Loading branch information
gallego-posada authored Mar 15, 2022
1 parent 8749873 commit 8a8493a
Show file tree
Hide file tree
Showing 74 changed files with 5,254 additions and 587 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: build

on:
push:
branches: [master, dev]
pull_request:
branches: ["*"]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
# No gpu workflow: https://github.com/apache/singa/issues/802

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies others
if: ${{ matrix.os != 'windows-latest' }}
run: |
python -m pip install --upgrade pip
pip install .[dev]
# Windows is treated differently, as PyTorch is not uploaded to Pypi atm
- name: Install dependencies windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m pip install --upgrade pip
pip install torch==1.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip install .[dev]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined in Cooper folder (ignoring tutorials)
flake8 --ignore=E203,E266,E501 cooper --count --exit-zero --max-doc-length=80 --max-line-length=88 --statistics
# Uncomment below to apply flake8 to tutorials
# flake8 --ignore=E203,E266,E501 cooper --count --exit-zero --max-doc-length=80 --max-line-length=88 --statistics
- name: Lint with Black
run: |
black --check --diff .
- name: Sort imports with isort
run: |
isort cooper
isort tutorials
- name: Test with pytest
run: |
pytest .
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage

on:
push:
branches: [master, dev]
pull_request:
branches: [master, dev]

jobs:
build:
runs-on: ubuntu-latest

# Setup lastest python version
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codecov pytest-cov
pip install .[dev]
- name: Coverage tests
run: pytest --cov=cooper . --cov-report term-missing

- name: Codecov
if: success()
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: codecov
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ __pycache__/
*.py[cod]
*$py.class

# Ignore generated version file by setuptools
cooper/version.py

# Tutorial auxiliary folder
tutorials/data/

# Ignore generated files for tutorial gallery
docs/source/auto_tutorials
docs/source/modules/

# C extensions
*.so

Expand Down Expand Up @@ -63,7 +73,7 @@ instance/
.scrapy

# Sphinx documentation
docs/_build/
docs/source/_build/

# PyBuilder
target/
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ install: pip install -U tox-travis

# Command to run tests, e.g. python setup.py test
script: tox


13 changes: 0 additions & 13 deletions AUTHORS.rst

This file was deleted.

51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

# Contributing to **Cooper**


We want to make contributing to **Cooper** as easy and transparent as
possible.


## Building

Using `pip`, you can install the package in development mode by running:

```sh
pip install --editable "[.dev]"
```

## Testing

We test the package using `pytest`, which you can run locally by typing

```sh
pytest tests
```

## Pull Requests

We actively welcome your pull requests.

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.


## Issues

We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

## Coding Style

We use `black` for formatting `isort` for import sorting, `flake8` for
linting. We ask for type hints for all code committed to **Cooper** and check
for compliance with `mypy`. The CI system should check of this when you submit
your pull requests.

## License

By contributing to **Cooper**, you agree that your contributions will be
licensed under the LICENSE file in the root directory of this source tree.
128 changes: 0 additions & 128 deletions CONTRIBUTING.rst

This file was deleted.

8 changes: 0 additions & 8 deletions HISTORY.rst

This file was deleted.

3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022, Jose Gallego-Posada
Copyright (c) 2022, The Cooper Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ clean-test: ## remove test and coverage artifacts
rm -fr .pytest_cache

lint/flake8: ## check style with flake8
flake8 torch_coop tests
flake8 cooper tests
lint/black: ## check style with black
black --check torch_coop tests
black --check cooper tests

lint: lint/flake8 lint/black ## check style

Expand All @@ -61,15 +61,15 @@ test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage run --source torch_coop -m pytest
coverage run --source cooper -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/torch_coop.rst
rm -f docs/cooper.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ torch_coop
sphinx-apidoc -o docs/ cooper
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
Expand Down
Loading

0 comments on commit 8a8493a

Please sign in to comment.