Fix GFS dataset import when ocf-data-sampler constants are unavailable#110
Fix GFS dataset import when ocf-data-sampler constants are unavailable#110AswaniSahoo wants to merge 2 commits intoopenclimatefix:mainfrom
Conversation
|
Hi @siddharth7113 @peterdudfield Just a gentle ping on this PR when you get a chance. Happy to make any changes or follow suggestions if needed. |
|
This was merged in 0.0.52 of data-sampler. I wonder if those constants have been moved somewhere? Note there is also the task #115 which might go over this |
|
Thanks for the clarification @peterdudfield Yes , the constants do exist in newer This PR is intended as a backwards-compatible safeguard, so Happy to:
Just let me know what direction you’d like |
In ocf-data-sampler==0.2.32, can you see those values anywhere? Or can you see which version they were removed/moved? |
|
I’ve double-checked this locally against In that version:
The available top-level modules in From what I can see, the constants were introduced later (e.g. in So there isn’t an alternative import path for those values in |
What version do they come in? |
|
The normalization constants ( Based on the repository tags, the first versions that include this change are v0.0.52 and later (including the v0.1.x series). |
and can you find when they are removed? |
|
I checked this in detail.
So |
|
Hi @AswaniSahoo & @peterdudfield , Sorry I should have commented sooner, the current script that you have been working needs to be removed and it is longer used, we made this when were using the old version of |
|
@AswaniSahoo apologies for all your trouble , this is why we haven't opened #115 for new contirbutors and was assinged to me, since we are working on making proper documentation soon. Meanwhile thank you for investigating different version, I would recommend to keep a watch on #111 , we'll open more issues for contributor soon. |
|
Thanks for the clarification @siddharth7113 — that makes sense. Appreciate you and @peterdudfield taking the time to explain the newer Glad the version investigation was still useful for understanding the Thanks again! |
Pull Request
Description
This PR fixes an import-time crash in
open_data_pvnet.nwp.gfs_dataset.NWP_MEANSandNWP_STDSwere introduced inocf-data-sampler(openclimatefix/ocf-data-sampler#145) but are not yet part of a PyPI release.
As a result, importing
gfs_datasetfails when installing dependenciesfrom PyPI with
ocf-data-sampler==0.2.32.This change adds a graceful fallback when these constants are unavailable,
allowing the module to be imported and used without normalization.
When the constants are present in a future release, the existing
normalization logic will be used automatically.
Minimal regression tests are included to lock this behavior.
Fixes #
How Has This Been Tested?
The following tests were run locally:
pytest tests/test_gfs_dataset.pypytestThese tests verify that:
gfs_datasetimports successfully when normalization constants are missingNaN handling behaves as expected
init_timeis correctly renamed toinit_time_utcGFSDataSamplerinitializes without crashingYes
If your changes affect data processing, have you plotted any changes?
Checklist: