Skip to content

import generated mf6 module lazily - #445

Merged
wpbonelli merged 1 commit into
modflowpy:developfrom
wpbonelli:sync-lazy-imports
Oct 9, 2026
Merged

wpbonelli merged 1 commit into
modflowpy:developfrom
wpbonelli:sync-lazy-imports

Conversation

@wpbonelli

@wpbonelli wpbonelli commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

import the generated modules only on first use. this prevents the installation from getting into a catch 22 state where the sync command, which imports the top-level mf6 module, can't be used to fix broken modules because of broken modules.

modules may be broken for one of two reasons

  1. sync to a mf6/dfn version that codegen turns into syntactically valid but unimportable code
  2. handwritten core code has changed (mixins, base classes)

moving the sync CLI command to a higher-level module would be one workaround, and may make sense at some point for other reasons, but it wouldn't really solve the problem, programmatic imports would still fail.

also, delete stale modules, i.e. generated modules the new DFNs don't cover

really we should verify generated modules aren't broken (can be imported) when we generate them. do that in a followup PR.

flopy4.mf6 loads its generated components on first use, so sync and
status run when they're broken or out of date. Codegen checks for
existing modules by file instead of importing them. With that, sync
removes generated modules the new DFNs don't cover instead of keeping
them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli wpbonelli added this to the MVP milestone Oct 9, 2026
@wpbonelli
wpbonelli marked this pull request as ready for review October 9, 2026 20:10
@wpbonelli
wpbonelli merged commit 77d1449 into modflowpy:develop Oct 9, 2026
17 checks passed
@wpbonelli
wpbonelli deleted the sync-lazy-imports branch October 10, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant