Skip to content

Conversation

@guan404ming
Copy link
Member

Purpose of PR

Merge root conftest.py into testing/conftest.py to keep the root clean

Related Issues or PRs

Changes Made

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Breaking Changes

  • Yes
  • No

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes
  • Successfully built and ran all unit tests or manual tests locally
  • PR title follows "MAHOUT-XXX: Brief Description" format (if related to an issue)
  • Code follows ASF guidelines

@guan404ming
Copy link
Member Author

cc @400Ping

Copy link
Contributor

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 consolidates the root-level conftest.py into testing/conftest.py to maintain a cleaner project root structure. The functionality from both files is merged while maintaining the same test behavior.

Changes:

  • Moved pytest configuration from root conftest.py to testing/conftest.py
  • Merged QDP availability checking, custom markers, and test fixtures into a single configuration file
  • Changed QDP detection from importlib.util.find_spec to try/except import approach

Reviewed changes

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

File Description
conftest.py Deleted root-level conftest.py to consolidate pytest configuration
testing/conftest.py Merged root conftest.py functionality, added comprehensive docstrings and QDP-related test infrastructure

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

Comment on lines 34 to +40
try:
import _qdp # noqa: F401
import torch # noqa: F401
except ImportError:
import _qdp # noqa: F401, PLC0415

_QDP_AVAILABLE = True
_QDP_IMPORT_ERROR = None
except ImportError as e:
_QDP_IMPORT_ERROR = str(e)
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The QDP availability check has changed from using importlib.util.find_spec to a try/except import. While both approaches work, the try/except approach will catch all import errors (including those from broken installations or dependency issues), whereas find_spec only checks if the module can be located. This behavioral change could make debugging more difficult if _qdp is found but fails to import due to dependency issues, as the error message will be more generic. Consider whether this change in behavior is intentional.

Copilot uses AI. Check for mistakes.

# Check if QDP extension is available at module load time
_QDP_AVAILABLE = False
_QDP_IMPORT_ERROR: str | None = "No module named '_qdp'"
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The initial assignment of _QDP_IMPORT_ERROR to "No module named '_qdp'" on line 33 is redundant, as this value will always be overwritten either to None (line 38) if import succeeds or to str(e) (line 40) if import fails. Consider removing this initial assignment for clarity.

Suggested change
_QDP_IMPORT_ERROR: str | None = "No module named '_qdp'"
_QDP_IMPORT_ERROR: str | None

Copilot uses AI. Check for mistakes.
import _qdp # noqa: F401
import torch # noqa: F401
except ImportError:
import _qdp # noqa: F401, PLC0415
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

Import of '_qdp' is not used.

Suggested change
import _qdp # noqa: F401, PLC0415
import _qdp # noqa: F401, PLC0415
del _qdp

Copilot uses AI. Check for mistakes.
@ryankert01
Copy link
Member

LG, thanks @guan404ming for the fix.

@ryankert01 ryankert01 merged commit cc90b09 into apache:main Jan 17, 2026
10 checks passed
@ryankert01
Copy link
Member

Oh, I discovered why we introduce root level test conf. That is because we want to use command pytest at the root and runs everything.

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