Skip to content

Python: make optional Lightning observability test skip nested import errors - #8071

Open
宇宙的山峰 (UniversePeak) wants to merge 1 commit into
microsoft:mainfrom
UniversePeak:UniversePeak/issue-8057-importorskip
Open

Python: make optional Lightning observability test skip nested import errors#8071
宇宙的山峰 (UniversePeak) wants to merge 1 commit into
microsoft:mainfrom
UniversePeak:UniversePeak/issue-8057-importorskip

Conversation

@UniversePeak

Copy link
Copy Markdown
Contributor

Motivation & Context

The optional Lightning observability test currently uses pytest.importorskip("agentlightning"). With pytest 9.1, that only skips ModuleNotFoundError; a nested ImportError from an installed transitive dependency propagates and hard-fails the resource-intensive lab test. This reproduces with agentlightning 0.3.0 importing LiteLLM proxy code against FastAPI 0.141, where get_flat_dependant is no longer available.

Description & Review Guide

  • What are the major changes?

    Configure the existing optional dependency guard with exc_type=ImportError, so both a missing agentlightning package and an installed package whose optional dependency import fails are treated as skips.

  • What is the impact of these changes?

    The resource-intensive observability test no longer hard-fails CI when an optional transitive import is incompatible. The existing tracer setup and assertions remain unchanged, so the test still runs whenever agentlightning imports successfully.

  • What do you want reviewers to focus on?

    Whether treating all ImportError failures from the optional integration as a skip matches the intended optional-test boundary.

Related Issue

Fixes #8057

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

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.

🟢 Approval recommended

The focused test-only change has no unresolved issues.

Pull request overview

Updates the optional Lightning observability test to skip when agentlightning or a transitive dependency raises ImportError.

Changes:

  • Expands pytest.importorskip to handle nested import failures.
  • Documents the optional dependency boundary.
File summaries
File Description
python/packages/lab/lightning/tests/test_lightning.py Expands the optional import guard to nested import failures.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@Ricky-7-Yan Ricky-7-Yan 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.

Reviewed against #8057 and pytest 9.1.1's importorskip implementation. The pinned pytest version now defaults exc_type to ModuleNotFoundError, and exc_type=ImportError is the documented compatibility path for nested import failures. The guard only wraps the optional import, so the tracer setup and assertions still execute whenever agentlightning imports successfully. The change is focused and matches the resource-intensive optional-test boundary; no blocking findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lab Usage: [Issues, PRs], Target: lab packages python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: lab lightning tests hard-fail on fastapi 0.141 (litellm proxy imports removed get_flat_dependant)

3 participants