Skip to content

Commit

Permalink
Merge pull request #356 from NREL/develop
Browse files Browse the repository at this point in the history
v3.0 release
  • Loading branch information
RHammond2 authored Oct 18, 2024
2 parents c45df23 + 670ff15 commit fd60f1e
Show file tree
Hide file tree
Showing 183 changed files with 44,141 additions and 8,571 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,26 +22,17 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install -y libglpk-dev glpk-utils coinor-cbc
python -m pip install --upgrade pip
pip install scikit-learn
pip install -r requirements.txt
- name: Install package
run: |
python setup.py install
pip install ".[develop]"
- name: Create env file
run: |
touch .env
# echo NREL_API_KEY=${{ secrets.NREL_API_KEY }} >> .env
# cat .env
- name: Install test dependencies
run: |
pip install pytest
pip install pytest-subtests
pip install responses
- name: Run tests
run: |
PYTHONPATH=. pytest tests
- name: Lint with flake8
run: |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
pip install flake8
flake8 . --count --exit-zero --statistics --ignore=E501
flake8 . --count --exit-zero --statistics --ignore=E501
6 changes: 3 additions & 3 deletions .github/workflows/conda_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
name: Conda
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.7
python-version: 3.9
- name: Build and upload conda package
shell: bash -l {0}
env:
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
if: github.event.action == 'published'
environment:
name: pypi-publishing
url: https://pypi.org/p/HOPP
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
python-version: 3.9
- name: Build package
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
pip install setuptools build wheel twine
python -m build
twine check --strict dist/*
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: True

34 changes: 34 additions & 0 deletions .github/workflows/publish_to_test_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Upload to PyPi

on:
push:
tags:
- 'v*'

jobs:
deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment:
name: pypi-publishing
url: https://test.pypi.org/p/HOPP
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Build package
run: |
python -m pip install --upgrade pip
pip install setuptools build wheel twine
python -m build
twine check --strict dist/*
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: True
repository-url: https://test.pypi.org/legacy/

11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ log/
# needed for h2 test inputs: tests/analysis/results/
*_disp.txt

# Results
resource_files/wind
resource_files/solar
resource_files/grid
# Resource files (force add ones that are really needed in the repository)
hopp/simulation/resource_files/wind
hopp/simulation/resource_files/solar
hopp/simulation/resource_files/grid

.idea/*
.idea/workspace.xml
Expand Down Expand Up @@ -119,5 +119,4 @@ ENV/
*.db
*.db-shm
*.gz
*.db-wal

*.db-wal
10 changes: 6 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
Expand All @@ -26,6 +26,8 @@ sphinx:

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
- requirements: requirements-dev.txt
install:
- method: pip
path: .
extra_requirements:
- develop
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2020, Alliance for Sustainable Energy, LLC
Copyright (c) 2024, Alliance for Sustainable Energy, LLC
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
78 changes: 46 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,93 @@
# Hybrid Optimization and Performance Platform
# HOPP: Hybrid Optimization and Performance Platform

[![PyPI version](https://badge.fury.io/py/hopp.svg)](https://badge.fury.io/py/hopp)
![CI Tests](https://github.com/NREL/HOPP/actions/workflows/ci.yml/badge.svg)
[![image](https://img.shields.io/pypi/pyversions/hopp.svg)](https://pypi.python.org/pypi/hopp)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)

As part of NREL's [Hybrid Energy Systems Research](https://www.nrel.gov/wind/hybrid-energy-systems-research.html), this
software assesses optimal designs for the deployment of utility-scale hybrid energy plants, particularly considering wind,
solar and storage.

## Software requirements
- Python version 3.8, 3.9, 3.10 64-bit
- Other versions may still work, but have not been extensively tested at this time

- Python version 3.9, 3.10, and 3.11 only (PySAM 4.2 is incompatible with 3.12)

## Installing from Package Repositories

1. HOPP is available as a PyPi package:

```
```bash
pip install HOPP
```

## Installing from Source

1. Using Git, navigate to a local target directory and clone repository:
```

```bash
git clone https://github.com/NREL/HOPP.git
```

2. Navigate to `HOPP`
```

```bash
cd HOPP
```

3. Create a new virtual environment and change to it. Using Conda and naming it 'hopp':
```

```bash
conda create --name hopp python=3.8 -y
conda activate hopp
```

4. Install dependencies:
```
conda install -c conda-forge coin-or-cbc=2.10.8 -y
conda install -c conda-forge glpk -y
pip install -r requirements.txt
4. Install HOPP and its dependencies:

```bash
conda install -y -c conda-forge coin-or-cbc=2.10.8 glpk
```
Note if you are on Windows, you will have to manually install Cbc: https://github.com/coin-or/Cbc

If you also want development dependencies for running tests and building docs:
Note if you are on Windows, you will have to manually install Cbc: https://github.com/coin-or/Cbc.

```
pip install -r requirements-dev.txt
```
- If you want to just use HOPP:

5. Install HOPP:
```
pip install -e .
```
```bash
pip install .
```

- If you want to work with the examples:

```bash
pip install ".[examples]"
```

- If you also want development dependencies for running tests and building docs:

```bash
pip install -e ".[develop]"
```

5. The functions which download resource data require an NREL API key. Obtain a key from:

6. The functions which download resource data require an NREL API key. Obtain a key from:
[https://developer.nrel.gov/signup/](https://developer.nrel.gov/signup/)

7. To set up the `NREL_API_KEY` and `NREL_API_EMAIL` required for resource downloads, you can create Environment Variables called `NREL_API_KEY` and `NREL_API_EMAIL`. Otherwise, you can keep the key in a new file called ".env" in the root directory of this project.
6. To set up the `NREL_API_KEY` and `NREL_API_EMAIL` required for resource downloads, you can create Environment Variables called `NREL_API_KEY` and `NREL_API_EMAIL`. Otherwise, you can keep the key in a new file called ".env" in the root directory of this project.

Create a file ".env" that contains the single line:
```

```bash
NREL_API_KEY=key
[email protected]
```

8. Verify setup by running tests:
```
7. Verify setup by running tests:

```bash
pytest tests/hopp
```

2. To set up `NREL_API_KEY` for resource downloads, first refer to section 7 and 8 above. But for the `.env` file method,
8. To set up `NREL_API_KEY` for resource downloads, first refer to section 6 and 7 above. But for the `.env` file method,
the file should go in the working directory of your Python project, e.g. directory from where you run `python`.

## Getting Started
Expand All @@ -82,4 +96,4 @@ The [Examples](./examples/) contain Jupyter notebooks and sample YAML files for
## Contributing
Interested in improving HOPP? Please see the [Contributing](./CONTRIBUTING.md) section for more information.
Interested in improving HOPP? Please see the [Contributing](./CONTRIBUTING.md) section for more information.
12 changes: 6 additions & 6 deletions alt_dev/run_alt.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def init_simulation_pv():

# Load in weather and price data files
solar_file = Path(
__file__).parent.parent / "resource_files" / "solar" / WEATHER_FILE #"Beni_Miha" / "659265_32.69_10.90_2019.csv"
grid_file = Path(__file__).parent.parent / "resource_files" / "grid" / PRICE_FILE #"tunisia_est_grid_prices.csv"
__file__).parent.parent / "hopp" / "simulation" / "resource_files" / "solar" / WEATHER_FILE #"Beni_Miha" / "659265_32.69_10.90_2019.csv"
grid_file = Path(__file__).parent.parent / "hopp" / "simulation" / "resource_files" / "grid" / PRICE_FILE #"tunisia_est_grid_prices.csv"

# Combine the data into a site definition
site_info = SiteInfo(site_data, solar_resource_file=solar_file, grid_resource_file=grid_file)
Expand Down Expand Up @@ -151,8 +151,8 @@ def init_simulation_csp():

# Load in weather and price data files
solar_file = Path(
__file__).parent.parent / "resource_files" / "solar" / WEATHER_FILE #"Beni_Miha" / "659265_32.69_10.90_2019.csv"
grid_file = Path(__file__).parent.parent / "resource_files" / "grid" / PRICE_FILE #"tunisia_est_grid_prices.csv"
__file__).parent.parent / "hopp" / "simulation" / "resource_files" / "solar" / WEATHER_FILE #"Beni_Miha" / "659265_32.69_10.90_2019.csv"
grid_file = Path(__file__).parent.parent / "hopp" / "simulation" / "resource_files" / "grid" / PRICE_FILE #"tunisia_est_grid_prices.csv"

# Combine the data into a site definition
site_info = SiteInfo(site_data, solar_resource_file=solar_file, grid_resource_file=grid_file)
Expand Down Expand Up @@ -228,8 +228,8 @@ def init_simulation_hybrid():

# Load in weather and price data files
solar_file = Path(
__file__).parent.parent / "resource_files" / "solar" / WEATHER_FILE #"Beni_Miha" / "659265_32.69_10.90_2019.csv"
grid_file = Path(__file__).parent.parent / "resource_files" / "grid" / PRICE_FILE #"tunisia_est_grid_prices.csv"
__file__).parent.parent / "hopp" / "simulation" / "resource_files" / "solar" / WEATHER_FILE #"Beni_Miha" / "659265_32.69_10.90_2019.csv"
grid_file = Path(__file__).parent.parent / "hopp" / "simulation" / "resource_files" / "grid" / PRICE_FILE #"tunisia_est_grid_prices.csv"

# Combine the data into a site definition
site_info = SiteInfo(site_data, solar_resource_file=solar_file, grid_resource_file=grid_file)
Expand Down
Loading

0 comments on commit fd60f1e

Please sign in to comment.