Skip to content

Improving open_nwp function and dev-dependency change in pyproject.toml#404

Merged
Sukh-P merged 5 commits intoopenclimatefix:mainfrom
siddharth7113:main
Mar 6, 2026
Merged

Improving open_nwp function and dev-dependency change in pyproject.toml#404
Sukh-P merged 5 commits intoopenclimatefix:mainfrom
siddharth7113:main

Conversation

@siddharth7113
Copy link
Contributor

@siddharth7113 siddharth7113 commented Mar 2, 2026

Pull Request

Description

While going through the code base I found in nwp.py the function open_nwp has an if-else block which requires changing everytime new provider is added, I modifed logic outside of the function to update in a private dictionaries, instead of adding if-else.

While installing dev dependency, I observed that these were grouped under [dependency-groups] , I changed it to [project.optional-dependencies] to make the uv pip install -e .[dev] work. (If this was intentional, I can revert the changes.) (Reverted due to CI breaking)

Fixes #

How Has This Been Tested?

All tests passes, except one unrelated test being skipped test_load_gfs

I haven't run black or ruff since on running black , it is reformatting more than 50 files, there is no defined pre-commit

  • Yes

If your changes affect data processing, have you plotted any changes? i.e. have you done a quick sanity check?

  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • [] I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

… of optional-dependeices , hence the pip install -e .[dev] doesn't work.
…en new providers are added, and removed the if pattern along with adding Callable type annotation.
@siddharth7113 siddharth7113 self-assigned this Mar 2, 2026
@siddharth7113 siddharth7113 requested review from Sukh-P and peterdudfield and removed request for Sukh-P March 2, 2026 22:31
@siddharth7113 siddharth7113 changed the title ## Improving open_nwp function and dev-dependency change in pyproject.toml Improving open_nwp function and dev-dependency change in pyproject.toml Mar 2, 2026
… instead of optional-dependeices , hence the pip install -e .[dev] doesn't work." due to CI failures.

This reverts commit a7500da.
@siddharth7113
Copy link
Contributor Author

I have reverted pyproject.toml due to CI breaking, but would highly recommend to make pyproject have an optional dependency group as dev to make pip install -e .[dev] work.

Copy link
Contributor

@AUdaltsova AUdaltsova left a comment

Choose a reason for hiding this comment

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

Hi, great to see you around & good spot! Really nice bit of type hinting there. Left a couple of comments but good to go otherwise I think, thanks!

@siddharth7113
Copy link
Contributor Author

Hi, great to see you around & good spot! Really nice bit of type hinting there. Left a couple of comments but good to go otherwise I think, thanks!

Hi @AUdaltsova , Thanks for the review, I have made the necessary changes, this should be good now !

@siddharth7113 siddharth7113 requested review from AUdaltsova and removed request for Sukh-P and peterdudfield March 3, 2026 19:28
@Sukh-P
Copy link
Member

Sukh-P commented Mar 4, 2026

Hey both, just wanted to bring this comment/issue linked in it to your attention #379 (comment) which is related to a refactoring idea for this file and moving away from having unique loaders for each NWP since in fact for at least those in the same coord system like lat long they could be handled by a more generic loader, not saying this should block this change but maybe something to think about for the next change related to this, thanks

@AUdaltsova
Copy link
Contributor

Hi @Sukh-P, yeah I thought about that but I don't think it's being actively worked on right now/is ready to be implemented any time soon (maybe I'm wrong!), so I don't think there's any harm in this being merged in the meantime as the work is done already anyway. Lmk if you disagree!

@Sukh-P
Copy link
Member

Sukh-P commented Mar 5, 2026

So I agree that this shouldn't block this but I think this further change which can be implemented now basically if someone has capacity to pick it up (@siddharth7113 might be hinting in your direction here ha) would probably have a larger impact in terms of simplifying and reducing lines of code

@AUdaltsova
Copy link
Contributor

Oh ok I see! @siddharth7113 would you be interested in taking up that issue? I think that would require putting in some renaming logic (different NWP sources might have different coordinate names that we rename into the same things), but then the lat-lon NWPs go through the same logic which can be shared between them, I think @Sukh-P recons 3-4 loaders can be removed after this.

Let me know if you'd like to take this up!

@siddharth7113
Copy link
Contributor Author

So I agree that this shouldn't block this but I think this further change which can be implemented now basically if someone has capacity to pick it up (@siddharth7113 might be hinting in your direction here ha) would probably have a larger impact in terms of simplifying and reducing lines of code

Oh ok I see! @siddharth7113 would you be interested in taking up that issue? I think that would require putting in some renaming logic (different NWP sources might have different coordinate names that we rename into the same things), but then the lat-lon NWPs go through the same logic which can be shared between them, I think @Sukh-P recons 3-4 loaders can be removed after this.

Let me know if you'd like to take this up!

Hey @Sukh-P @AUdaltsova , Yeah I could work on that, I am trying to understand how ocf-data-sampler works, I think it would be a step in that direction, but Should I do it in a separate PR or this one itself?

@AUdaltsova
Copy link
Contributor

Hi @siddharth7113, amazing, thanks for taking this up! Yeah maybe for cleanliness would be better to have a separate PR, and this one we would close for now as the new one should supersede it. Thanks again & reach out if you have questions!

@AUdaltsova AUdaltsova closed this Mar 6, 2026
@Sukh-P Sukh-P reopened this Mar 6, 2026
@Sukh-P
Copy link
Member

Sukh-P commented Mar 6, 2026

Hi @siddharth7113 I spoke to @AUdaltsova and I realised I muddied the water with my interjection and confused things, we decided that this PR can be merged in (I'll give it a quick review again after your latest changes) and then the additional changes I suggested if you're happy to work on that can be added on top of this in a separate PR, this way the PRs can be kept small, I can add you to that issue and give you more direction as well if you want it, hope that's alright, apologies all for the confusion!

Copy link
Member

@Sukh-P Sukh-P left a comment

Choose a reason for hiding this comment

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

Thanks for this addition!

@Sukh-P
Copy link
Member

Sukh-P commented Mar 6, 2026

@siddharth7113 will merge this in and tag you on the other issue related to these loader files, thanks!

@Sukh-P Sukh-P merged commit d22b3f0 into openclimatefix:main Mar 6, 2026
11 checks passed
@siddharth7113
Copy link
Contributor Author

Hi @siddharth7113 I spoke to @AUdaltsova and I realised I muddied the water with my interjection and confused things, we decided that this PR can be merged in (I'll give it a quick review again after your latest changes) and then the additional changes I suggested if you're happy to work on that can be added on top of this in a separate PR, this way the PRs can be kept small, I can add you to that issue and give you more direction as well if you want it, hope that's alright, apologies all for the confusion!

No worries @Sukh-P , Thanks for merging this one, I 'll start working on the other issue soon !

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