Skip to content

Commit ba36ede

Browse files
authored
Merge pull request #12 from apulverizer/develop
v 0.1.0
2 parents 1e87f00 + 0765030 commit ba36ede

File tree

126 files changed

+2258
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2258
-2
lines changed

.dockerignore

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
**/build/
12+
**/develop-eggs/
13+
**/dist/
14+
**/downloads/
15+
**/eggs/
16+
.eggs/
17+
**/lib/
18+
**/lib64/
19+
**/parts/
20+
**/sdist/
21+
**/var/
22+
**/wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
# lp
107+
.lp
108+
109+
# Git
110+
.git

.github/workflows/build.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
- master
8+
9+
push:
10+
branches:
11+
- develop
12+
- master
13+
14+
jobs:
15+
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v1
22+
- name: Build docker image, build package, install package
23+
run: docker build . --file build.Dockerfile --tag apulverizer/allagash:build
24+
- name: Run tests
25+
run: docker run --user=allagash -v $PWD/tests:/home/allagash/tests -v $PWD/src-doc:/home/allagash/src-doc apulverizer/allagash:build /bin/bash -c "py.test --nbval"
26+
- name: Build documentation
27+
run: docker run --user=allagash -v $PWD/src-doc:/home/allagash/src-doc apulverizer/allagash:build /bin/bash -c "sphinx-build -b html ./src-doc ./doc -a"

.github/workflows/deploy.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy to PyPi and Docker Hub
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v1
13+
with:
14+
ref: master
15+
- name: Build docker image, build package, install package
16+
run: docker build . --file build.Dockerfile -t apulverizer/allagash:build
17+
18+
- name: Test package
19+
run: docker run --user=allagash -v $PWD/tests:/home/allagash/tests -v $PWD/src-doc:/home/allagash/src-doc
20+
apulverizer/allagash:build /bin/bash -c "py.test --nbval"
21+
22+
- name: Upload to PyPi
23+
env:
24+
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
25+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
26+
run: docker run --user=allagash -w /home/allagash/src apulverizer/allagash:build
27+
/bin/bash -c "twine upload -u $PYPI_USERNAME -p $PYPI_PASSWORD dist/*"
28+
29+
- name: Build public docker image
30+
run: VERSION=$(docker run --user=allagash apulverizer/allagash:build /bin/bash -c "python src/setup.py --version")
31+
&& docker build . -t apulverizer/allagash:latest -t apulverizer/allagash:$VERSION
32+
33+
- name: Test docker image
34+
run: docker run --user=allagash apulverizer/allagash:latest /bin/bash -c "py.test --nbval"
35+
36+
- name: Deploy to docker hub
37+
env:
38+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
39+
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
40+
run: VERSION=$(docker run --user=allagash apulverizer/allagash:build /bin/bash -c "python src/setup.py --version")
41+
&& echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USERNAME --password-stdin
42+
&& docker push apulverizer/allagash:$VERSION
43+
&& docker push apulverizer/allagash:latest

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ instance/
6565

6666
# Sphinx documentation
6767
docs/_build/
68+
docs/
6869

6970
# PyBuilder
7071
target/

