Removing ndsl.Namelist from PyFV3#88
Conversation
…micalCoreConfig from f90nml.Namelist; using it in translate tests
…f90nml util function
…ng utility function to create DynamicalCoreConfig from f90nml.Namelist using default groups or all
Using dycore_config_from_f90nml
romanc
left a comment
There was a problem hiding this comment.
Thanks, Janice. That looks like a step in the right direction to me. I agree that DynamicalCoreConfig.from_namelist() should go away. And I think it's smart to store the dycore config in test classes as self.config.
I'm curious to hear why you decided to have dycore_config_from_f90nml as a standalone function instead of updating DynamicalCoreConfig.from_f90nml(). It seems to me that what ever is done in dycore_config_from_f90nml() could just move into DynamicalCoreConfig.from_f90nml(), no? Maybe I'm missing something.
Removing utils/namelist.py Using DynamicalCoreConfig.from_f90nml in translate tests Tweaking override unit test
You bring up a good point on keeping DynamicalCoreConfig.from_f90nml(). This was likely a misunderstanding on my part. I added it back. There's also the fact that DynamicalCoreConfig.from_yaml() exists as well. So, keeping the from_f90nml() would just keep following that convention. |
| return [main_file_path, override_file_path] | ||
|
|
||
|
|
||
| def test_config_from_f90nml_with_override(): |
There was a problem hiding this comment.
This is a really simple test for trying out the override_namelist. I didn't see one that tested it out, so I didn't think it would hurt.
However:
- I don't know if it goes here or in the Pace unit tests. It's not currently being run during the CI because there's another test in the same directory that also isn't being run and may be outdated.
- I'm hoping I got the functionality of the test right -- that the namelist_override completely overrides the previous namelist?
If no one knows, I'll just remove the test.
Edit: Ultimately, i just removed the unit test for now.
|
I changed a few things:
|
romanc
left a comment
There was a problem hiding this comment.
Thanks, Janice! I think we are moving the right direction. A couple of smaller things inline.
I think some tests will break because the don't automatically get self.config added. The class hierarchy for translate tests is a mess (and I'm not sure we get to clean it up anytime soon).
And while we're at it, I'd suggest to take TranslateDycoreFortranData2Py out of translate_fvdynamics.py because the class isn't used there. I'd suggest to put it in a separate file in the same folder and then adjust the path in the __init__.py such that imports like "from pyfv3.testing import TranslateDycoreFortranData2Py" don't need any change.
| def from_dict( | ||
| cls, | ||
| data: dict, | ||
| ) -> "DynamicalCoreConfig": |
There was a problem hiding this comment.
| ) -> "DynamicalCoreConfig": | |
| ) -> DynamicalCoreConfig: |
You can add from __future__ import annotations at the top of the file and then you don't need to add quotes around types any more that the old type resolver couldn't resolve
There was a problem hiding this comment.
I'll update this.
Edit -- NOTE: I made a slight tweak to Pace's tests/main/fv3core/test_config.py::test_types_match test to account for this change.
comment fix Co-authored-by: Roman Cattaneo <romanc@users.noreply.github.com>
…3 into 20250925_namelist_helper
…nData2Py into its own translate_data.py
|
Okay, I tried to move |
romanc
left a comment
There was a problem hiding this comment.
Thanks, Janice. From my point of view, this is good to go 🚀
Description
This follows from NDSL PR #246 and is part of NDSL Issue # 64.
This PR attempts to remove
ndsl.Namelistfrom PyFV3 by doing the following:DynamicalCoreConfig.from_f90nml()to use onlyf90nml.Namelistvia NDSL helper functionsDynamicalCoreConfig.from_namelist()ndsl.Namelistin favor theDynamicalCoreConfig--no_legacy_namelistto the github workflowtranslate.yamlPartial work on NDSL Issue # 64
How Has This Been Tested?
Checklist: