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

update configs and clis to use config QA #61

Merged
merged 1 commit into from
Jul 15, 2020
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
8 changes: 4 additions & 4 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ requirements:
- dask
- geopandas
- h5py
- nrel-rex>=0.1.13
- nrel-rev>=0.4.5
- nrel-rex>=0.2.2
- nrel-rev>=0.4.7
- numpy>=1.16
- pandas
- psutil
Expand All @@ -40,8 +40,8 @@ requirements:
- dask
- geopandas
- h5py
- nrel-rex>=0.1.13
- nrel-rev>=0.4.5
- nrel-rex>=0.2.2
- nrel-rev>=0.4.7
- {{ pin_compatible('numpy') }}
- pandas
- psutil
Expand Down
33 changes: 10 additions & 23 deletions reVX/config/reeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"""
reVX ReEDS Configuration
"""

from reV.config.base_config import BaseConfig
from reV.config.base_analysis_config import AnalysisConfig


class ReedsConfig(AnalysisConfig):
"""Config framework for REEDS jobs."""

NAME = 'ReEDS'
REQUIREMENTS = ('rev_table', )

@property
def classify(self):
"""Get the classify input group in the config dict."""
classify = self.get('classify', None)
if classify is not None:
classify = ClassifyConfigGroup(classify)

return classify

@property
Expand All @@ -26,6 +26,7 @@ def profiles(self):
profiles = self.get('profiles', None)
if profiles is not None:
profiles = ProfilesConfigGroup(profiles)

return profiles

@property
Expand All @@ -34,30 +35,14 @@ def timeslices(self):
timeslices = self.get('timeslices', None)
if timeslices is not None:
timeslices = TimeslicesConfigGroup(timeslices)
return timeslices


class ReedsConfigGroup(dict):
"""Super class for handling Reeds config input groups."""

def __init__(self, config):
"""
Parameters
----------
config : dict
Dictionary with pre-extracted config input group.
"""
if not isinstance(config, dict):
raise TypeError('Config input must be a dict but received: {}'
.format(type(config)))

super().__init__()
self.update(config)
return timeslices


class ClassifyConfigGroup(ReedsConfigGroup):
class ClassifyConfigGroup(BaseConfig):
"""Subclass for handling the Reeds config input group for the reVX-REEDS
classify framework."""
REQUIREMENTS = ('rev_table', 'resource_classes')

def __init__(self, config):
"""
Expand Down Expand Up @@ -106,9 +91,10 @@ def pre_filter(self):
return self.get('pre_filter', None)


class ProfilesConfigGroup(ReedsConfigGroup):
class ProfilesConfigGroup(BaseConfig):
"""Subclass for handling the Reeds config input group for the reVX-REEDS
representative profiles framework."""
REQUIREMENTS = ('reeds_table', 'cf_profiles')

def __init__(self, config):
"""
Expand Down Expand Up @@ -179,9 +165,10 @@ def max_workers(self):
return self.get('max_workers', None)


class TimeslicesConfigGroup(ReedsConfigGroup):
class TimeslicesConfigGroup(BaseConfig):
"""Subclass for handling the Reeds config input group for the reVX-REEDS
timeslices framework."""
REQUIREMENTS = ('timeslices', )

def __init__(self, config):
"""
Expand Down
18 changes: 16 additions & 2 deletions reVX/reeds/reeds_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from rex.utilities.loggers import init_mult
from rex.utilities.cli_dtypes import STR, STRLIST, INT
from rex.utilities.execution import SLURM, SubprocessManager
from rex.utilities.utilities import dict_str_load
from rex.utilities.utilities import dict_str_load, get_class_properties

from reVX.config.reeds import ReedsConfig
from reVX.config.reeds import (ReedsConfig, ClassifyConfigGroup,
ProfilesConfigGroup, TimeslicesConfigGroup)
from reVX.reeds.reeds_classification import ReedsClassifier
from reVX.reeds.reeds_profiles import ReedsProfiles
from reVX.reeds.reeds_timeslices import ReedsTimeslices
Expand All @@ -36,6 +37,19 @@ def main(ctx, name, verbose):
ctx.obj['VERBOSE'] = verbose


@main.command()
def valid_config_keys():
"""
Echo the valid ReEDS config keys
"""
config_classes = [ReedsConfig, ClassifyConfigGroup,
ProfilesConfigGroup, TimeslicesConfigGroup]
for cls in config_classes:
cls_name = str(cls).split('.')[-1].strip("'>")
click.echo("Valid keys for {}: {}"
.format(cls_name, ', '.join(get_class_properties(cls))))


def run_local(ctx, config):
"""
Run reV to ReEDs locally from config
Expand Down
2 changes: 1 addition & 1 deletion reVX/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
reVX version number
"""

__version__ = "0.3.3"
__version__ = "0.3.4"
9 changes: 9 additions & 0 deletions reVX/wind_dirs/wind_dirs_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rex.utilities.loggers import init_mult
from rex.utilities.cli_dtypes import STR, INT
from rex.utilities.execution import SLURM, SubprocessManager
from rex.utilities.utilities import get_class_properties

from reVX.config.wind_dirs import WindDirsConfig
from reVX.wind_dirs.wind_dirs import WindDirections
Expand All @@ -31,6 +32,14 @@ def main(ctx, name, verbose):
ctx.obj['VERBOSE'] = verbose


@main.command()
def valid_config_keys():
"""
Echo the valid Wind Dirs config keys
"""
click.echo(', '.join(get_class_properties(WindDirsConfig)))


def run_local(ctx, config):
"""
Run WindDirections locally using config
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ dask>=2.8
dask[array]>=2.8
geopandas>=0.4
h5py>=2.9
NREL-reV>=0.4.5
NREL-rex>=0.1.13
NREL-reV>=0.4.7
NREL-rex>=0.2.2
numpy>=1.16
pandas>=0.25
psutil>=5.6
Expand Down