-
Notifications
You must be signed in to change notification settings - Fork 47
Add ABAC Agent into uc-quickstart/utils #611
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
base: main
Are you sure you want to change the base?
Conversation
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 introduces an ABAC (Attribute-Based Access Control) Policy Assistant agent into the uc-quickstart/utils directory. The agent is designed to analyze Unity Catalog tables and generate ABAC policy recommendations using AI-powered analysis.
Key changes:
- Adds a complete Streamlit-based chat application for ABAC policy generation
- Implements an MLflow ResponsesAgent with Unity Catalog function tools
- Provides comprehensive documentation and deployment configuration
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| requirements.txt | Defines Python dependencies for the application (mlflow, streamlit) |
| model_serving_utils.py | Provides utility functions for querying serving endpoints and handling different agent response formats |
| messages.py | Defines message classes for the chat interface with rendering logic |
| driver.py | Databricks notebook implementing the agent with MLflow logging and deployment |
| app.yaml | Configuration file for Databricks Apps deployment |
| app.py | Main Streamlit application implementing the chat interface |
| README.md | Comprehensive documentation covering features, setup, and usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # MAGIC | ||
| # MAGIC Find additional examples in the documentation - https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/policies?language=SQL | ||
| # MAGIC | ||
| # MAGIC Usually table name is given as catalog_name.schem_name.table_name. |
Copilot
AI
Dec 23, 2025
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.
Corrected spelling of 'schem_name' to 'schema_name'.
| # MAGIC Usually table name is given as catalog_name.schem_name.table_name. | |
| # MAGIC Usually table name is given as catalog_name.schema_name.table_name. |
| scorers=[RelevanceToQuery(), Safety()], # add more scorers here if they're applicable | ||
| ) | ||
|
|
||
| # Review the evaluation results in the MLfLow UI (see console output) |
Copilot
AI
Dec 23, 2025
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.
Corrected spelling of 'MLfLow' to 'MLflow'.
| # Review the evaluation results in the MLfLow UI (see console output) | |
| # Review the evaluation results in the MLflow UI (see console output) |
| secret_scope = 'david_scope' | ||
| client_secret_key = 'DATABRICKS_CLIENT_SECRET' | ||
| client_id_key = 'DATABRICKS_CLIENT_ID' |
Copilot
AI
Dec 23, 2025
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.
The hardcoded secret scope name 'david_scope' appears to be user-specific and should not be committed to the repository. This should be parameterized or documented as requiring user configuration.
| deployment_info = agents.deploy( | ||
| UC_MODEL_NAME, | ||
| uc_registered_model_info.version, | ||
| environment_vars={ | ||
| "DATABRICKS_HOST": "https://dbc-a612b3a4-f0ff.cloud.databricks.com", |
Copilot
AI
Dec 23, 2025
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.
The hardcoded Databricks host URL appears to be workspace-specific and should not be committed. This should be parameterized or retrieved from the environment/workspace context.
| deployment_info = agents.deploy( | |
| UC_MODEL_NAME, | |
| uc_registered_model_info.version, | |
| environment_vars={ | |
| "DATABRICKS_HOST": "https://dbc-a612b3a4-f0ff.cloud.databricks.com", | |
| workspace_host = dbutils.notebook.entry_point.getDbutils().notebook().getContext().apiUrl().get() | |
| deployment_info = agents.deploy( | |
| UC_MODEL_NAME, | |
| uc_registered_model_info.version, | |
| environment_vars={ | |
| "DATABRICKS_HOST": workspace_host, |
| 1. **Clone the repository** | ||
| ```bash | ||
| git clone <repository-url> | ||
| cd e2e-chatbot-app |
Copilot
AI
Dec 23, 2025
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.
The directory name 'e2e-chatbot-app' in the installation instructions doesn't match the actual directory structure 'uc-quickstart/utils/abac-agent'. This should be updated to reflect the correct path.
| cd e2e-chatbot-app | |
| cd uc-quickstart/utils/abac-agent |
| except: | ||
| pass |
Copilot
AI
Dec 23, 2025
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.
Bare except clause catches all exceptions including system exits. Specify the expected exception type (e.g., except json.JSONDecodeError:) or at minimum use except Exception:.
| except: | ||
| # If not JSON, show as code |
Copilot
AI
Dec 23, 2025
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.
Bare except clause catches all exceptions including system exits. Specify the expected exception type (e.g., except json.JSONDecodeError:) or at minimum use except Exception:.
| messages=[{"role": "assistant", "content": accumulated_content}], | ||
| request_id=request_id | ||
| ) | ||
| except Exception: |
Copilot
AI
Dec 23, 2025
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.
The error message doesn't provide any information about what went wrong. Consider logging the exception details and providing a more descriptive error message to help with debugging.
| except Exception: | |
| except Exception as e: | |
| logging.exception("Error during streaming query to serving endpoint") |
| except Exception: | ||
| response_area.markdown("_Ran into an error. Retrying without streaming..._") |
Copilot
AI
Dec 23, 2025
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.
The error message doesn't provide any information about what went wrong. Consider logging the exception details and providing a more descriptive error message to help with debugging.
| except Exception: | |
| response_area.markdown("_Ran into an error. Retrying without streaming..._") | |
| except Exception as exc: | |
| logging.exception( | |
| "Error while streaming response from endpoint '%s'. Falling back to non-streaming query.", | |
| SERVING_ENDPOINT, | |
| ) | |
| response_area.markdown( | |
| "_Ran into an error while streaming from the endpoint. " | |
| "Retrying without streaming (see logs for details)..._" | |
| ) |
| except Exception: | ||
| response_area.markdown("_Ran into an error. Retrying without streaming..._") |
Copilot
AI
Dec 23, 2025
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.
The error message doesn't provide any information about what went wrong. Consider logging the exception details and providing a more descriptive error message to help with debugging.
| except Exception: | |
| response_area.markdown("_Ran into an error. Retrying without streaming..._") | |
| except Exception as e: | |
| logging.exception("Error during streaming response in query_responses_endpoint_and_render") | |
| response_area.markdown("_Ran into an error while streaming the response. Retrying without streaming..._") |
|
@dlevy324 please fix Copilot suggestions |
No description provided.