This folder contains automation utilities, orchestrators, and tools for the QAI workspace.
- Training scripts: training/ (train_vision)
- Monitoring utilities:
status_dashboard.py,resource_monitor.py,system_health_check.py - Shims: legacy paths in scripts/ still dispatch to the moved files for backwards compatibility.
# Quick multi-model training with evaluation
python .\scripts\automated_training_pipeline.py --quick
# TinyLlama ultrafast iteration
python .\scripts\automated_training_pipeline.py --models tinyllama --quick
# Parallel training (Phi + Qwen)
python .\scripts\parallel_train.py --models phi,qwen --quick
# Single model training
python .\scripts\auto_data_train.py --model phi --quick# Run all fast tests
python .\scripts\test_runner.py --all
# Unit tests only
python .\scripts\test_runner.py --unit
# Full CI pipeline
python .\scripts\ci_orchestrator.py --ci-pipeline
# Validate orchestrators
python .\scripts\ci_orchestrator.py --validate-all
# Fast integration smoke checks
python .\scripts\integration_smoke.py
# Focused integration contract tests
python .\scripts\ci_orchestrator.py --integration-contract-tests
# One-command local gate script
bash ./scripts/integration_contract_gate.sh
# Use the repository venv when python3 is not the desired interpreter
PYTHON_BIN=.venv/bin/python bash ./scripts/integration_contract_gate.sh
# One-command local gate (VS Code task label)
# integration:contract-gate
# Run deterministic repository inspection agents
python .\scripts\run_repo_agents.py --dry-run
python .\scripts\run_repo_agents.py --json
# Automate the repeated local fix/validate loop (one-shot)
python .\scripts\repo_health_automation.py --once --strict-endpoints
# Include repository inspection agents in the health cycle
python .\scripts\repo_health_automation.py --once --run-agents
# Same automation, but also run full pytest smoke
python .\scripts\repo_health_automation.py --once --strict-endpoints --full-pytest
# Continuous unattended loop every 5 minutes
python .\scripts\repo_health_automation.py --watch --interval 300 --strict-endpoints
# Shell wrapper (friendlier command UX)
./scripts/start_repo_health_automation.sh once --strict
./scripts/start_repo_health_automation.sh watch --strict --interval 300
./scripts/start_repo_health_automation.sh status
# VS Code task labels:
# - repo-health:once-strict
# - repo-health:once-strict-full-pytest
# - repo-health:watch-strictPurpose: Automate repeated repo-health cycles (pre-commit + optional repository agents + integration contract gate + optional full pytest) so fix/validation can run unattended.
Key options:
--once/--watch— run one cycle or continuous loop--strict-endpoints— run integration gate in strict endpoint mode--full-pytest— includepytest tests -q --maxfail=1 --tb=short--auto-fix-ruff— runruff check --fixon changed.pyfiles before checks--run-agents— runscripts/run_repo_agents.pyafter the integration contract gate--continue-on-fail— continue all steps even after a failed step
Status output:
data_out/repo_health_automation/status.json
Purpose: Run deterministic, side-effect-free repository checks and write structured status for dashboards or follow-up automation.
Current agents:
| Agent | Checks | Primary source |
|---|---|---|
status-freshness |
Stale, failed, unparseable, or timestamp-less data_out/**/status.json files |
scripts/agents/status_freshness_agent.py |
marker-audit |
TODO, FIXME, HACK, XXX, and BUG markers in source-like files |
scripts/agents/marker_audit_agent.py |
docstring-audit |
Module/class/function docstring coverage for Python paths, defaulting to shared and scripts/agents |
scripts/agents/docstring_audit_agent.py |
agents-md-audit |
Structure and hygiene of AGENTS.md Learned sections (bullet limits, secrets, stale dates) |
scripts/agents/agents_md_audit_agent.py |
Result contract: Every agent returns an AgentResult with name, status, summary, findings, metrics, and timestamp. Valid statuses are ok, warning, and error; only ok makes AgentResult.ok true.
Usage:
# Run all registered agents and write status files
python .\scripts\run_repo_agents.py
make agents
# Preview without writing data_out/agents/*
python .\scripts\run_repo_agents.py --dry-run
make agents-dry
# Shell wrapper
./scripts/run_ai_automation.sh --json
# Run one agent, emit aggregate JSON, and fail CI on warnings
python .\scripts\run_repo_agents.py --agent status-freshness --json --fail-on-warning
# Run an individual agent CLI
python .\scripts\agents\docstring_audit_agent.py --path scripts/agents --min-coverage 80 --jsonStatus output:
- Per-agent status:
data_out/agents/<agent-name>/status.json - Aggregate summary:
data_out/agents/status.json - Health-cycle wrapper:
python .\scripts\repo_health_automation.py --once --run-agents
Adding an agent: Create a class that extends AutomationAgent, set a unique kebab-case name, implement run(), and decorate the class with @register. Import the module from _AGENT_MODULES in scripts/run_repo_agents.py so the registry can discover it.
# Run quantum training jobs
python .\scripts\quantum_autorun.py --dry-run
# Validate quantum environment
python -m pytest tests\test_validate_qiskit_env.py -vPurpose: Single entry point for multi-model LoRA training with data generation, evaluation, and Azure ML spec emission.
Key Features:
- Generate synthetic data (phi, qwen, tinyllama)
- Sequential or parallel model training
- Evaluation with perplexity & diversity metrics
- Multiple ranking strategies (improvement, diversity, combined)
- Azure ML job spec emission
- Checkpoint cleanup
Usage:
# Quick both models with evaluation
python .\scripts\automated_training_pipeline.py --quick
# Custom samples and ranking
python .\scripts\automated_training_pipeline.py --models phi --samples 300 --ranking-metric diversity_avg
# Generate data only
python .\scripts\automated_training_pipeline.py --generate-only --samples 200
# Emit Azure ML spec
python .\scripts\automated_training_pipeline.py --azure-ml-spec --quick --models phi,qwenPurpose: Parallel execution of multiple LoRA training jobs with shared evaluation and ranking.
Key Features:
- Concurrent training via ThreadPoolExecutor
- Shared evaluation step (perplexity, diversity, echo ratio)
- Configurable ranking metrics
- Append-only status history
- Supports 5+ ranking strategies
Usage:
# Train all models in parallel
python .\scripts\parallel_train.py --models phi,qwen,tinyllama --quick
# Custom ranking metric
python .\scripts\parallel_train.py --models phi,qwen --ranking-metric combined_improvementPurpose: Generate synthetic training data + single model LoRA training.
Usage:
# Phi model with synthetic data
python .\scripts\auto_data_train.py --model phi --quick
# TinyLlama with custom samples
python .\scripts\auto_data_train.py --model tinyllama --samples 300Purpose: High-level workflow coordination for complex training pipelines.
Workflows:
quick_validation: Validate all configsfull_training: Complete training cycleevaluation_only: Run evaluations on existing models
Usage:
# Quick validation
python .\scripts\master_orchestrator.py --workflow quick_validation
# Check status
python .\scripts\master_orchestrator.py --statusPurpose: HuggingFace AutoTrain wrapper with multi-job support.
Usage:
# Dry run validation
python .\scripts\autotrain.py --dry-run
# Run all jobs
python .\scripts\autotrain.py
# Single job
python .\scripts\autotrain.py --job phi35_mixed_chatPurpose: Centralized test orchestrator with intelligent filtering and result aggregation.
Test Suites:
unit: fast unit tests, excluding slow, Azure, integration, quantum, and GPU markersintegration: tests markedintegrationall_fast: all tests except slow and Azure markersall: the full suiteautotrain,quantum,database,chat: focused suites
The exact test count changes as coverage grows. Use python .\scripts\test_runner.py --list-suites for the current suite list; Cursor Cloud agents should prefer .venv/bin/python scripts/test_runner.py --unit.
Usage:
# Run all fast tests
python .\scripts\test_runner.py --all
# Unit tests with coverage
python .\scripts\test_runner.py --unit --coverage
# Watch mode (re-run on change)
python .\scripts\test_runner.py --unit --integration --watch
# List available suites
python .\scripts\test_runner.py --list-suitesFeatures:
- ANSI escape code handling
- Regex-based pytest output parsing
- Marker filtering (
not slow and not azure) - JSON + Markdown result reports
- Parallel suite execution
- Coverage integration
Purpose: Continuous integration pipeline with staged validation gates.
Steps:
- Orchestrator validations (autotrain, quantum, evaluation)
- Integration smoke checks (cross-component)
- Integration contract unit tests (resolver, scheduler, status schemas)
- Unit tests (via test_runner)
- Dataset validation
- Integration tests
- Code quality checks
- Security scanning
- Deployment preparation
- Azure ML validation
Usage:
# Full CI pipeline
python .\scripts\ci_orchestrator.py --ci-pipeline
# Validate orchestrators only
python .\scripts\ci_orchestrator.py --validate-all
# Run focused integration contract tests only
python .\scripts\ci_orchestrator.py --integration-contract-tests
# Run full contract gate sequence (smoke + contract tests + validate-all)
bash ./scripts/integration_contract_gate.sh
# Use the repo virtualenv explicitly
PYTHON_BIN=.venv/bin/python bash ./scripts/integration_contract_gate.sh
# Strict endpoint mode: also require /api/ai/status reachability
INTEGRATION_AI_STATUS_ENDPOINT=http://localhost:7071/api/ai/status \
RETRY_COUNT=30 \
RETRY_INTERVAL=1 \
bash ./scripts/integration_contract_gate.sh --strict-endpoints
# Or run the VS Code task: integration:contract-gateFor current CI health, prefer the latest workflow result or a fresh local run over a fixed count in this guide.
Purpose: Parallel evaluation of multiple models with comprehensive result aggregation.
Features:
- Parallel model evaluation (ThreadPoolExecutor)
- Support for LoRA, Azure, OpenAI, Local, Quantum models
- Configurable metrics per model type
- Result ranking and comparison
- Export to JSON/Markdown/CSV
Usage:
# Scan and evaluate all models
python .\scripts\batch_evaluator.py --scan-models --evaluate-all
# Compare specific models
python .\scripts\batch_evaluator.py --compare lora azure openai
# Export results
python .\scripts\batch_evaluator.py --export markdown --output report.mdPurpose: Analyze training metrics and generate performance reports.
Usage:
# Analyze recent training runs
python .\scripts\training_analytics.py --recent 5
# Generate comparison report
python .\scripts\training_analytics.py --compare phi qwen tinyllamaPurpose: Validate and optionally submit Azure ML job specs.
Features:
- YAML schema validation
- Environment spec checking
.envplaceholder gating (prevents submission with unresolved credentials)- Graceful fallback when Azure CLI not installed
Usage:
# Validate latest job spec
python .\scripts\azureml_ci_validate.py
# Validate and submit
python .\scripts\azureml_ci_validate.py --submit
# Force submit (bypass gating)
python .\scripts\azureml_ci_validate.py --submit --force-submitPurpose: Validate dataset integrity across all categories.
Categories: quantum, chat, all
Usage:
# Validate chat datasets
python .\scripts\validate_datasets.py --category chat
# Validate all
python .\scripts\validate_datasets.py --category allPurpose: Download and organize datasets from HuggingFace.
Usage:
# Download all configured datasets
python .\scripts\download_datasets.py
# Download specific dataset
python .\scripts\download_datasets.py --dataset dolly-15kPurpose: Monitor system resources during training.
Usage:
# Single snapshot
python .\scripts\resource_monitor.py --snapshot
# Stream for 60 seconds
python .\scripts\resource_monitor.py --stream --duration 60Purpose: Comprehensive system health validation.
Checks:
- Python environment
- Required packages
- GPU availability
- Disk space
- Dataset accessibility
Usage:
python .\scripts\system_health_check.pyPurpose: Database migration tool for chat/telemetry tables.
Usage:
# Run migrations
python .\scripts\sql_migrate.pyPurpose: Monitor SQL connection pool and query performance.
Usage:
python .\scripts\sql_health_monitor.pyStart-LocalLoraTraining.ps1: Task Scheduler-friendly training wrapperAnalyze-TrainingLogs.ps1: Parse and analyze training logsquick_status.ps1: Quick system status checkfast_train.ps1: Rapid training shortcut
env_autofix.py: Auto-fix environment issuespre_commit_check.py: Pre-commit validation hooksmetrics_ranker.py: Rank models by custom metricsresults_exporter.py: Export results to multiple formats
One-command offline LoRA training for TinyLlama on CPU. It auto-creates a venv under ai-projects/lora-training/microsoft_phi-silica-3.6_v1/local_train, installs requirements, and runs the training script with a small dataset and minimal epochs so it completes quickly on Windows.
Usage (PowerShell):
# From repo root
python .\scripts\run_local_lora_training.py
# Customize
python .\scripts\run_local_lora_training.py --max-samples 50 --epochs 2 --config local_config.yaml
# Force reinstall deps in the venv
python .\scripts\run_local_lora_training.py --reinstall
# Preview without training
python .\scripts\run_local_lora_training.py --dry-runOutputs are written to ai-projects/lora-training/microsoft_phi-silica-3.6_v1/local_train/outputs/final (LoRA adapter + tokenizer files).
Notes:
- 4-bit quantization is disabled by default for Windows/CPU; the tiny training still runs fast with TinyLlama.
- The runner sets
HF_HUB_DISABLE_SYMLINKS_WARNING=1to reduce warnings on Windows filesystems.
PowerShell wrapper that resolves paths, sets env, logs to a timestamped file, and runs the Python runner.
Usage (PowerShell):
# From repo root (or any folder)
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\Start-LocalLoraTraining.ps1 -MaxSamples 10 -Epochs 1 -Config local_config.yaml
# Optional flags
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\Start-LocalLoraTraining.ps1 -Reinstall
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\Start-LocalLoraTraining.ps1 -DryRunLogs:
- Default log directory:
ai-projects/lora-training/microsoft_phi-silica-3.6_v1/local_train/logs - File name:
train_YYYYMMDD_HHMMSS.log
Task Scheduler tip:
- Action:
Start a program - Program/script:
powershell.exe - Add arguments:
-NoProfile -ExecutionPolicy Bypass -File "C:\Users\Bryan\OneDrive\AI\scripts\Start-LocalLoraTraining.ps1" -MaxSamples 10 -Epochs 1 - Start in:
C:\Users\Bryan\OneDrive\AI
A task labeled Run: Local LoRA training is available. Open the Command Palette → “Run Task…” → select it to run.