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

Python 3.11 support #432

Merged
merged 8 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pull_request_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10']
python-version: [3.11]
include:
- os: ubuntu-latest
python-version: '3.10'
- os: ubuntu-latest
python-version: 3.9
- os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ A visual summary of this process is given below:
To get up and running with reV, first head over to the `installation page <https://nrel.github.io/reV/misc/installation.html>`_,
then check out some of the `Examples <https://nrel.github.io/reV/misc/examples.html>`_ or
go straight to the `CLI Documentation <https://nrel.github.io/reV/_cli/cli.html>`_!

You can also check out the `guide on running GAPs models <https://nrel.github.io/gaps/misc/examples.users.html>`_.

.. inclusion-install

Expand Down
7 changes: 5 additions & 2 deletions reV/econ/econ.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _get_data_shape(self, dset, n_sites):
return data_shape

def run(self, out_fpath=None, max_workers=1, timeout=1800,
pool_size=os.cpu_count() * 2):
pool_size=None):
"""Execute a parallel reV econ run with smart data flushing.

Parameters
Expand All @@ -476,14 +476,17 @@ def run(self, out_fpath=None, max_workers=1, timeout=1800,
seconds.
pool_size : int, optional
Number of futures to submit to a single process pool for
parallel futures. By default, ``os.cpu_count() * 2``.
parallel futures. If ``None``, the pool size is set to
``os.cpu_count() * 2``. By default, ``None``.

Returns
-------
str | None
Path to output HDF5 file, or ``None`` if results were not
written to disk.
"""
if pool_size is None:
pool_size = os.cpu_count() * 2

# initialize output file or append econ data to gen file
if self._append:
Expand Down
20 changes: 13 additions & 7 deletions reV/generation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,15 +1093,16 @@ def flush(self):

logger.debug('Flushed output successfully to disk.')

def _pre_split_pc(self, pool_size=os.cpu_count() * 2):
def _pre_split_pc(self, pool_size=None):
"""Pre-split project control iterator into sub chunks to further
split the parallelization.

Parameters
----------
pool_size : int
Number of futures to submit to a single process pool for
parallel futures.
parallel futures. If ``None``, the pool size is set to
``os.cpu_count() * 2``. By default, ``None``.

Returns
-------
Expand All @@ -1113,6 +1114,8 @@ def _pre_split_pc(self, pool_size=os.cpu_count() * 2):
N = 0
pc_chunks = []
i_chunk = []
if pool_size is None:
pool_size = os.cpu_count() * 2

for i, split in enumerate(self.points_control):
N += 1
Expand All @@ -1129,8 +1132,8 @@ def _pre_split_pc(self, pool_size=os.cpu_count() * 2):
.format(len(pc_chunks), [len(x) for x in pc_chunks]))
return N, pc_chunks

def _parallel_run(self, max_workers=None, pool_size=os.cpu_count() * 2,
timeout=1800, **kwargs):
def _parallel_run(self, max_workers=None, pool_size=None, timeout=1800,
**kwargs):
"""Execute parallel compute.

Parameters
Expand All @@ -1139,15 +1142,18 @@ def _parallel_run(self, max_workers=None, pool_size=os.cpu_count() * 2,
Number of workers. None will default to cpu count.
pool_size : int
Number of futures to submit to a single process pool for
parallel futures.
parallel futures. If ``None``, the pool size is set to
``os.cpu_count() * 2``. By default, ``None``.
timeout : int | float
Number of seconds to wait for parallel run iteration to complete
before returning zeros.
kwargs : dict
Keyword arguments to self._run_single_worker().
"""

max_workers = os.cpu_count() if max_workers is None else max_workers
if pool_size is None:
pool_size = os.cpu_count() * 2
if max_workers is None:
max_workers = os.cpu_count()
logger.info('Running parallel execution with max_workers={}'
.format(max_workers))
i = 0
Expand Down
7 changes: 5 additions & 2 deletions reV/generation/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def _parse_output_request(self, req):
return list(set(output_request))

def run(self, out_fpath=None, max_workers=1, timeout=1800,
pool_size=os.cpu_count() * 2):
pool_size=None):
"""Execute a parallel reV generation run with smart data flushing.

Parameters
Expand All @@ -789,7 +789,8 @@ def run(self, out_fpath=None, max_workers=1, timeout=1800,
seconds.
pool_size : int, optional
Number of futures to submit to a single process pool for
parallel futures. By default, ``os.cpu_count() * 2``.
parallel futures. If ``None``, the pool size is set to
``os.cpu_count() * 2``. By default, ``None``.

Returns
-------
Expand All @@ -801,6 +802,8 @@ def run(self, out_fpath=None, max_workers=1, timeout=1800,
self._init_fpath(out_fpath, module=ModuleName.GENERATION)
self._init_h5()
self._init_out_arrays()
if pool_size is None:
pool_size = os.cpu_count() * 2

kwargs = {'tech': self.tech,
'res_file': self.res_file,
Expand Down
3 changes: 3 additions & 0 deletions reV/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ModuleName(str, Enum):
def __str__(self):
return self.value

def __format__(self, format_spec):
return str.__format__(self.value, format_spec)

@classmethod
def all_names(cls):
"""All module names.
Expand Down
2 changes: 1 addition & 1 deletion reV/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
reV Version number
"""

__version__ = "0.8.2"
__version__ = "0.8.3"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NREL-gaps>=0.6.0
NREL-gaps>=0.6.2
NREL-NRWAL>=0.0.7
NREL-PySAM~=4.1.0
NREL-rex>=0.2.80
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def run(self):
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
test_suite="tests",
install_requires=install_requires,
Expand Down