Skip to content

Refactor: bmi_model.py, config.py, model.py - #191

Open
mdeshotel wants to merge 64 commits into
NGWPC-7625_PI_10_ngen_forcing_refactorfrom
pre_dev
Open

Refactor: bmi_model.py, config.py, model.py#191
mdeshotel wants to merge 64 commits into
NGWPC-7625_PI_10_ngen_forcing_refactorfrom
pre_dev

Conversation

@mdeshotel

Copy link
Copy Markdown

PR to merge a pre_dev branch containing major refactoring to BMI_model.py, Config.py, and Model.py. The pre_dev branch is intended as a staging branch whereby combinations of the 3 refactored files can be tested and adjustments made before an actual merge into development.

Additions

Removals

Changes

Testing

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Linux

@mdeshotel
mdeshotel marked this pull request as draft June 30, 2026 20:36
@mxkpp

mxkpp commented Aug 7, 2026

Copy link
Copy Markdown

This PR received merges equivalent to these now-closed PRs / branches (those merges need to be reviewed, but I have closed the other PRs to help clean up the repo):

Already merged into this PR

Refactor of config.py:

PR: #163
aka Branch: mdeshotel_ngwpc-10580

Refactor of bmi_model.py

Branch: mdeshotel_ngwpc-10578

Refactor of model.py

PR: #149
aka Branch: maxkipp-refactor-model-py

@mxkpp mxkpp mentioned this pull request Aug 7, 2026
12 tasks
@mxkpp mxkpp changed the title Pre dev Refactor: bmi_model.py, config.py, model.py Aug 11, 2026
@mxkpp

mxkpp commented Aug 13, 2026

Copy link
Copy Markdown

Rebased against development.

@mxkpp
mxkpp changed the base branch from development to NGWPC-7625_PI_10_ngen_forcing_refactor August 15, 2026 01:59
@mxkpp

mxkpp commented Aug 15, 2026

Copy link
Copy Markdown

Rebased against NGWPC-7625_PI_10_ngen_forcing_refactor and changed the base to that.

@mxkpp
mxkpp requested review from idtodd and mxkpp August 18, 2026 01:23
@mxkpp
mxkpp marked this pull request as ready for review August 18, 2026 01:23
Comment on lines +142 to +144
element_slope_azmuith[i] = hyfab.aspect_circmean[
i
] # NHF aspect is currently in radians, may need to be converted to degrees

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
element_slope_azmuith[i] = hyfab.aspect_circmean[
i
] # NHF aspect is currently in radians, may need to be converted to degrees
# NHF aspect is currently in radians, may need to be converted to degrees
element_slope_azmuith[i] = hyfab.aspect_circmean[i]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +19 to +22
if TYPE_CHECKING:
from NextGen_Forcings_Engine_BMI.NextGen_Forcings_Engine.core.config import (
ConfigOptions,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double import

Suggested change
if TYPE_CHECKING:
from NextGen_Forcings_Engine_BMI.NextGen_Forcings_Engine.core.config import (
ConfigOptions,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +138 to +140
b_date: str = None,
geogrid: str = None,
output_path: str = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these necessary? BMI standards have the constructor not take any additional arguments. If there are properties that the BMI should potentially know about, they should probably be included in the config file and loaded from that in initialize.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official initialize() method (BMI spec) does take only a config file. The class's __init__ exposes these overrides for these 3 parameters. run_bmi_model.py leverages these overrides and continues their exposure through to CLI args, presumably so that a user could point to one configuration file, while varying one or more of these parameters in a for loop, or some similar workflow. Since the run_bmi_model.py was originally set up this way, I feel that we should preserve this behavior.

@mxkpp
mxkpp requested a review from idtodd August 18, 2026 18:18
@mxkpp
mxkpp force-pushed the NGWPC-7625_PI_10_ngen_forcing_refactor branch from c6360b3 to 6ec7d80 Compare August 18, 2026 18:22
mxkpp and others added 26 commits August 18, 2026 14:24
…fix namespace error, remove call to `validate_config` (validation occurs automatically in new design)
…ly if rqiMethod is 0 (unused) then rqiThresh property now resolves to None regardless of the value of the RqiThresh key in the config file.
…s tests relative to refactored class structures and new key exclusions in test utils
@mxkpp

mxkpp commented Aug 18, 2026

Copy link
Copy Markdown

Rebased after rebasing the base

@mxkpp mxkpp mentioned this pull request Aug 19, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants