Repository navigation
python-rust-integration - #46851
python-rust-integration#46851dibahlfi wants to merge 145 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an internal “backend dispatch” layer for azure-cosmos (sync + async) to allow selecting between the existing core-Python implementation and an opt-in Rust/PyO3-backed path, including per-request backend tagging in the User-Agent and a unit-test suite to pin down the wiring/selection rules.
Changes:
- Add sync/async backend abstractions, constants, and factories with selection precedence
_backendkwarg >COSMOS_BACKENDenv var > defaultcore-python. - Wire backend selection into
CosmosClient/async client construction, expose backend instances onclient_connection, and addcreate_itemdispatch + per-request backend stamping. - Extend
CosmosUserAgentPolicyto appendbackend=<name>and add fast unit tests (including an import-guard) to verify wiring and behavior.
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/tests/test_backend_wiring_unit.py | New unit tests covering import-guard, backend selection precedence/validation, container dispatch behavior, and UA stamping. |
| sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py | Selects/initializes sync backend(s) at client construction and attaches them to client_connection. |
| sdk/cosmos/azure-cosmos/azure/cosmos/container.py | Adds sync create_item dispatch and stamps the chosen backend into per-request options. |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client.py | Selects/initializes async backend(s) at client construction and attaches them to client_connection. |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py | Adds async create_item dispatch and stamps the chosen backend into per-request options. |
| sdk/cosmos/azure-cosmos/azure/cosmos/_user_agent_policy.py | Appends a backend=<name> token to the User-Agent based on per-request options. |
| sdk/cosmos/azure-cosmos/azure/cosmos/_backend/base.py | Defines the sync backend ABC and shared immutable request/response dataclasses. |
| sdk/cosmos/azure-cosmos/azure/cosmos/_backend/constants.py | Centralizes backend names, env var, and per-request option key. |
| sdk/cosmos/azure-cosmos/azure/cosmos/_backend/factory.py | Implements backend name resolution + sync backend instance factory. |
| sdk/cosmos/azure-cosmos/azure/cosmos/_backend/core_python.py | Sync “core-python” backend stub (returns None to fall through to existing path). |
| sdk/cosmos/azure-cosmos/azure/cosmos/_backend/rust.py | Sync Rust backend stub with guarded PyO3 import and loud NotImplementedError. |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_backend/base.py | Defines the async backend ABC and re-exports shared dataclasses. |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_backend/factory.py | Async backend factory mapping resolved backend name to async backend instance. |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_backend/core_python.py | Async “core-python” backend stub (returns None to fall through). |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_backend/rust.py | Async Rust backend stub with guarded PyO3 import and loud NotImplementedError. |
| sdk/cosmos/azure-cosmos/azure/cosmos/_backend/init.py | Backend package marker/export surface (no diff shown). |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_backend/init.py | Async backend package marker/export surface (no diff shown). |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6953df5e-04ab-4c2d-9a7d-8311008c4d86
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 81f127fc-3491-4932-9a45-0b1cdaea46a1
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 13b35e7d-a3e2-4c8b-957b-de08a854af98
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Rename the shared client context, operation defaults, and context handoff across sync/async paths. Refresh only affected assertion-ledger fingerprints. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 81f127fc-3491-4932-9a45-0b1cdaea46a1
This comment has been minimized.
This comment has been minimized.
[Pilot] PR Pipeline Failure AnalysisWhat failedBuild 7101376 (
Recommended next steps
Automated fix: Fix found, view and apply fix
|
migrating from core-python to rust native