From 23fb6e691c9ddb8ab0343e0e4946db22bf64132b Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Mon, 9 Sep 2024 10:42:08 -0400 Subject: [PATCH 01/13] adds empty pyproj file --- pyproject.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 From 1446f80ce547e61254a8d2320139843aaea67b39 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Mon, 9 Sep 2024 20:21:16 -0400 Subject: [PATCH 02/13] removes setup.py --- setup.py | 112 ------------------------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 45fcd3c..0000000 --- a/setup.py +++ /dev/null @@ -1,112 +0,0 @@ -from __future__ import absolute_import, division, print_function -from os.path import join as pjoin -import sys -from setuptools import setup, find_packages - - -# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z" -_version_major = 0 -_version_minor = 3 -_version_micro = 0 # use '' for first of series, number for 1 and above -# _version_extra = 'dev' -_version_extra = '' # Uncomment this for full releases - -# Construct full version string from these. -_ver = [_version_major, _version_minor] -if _version_micro: - _ver.append(_version_micro) -if _version_extra: - _ver.append(_version_extra) - -__version__ = '.'.join(map(str, _ver)) - -CLASSIFIERS = ["Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Topic :: Scientific/Engineering"] - -# Description should be a one-liner: -description = "osier: A justice oriented energy system optimization tool" -# Long description will go up on the pypi page - -NAME = "osier" -MAINTAINER = "Samuel Dotson" -MAINTAINER_EMAIL = "samgdotson@gmail.com" -DESCRIPTION = description -with open("README.md", encoding="utf-8") as f: - LONG_DESCRIPTION = f.read() -LONG_DESCRIPTION_CONTENT_TYPE = 'text/markdown' -URL = "https://osier.readthedocs.io/en/latest/" -DOWNLOAD_URL = "http://github.com/arfc/osier" -LICENSE = "BSD-3" -AUTHOR = "Samuel Dotson" -AUTHOR_EMAIL = "sgd2@illinois.edu" -PLATFORMS = "OS Independent" -MAJOR = _version_major -MINOR = _version_minor -MICRO = _version_micro -VERSION = __version__ -PACKAGE_DATA = {'osier': [pjoin('data', '*')]} -REQUIRES = [ - 'numpy', - 'pandas', - 'matplotlib', - 'pytest', - 'dill', - 'openpyxl', - 'nrelpy', - 'unyt', - 'pymoo', - 'pyentrp', - 'deap',] -EXTRAS_REQUIRE = { - 'doc': [ - 'sphinx>=5.1', - 'sphinx-autobuild', - 'myst-parser', - "sphinx_design", - "sphinx-autodoc-typehints", - 'numpydoc', - 'pydata_sphinx_theme', - 'nbsphinx', - 'pandoc' - ]} -PYTHON_REQUIRES = ">= 3.6" - -PACKAGES = find_packages() - -ENTRY_POINTS = {} - -SETUP_REQUIRES = ['setuptools >= 24.2.0'] -# This enables setuptools to install wheel on-the-fly -SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else [] - -opts = dict(name=NAME, - maintainer=MAINTAINER, - maintainer_email=MAINTAINER_EMAIL, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - long_description_content_type=LONG_DESCRIPTION_CONTENT_TYPE, - url=URL, - download_url=DOWNLOAD_URL, - license=LICENSE, - classifiers=CLASSIFIERS, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - platforms=PLATFORMS, - version=VERSION, - packages=PACKAGES, - package_data=PACKAGE_DATA, - install_requires=REQUIRES, - extras_require=EXTRAS_REQUIRE, - python_requires=PYTHON_REQUIRES, - setup_requires=SETUP_REQUIRES, - requires=REQUIRES, - entry_points=ENTRY_POINTS) - - -if __name__ == '__main__': - setup(**opts) From 744e36565179f1c050b55c9644cbffd10cfae6c3 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Mon, 9 Sep 2024 20:21:35 -0400 Subject: [PATCH 03/13] first attempt at pyproject.toml --- pyproject.toml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index e69de29..683f4cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] +docs = [ + 'sphinx>=5.1', + 'sphinx-autobuild', + 'myst-parser', + "sphinx_design", + "sphinx-autodoc-typehints", + 'numpydoc', + 'pydata_sphinx_theme', + 'nbsphinx', + 'pandoc' +] + +[tool.setuptools.packages.find] +include = ['osier'] \ No newline at end of file From 2eb861d4c9e51c9518d1efb50b538bb1ed32ef90 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Mon, 9 Sep 2024 20:52:45 -0400 Subject: [PATCH 04/13] set the log level for the root logger --- osier/models/dispatch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osier/models/dispatch.py b/osier/models/dispatch.py index 4bfaf68..b0d4d02 100644 --- a/osier/models/dispatch.py +++ b/osier/models/dispatch.py @@ -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): From c8ae1614a585f3b5a32ec68b14cb9c28fdba141e Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Mon, 9 Sep 2024 21:00:18 -0400 Subject: [PATCH 05/13] updates the README to reflect fixes --- README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index 54b0f4e..35cf146 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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: From 8f4e0c57f4a763f3866e705ee1fa61ae249348f6 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Mon, 9 Sep 2024 21:26:46 -0400 Subject: [PATCH 06/13] adds new workflows to ci --- .github/workflows/CI.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8642851..7f75104 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,7 +15,15 @@ permissions: jobs: build: name: Build and test - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ${{ fromJSON(needs.build.outputs.python-versions) }} + os: + - ubuntu-latest + - macos-latest + - windows-latest defaults: run: @@ -36,11 +44,10 @@ 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 CBC run: | - mamba install coincbc + mamba install coin-or-cbc coincbc - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -50,9 +57,6 @@ jobs: - name: Install osier package run: | pip install . - - name : Install recent unyt update - run: | - python3 -m pip install -e git+https://github.com/yt-project/unyt.git#egg=unyt - name: Test with pytest run: | pytest tests/ From 7a103431b987d93504c5d6e90a18afe37491f6f8 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 13:02:06 -0400 Subject: [PATCH 07/13] updates the ci workflow --- .github/workflows/CI.yml | 25 +++++++++++++++++++++---- pyproject.toml | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7f75104..25a7cf4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,7 +19,11 @@ jobs: strategy: fail-fast: false matrix: - python-version: ${{ fromJSON(needs.build.outputs.python-versions) }} + python-version: + - 3.9 + - 3.10 + - 3.11 + - 3.12 os: - ubuntu-latest - macos-latest @@ -46,17 +50,30 @@ jobs: python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Install CBC + if: matrix.os != 'windows-latest' run: | mamba install coin-or-cbc coincbc - - name: Lint with flake8 + - name: install CBC (Windows) + if: matrix.os == 'windows-latest' + run: | + 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: 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 - - name: Install osier package + - name: Install osier package (macos) + if: matrix.os == 'macos-latest' + run: | + pip install -e .'[doc]' + - name: Install osier package (macos) + if: matrix.os != 'macos-latest' run: | - pip install . + pip install -e .[doc] + - name: Test with pytest run: | pytest tests/ diff --git a/pyproject.toml b/pyproject.toml index 683f4cd..7c30ac0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ Repository = "https://github.com/arfc/osier" Issues = "https://github.com/arfc/osier/issues" [project.optional-dependencies] -docs = [ +doc = [ 'sphinx>=5.1', 'sphinx-autobuild', 'myst-parser', From 019517e417851d017fba648c7ac4b5029769dc94 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 13:03:56 -0400 Subject: [PATCH 08/13] fixes python versions on workflow --- .github/workflows/CI.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 25a7cf4..0c5fce1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,10 +20,10 @@ jobs: fail-fast: false matrix: python-version: - - 3.9 - - 3.10 - - 3.11 - - 3.12 + - "3.9" + - "3.10" + - "3.11" + - "3.12" os: - ubuntu-latest - macos-latest From 4ec3c1488edde7f13fd9596b31f9d8fd339fb319 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 13:07:36 -0400 Subject: [PATCH 09/13] adds flake8 installation --- .github/workflows/CI.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0c5fce1..c154690 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -49,6 +49,9 @@ jobs: run: | python -m pip install --upgrade pip 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: | @@ -59,12 +62,6 @@ jobs: 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: 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 - name: Install osier package (macos) if: matrix.os == 'macos-latest' run: | @@ -77,3 +74,10 @@ jobs: - 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 From e2ecd306f675505dbeb26dbfa5550b5f00ca1d86 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 13:17:59 -0400 Subject: [PATCH 10/13] updates the default solver to cbc --- .github/workflows/CI.yml | 4 ++-- osier/models/capacity_expansion.py | 2 +- osier/models/dispatch.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c154690..1358aa1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -51,7 +51,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Install flake8 run: | - python -m pip install flake8 + python -m pip install flake8 - name: Install CBC if: matrix.os != 'windows-latest' run: | @@ -66,7 +66,7 @@ jobs: if: matrix.os == 'macos-latest' run: | pip install -e .'[doc]' - - name: Install osier package (macos) + - name: Install osier package if: matrix.os != 'macos-latest' run: | pip install -e .[doc] diff --git a/osier/models/capacity_expansion.py b/osier/models/capacity_expansion.py index 786ceb3..f59f4ae 100644 --- a/osier/models/capacity_expansion.py +++ b/osier/models/capacity_expansion.py @@ -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 diff --git a/osier/models/dispatch.py b/osier/models/dispatch.py index b0d4d02..392b3a9 100644 --- a/osier/models/dispatch.py +++ b/osier/models/dispatch.py @@ -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, From ccb308d6fd39564981ea38e5fb5397208805dd01 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 13:22:54 -0400 Subject: [PATCH 11/13] changes windows solver to cbc to make CI work --- tests/test_equations.py | 2 +- tests/test_models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_equations.py b/tests/test_equations.py index 95833c9..7f5bc12 100644 --- a/tests/test_equations.py +++ b/tests/test_equations.py @@ -7,7 +7,7 @@ import functools if "win32" in sys.platform: - solver = 'cplex' + solver = 'cbc' elif "linux" in sys.platform: solver = "cbc" else: diff --git a/tests/test_models.py b/tests/test_models.py index 87396b9..2370a51 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -8,7 +8,7 @@ import sys if "win32" in sys.platform: - solver = 'cplex' + solver = 'cbc' elif "linux" in sys.platform: solver = "cbc" else: From eafd0ffeaab9773483bc820df62943f3db1d4949 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 13:30:07 -0400 Subject: [PATCH 12/13] updates readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 35cf146..8a61577 100644 --- a/README.md +++ b/README.md @@ -44,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 From 7ed87331e9db38968e6fa73c1b74ce9325b4c10e Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Tue, 10 Sep 2024 16:02:03 -0400 Subject: [PATCH 13/13] updates readthedocs build --- .readthedocs.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 277d6f9..49eb6b3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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