Spaces:
Running on CPU Upgrade
Download web_docs/docs/deployment/databricks-migration.md from CommunityOne/open-navigator: direct link, hf CLI and curl.
- Browser
- Download file 9.17 kB
-
https://huggingface.co/spaces/CommunityOne/open-navigator/resolve/main/web_docs/docs/deployment/databricks-migration.md
- Command line
-
hf download hf://spaces/CommunityOne/open-navigator/web_docs/docs/deployment/databricks-migration.md
-
curl -L -o databricks-migration.md https://huggingface.co/spaces/CommunityOne/open-navigator/resolve/main/web_docs/docs/deployment/databricks-migration.md
sidebar_position: 2
Databricks Agent Bricks Refactoring - Summary
What Was Done
This system has been refactored to support Databricks Agent Bricks (Mosaic AI Agent Framework), enabling production-ready deployment on Databricks with full governance, monitoring, and scalability.
New Files Created
1. Core Agent Infrastructure
agents/mlflow_base.py- MLflow Pyfunc base classes for agentsMLflowAgentBase: Base class with tracing, Model Serving compatibilityMLflowChainAgent: LangChain integration with automatic loggingAutomatic signature inference
Unity Catalog registration methods
Model Serving deployment helpers
agents/mlflow_classifier.py- Production classifier agentHybrid keyword + LLM classification
MLflow tracing for all calls
Unity Catalog ready
Can be deployed to Model Serving
Includes registration script
2. Deployment & Operations
databricks/deployment.py- Deployment automationAgentDeploymentManagerclassRegister agents to Unity Catalog
Deploy to Model Serving endpoints
Multi-agent endpoints with traffic splitting
Endpoint testing and monitoring
Auto-scaling configuration
databricks/evaluation.py- Quality assuranceAgentEvaluatorclassAutomated evaluation pipelines
A/B testing between versions
Metrics: accuracy, precision, recall, F1, latency
Confusion matrix generation
Feedback loop integration with Delta Lake
3. Interactive Development
databricks/notebooks/01_agent_bricks_quickstart.py- Databricks notebookStep-by-step deployment guide
Local testing examples
Unity Catalog registration
Model Serving deployment
Evaluation examples
Delta Lake queries
Monitoring and observability
databricks/README.md- Comprehensive documentationArchitecture diagrams
Deployment workflows
API usage examples
Cost considerations
Troubleshooting guide
Best practices
4. Dependencies
- Updated
requirements-cpu.txtwith: mlflow>=2.10.0- MLflow tracking and servingdatabricks-agents>=0.1.0- Agent Frameworkdatabricks-vectorsearch>=0.22.0- Vector searchlanggraph>=0.0.20- Stateful agent graphsdatabricks-sdk>=0.18.0- Databricks API client
5. Updated Existing Files
README.md- Added Databricks Agent Bricks sectioninstall.sh- Detects and usesrequirements-cpu.txt
Key Features Added
1. MLflow Integration
Yes Automatic tracing of all agent calls Yes LLM request/response logging Yes Metrics tracking (latency, tokens, cost) Yes Experiment tracking and versioning Yes Model registry integration
2. Unity Catalog Governance
Yes Centralized model registration Yes Permissions and access control Yes Data lineage tracking Yes Version management Yes Tag-based organization
3. Model Serving
Yes REST API endpoints Yes Auto-scaling (scale-to-zero capable) Yes A/B testing with traffic splitting Yes Multi-agent pipelines Yes Monitoring and alerting
4. Evaluation Framework
Yes Automated quality metrics Yes Regression detection Yes Version comparison Yes Confusion matrices Yes Feedback loop from production
5. Production Ready
Yes CPU-only compatibility (no GPU needed) Yes Enterprise monitoring Yes Cost optimization (keyword filtering before LLM) Yes Error handling and retries Yes Comprehensive logging
Deployment Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Databricks Workspace β
β β
β ββββββββββββββββββββ ββββββββββββββββββββββ β
β β Unity Catalog βββββββ€ MLflow Tracking β β
β β - Policy Class. β β - Experiments β β
β β - Sentiment An. β β - Traces β β
β β - Advocacy Gen. β β - Metrics β β
β ββββββββββ¬ββββββββββ ββββββββββββββββββββββ β
β β β
β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β Model Serving Endpoints β β
β β ββββββββββββββ βββββββββββββββββββββββ β β
β β β Classifier β β Sentiment Analyzer β β β
β β β (Small) β β (Small) β β β
β β β Scale-to-0 β β Scale-to-0 β β β
β β ββββββββββββββ βββββββββββββββββββββββ β β
β βββββββββββββββ¬βββββββββββββββββββββββββββββ β
β β β
ββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββ
β External API β
β FastAPI App β
ββββββββββββββββββ
Usage Examples
Register Agent to Unity Catalog
from agents.mlflow_classifier import PolicyClassifierAgent
from databricks.deployment import AgentDeploymentManager
manager = AgentDeploymentManager()
version = manager.register_agent(
agent_class=PolicyClassifierAgent,
agent_name="policy_classifier",
description="Classifies documents for oral health topics",
tags={"team": "advocacy"}
)
Deploy to Model Serving
endpoint_url = manager.deploy_agent(
agent_name="policy_classifier",
endpoint_name="policy-classifier-prod",
workload_size="Small",
scale_to_zero=True
)
Evaluate Agent
from databricks.evaluation import AgentEvaluator
evaluator = AgentEvaluator("policy_classifier")
metrics = evaluator.evaluate_classifier(
model_uri="models:/main.agents.policy_classifier/1",
test_documents=test_docs,
ground_truth=labels
)
print(f"Accuracy: {metrics.accuracy:.2%}")
Invoke via API
curl -X POST https://workspace.cloud.databricks.com/serving-endpoints/policy-classifier-prod/invocations \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dataframe_records": [{
"document_id": "doc_001",
"title": "Meeting",
"content": "Fluoride discussion..."
}]
}'
Benefits
Before (Custom Implementation)
- No Manual deployment and versioning
- No No built-in observability
- No Limited scalability
- No No governance or lineage
- No Manual evaluation pipelines
- No Complex monitoring setup
After (Databricks Agent Bricks)
- Yes One-command deployment
- Yes Automatic tracing and logging
- Yes Auto-scaling Model Serving
- Yes Unity Catalog governance
- Yes Built-in evaluation framework
- Yes Enterprise monitoring included
Cost Optimization
The refactored system includes several cost optimizations:
- Hybrid Classification: Uses keyword matching before expensive LLM calls
- Scale-to-Zero: Endpoints scale down when idle
- Batch Processing: Supports bulk document classification
- Caching: Frequently requested results can be cached
- Small Workloads: Starts with small endpoints, scales on demand
Estimated cost: ~$0.10-0.50/hour for active endpoints (much less with scale-to-zero)
Next Steps
- Deploy to Databricks:
python -m databricks.deployment
- Run Evaluation:
python -m databricks.evaluation
Test in Notebook: Open
databricks/notebooks/01_agent_bricks_quickstart.pyMonitor Production: Set up alerts in Databricks UI
Add Feedback Loop: Collect corrections and retrain
Migration Path
For existing users:
- Yes Standalone mode still works - No breaking changes to existing code
- Gradual migration - Can use both modes simultaneously
- Databricks optional - Only needed for production scale
- Choose your path:
- Small projects: Use standalone mode
- Production/Enterprise: Use Databricks Agent Bricks
Questions?
- See
databricks/README.mdfor detailed docs - Run
databricks/notebooks/01_agent_bricks_quickstart.pyfor hands-on tutorial - Check examples in
databricks/deployment.pyanddatabricks/evaluation.py
Summary
This refactoring transforms the CommunityOne Open Navigator from a standalone multi-agent system into a production-ready, enterprise-grade application that leverages Databricks' full stack for AI governance, deployment, and monitoring. The system now has:
- Enterprise deployment via Model Serving
- Automatic observability with MLflow tracing
- Data governance through Unity Catalog
- Quality assurance with evaluation framework
- Cost optimization with scale-to-zero and hybrid approach
- Production readiness out of the box
All while maintaining backward compatibility with the standalone mode!