Nl blend region#166
Conversation
… blend and save steps for adjuster pass
…ls and location filtering
| NL_NATIONAL_CANDIDATE_MODELS: list[str] = _cfg.national_candidate_models | ||
| NL_REGIONAL_CANDIDATE_MODELS: list[str] = _cfg.regional_candidate_models | ||
| BLEND_KERNEL: list[float] = _cfg.blend_kernel | ||
| MIN_FORECAST_HORIZON: pd.Timedelta = _cfg.min_forecast_horizon |
There was a problem hiding this comment.
for me this are constants, there are parameters, and therefore should be in lowercase.
I'd move these _cfg = load_blend_config() to within the function, or pass a config into the functions.
This will be important when the config is no longer just for NL, but for NL or Adani, or other country's e.t.c.
You could do this in a separate PR I think
| logger = logging.getLogger("blend_app") | ||
|
|
||
| # location_type key that identifies the national location in the DP location map. | ||
| NL_NATIONAL_LOCATION_KEY = "nl_national" |
There was a problem hiding this comment.
could you add a TODO here, this should come from the config at some point
| loc.location_name: loc.location_uuid | ||
| for loc in dp_locations | ||
| if loc.location_name != NL_NATIONAL_LOCATION_KEY | ||
| and loc.location_type == dp.LocationType.STATE |
There was a problem hiding this comment.
I've move dp.LocationType.STATE into the config, as for other countries, models this wont be the case
| geometry_wkt="POINT(0 0)", | ||
| location_type=dp.LocationType.SITE, | ||
| effective_capacity_watts=1_000, | ||
| valid_from_utc=datetime(2020, 1, 1, tzinfo=UTC), |
There was a problem hiding this comment.
why has this be added?
There was a problem hiding this comment.
That block of code is required to seed the test database before the application runs. because initially dp container is empty
There was a problem hiding this comment.
yea, but why a SITE? NL doesnt use sites
| assert deps["get_blend_weights"].call_count == 2 | ||
| assert deps["get_regional_blend_weights"].call_count == 2 | ||
| assert deps["get_blend_forecast_values_latest"].call_count == 4 | ||
| assert deps["_save_forecasts"].call_count == 4 |
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def dp_address(): |
There was a problem hiding this comment.
how come you need this now? I thought you mocked most things out?
peterdudfield
left a comment
There was a problem hiding this comment.
Please see comments
Pull Request
Description
This PR introduces regional forecasting to the NL blend application. It updates the orchestration logic to selectively process regional locations (filtering out irrelevant sites by matching names starting with
nl_) and applies a distinct set of candidate models for generating regional blend weights.Key changes:
weights.pyand added a newget_regional_blend_weightsfunction that usesNL_REGIONAL_CANDIDATE_MODELS._run_blend_passinapp.pyto support ause_regional_weightsflag, ensuring the correct weight retrieval function is used based on whether the location is national or regional.nl_nationaland regional states`.Fixes #
How Has This Been Tested?
Tests run:
Added a new unit test
test_run_blend_app_filters_regional_locationsintest_nl_app.pywhich mocks Data Platform dependencies and confirms that only relevantstatelocations are processed.Verified that national (
nl_national) locations correctly useget_blend_weightswhile regional locations useget_regional_blend_weights.Validated that both the standard blend and adjuster passes are executed correctly (2 calls per valid location) without processing unrelated sites.
Yes
Checklist: