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

reV updates #10

Merged
merged 61 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d78df6d
Moved and updated `GAPS_SUPPLIED_ARGS`
ppinchuk Jun 22, 2023
cd4b5e4
Logging parameters now passed to preprocessor
ppinchuk Jun 22, 2023
157410c
Updated docstrings
ppinchuk Jun 22, 2023
b75e0c0
Added info logging
ppinchuk Jun 22, 2023
7fdc24b
Log command name
ppinchuk Jun 22, 2023
e4a15a6
More thorough test for `_should_run` function
ppinchuk Jun 22, 2023
0928a4a
Add missing command name in log
ppinchuk Jun 23, 2023
df31e7e
Added logging to status updates
ppinchuk Jul 10, 2023
cd2854e
Updated order of logging statements
ppinchuk Jul 10, 2023
386b999
Added to QOS documentation
ppinchuk Jul 11, 2023
74cc127
Minor docstring updates
ppinchuk Jul 21, 2023
7eae807
Update docstrings
ppinchuk Jul 21, 2023
5fbe55b
Allow extra args to be added to exec control
ppinchuk Jul 21, 2023
a252d44
Add main CLI help docs
ppinchuk Jul 22, 2023
90ea6d8
Minor docstring updates
ppinchuk Jul 22, 2023
e8673c8
More typo fixes
ppinchuk Jul 22, 2023
03f7807
Add extra command help documentation
ppinchuk Jul 22, 2023
1a9c636
Added minor text to doc
ppinchuk Jul 23, 2023
87323f9
Documentation updates
ppinchuk Jul 23, 2023
6975ec1
Update README with more info about target audience
ppinchuk Aug 1, 2023
6978423
Add explanation about `tag` to docs
ppinchuk Aug 2, 2023
b7bee0e
Added extra tests for pipeline specification
ppinchuk Aug 2, 2023
bdd3117
Add `split_keys=None` test
ppinchuk Aug 2, 2023
bfa508a
Added test and docs for empty split key input
ppinchuk Aug 2, 2023
1acf53c
Log messages no longer propagate to root logger
ppinchuk Aug 3, 2023
1b08c1d
More detailed logger print statement
ppinchuk Aug 3, 2023
102306d
Updated variable name to `memory_utilization_limit`
ppinchuk Aug 3, 2023
63cb9a2
Updated pipeline log docs
ppinchuk Aug 3, 2023
e66907c
Fix bug with stdout not returning properly
ppinchuk Aug 4, 2023
7507930
Update documentation
ppinchuk Aug 4, 2023
c79e175
Major update with multiple bug fixes
ppinchuk Aug 5, 2023
902f202
Updated message text
ppinchuk Aug 5, 2023
80d23e2
Runtime not added to status monitor if job fails unexpectedly
ppinchuk Aug 5, 2023
81ea8c5
Failed jobs default to 0 runtime
ppinchuk Aug 7, 2023
672ef5f
Updated log versions logic
ppinchuk Aug 7, 2023
1f8af50
Added timestamp to monitor output
ppinchuk Aug 7, 2023
a28cb90
Fix error message
ppinchuk Aug 7, 2023
dd07f7e
Add `reset_query_cache` function
ppinchuk Aug 7, 2023
e8c4161
Monitor jobs now correctly query the hardware
ppinchuk Aug 7, 2023
a55d0fd
Updated status option check to be more robust
ppinchuk Aug 7, 2023
2198571
Do not submit pipeline if another monitor pipeline is already running
ppinchuk Aug 7, 2023
fe04d39
Monitor jobs now cancelled if exdception detected
ppinchuk Aug 7, 2023
984d61a
Cancelling jobs is now hardware-aware
ppinchuk Aug 7, 2023
b27c3e5
Update logger initialization
ppinchuk Aug 7, 2023
b10ccbc
Tabs now grouped together in docs
ppinchuk Aug 8, 2023
c5da395
Set max width on terminal to look good with docs
ppinchuk Aug 8, 2023
da1c6f3
Add `_is_sphinx_build` utility function
ppinchuk Aug 8, 2023
1087692
CLI command now says "Config Parameters"
ppinchuk Aug 9, 2023
8105c82
Big update to documentation formatting to support pretty docs in both…
ppinchuk Aug 9, 2023
ddee6ae
Minor formatting
ppinchuk Aug 9, 2023
bb6014a
Add zfill fix
ppinchuk Aug 9, 2023
31ecfb8
Add support for JSON5
ppinchuk Aug 9, 2023
d19d24d
Add GHA to run reV CLI tests
ppinchuk Aug 9, 2023
da5fc8d
Expanded collection tests slightly
ppinchuk Aug 9, 2023
aba2f9c
Updated status output
ppinchuk Aug 10, 2023
a3ad402
Updated tests to be more robust against messages in result
ppinchuk Aug 10, 2023
5b805b1
Bump version
ppinchuk Aug 10, 2023
6966cfd
Better str comparison in test
ppinchuk Aug 10, 2023
8ccba10
Install pytest with gaps
ppinchuk Aug 10, 2023
da8ac58
Increase wait limit for test
ppinchuk Aug 10, 2023
ce9fd12
Increase wait time in tests again
ppinchuk Aug 10, 2023
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
40 changes: 40 additions & 0 deletions .github/workflows/pr_rev_cli_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: reV CLI Tests

