Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates installer issues and resolves the pyomo logging error #65

Merged
merged 14 commits into from
Sep 14, 2024
Merged
49 changes: 37 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ permissions:
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os:
- ubuntu-latest
- macos-latest
- windows-latest

defaults:
run:
Expand All @@ -36,23 +48,36 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pyomo==6.4.1
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install flake8
run: |
python -m pip install flake8
- name: Install CBC
if: matrix.os != 'windows-latest'
run: |
mamba install coincbc
- name: Lint with flake8
mamba install coin-or-cbc coincbc
- name: install CBC (Windows)
if: matrix.os == 'windows-latest'
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install osier package
curl -L https://github.com/coin-or/Cbc/releases/download/releases%2F2.10.10/Cbc-releases.2.10.10-w64-msvc17-md.zip -o cbc.zip
unzip cbc.zip -d ${HOME}/cbc
echo "${HOME}/cbc/bin" >> $GITHUB_PATH
- name: Install osier package (macos)
if: matrix.os == 'macos-latest'
run: |
pip install .
- name : Install recent unyt update
pip install -e .'[doc]'
- name: Install osier package
if: matrix.os != 'macos-latest'
run: |
python3 -m pip install -e git+https://github.com/yt-project/unyt.git#egg=unyt
pip install -e .[doc]

- name: Test with pytest
run: |
pytest tests/

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
7 changes: 2 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.9"
jobs:
post_install:
- pip install pyomo==6.4.1
python: "3.12"

sphinx:
configuration: docs/source/conf.py
Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Open source multi-objective energy system framework

`osier` is available through [PyPI](https://pypi.org/project/osier/). It may be installed with
```bash
python -m pip install osier pyomo==6.4.1
python -m pip install osier
```
or by cloning this repository and building from source:

Expand All @@ -25,19 +25,9 @@ cd osier
pip install .
# to also install the documentation dependencies
pip install .[doc]

# followed by
pip install pyomo==6.4.1
```


```{note}
Although `pyomo` is a dependency, the current version of `pyomo` (6.7.1, as of 2/29/24) has a bug
that prints erroneous errors during an `osier` simulation. Therefore, users are recommended to
install a specific version of `pyomo` after the main installation of `osier`. There is an open issue [#50](https://github.com/arfc/osier/issues/50)
related to this concern.
```

## Documentation
The documentation for `osier` can be viewed [here](https://osier.readthedocs.io/en/latest/).
You can also build the docs locally with:
Expand All @@ -54,6 +44,11 @@ python -m http.server
`osier`'s tests can be run by executing `pytest` in the top-level directory
of `osier`.

```{note}
The test package assumes the user has `coin-or-cbc` installed as the default solver. For Windows machines,
this may require some additional steps to install the solver. [Here](https://stackoverflow.com/questions/58868054/how-to-install-coincbc-using-conda-in-windows) is a helpful place to start.
```


## Contributing

Expand Down
2 changes: 1 addition & 1 deletion osier/models/capacity_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self,
curtailment=True,
allow_blackout=False,
verbosity=50,
solver='cplex',
solver='cbc',
**kwargs):
self.technology_list = deepcopy(technology_list)
self.demand = demand
Expand Down
6 changes: 3 additions & 3 deletions osier/models/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(self,
technology_list,
net_demand,
time_delta=None,
solver='cplex',
solver='cbc',
lower_bound=0.0,
oversupply=0.0,
undersupply=0.0,
Expand Down Expand Up @@ -248,8 +248,8 @@ def __init__(self,
unit_power=self.power_units,
unit_time=self.time_delta.units)


logging.getLogger('pyomo.core').setLevel(verbosity)
logging.basicConfig(level=verbosity, format='%(message)s')


@property
def time_delta(self):
Expand Down
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[build-system]
requires = ["setuptools >= 64.0"]
build-backend = "setuptools.build_meta"

[project]
name="osier"
version = "0.3.0"
description = "osier: A justice oriented energy system optimization tool"
readme = "README.md"
keywords = ["energy systems", "optimization", "multi-objective", "justice", "multi-criteria decision"]

license = { file = "LICENSE" }

requires-python = ">= 3.9"

dependencies = [
'numpy',
'pandas',
'matplotlib',
'pytest',
'dill',
'openpyxl',
'nrelpy',
'unyt',
'pymoo',
'pyentrp',
'deap',
'pyomo'
]

authors = [
{name = "Sam Dotson", email = "samgdotson@gmail.com"},
]
maintainers = [
{name = "Sam Dotson", email = "samgdotson@gmail.com"}
]

classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Environment :: Console",
"Natural Language :: English",
"Operating System :: OS Independent"
]

[project.urls]
Homepage = "https://osier.readthedocs.io"
Repository = "https://github.com/arfc/osier"
Issues = "https://github.com/arfc/osier/issues"

[project.optional-dependencies]
doc = [
'sphinx>=5.1',
'sphinx-autobuild',
'myst-parser',
"sphinx_design",
"sphinx-autodoc-typehints",
'numpydoc',
'pydata_sphinx_theme',
'nbsphinx',
'pandoc'
]

[tool.setuptools.packages.find]
include = ['osier']
112 changes: 0 additions & 112 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import functools

if "win32" in sys.platform:
solver = 'cplex'
solver = 'cbc'
elif "linux" in sys.platform:
solver = "cbc"
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys

if "win32" in sys.platform:
solver = 'cplex'
solver = 'cbc'
elif "linux" in sys.platform:
solver = "cbc"
else:
Expand Down
Loading