-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(createpackages): use jinja for mf6 module code generation #2333
Conversation
a3b7c2e
to
af1e7a5
Compare
d1e8a21
to
a7f2644
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked through everything, but I left you a PR on your own branch with indications on how I would probably approach this. Let's take a look at it together and see if we can get rid of the shim :)
bab83ac
to
cf68432
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2333 +/- ##
=========================================
+ Coverage 68.4% 75.9% +7.5%
=========================================
Files 294 296 +2
Lines 59390 63918 +4528
=========================================
+ Hits 40652 48577 +7925
+ Misses 18738 15341 -3397
🚀 New features to boost your workflow:
|
f95ad8c
to
6d57fae
Compare
6e792fc
to
483ac2e
Compare
IMO this should wait til this week's release goes out, then it can get some exercise on the develop branch for a while |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice big step forward, @wpbonelli. I don't have anything to add other than I think this is the right direction toward a leaner and more sustainable implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have suggested some improvements that I think could make the code a bit cleaner. The general concept is great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only looked through some of the output files, but I have found some remarkable differences that we should check.
Thanks. Yeah, this is why I want to wait to merge til after release. I think it'll take some time to ferret out all the minute differences and make sure no behavior has changed, even after merge. |
here goes nothing.. |
Carved out of #2317. Just move to Jinja as a first step. Type hints can come afterwards as they will take some effort to get right. The aim here is to match the old
createpackages.py
capabilities without relying onmfstructure.py
. This is an initial step to trimmfstructure.py
in favor of a leaner representation of the input spec.mfstructure.py
is still used at runtime which will need to be unraveled in followup work.Introduce a
flopy.mf6.utils.codegen
module with some new machinery for generating code with Jinja. This includes a bunch of filters handling quirks of the generated classes which we can aim to gradually eliminate. The templates should also get simpler over time.The codegen module consumes TOML rather than legacy DFNs. Devtools is used at code generation time to first convert DFNs to TOML. This happens under the hood, with no change in apparent behavior to the user of the codegen utility.
Jinja2
andmodflow-devtools
are added to a new optional dependency groupcodegen
. These are required to use the code generation utilities. These as well as transitive dependencies are added toenvironment.yml
.Miscellaneous:
flopy/mf6/data/mfdatastorage.py
to avoid referencing a variable before it exists