on: pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout gaps
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 1
path: gaps
- name: checkout reV
uses: actions/checkout@v2
with:
repository: nrel/reV
fetch-depth: 1
path: reV
- name: Set up Python
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.9
- name: Install reV
working-directory: ./reV
shell: bash -l {0}
run: |
pip install -e .
- name: Install gaps
working-directory: ./gaps
shell: bash -l {0}
run: |
pip install -e .[dev]
- name: Run reV CLI tests
working-directory: ./reV
shell: bash -l {0}
run: |
pytest -k cli -v --disable-warnings
36 changes: 26 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,37 @@ Welcome to Geospatial Analysis Pipelines (GAPs)!
.. inclusion-intro

Geospatial Analysis Pipelines (GAPs) is a framework designed
to assist users in scaling their geospatial models to a
High-Performance Computing (HPC) environment. In particular,
GAPs automatically distributes the execution of a
single-location model (such as the `System Advisor Model <https://sam.nrel.gov>`_)
over a large geospatial extent (e.g. CONUS) across many parallel
HPC nodes. Born from the open-source `reV <https://github.com/NREL/reV>`_ model, GAPs is a
to assist researchers and software developers add execution
tools to their geospatial python models. Born from the
open-source `reV <https://github.com/NREL/reV>`_ model, GAPs is a
robust and easy-to-use engine that provides a rich set of features
such as configuration file generation, job status monitoring,
CLI Documentation, and more.

such as command-line interface (CLI) generation and documentation,
basic High-Performance Computing (HPC) scaling capabilities,
configuration file generation, job status monitoring, and more.


Who should use GAPs
===================
GAPs is intended to be used by researchers and/or software developers
who have implemented a working python model but have not yet added any
external model execution tools. Within minimal effort, developers can
use GAPs to add a variety of utility for end-users, including a complete
set of CLI commands and documentation pulled from the model run function
docstrings. In addition, GAPs provides basic HPC execution capabilities,
particularly catered towards embarrassingly parallel geospatial models
(e.g. single-location models such as the `System Advisor Model <https://sam.nrel.gov>`_).
GAPs can automatically distribute the execution of such models over a large
geospatial extent (e.g. CONUS) across many parallel HPC nodes.

GAPs is **NOT** a workflow management system (WMS), and therefore does not
provide any of the in-depth tools/capabilities expected from a proper WMS.
However, GAPs-supported models can sometimes be included as part of the workflow in
WMS tools like `Torc <https://pages.github.nrel.gov/viz/wms/index.html#/>`_.

To get started, take a look at the `documentation <https://nrel.github.io/gaps/>`_ (examples coming soon!)


Installing gaps
Installing GAPs
===============

NOTE: The installation instruction below assume that you have python installed
Expand Down
1 change: 1 addition & 0 deletions gaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
logger.setLevel("DEBUG")
logger.propagate = False
11 changes: 1 addition & 10 deletions gaps/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@

from rex.utilities import parse_year

