Uh oh!
There was an error while loading. Please reload this page.
cleanup(xdmf/snapshot): silence internal write_checkpoint FutureWarning + drop dead cell_dim read (#252) - #256
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
lmoresi
commented
Jun 19, 2026
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. |
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.
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", FutureWarning) | ||
| mesh.write_checkpoint( |
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