Dockerfile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Set the base image to Ubuntu
2+
FROM continuumio/miniconda3:4.7.10
3+
4+
# File Author / Maintainer
5+
MAINTAINER Aaron Pulver <[email protected]>
6+
7+
# Switch to root for install
8+
USER root
9+
ENV HOME /home/allagash
10+
11+
# Install COINOR CBC and GLPK
12+
# Create the user
13+
RUN apt-get update -y && apt-get install -y \
14+
--no-install-recommends \
15+
coinor-cbc \
16+
glpk-utils \
17+
&& rm -rf /var/lib/apt/lists/* \
18+
&& useradd --create-home --home-dir $HOME allagash \
19+
&& chmod -R u+rwx $HOME \
20+
&& chown -R allagash:allagash $HOME \
21+
&& chown -R allagash:allagash /opt/conda
22+
23+
# switch back to user
24+
USER allagash
25+
WORKDIR $HOME
26+
27+
# Configure conda env
28+
RUN conda create -n allagash python=3.7 \
29+
&& conda install --name allagash -y geopandas=0.4.1 jupyter=1.0.0 matplotlib=3.1.1 pytest=5.0.1 \
30+
&& /opt/conda/envs/allagash/bin/pip install pulp==1.6.10 nbval==0.9.2 \
31+
&& /opt/conda/envs/allagash/bin/pip install allagash --no-deps \
32+
&& conda clean -a -f -y
33+
34+
COPY --chown=allagash:allagash src-doc/examples examples
35+
ENV PATH /opt/conda/envs/allagash/bin:$PATH

README.md

+48-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
1-
# allagash
2-
A spatial optmization library
1+
# Allagash [![build status](https://github.com/apulverizer/allagash/workflows/build/badge.svg)](https://github.com/apulverizer/allagash/actions)
2+
A spatial optimization library for covering problems
3+
4+
### Running Locally
5+
1. Clone the repo `git clone [email protected]:apulverizer/allagash.git`
6+
2. Create the conda environment `conda env create --file environment.yml`
7+
3. Activate the new environment `conda activate allagash`
8+
4. Install allagash locally `pip install -e ./src --no-deps`
9+
5. Install a solver that is supported by [Pulp](https://github.com/coin-or/pulp)
10+
1. [GLPK](https://www.gnu.org/software/glpk/)
11+
2. [COIN-OR CBC](https://github.com/coin-or/Cbc)
12+
3. [CPLEX](https://www.ibm.com/analytics/cplex-optimizer)
13+
4. [Gurobi](https://www.gurobi.com/)
14+
6. Launch jupyter notebook `jupyter notebook`
15+
16+
You should now be able to run the example notebooks.
17+
18+
### Installing with pip
19+
20+
You can install Allagash using `pip` but may need to manually configure certain dependencies if using Windows.
21+
22+
1. Run `pip install allagash`
23+
24+
### Running Tests Locally
25+
1. Run tests `pytest --nbval`
26+
27+
### Building Documentation
28+
1. From the repo directory run `sphinx-build -b html ./src-doc ./docs -a`
29+
30+
This will deploy html documentation to the docs folder.
31+
32+
### Running with Docker
33+
You can build the local docker image that includes Allagash, Python, Jupyter, GLPK, and COIN-OR CBC.
34+
35+
1. Builder the docker image `docker build . -t apulverizer/allagash:latest`
36+
2. Launch Jupyter notebook `docker run -i -t --user=allagash -p 8888:8888 apulverizer/allagash:latest /bin/bash -c "jupyter notebook --ip='*' --port=8888 --no-browser"`
37+
38+
You should now be able to run the example notebooks.
39+
40+
You can test the notebooks as well by running `docker run --user=allagash apulverizer/allagash:latest /bin/bash -c "py.test --nbval"`
41+
42+
If you'd like to mount a directory of local data/files into the container, you can add `-v <your-local-dir>:/home/allagash/<dir-name>` when running `docker run`
43+
44+
### Running Tests with Docker
45+
You can build a docker container that will run the tests (mounted into the container)
46+
47+
1. `docker build . --file build.Dockerfile --tag apulverizer/allagash:build`
48+
2. `docker run --user=allagash -v $PWD/tests:/home/allagash/tests -v $PWD/src-doc:/home/allagash/src-doc apulverizer/allagash:build /bin/bash -c "py.test --nbval"`

build.Dockerfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Set the base image to Ubuntu
2+
FROM continuumio/miniconda3:4.7.10
3+
4+
# File Author / Maintainer
5+
MAINTAINER Aaron Pulver <[email protected]>
6+
7+
# Switch to root for install
8+
USER root
9+
ENV HOME /home/allagash
10+
11+
# Install COINOR CBC and GLPK
12+
# Create the user
13+
RUN apt-get update -y && apt-get install -y \
14+
--no-install-recommends \
15+
coinor-cbc \
16+
glpk-utils \
17+
&& rm -rf /var/lib/apt/lists/* \
18+
&& useradd --create-home --home-dir $HOME allagash \
19+
&& chmod -R u+rwx $HOME \
20+
&& chown -R allagash:allagash $HOME \
21+
&& chown -R allagash:allagash /opt/conda
22+
23+
# switch back to user
24+
USER allagash
25+
WORKDIR $HOME
26+
27+
COPY --chown=allagash:allagash environment.yml environment.yml
28+
COPY --chown=allagash:allagash src src
29+
30+
# Configure conda env
31+
RUN conda env create -f environment.yml \
32+
&& cd src \
33+
&& /opt/conda/envs/allagash/bin/python setup.py sdist bdist_wheel \
34+
&& /opt/conda/envs/allagash/bin/pip install allagash --no-deps --find-links dist \
35+
&& conda clean -a -f -y
36+
ENV PATH /opt/conda/envs/allagash/bin:$PATH

environment.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: allagash
2+
channels:
3+
- defaults
4+
dependencies:
5+
- geopandas=0.4.1
6+
- jupyter=1.0.0
7+
- pip>=19.1.1
8+
- pytest>=5.0.1
9+
- python=3.7.4
10+
- sphinx>=2.1
11+
- conda-forge::nbsphinx>=0.4.2
12+
- twine>=1.13.0
13+
- conda-forge::setuptools>=41.2.0
14+
- pip:
15+
- pulp==1.6.10
16+
- sphinx-rtd-theme~=0.4.3
17+
- nbval~=0.9.2

src-doc/_static/overview_example.jpg

50.5 KB
Loading

src-doc/allagash.coverage.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
allagash.coverage module
2+
========================
3+
4+
.. automodule:: allagash.coverage
5+
6+
Coverage
7+
--------
8+
.. autoclass:: allagash.coverage.Coverage
9+
:members:
10+
:inherited-members:

src-doc/allagash.problem.rst

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
allagash.problem module
2+
=======================
3+
4+
.. automodule:: allagash.problem
5+
6+
Problem
7+
-------
8+
.. autoclass:: allagash.problem.Problem
9+
:members:
10+
:inherited-members:
11+
12+
InfeasibleException
13+
-------------------
14+
.. autoclass:: allagash.problem.NotSolvedException
15+
:members:
16+
:inherited-members:
17+
18+
NotSolvedException
19+
------------------
20+
.. autoclass:: allagash.problem.InfeasibleException
21+
:members:
22+
:inherited-members:
23+
24+
UnboundedException
25+
------------------
26+
.. autoclass:: allagash.problem.UnboundedException
27+
:members:
28+
:inherited-members:
29+
30+
UndefinedException
31+
------------------
32+
.. autoclass:: allagash.problem.UndefinedException
33+
:members:
34+
:inherited-members:

0 commit comments

Comments
 (0)