cleanup(xdmf/snapshot): silence internal write_checkpoint FutureWarning + drop dead cell_dim read (#252) - #256
Merged
Conversation
…ng + drop dead cell_dim read (#252) Follow-ups from the #218 review: - disk_snapshot._write_disk_snapshot is a legitimate internal user of the user-deprecated write_checkpoint (it depends on the .mesh.00000.h5 / .<var>.00000.h5 filename convention its reload path reads). Wrap the call in warnings.catch_warnings()+ignore FutureWarning so persistent snapshots don't spam the deprecation warning. (Full migration to write_timestep tracked in #252.) - checkpoint_xdmf read topo["cells"].attrs["cell_dim"] into cellDim but never used it (topology_precision now derives from cells.dtype.itemsize). Removed — it was a needless dependency on a PETSc-internal attr that could KeyError. Verified: test_0007/0008 (snapshot) pass with -W error::FutureWarning (26/26); test_0003/0005 (save_load/xdmf) green (39/39 total). Item 3 (unify swarmVar HyperSlab XDMF block with the flattened meshVar form) deferred: cosmetic, ParaView-sensitive, no easy local validation — left in #252. Underworld development team with AI support from Claude Code
Member
Author
|
Self-review: low-risk cleanups. Snapshot path verified clean under -W error::FutureWarning (26/26). Item 3 (swarmVar XDMF flatten) deferred to #252 as a cosmetic ParaView-sensitive nit. Merging. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR cleans up two follow-ups in UW3’s checkpoint/snapshot output paths: it removes an unused/fragile HDF5 attribute read in the XDMF checkpoint writer and silences FutureWarning spam triggered by UW3’s internal snapshot backend calling the user-deprecated Mesh.write_checkpoint().
Changes:
- Remove dead
cell_dimHDF5 attribute read fromcheckpoint_xdmf()(avoids needless dependency on a PETSc-internal attr name). - Wrap the snapshot backend’s internal
mesh.write_checkpoint(...)call in a warnings context to avoid emittingFutureWarningon every snapshot. - Add the required
warningsimport for the snapshot backend.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/underworld3/discretisation/discretisation_mesh.py |
Removes unused cell_dim attr read in checkpoint_xdmf() to avoid a fragile/unused dependency. |
src/underworld3/checkpoint/disk_snapshot.py |
Suppresses FutureWarning spam from an internal write_checkpoint() call used to produce snapshot bulk files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+321
to
+323
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", FutureWarning) | ||
| mesh.write_checkpoint( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses items 1 & 2 of #252 (follow-ups from the #218 review):
disk_snapshot._write_disk_snapshotcalls the user-deprecatedmesh.write_checkpoint— but it's a legitimate internal user (it depends on the.mesh.00000.h5/.<var>.00000.h5filename convention its own reload path reads, whichwrite_timestepdoes not produce). Wrapped inwarnings.catch_warnings()+ ignoreFutureWarningso every persistent snapshot no longer emits a deprecation warning. Full migration towrite_timestepleft as the larger item in Follow-ups from #218: route snapshot subsystem off deprecated write_checkpoint + XDMF cleanups #252.cell_dimread.checkpoint_xdmfreadtopo["cells"].attrs["cell_dim"]intocellDimbut never used it (precision now derives fromcells.dtype.itemsize). Removed — a needless dependency on a PETSc-internal attr name that couldKeyError.Item 3 (unify the swarmVar HyperSlab XDMF block with the flattened meshVar form) is deferred — cosmetic, ParaView-sensitive, no easy local validation. Left open in #252.
Verification (amr-dev)
test_0007/test_0008(snapshot) pass with-W error::FutureWarning→ 26/26 (confirms the disk path no longer leaks the warning).test_0003(save/load) +test_0005(xdmf) green → 39/39 total.Underworld development team with AI support from Claude Code