Skip to content

Conversation

@MGAMZ
Copy link

@MGAMZ MGAMZ commented Oct 26, 2025

Error caused by the removal of numpy.compat

Motivation

According to https://numpy.org/devdocs/release/2.0.0-notes.html#deprecations, np.compat has been deprecated, as Python 2 is no longer supported.

This causes several failures in pytest: tests/test_config/test_lazy.py. Fixing this issue now.

Modification

test_lazy.py utilize numpy.compat as an example numpy module to test if the lazy import function can properly working. So simply replacing it with any other existing numpy module, numpy.fft for this PR.

aim dependency

Can't find a valid distribution for aim in python=3.13, so add python version check for this dependency.

Improve _is_builtin_module

In some optimized python version (e.g. conda-forge), the os can be a frozen module. In this case, _is_builtin_module malfunctioned and cause the above test fails. So adding an if-branch to handle this scenario.

Copilot AI review requested due to automatic review settings October 26, 2025 07:18
@CLAassistant
Copy link

CLAassistant commented Oct 26, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a comment

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 fixes test failures in test_lazy.py caused by NumPy 2.0's removal of the deprecated numpy.compat module, adds Python version restrictions for the aim dependency which lacks Python 3.13 support, and improves the _is_builtin_module function to handle frozen modules in optimized Python distributions.

  • Replaces numpy.compat with numpy.fft in lazy import tests
  • Restricts aim dependency to Python < 3.13
  • Adds frozen module detection to _is_builtin_module

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/test_config/test_lazy.py Updates test imports and assertions to use numpy.fft instead of deprecated numpy.compat
pyproject.toml Adds Python version constraint to aim dependency for compatibility
mmengine/config/utils.py Adds frozen module handling in _is_builtin_module function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MGAMZ
Copy link
Author

MGAMZ commented Oct 26, 2025

@lauriebax I'm creating this PR, as mentioned in open-mmlab/mmengine. I may create more when I have time.

@MGAMZ
Copy link
Author

MGAMZ commented Oct 27, 2025

revert done

@MatthijsBurgh
Copy link

We should squash this PR to keep the history clean

@lauriebax
Copy link

I've copied your changes to #20 and fixed the pipeline to not break on outside PRs. So I'm closing the PR, thanks for your contribution!

@lauriebax lauriebax closed this Oct 28, 2025
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.

4 participants