Skip to content

[python-package] [ci] simplify test-skipping logic - #7297

Merged
jameslamb merged 1 commit into
masterfrom
importorskip
Jun 1, 2026
Merged

jameslamb merged 1 commit into
masterfrom
importorskip

Conversation

@jameslamb

@jameslamb jameslamb commented May 28, 2026 •

Copy link
Copy Markdown
Member

Contributes to #7273

We've seen an increase in activity and first-time contributors here recently, which is exciting!

I'd like to make it easier for contributors and reviewers to work on the Python tests, as those are a place full of LightGBM-specific conventions and accumulated tech debt / complexity.

This PR is a first step:

  • consolidates various getenv("TASK") calls into a small data structure with values like BuildInfo.has_cuda
  • replaces many uses of lgb.compat.{module}_INSTALLED imports with pytest.importorskip()
    • removing this LightGBM-specific convention from view makes the tests easier for new contributors to modify
    • makes the code easier for humans and automated tools to read and modify (no need to think about pd.DataFrame vs. pd_DataFrame)
  • adds -ra to all pytest invocations, so we'll get a nice summary of which tests were skipped and why in logs

Notes for Reviewers

I tried to intentionally avoid code paths (like test_arrow.py) that'd cause conflicts with #7275. Planning another PR like this after that's merged.

@jameslamb jameslamb changed the title [python-package] [ci] simplify test-skipping logic WIP: [python-package] [ci] simplify test-skipping logic May 28, 2026
@jameslamb
jameslamb marked this pull request as ready for review May 28, 2026 04:32
@jameslamb jameslamb changed the title WIP: [python-package] [ci] simplify test-skipping logic [python-package] [ci] simplify test-skipping logic May 28, 2026

@borchero borchero left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@jameslamb

Copy link
Copy Markdown
Member Author

Thanks for the review, glad you found this useful 😊

@jameslamb
jameslamb merged commit 5695c04 into master Jun 1, 2026
60 checks passed
@jameslamb
jameslamb deleted the importorskip branch June 1, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants