Commit a6af99c
Viewer consolidation, workflow segmentation, and VM monitoring (#9)
* feat: add openadapt-viewer dependency and adapter module (Phase 1)
Phase 1 of viewer consolidation plan: Foundation
Changes:
- Add openadapt-viewer as local file dependency in pyproject.toml
- Create openadapt_ml/training/viewer_components.py adapter module
* screenshot_with_predictions() - Screenshot with human/AI overlays
* training_metrics() - Training stats metrics grid
* playback_controls() - Playback UI controls
* correctness_badge() - Pass/fail badge component
* generate_comparison_summary() - Model comparison summary
- Add tests/test_viewer_screenshots.py with component validation tests
- Add openadapt_ml/training/viewer_migration_example.py validation example
Design:
- Zero breaking changes to existing viewer.py code
- Adapter pattern wraps openadapt-viewer with ML-specific context
- Functions accept openadapt-ml data structures
- Can be incrementally adopted in future phases
Next steps (Phase 2):
- Gradually migrate viewer.py to use these adapters
- Replace inline HTML generation with component calls
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat: add workflow segmentation system with capture adapter
Restored and enhanced the workflow segmentation system from commit dd9a393
with new integration for openadapt-capture format.
## What's Added
### Core Segmentation Pipeline (4 stages):
1. **Stage 1 - Frame Description (VLM)**:
- Converts screenshots + actions into semantic descriptions
- Supports Gemini, Claude, GPT-4o backends
- Automatic caching for efficiency
- File: openadapt_ml/segmentation/frame_describer.py
2. **Stage 2 - Episode Extraction (LLM)**:
- Identifies coherent workflow boundaries
- Few-shot prompting for better quality
- Confidence-based filtering
- File: openadapt_ml/segmentation/segment_extractor.py
3. **Stage 3 - Deduplication (Embeddings)**:
- Finds similar workflows across recordings
- Agglomerative clustering with cosine similarity
- Supports OpenAI or local HuggingFace embeddings
- File: openadapt_ml/segmentation/deduplicator.py
4. **Stage 4 - Annotation (VLM Quality Control)**:
- Auto-annotates episodes for training data quality
- Detects failures, boundary issues, incompleteness
- Human-in-the-loop review workflow
- File: openadapt_ml/segmentation/annotator.py
### Integration Features:
- **CaptureAdapter**: Loads recordings from openadapt-capture SQLite format
- File: openadapt_ml/segmentation/adapters/capture_adapter.py
- Automatically used when capture.db is detected
- Converts events to segmentation format
- **Unified Pipeline**: Run all stages with single API
- File: openadapt_ml/segmentation/pipeline.py
- Automatic intermediate result caching
- Resume support for interrupted runs
- **CLI Interface**: Full command-line interface for all stages
- File: openadapt_ml/segmentation/cli.py
- Commands: describe, extract, deduplicate, annotate, review, export-gold
- **Comprehensive Documentation**:
- File: openadapt_ml/segmentation/README.md
- 20+ code examples
- Complete API reference
- Integration guide
- Cost estimates and performance benchmarks
## Use Cases
1. **Training Data Curation**: Extract and filter high-quality demonstration episodes
2. **Demo Retrieval**: Build searchable libraries for demo-conditioned prompting
3. **Workflow Documentation**: Auto-generate step-by-step guides from recordings
## Data Schemas
All schemas use Pydantic for type safety (openadapt_ml/segmentation/schemas.py):
- ActionTranscript: Frame-by-frame semantic descriptions
- Episode: Coherent workflow segment with boundaries
- CanonicalEpisode: Deduplicated workflow definition
- EpisodeAnnotation: Quality assessment for training data
## Example Usage
```python
from openadapt_ml.segmentation import SegmentationPipeline, PipelineConfig
config = PipelineConfig(
vlm_model="gemini-2.0-flash",
llm_model="gpt-4o",
similarity_threshold=0.85
)
pipeline = SegmentationPipeline(config)
result = pipeline.run(
recordings=["/path/to/recording1", "/path/to/recording2"],
output_dir="workflow_library"
)
print(f"Found {result.unique_episodes} unique workflows")
```
## Next Steps
See openadapt_ml/segmentation/README.md for:
- P0: Integration tests with real openadapt-capture recordings
- P0: Visualization generator for segment boundaries
- P1: Improved prompt engineering and cost optimization
- P2: Active learning and multi-modal features
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Enhance vm monitor command with comprehensive VM usage visibility
Features added:
- Azure ML job tracking: Shows recent jobs from last 7 days with status
- Cost tracking: Real-time uptime, hourly rate, and cost estimation
- VM activity detection: Identifies what VM is currently doing
- Evaluation history: Past benchmark runs and success rates (--details flag)
- Enhanced UI: Structured dashboard with clear sections and icons
New utility functions in vm_monitor.py:
- fetch_azure_ml_jobs(): Fetch recent Azure ML jobs with filtering
- calculate_vm_costs(): Calculate VM costs with hourly/daily/weekly rates
- get_vm_uptime_hours(): Get VM uptime from Azure activity logs
- detect_vm_activity(): Detect current VM activity (idle, running, setup)
- get_evaluation_history(): Load past evaluation runs from results dir
CLI enhancements:
- Added --details flag for extended information
- Improved output formatting with sections and separators
- Better error handling and status icons
- Preserved existing SSH tunnel and dashboard functionality
Documentation:
- Updated CLAUDE.md with new features and usage examples
- Added detailed docstrings to all new functions
This consolidates VM monitoring into a single enhanced command rather than
creating duplicate dashboards, following the viewer consolidation strategy.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Refactor segmentation pipeline to use screen.frame events
Update CaptureAdapter to work with actual openadapt-capture database
format. Key changes:
- Use screen.frame events instead of generic event types
- Pair action events (mouse.down + mouse.up → single click)
- Map frame events to screenshots via timestamp matching
- Update event type filtering to match openadapt-capture schema
- Improve frame-to-action association logic
This enables the segmentation pipeline to process real capture recordings
from openadapt-capture instead of requiring simulated data.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add VM monitoring dashboard with comprehensive usage visibility
Enhance vm monitor command to provide complete VM usage tracking:
- Real-time VM status (size, IP, power state)
- Activity detection (idle, benchmark running, setup)
- Cost tracking (uptime hours, hourly rate, total cost)
- Azure ML jobs list (last 7 days with status)
- Evaluation history (with --details flag)
- Mock mode for testing without VM (--mock flag)
Add new API endpoints to local.py dashboard server:
- /api/benchmark/status - current job status with ETA
- /api/benchmark/costs - cost breakdown (Azure VM, API, GPU)
- /api/benchmark/metrics - performance metrics by domain
- /api/benchmark/workers - worker status and utilization
- /api/benchmark/runs - list all benchmark runs
- /api/benchmark/tasks/{run}/{task} - task execution details
Update README with VM monitor section including screenshots and
usage examples.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add segmentation testing documentation and test files
Add comprehensive test plan and results for workflow segmentation pipeline:
- Test plan with 8 stages from environment setup to documentation
- Test results documenting real capture processing outcomes
- Test files for CaptureAdapter and segmentation pipeline
Add VM monitor screenshot generation scripts and documentation:
- Scripts for automated dashboard screenshot generation
- Implementation plan for VM monitor screenshot feature
- Analysis of screenshot capture approaches
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Document archived OpenAdapter repository
- Archive OpenAdapter (incomplete pre-refactor cloud deployment POC)
- Document key takeaways and lessons learned
- Reference modern cloud infrastructure in openadapt-ml
- Add guidelines for when to archive repositories
OpenAdapter was an incomplete proof-of-concept from October 2024
with only 165 lines of code and no ecosystem usage. Cloud deployment
is now production-ready in openadapt_ml/cloud/ and benchmarks/azure.py.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add search functionality to training viewer
- Add search bar to viewer controls with Ctrl+F / Cmd+F keyboard shortcut
- Implement advanced token-based search across step indices, action types, and text
- Search filters step list in real-time with result count display
- Clear button and Escape key support for resetting search
- Consistent UI styling with existing viewer components
- Integrates with existing step list filtering
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: resolve ruff linting and formatting issues
* fix: resolve test failures from missing dependencies
- Remove non-existent openadapt_ml.shared_ui import from viewer.py
- Skip anthropic test when anthropic package not installed (optional dependency)
- Skip viewer_components test when openadapt-viewer not installed (optional dependency)
All tests now pass (334 passed, 6 skipped).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent aeed4bf commit a6af99c
33 files changed
Lines changed: 10559 additions & 88 deletions
File tree
- docs
- screenshots
- openadapt_ml
- benchmarks
- cloud
- segmentation
- adapters
- training
- scripts
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
3 | 14 | | |
4 | 15 | | |
5 | 16 | | |
| |||
18 | 29 | | |
19 | 30 | | |
20 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
21 | 53 | | |
22 | 54 | | |
23 | 55 | | |
| 56 | + | |
| 57 | + | |
24 | 58 | | |
25 | 59 | | |
26 | 60 | | |
| |||
120 | 154 | | |
121 | 155 | | |
122 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
123 | 163 | | |
124 | 164 | | |
125 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
781 | 781 | | |
782 | 782 | | |
783 | 783 | | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
784 | 830 | | |
785 | 831 | | |
786 | 832 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments