Skip to content

[CQA SDK] [Bug] Fix shared namespace exports for CQA authoring#45220

Open
Amichelangelo wants to merge 1 commit intomainfrom
qiyin/fix-qna-shared-namespace-export
Open

[CQA SDK] [Bug] Fix shared namespace exports for CQA authoring#45220
Amichelangelo wants to merge 1 commit intomainfrom
qiyin/fix-qna-shared-namespace-export

Conversation

@Amichelangelo
Copy link
Member

Description

Background:

The Question Answering runtime and authoring libraries share the [azure.ai.language.questionanswering] namespace. When both distributions are installed in the same environment, the shared namespace could resolve as a namespace-only package, causing [from azure.ai.language.questionanswering import QuestionAnsweringClient] to fail (or not expose runtime symbols as expected).

What changed:

Adjust authoring packaging discovery so the shared parent package is not excluded, preventing the namespace from becoming “empty” from the authoring wheel’s perspective.
Add a compatibility re-export in the shared namespace [init.py] so runtime symbols (e.g., [QuestionAnsweringClient]) remain importable when authoring + runtime are co-installed.

Impact:

Fixes import stability for environments that install both packages (editable or wheel).
No functional changes to service behavior; this is packaging/import surface only.

Testing:

Local sanity import check: [from azure.ai.language.questionanswering import QuestionAnsweringClient] succeeds with both packages installed.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

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 fixes a packaging and import issue in the Question Answering authoring SDK where importing runtime symbols from the shared namespace could fail when both authoring and runtime packages are installed together.

Changes:

  • Remove exclusion of the shared namespace azure.ai.language.questionanswering from packaging discovery
  • Add re-export logic in the shared namespace __init__.py to ensure runtime symbols remain importable

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Removes azure.ai.language.questionanswering from the exclude list, allowing the authoring package to contribute to the shared namespace
azure/ai/language/questionanswering/init.py Adds pkgutil.extend_path for namespace merging and re-exports QuestionAnsweringClient from the runtime package with graceful ImportError handling

Comment on lines +6 to +13
try:
from ._client import QuestionAnsweringClient # type: ignore
from ._version import VERSION # type: ignore

__version__ = VERSION
__all__ = ["QuestionAnsweringClient"]
except ImportError:
__all__ = []
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The runtime package's init.py includes additional initialization logic (importing from _patch and calling patch_sdk()) that won't execute if the authoring package's init.py is loaded first. While patch_sdk() is currently empty, consider calling it here for consistency and future-proofing: add from ._patch import patch_sdk and patch_sdk() in the try block after line 8. This ensures the runtime package initializes correctly regardless of import order.

Copilot uses AI. Check for mistakes.
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.

1 participant