from gaps.config import (
load_config,
init_logging_from_config,
ConfigType,
resolve_all_paths,
)
from gaps.config import load_config, ConfigType, resolve_all_paths
import gaps.cli.pipeline
from gaps.pipeline import Pipeline
from gaps.exceptions import gapsValueError, gapsConfigError
Expand Down Expand Up @@ -56,8 +51,6 @@ def __init__(self, config):
self._job_tags = None
self._base_dir, config = _load_batch_config(config)
self._pipeline_fp = Path(config["pipeline_config"])

init_logging_from_config(config)
self._sets = _parse_config(config)

logger.info("Batch job initialized with %d sub jobs.", len(self._sets))
Expand Down Expand Up @@ -97,14 +90,12 @@ def _make_job_dirs(self):

# walk through current directory getting everything to copy
for source_dir, _, filenames in os.walk(self._base_dir):

# don't make additional copies of job sub directories.
if any(job_tag in source_dir for job_tag in self._sets):
continue

# For each dir level, iterate through the batch arg combos
for tag, (arg_comb, mod_files, __) in self._sets.items():

# Add the job tag to the directory path.
# This will copy config subdirs into the job subdirs
source_dir = Path(source_dir)
Expand Down
9 changes: 8 additions & 1 deletion gaps/cli/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import click

import gaps.batch
from gaps.config import init_logging_from_config_file
from gaps.cli.command import _WrappedCommand
from gaps.cli.documentation import _batch_command_help


def _batch(config_file, dry, cancel, delete, monitor_background):
"""Execute an analysis pipeline over a parametric set of inputs"""
init_logging_from_config_file(config_file, background=monitor_background)

if cancel:
gaps.batch.BatchJob(config_file).cancel()
elif delete:
Expand Down Expand Up @@ -64,7 +67,11 @@ def batch_command():
context_settings=None,
callback=_batch,
params=params,
help="Execute an analysis pipeline over a parametric set of inputs",
help=(
"Execute an analysis pipeline over a parametric set of inputs.\n\n"
"The general structure for calling this CLI command is given "
"below (add``--help`` to print help info to the terminal)."
),
epilog=None,
short_help=None,
options_metavar="[OPTIONS]",
Expand Down
25 changes: 17 additions & 8 deletions gaps/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CLICommandFromFunction,
_WrappedCommand,
)
from gaps.cli.documentation import _main_command_help
from gaps.cli.preprocessing import preprocess_collect_config
from gaps.cli.status import status_command

Expand Down Expand Up @@ -56,9 +57,8 @@ def convert_to_commands(self):
command = as_click_command(command_config)
self.commands.append(command)
Pipeline.COMMANDS[command_config.name] = command
self.template_configs[command_config.name] = (
command_config.documentation.template_config
)
template_config = command_config.documentation.template_config
self.template_configs[command_config.name] = template_config
return self

def add_pipeline_command(self):
Expand Down Expand Up @@ -168,6 +168,8 @@ def make_cli(commands, info=None):

name : str
Name of program to display at the top of the CLI help.
This input is optional, but specifying it yields richer
documentation for the main CLI command.
version : str
Include program version with a ``--version`` CLI option.

Expand All @@ -181,6 +183,7 @@ def make_cli(commands, info=None):
"""
info = info or {}
command_generator = _CLICommandGenerator(commands)
commands = command_generator.generate()

options = [
click.Option(
Expand All @@ -189,12 +192,17 @@ def make_cli(commands, info=None):
help="Flag to turn on debug logging. Default is not verbose.",
),
]
prog_name = [info["name"]] if "name" in info else []

prog_name = info.get("name")
if prog_name:
main_help = _main_command_help(
prog_name, command_generator.command_configs
)
else:
main_help = "Command Line Interface"

main = click.Group(
help=" ".join(prog_name + ["Command Line Interface"]),
params=options,
callback=_main_cb,
commands=command_generator.generate(),
help=main_help, params=options, callback=_main_cb, commands=commands
)
version = info.get("version")
if version is not None:
Expand All @@ -208,3 +216,4 @@ def _main_cb(ctx, verbose):
"""Set the obj and verbose settings of the commands."""
ctx.ensure_object(dict)
ctx.obj["VERBOSE"] = verbose
ctx.max_content_width = 92
Loading
Loading