Skip to content

cleanup(xdmf/snapshot): silence internal write_checkpoint FutureWarning + drop dead cell_dim read (#252) - #256

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/xdmf-followups-252
Jun 19, 2026
Merged

cleanup(xdmf/snapshot): silence internal write_checkpoint FutureWarning + drop dead cell_dim read (#252)#256
lmoresi merged 1 commit into
developmentfrom
bugfix/xdmf-followups-252

Conversation

@lmoresi

@lmoresi lmoresi commented Jun 19, 2026

Copy link
Copy Markdown
Member

Addresses items 1 & 2 of #252 (follow-ups from the #218 review):

  1. Snapshot FutureWarning spam. disk_snapshot._write_disk_snapshot calls the user-deprecated mesh.write_checkpoint — but it's a legitimate internal user (it depends on the .mesh.00000.h5/.<var>.00000.h5 filename convention its own reload path reads, which write_timestep does not produce). Wrapped in warnings.catch_warnings() + ignore FutureWarning so every persistent snapshot no longer emits a deprecation warning. Full migration to write_timestep left as the larger item in Follow-ups from #218: route snapshot subsystem off deprecated write_checkpoint + XDMF cleanups #252.
  2. Dead cell_dim read. checkpoint_xdmf read topo["cells"].attrs["cell_dim"] into cellDim but never used it (precision now derives from cells.dtype.itemsize). Removed — a needless dependency on a PETSc-internal attr name that could KeyError.

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

…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
Copilot AI review requested due to automatic review settings June 19, 2026 02:19
@lmoresi

lmoresi commented Jun 19, 2026

Copy link
Copy Markdown
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.

@lmoresi
lmoresi merged commit 7d776e2 into development Jun 19, 2026
2 checks passed
@lmoresi
lmoresi deleted the bugfix/xdmf-followups-252 branch June 19, 2026 02:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dim HDF5 attribute read from checkpoint_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 emitting FutureWarning on every snapshot.
  • Add the required warnings import 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(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants