[CQA SDK] [Bug] Fix shared namespace exports for CQA authoring#45220
[CQA SDK] [Bug] Fix shared namespace exports for CQA authoring#45220Amichelangelo wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
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.questionansweringfrom packaging discovery - Add re-export logic in the shared namespace
__init__.pyto 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 |
| try: | ||
| from ._client import QuestionAnsweringClient # type: ignore | ||
| from ._version import VERSION # type: ignore | ||
|
|
||
| __version__ = VERSION | ||
| __all__ = ["QuestionAnsweringClient"] | ||
| except ImportError: | ||
| __all__ = [] |
There was a problem hiding this comment.
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.
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:
General Guidelines and Best Practices
Testing Guidelines