Skip to content

Fix warning in tests#151

Merged
FlorianDeconinck merged 1 commit into
NOAA-GFDL:developfrom
romanc:romanc/fix-test
May 28, 2025
Merged

Fix warning in tests#151
FlorianDeconinck merged 1 commit into
NOAA-GFDL:developfrom
romanc:romanc/fix-test

Conversation

@romanc
Copy link
Copy Markdown
Collaborator

@romanc romanc commented May 27, 2025

Description

Fixes

tests/test_halo_update.py::test_halo_updater_stability[interface_3d-numpy-layout0-2-more-0]
  [...]/NDSL/.venv/lib/python3.11/site-packages/_pytest/unraisableexception.py:85: PytestUnraisableExceptionWarning: Exception ignored in: <function HaloUpdater.__del__ at 0x7f74b5b91260>
  
  Traceback (most recent call last):
    File "[...]/NDSL/ndsl/halo/updater.py", line 88, in __del__
      transformer.finalize()
    File "[...]/NDSL/ndsl/halo/data_transformer.py", line 228, in finalize
      Buffer.push_to_cache(self._pack_buffer)
    File "[...]/NDSL/ndsl/buffer.py", line 70, in push_to_cache
      BUFFER_CACHE[buffer._key].append(buffer)
                   ^^^^^^^^^^^
  AttributeError: 'NoneType' object has no attribute '_key'
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

as seen e.g. in https://github.com/NOAA-GFDL/NDSL/actions/runs/15278670407/job/42971686345?pr=150#step:6:773

A bit more context on when/why this happens: The key error comes from test_halo_updater_stability() manually calling transformer.finalize() before finalize() is called again from the HaloUpdater's __del__ function. In "normal" execution mode, this shouldn't be a problem because developers aren't supposed to manually call finalize() on the transformers.

An alternative way to avoid the error could be to add a finalized: bool state to HaloDataTransformer and exit early in finalize() in case the transformer has already been finalized.

How Has This Been Tested?

Running tests locally

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included

@romanc romanc requested a review from FlorianDeconinck May 27, 2025 15:44
@romanc romanc force-pushed the romanc/fix-test branch from 208c360 to f4c7260 Compare May 28, 2025 08:09
Copy link
Copy Markdown
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

That tracks, the del routine still catches missing wait

@FlorianDeconinck FlorianDeconinck merged commit 65acd24 into NOAA-GFDL:develop May 28, 2025
5 checks passed
@romanc romanc deleted the romanc/fix-test branch May 28, 2025 12:58
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