refactor(BA-5961): introduce AppProxyClientRegistry for app-proxy domain clients#11491
Closed
jopemachine wants to merge 8 commits into
Closed
refactor(BA-5961): introduce AppProxyClientRegistry for app-proxy domain clients#11491jopemachine wants to merge 8 commits into
AppProxyClientRegistry for app-proxy domain clients#11491jopemachine wants to merge 8 commits into
Conversation
…ain clients Apply the BackendAIClientRegistry / V2ClientRegistry pattern to app-proxy clients. DeploymentChatClient was previously a direct subclass of BackendAIAppProxyClient, instantiated by the CLI with a raw ClientConfig; this divergence from the manager-side SDK shape (where domain clients are lazy-loaded via a registry) does not scale once more app-proxy domain clients are added (custom containers, /generate, etc.). - Add BaseAppProxyDomainClient mirroring BaseDomainClient. - Compose DeploymentChatClient via BaseAppProxyDomainClient instead of subclassing BackendAIAppProxyClient. - Add AppProxyClientRegistry in client/v2/approxy_registry.py with the same lifecycle as BackendAIClientRegistry (create / close / @cached_property accessors). - Add create_appproxy_registry helper alongside create_v2_registry. - Switch ./bai deployment chat to consume the registry. - Update tests for the new DeploymentChatClient constructor. Resolves BA-5961. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the test_registry.py pattern used by BackendAIClientRegistry: factory creation, domain client type/inheritance, cached_property identity, and close() delegation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the runtime list and the "domain clients add X / Y / Z" enumeration — that's downstream-specific filler that does not belong on the base class. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
App-proxy fronts more than deployment runtimes (e.g. health checks); drop the "deployment-specific" framing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
769d8dc to
f466c7f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the app-proxy (“direct-to-deployment”) SDK layer to follow the same domain-client + registry composition pattern used by the existing v2 client registries, and updates the bai deployment chat CLI flow accordingly.
Changes:
- Introduces
BaseAppProxyDomainClientand refactorsDeploymentChatClientfrom inheritingBackendAIAppProxyClientto being composed over it. - Adds
AppProxyClientRegistrywith lazy@cached_propertydomain client accessors and updates CLI to use it. - Updates unit tests/fixtures to construct domain clients via injected
BackendAIAppProxyClient, and adds new registry unit tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/client/v2/test_deployment_chat_client.py | Updates fixture to inject BackendAIAppProxyClient into DeploymentChatClient. |
| tests/unit/client_v2/test_approxy_registry.py | Adds unit tests for AppProxyClientRegistry lifecycle and cached properties. |
| src/ai/backend/client/v2/deployment_chat.py | Refactors DeploymentChatClient into an app-proxy domain client composed over _client. |
| src/ai/backend/client/v2/base_client.py | Updates BackendAIAppProxyClient docstring to reflect new composition approach. |
| src/ai/backend/client/v2/base_appproxy_domain.py | Adds BaseAppProxyDomainClient base class for app-proxy domain clients. |
| src/ai/backend/client/v2/approxy_registry.py | Adds AppProxyClientRegistry for lazy app-proxy domain client construction and lifecycle. |
| src/ai/backend/client/cli/v2/helpers.py | Adds create_appproxy_registry helper for CLI usage. |
| src/ai/backend/client/cli/v2/deployment/chat/commands.py | Switches bai deployment chat to use the app-proxy registry and close it explicitly. |
| pyproject.toml | Adds Ruff per-file ignore for lazy import pattern in the new registry module. |
| changes/11491.enhance.md | Adds a Towncrier fragment announcing the new app-proxy registry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+135
to
+136
| jar are intentionally ignored — only TLS / timeout knobs from the | ||
| manager-side config are reused. |
| @@ -0,0 +1 @@ | |||
| Add `AppProxyClientRegistry` to expose app-proxy domain clients (`DeploymentChatClient`) with the same lazy `@cached_property` pattern as `BackendAIClientRegistry`. | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BaseAppProxyDomainClientmirroringBaseDomainClient, and refactorDeploymentChatClientfrom aBackendAIAppProxyClientsubclass to a domain client composed over one.AppProxyClientRegistry(client/v2/approxy_registry.py) with the same shape asBackendAIClientRegistry/V2ClientRegistry:create()/close()lifecycle and@cached_propertyaccessors (currentlydeployment_chat).create_appproxy_registryCLI helper alongsidecreate_v2_registry, and switch./bai deployment chatto consume the registry instead of instantiatingDeploymentChatClientdirectly.BackendAIAppProxyClientintoDeploymentChatClientvia the new constructor.Resolves BA-5961.