-
Notifications
You must be signed in to change notification settings - Fork 686
Python: [Purview] Add Caching and background processing in Python Purview Middleware #1844
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
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements caching, background processing, and enhanced exception handling for the Purview integration. The main changes include:
- Added protection scopes response caching with configurable TTL and size limits
- Implemented background task processing for content activities and offline policy evaluation
- Added support for execution modes (inline vs. offline) and payment required error handling
- Removed the
process_inlinesetting in favor of dynamic execution mode detection - Enhanced exception handling with
ignore_exceptionsandignore_payment_requiredconfiguration options
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
agent_framework_purview/_cache.py |
New cache provider implementation with in-memory caching |
agent_framework_purview/_processor.py |
Added caching, background processing, and execution mode handling |
agent_framework_purview/_settings.py |
Removed process_inline, added cache settings and exception handling flags |
agent_framework_purview/_client.py |
Added scope identifier and Prefer header handling, 402 error support |
agent_framework_purview/_middleware.py |
Enhanced exception handling for payment required and general errors |
agent_framework_purview/_exceptions.py |
Added PurviewPaymentRequiredError exception |
agent_framework_purview/_models.py |
Added ExecutionMode enum and scope_identifier to requests |
tests/test_*.py |
Updated tests for new functionality and behavior changes |
README.md |
Updated documentation with new features and configuration options |
Comments suppressed due to low confidence (2)
python/packages/purview/agent_framework_purview/_cache.py:13
- The global variable 'T' is not used.
T = TypeVar("T")
python/packages/purview/agent_framework_purview/_cache.py:83
- This import of module json is redundant, as it was previously imported on line 7.
import json
f0addc7 to
7153e3d
Compare
7153e3d to
79e7437
Compare
eavanvalkenburg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other then some formatting, looks good. However I would like to see some samples with caching and a custom cache provider.
f27c9c3 to
7c11166
Compare
7c11166 to
a3e5510
Compare
Python Purview: Add Caching and Background Processing
Motivation and Context
This PR enhances the Python Purview integration with performance optimizations and reliability improvements that address follow-up opportunities identified in PR #1142.
Why is this change required?
What problem does it solve?
What scenario does it contribute to?
This change improves the production readiness of Purview middleware by making it more performant and resilient for high-throughput conversational AI applications that enforce data governance policies.
Description
This PR adds comprehensive caching and background processing capabilities to the Python Purview integration.
Key Implementation Details:
asyncio.create_taskfor non-blocking executionContribution Checklist