-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Deprecation warning for using old class named AgentEndpoint (instead of new one AgentEndpoingConfig) #46658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dargilco
wants to merge
7
commits into
feature/azure-ai-projects/2.2.0
Choose a base branch
from
dargilco/deprecation-notice-agent-endpoint-class
base: feature/azure-ai-projects/2.2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Deprecation warning for using old class named AgentEndpoint (instead of new one AgentEndpoingConfig) #46658
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8af6e9b
First
dargilco d098da4
Merge remote-tracking branch 'origin/feature/azure-ai-projects/2.2.0'…
dargilco c11a486
fix merge
dargilco 977a68f
Use __getattr__ insted
dargilco 65d78b8
Fixes
dargilco c422bef
Remove not-needed code
dargilco a929282
fix pylance
dargilco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
71 changes: 71 additions & 0 deletions
71
sdk/ai/azure-ai-projects/tests/deprecation/test_agent_endpoint_deprecation.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| """Tests for AgentEndpoint deprecation warning.""" | ||
|
|
||
| import warnings | ||
|
|
||
| class TestAgentEndpointDeprecation: | ||
| """Test that AgentEndpoint is deprecated but still functional (PEP 562 __getattr__).""" | ||
|
|
||
| def test_agent_endpoint_emits_deprecation_warning_on_access(self): | ||
| """Test that accessing AgentEndpoint emits a DeprecationWarning (PEP 562).""" | ||
| import azure.ai.projects.models as models | ||
|
|
||
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.simplefilter("always") | ||
| # Warning is emitted on attribute access, not instantiation | ||
| _ = models.AgentEndpoint # type: ignore[attr-defined] | ||
|
|
||
| assert len(w) == 1 | ||
| assert issubclass(w[0].category, DeprecationWarning) | ||
| assert "AgentEndpoint" in str(w[0].message) | ||
| assert "AgentEndpointConfig" in str(w[0].message) | ||
|
|
||
| def test_agent_endpoint_config_no_warning(self): | ||
| """Test that using AgentEndpointConfig does not emit a warning.""" | ||
| import azure.ai.projects.models as models | ||
|
|
||
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.simplefilter("always") | ||
| _ = models.AgentEndpointConfig | ||
| config = models.AgentEndpointConfig() | ||
|
|
||
| # Filter only DeprecationWarnings related to AgentEndpoint | ||
| deprecation_warnings = [ | ||
| warning for warning in w | ||
| if issubclass(warning.category, DeprecationWarning) | ||
| and "AgentEndpoint" in str(warning.message) | ||
| ] | ||
| assert len(deprecation_warnings) == 0 | ||
|
|
||
| def test_agent_endpoint_is_same_class_as_config(self): | ||
| """Test that AgentEndpoint returns the same class as AgentEndpointConfig (PEP 562).""" | ||
| import azure.ai.projects.models as models | ||
|
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", DeprecationWarning) | ||
| # With PEP 562 __getattr__, AgentEndpoint IS AgentEndpointConfig | ||
| assert models.AgentEndpoint is models.AgentEndpointConfig # type: ignore[attr-defined] | ||
|
|
||
| def test_agent_endpoint_instance_is_config_instance(self): | ||
| """Test that AgentEndpoint instance is also an AgentEndpointConfig instance.""" | ||
| import azure.ai.projects.models as models | ||
|
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", DeprecationWarning) | ||
| endpoint = models.AgentEndpoint() # type: ignore[attr-defined] | ||
|
|
||
| assert isinstance(endpoint, models.AgentEndpointConfig) | ||
|
|
||
| def test_agent_endpoint_functionality_preserved(self): | ||
| """Test that AgentEndpoint still works with all its parameters.""" | ||
| import azure.ai.projects.models as models | ||
|
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", DeprecationWarning) | ||
| endpoint = models.AgentEndpoint( # type: ignore[attr-defined] | ||
| protocols=[models.AgentEndpointProtocol.A2A], | ||
| ) | ||
|
|
||
| assert endpoint.protocols == [models.AgentEndpointProtocol.A2A] | ||
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.
Uh oh!
There was an error while loading. Please reload this page.