Skip to content

Commit dfc49cd

Browse files
Patch: Dependency updates (NREL#262)
* address dependency stack items in NREL#259 * reduce configuration file count when toml option is available * add easier way to run unit and/or regression * remove optional from required * restore dask requirement, but through xarray * update installation instructions * remove unnecessary requirements file * remove unnecessary file and fix conditions test in options * dont' forget to save your work * ensure all test pathways are found with(out) flags * update changelog * add missing * added h5pyd to examples extra, updated readme * support python 3.11 and reorganize modifiers * add note on Python 3.11 recommended install flow * add additional description * minor language updates and clarifications * add in a python 3.11 for bleeding edge tests runner * reinstate requests as required * update changelog for python 3.11 support --------- Co-authored-by: Jordan Perr-Sauer <[email protected]>
1 parent bbf8cd1 commit dfc49cd

18 files changed

+317
-192
lines changed

.coveragerc

-9
This file was deleted.

.github/workflows/ci-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, windows-latest]
18-
python-version: [3.9]
18+
python-version: [3.9, 3.11]
1919

2020
steps:
2121
- uses: actions/checkout@v3

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# Changelog
22
All notable changes to this project will be documented in this file. If you make a notable change to the project, please add a line describing the change to the "unreleased" section. The maintainers will make an effort to keep the [Github Releases](https://github.com/NREL/OpenOA/releases) page up to date with this changelog. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

4+
## Unreleased - TBD
5+
6+
- Python 3.11 is now supported.
7+
- Updates the dependency requirements to minimize the number of required packages, and have a more
8+
expansive list of modifiers. Users can now use any combination of
9+
`pip install openoa[examples, develop, docs, nrel-wind, reanalysis]` to ensure the appropriate
10+
packages are installed for their workflow.
11+
- Adds a `--unit` and `--regression` flag for running pytest that works in addition to
12+
`pytest test/unit` or `pytest test/regression`.
13+
- Converts some configuration files into `pyproject.toml` settings to reduce visual clutter
14+
at the top-level of the directory.
15+
416
## v3.0 - 29 September 2023
517

618
Please see the [updated documentation](https://openoa.readthedocs.io/en/latest/index.html) for a complete overview of the new and improved OpenOA. Much will look familiar, but using the library should now be much more streamlined, and usage should be significantly faster.

contributing.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
# Contributing
33

4-
54
## Getting Started
65

76
These contributing guidelines should be read by software developers wishing to contribute code or
@@ -209,13 +208,13 @@ To run the tests you can use any of the following commands, depending on your ne
209208
3. Only the unit tests:
210209

211210
```bash
212-
pytest test/unit
211+
pytest --unit
213212
```
214213

215214
4. Only the regression (integration) tests:
216215

217216
```bash
218-
pytest test/regression
217+
pytest --regression
219218
```
220219

221220
## Pull Request
@@ -239,6 +238,7 @@ base. Be sure to write a complete description of these changes in the pull reque
239238
All tests must pass. Pull requests will be rejected or have changes requested if tests do not pass,
240239
or cannot pass with changes. Tests are automatically run through Github Actions for any pull request
241240
or push to the main or develop branches, but should also be run locally before submission.
241+
242242
#### Test Coverage
243243

244244
The testing framework described below will generate a coverage report from the tests run through

examples/02b_plant_aep_analysis_cubico.ipynb

+71-69
Large diffs are not rendered by default.

examples/README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
# Examples Requirements
2+
13
Please be sure to install the required packages for running the example notebooks by
2-
executing the following command:
4+
executing one of the following commands:
35

6+
```bash
7+
pip install "openoa[examples]"
48
```
5-
pip install -r requirements.txt
9+
10+
or for a source installation:
11+
12+
```bash
13+
pip install ".[examples]"
614
```

examples/requirements.txt

-7
This file was deleted.

pyproject.toml

+34-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,37 @@ length_sort_straight = "True"
3535
lines_after_imports = "2"
3636
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
3737
known_first_party = "openoa"
38-
known_third_party = ["numpy","scipy","pandas","pygam","tqdm","statsmodels","scikit_learn","EIA-python","requests","pyproj","shapely"]
38+
known_third_party = [
39+
"numpy",
40+
"scipy",
41+
"pandas",
42+
"pygam",
43+
"tqdm",
44+
"statsmodels",
45+
"scikit_learn",
46+
"EIA-python",
47+
"requests",
48+
"pyproj",
49+
"shapely"
50+
]
51+
52+
[tool.pytest.ini_options]
53+
python_files = [
54+
"test/*.py",
55+
]
56+
testpaths = [
57+
"test/unit/*.py",
58+
"test/regression/*.py",
59+
]
60+
filterwarnings = [
61+
"ignore::DeprecationWarning:sklearn.*:",
62+
"ignore::DeprecationWarning:patsy.*:",
63+
"ignore::DeprecationWarning:pygam.*:",
64+
]
65+
66+
[tool.coverage.report]
67+
exclude_lines = [
68+
"# pragma: no cover",
69+
"def .+plot",
70+
"def plot_.+",
71+
]

pytest.ini

-6
This file was deleted.

readme.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ If you would like to try out the code before installation or simply explore the
2626

2727
If you use this software in your work, please cite our JOSS article with the following BibTex:
2828

29-
```
29+
```bibtex
3030
@article{Perr-Sauer2021,
3131
doi = {10.21105/joss.02171},
3232
url = {https://doi.org/10.21105/joss.02171},
@@ -43,7 +43,7 @@ If you use this software in your work, please cite our JOSS article with the fol
4343

4444
### Requirements
4545

46-
- Python 3.8, 3.9, or 3.10 with pip.
46+
- Python 3.8-3.11 with pip.
4747

4848
We strongly recommend using the Anaconda Python distribution and creating a new conda environment for OpenOA. You can download Anaconda through [their website.](https://www.anaconda.com/products/individual)
4949

@@ -72,6 +72,22 @@ python
7272
>>> openoa.__version__
7373
```
7474

75+
#### Installation Options
76+
77+
There are a number of installation options that can be used, depending on the use case, which can be
78+
installed with the following pattern `pip install "openoa[opt1,opt2]"` (`pip install .[opt1,opt2]` is also allowed).
79+
80+
- `develop`: for linting, automated formatting, and testing
81+
- `docs`: for building the documentation
82+
- `examples`: for the full Jupyter Lab suite (also contains `reanalysis` and `nrel-wind`)
83+
- `renalysis`: for accessing and processing MERRA2 and ERA5 data
84+
- `nrel-wind`: for accessing the NREL WIND Toolkit
85+
- `all`: for the complete dependency stack
86+
87+
> **Important**
88+
> If using Python 3.11, install `openoa` only, then reinstall adding the modifiers to reduce
89+
> the amount of time it takes for pip to resolve the dependency stack.
90+
7591
#### Common Installation Issues
7692

7793
- In Windows you may get an error regarding geos_c.dll. To fix this install Shapely using:
@@ -88,6 +104,8 @@ pip install --upgrade pywin32==255
88104

89105
#### Example Notebooks and Data
90106

107+
Be sure to install OpenOA using the `examples` modifier from [above](#installation-options). Such as: `pip install ".[examples]"`
108+
91109
The example data will be automaticaly extracted as needed by the tests. To manually extract the example data for use with the example notebooks, use the following command:
92110

93111
```bash
@@ -100,6 +118,8 @@ The example notebooks are located in the `examples` directory. We suggest instal
100118
jupyter lab # "jupyter notebook" is also ok if that's your preference
101119
```
102120

121+
Open the URL printed to your command prompt in your favorite browser. Once jupyter is open, navigate to the "examples" directory in the file explorer and open an example notebook.
122+
103123
### Development
104124

105125
Please see the developer section of the contributing guide [here](contributing.md), or on the [documentation site](https://openoa.readthedocs.io/en/latest/getting_started/contributing.html) for complete details.
@@ -110,7 +130,7 @@ this second step must be done before committing any changes):
110130

111131
```bash
112132
cd OpenOA
113-
pip install -e ".[develop, docs]"
133+
pip install -e ".[develop, docs, examples]"
114134
pre-commit install
115135
```
116136

@@ -138,7 +158,7 @@ pytest
138158
To run unit tests only:
139159

140160
```bash
141-
pytest test/unit
161+
pytest --unit
142162
```
143163

144164
To run all tests and generate a code coverage report

setup.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,16 @@
1919
"pandas>=2.0",
2020
"pygam>=0.9.0",
2121
"scipy>=1.7",
22-
"statsmodels>=0.11",
22+
"statsmodels>=0.11; python_version<'3.11'",
23+
"statsmodels>=0.13.3; python_version=='3.11'",
2324
"tqdm>=4.28.1",
2425
"matplotlib>=3.6",
2526
"bokeh>=2.4",
26-
"attrs>=22",
27+
"attrs>=22.2",
2728
"pytz",
28-
"h5pyd",
2929
"pyyaml",
30-
"pyspark",
3130
"tabulate",
32-
"statsmodels",
33-
"jupyterlab",
34-
"xarray",
35-
"dask",
36-
"netcdf4",
37-
"cdsapi",
31+
"ipython",
3832
]
3933

4034
# Testing-only dependencies
@@ -43,7 +37,6 @@
4337
# All extra dependencies (see keys for breakdown by purpose)
4438
EXTRAS = {
4539
"docs": [
46-
"ipython",
4740
"Sphinx>=5.0,!=7.2.0",
4841
"pydata-sphinx-theme",
4942
"sphinx_design>=0.3",
@@ -58,8 +51,20 @@
5851
"flake8",
5952
"flake8-docstrings",
6053
],
54+
"examples": [
55+
"jupyterlab",
56+
],
57+
"nrel-wind": ["h5pyd"],
58+
"reanalysis": [
59+
"cdsapi",
60+
"xarray[parallel]", # Dask required for loading data
61+
"h5py", # Required for netcdf4
62+
"netcdf4",
63+
],
6164
}
6265
EXTRAS["develop"] += TESTS
66+
EXTRAS["examples"] += EXTRAS["reanalysis"] + EXTRAS["nrel-wind"]
67+
EXTRAS["all"] = EXTRAS["develop"] + EXTRAS["docs"] + EXTRAS["examples"]
6368

6469

6570
# Read the version from the __init__.py file without importing it
@@ -99,6 +104,5 @@ def read_file(filename):
99104
include_package_data=True,
100105
install_requires=REQUIRED,
101106
extras_require=EXTRAS,
102-
tests_require=TESTS,
103-
python_requires=">=3.8, <3.11",
107+
python_requires=">=3.8, <3.12",
104108
)

sphinx/examples/02b_plant_aep_analysis_cubico.ipynb

+71-69
Large diffs are not rendered by default.

sphinx/examples/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notebooks are located at /examples in the OpenOA repository, and can be modified and run on
44
[Binder](https://mybinder.org/v2/gh/NREL/OpenOA/develop_v3?filepath=examples).
55

6+
```{important}
7+
Be sure to install OpenOA using the `examples` modifier (`pip install "openoa[examples]"`). This
8+
will install all of the dependencies used by the additional methods contained within the examples
9+
notebooks.
10+
```
11+
612
## Overview
713

814
In each of the following examples we'll be providing more insight into the different functionalities
@@ -32,6 +38,11 @@ of OpenOA. In each notebook, OpenOA is demonstrated using two years of operation
3238

3339
## Gap Analysis Step 1b: Estimate the AEP and Its Uncertainty Using Cubico Open Data [[link]](02b_plant_aep_analysis_cubico.ipynb)
3440

41+
```{important}
42+
Be sure to install OpenOA using the `examples` and `reanalysis` modifiers for this notebook
43+
(`pip install "openoa[examples,reanalysis]"`).
44+
```
45+
3546
* Introduces the annual energy production (AEP) class, and how to estimate the uncertainty using
3647
a Monte Carlo approach
3748
* Demonstrates some of the supplementary tools to analysis, such as the plotting routines, and

sphinx/getting_started/index.rst

+20-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ library on our `Binder page`_.
99
Quick Start
1010
***********
1111

12-
For most users, getting started should be as easy as either below code blocks, but if you get hung up on running examples
13-
locally, or interacting with the code, you can always interact with our `Binder page`_
14-
12+
For most users, getting started should be as easy as either below code blocks, but if you get hung
13+
up on running examples locally, or interacting with the code, you can always interact with our
14+
`Binder page`_
1515

1616
Pip
1717
---
@@ -29,6 +29,23 @@ Source
2929
cd openoa
3030
pip install -e .
3131
32+
Additional Dependencies
33+
-----------------------
34+
35+
.. important::
36+
If using Python 3.11, install ``openoa`` only, then reinstall adding the modifiers to reduce
37+
the amount of time it takes for pip to resolve the dependency stack.
38+
39+
Whether installing from PyPI or source, any combination of the following can be used to install
40+
additional dependencies. For example, the examples requirements can be installed using
41+
`pip install "openoa[examples]"`.
42+
43+
- `develop`: for linting, automated formatting, and testing
44+
- `docs`: for building the documentation
45+
- `examples`: for the full Jupyter Lab suite (also contains `reanalysis` and `nrel-wind`)
46+
- `renalysis`: for accessing and processing MERRA2 and ERA5 data
47+
- `nrel-wind`: for accessing the NREL WIND Toolkit
48+
- `all`: for the complete dependency stack
3249

3350
Installation and Contributing
3451
*****************************
@@ -40,5 +57,4 @@ Installation and Contributing
4057
changelog
4158

4259

43-
4460
.. _Binder page: https://mybinder.org/v2/gh/NREL/OpenOA/develop_v3?filepath=examples

sphinx/getting_started/install.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ at the same time with the following.
3131
3232
pip install "OpenOA[develop]"
3333
34+
.. important::
35+
If using Python 3.11, install ``openoa`` only, then reinstall adding the modifiers to reduce
36+
the amount of time it takes for pip to resolve the dependency stack.
37+
38+
Additional options:
39+
- `develop`: for linting, automated formatting, and testing
40+
- `docs`: for building the documentation
41+
- `examples`: for the full Jupyter Lab suite (also contains `reanalysis` and `nrel-wind`)
42+
- `renalysis`: for accessing and processing MERRA2 and ERA5 data
43+
- `nrel-wind`: for accessing the NREL WIND Toolkit
44+
- `all`: for the complete dependency stack
45+
3446

3547
Now you can verify the version that was installed
3648

@@ -54,7 +66,7 @@ guidelines and processes, please see the :ref:`contributors guide <contributing>
5466
pip install -e .
5567
5668
# Extras can also be installed as one or any combination of the following
57-
pip install -e ".[develop,docs,extras]"
69+
pip install -e ".[develop,docs]"
5870
5971
Now you can verify the version that was installed
6072

0 commit comments

Comments
 (0)