Microsoft Azure Cognitive Services Search Namespace Package for Python 2/3 compatibility
64
Quality
Pending
Does it follow best practices?
Impact
64%
1.25xAverage score across 6 eval scenarios
A small diagnostic module that verifies the search namespace relies on shared namespace wiring and guards against legacy package conflicts.
azure==0.9.9 raises a RuntimeError whose message tells the user to uninstall the legacy package before proceeding. @testvalidate_namespace returns a NamespaceStatus with wired=True, namespace_paths mirroring azure.cognitiveservices.__path__, and detail noting that shared namespace wiring is active. @testvalidate_namespace returns wired=False with an empty namespace_paths list and a detail string that explicitly says the namespace package dependency is missing. @testensure_search_import("custom") when that child module is absent under the search namespace returns ok=False, keeps module=None, captures an empty search_path, and includes a message that the child is not importable. @testcustom is preloaded under the search namespace, ensure_search_import("custom") returns ok=True, provides the loaded module, and captures its __path__ entries in search_path. @test@generates
from dataclasses import dataclass
from typing import List, Optional, Any
@dataclass
class NamespaceStatus:
wired: bool
namespace_paths: List[str]
detail: str
def detect_legacy_conflict(installed: List[str]) -> None:
"""
Raise RuntimeError if an azure==0.x legacy package string is present in installed.
"""
...
def validate_namespace() -> NamespaceStatus:
"""
Attempt to import the search namespace and report whether parent namespace wiring is active.
namespace_paths mirrors the current azure.cognitiveservices.__path__ as plain strings.
"""
...
@dataclass
class ImportResult:
ok: bool
module: Optional[Any]
message: str
search_path: List[str]
def ensure_search_import(child: str) -> ImportResult:
"""
Attempt to import azure.cognitiveservices.search.<child> and describe the result.
On success, returns the module and its __path__ entries as search_path.
"""
...Provides namespace wiring so search-specific child clients share the azure.cognitiveservices namespace across distributions.
Install with Tessl CLI
npx tessl i tessl/pypi-azure-cognitiveservices-search-nspkg