Download platform/signalcore/verify_deployment.py from LevelUp2x/adaptai: direct link, hf CLI and curl.
- Browser
- Download file 5.99 kB
-
https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/main/platform/signalcore/verify_deployment.py
- Command line
-
hf download hf://datasets/LevelUp2x/adaptai/platform/signalcore/verify_deployment.py
-
curl -L -o verify_deployment.py https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/main/platform/signalcore/verify_deployment.py
5.99 kB
| #!/usr/bin/env python3 | |
| """ | |
| Phase 2 Deployment Verification Script | |
| Tests the deployed neuromorphic security and DataOps integration services | |
| """ | |
| import asyncio | |
| import sys | |
| import time | |
| import sys | |
| import os | |
| sys.path.append(os.path.join(os.path.dirname(__file__), 'commsops')) | |
| from neuromorphic_security import NeuromorphicSecurityAPI | |
| from dataops_integration import DataOpsIntegration, create_dataops_integration | |
| async def test_neuromorphic_security(): | |
| """Test the neuromorphic security service""" | |
| print("π Testing Neuromorphic Security Service...") | |
| api = NeuromorphicSecurityAPI() | |
| # Test various message types | |
| test_messages = [ | |
| (b'Normal operational data', 'Normal message'), | |
| (b'X' * 5000, 'Large payload'), | |
| (b'\x00\x01\x02\x03' * 100, 'Binary data'), | |
| (b'Potential security threat pattern', 'Suspicious content') | |
| ] | |
| results = [] | |
| for message_data, description in test_messages: | |
| result = await api.scan_message(message_data, 'data_ops') | |
| results.append({ | |
| 'description': description, | |
| 'approved': result.approved, | |
| 'confidence': result.confidence, | |
| 'risk_score': result.risk_score, | |
| 'processing_time': result.processing_time_ms | |
| }) | |
| print(f" {description}: {'β ' if result.approved else 'β'} " | |
| f"(Risk: {result.risk_score:.2f}, Time: {result.processing_time_ms:.2f}ms)") | |
| # Get overall metrics | |
| metrics = await api.get_security_metrics() | |
| print(f" Total messages scanned: {metrics['total_messages_scanned']}") | |
| print(f" Approval rate: {metrics['approval_rate']:.2%}") | |
| return all(r['approved'] for r in results if 'Normal' in r['description']) | |
| async def test_dataops_integration(): | |
| """Test the DataOps integration service""" | |
| print("π Testing DataOps Integration Service...") | |
| integration = create_dataops_integration() | |
| # Test storage with security | |
| test_data = { | |
| 'operation': 'test_storage', | |
| 'data': {'sample': 'integration_test', 'value': 42, 'timestamp': time.time()}, | |
| 'metadata': {'test_id': 'phase2_verification', 'domain': 'data_ops'} | |
| } | |
| start_time = time.time() | |
| storage_result = await integration.store_with_security(test_data, 'data_ops') | |
| storage_time = (time.time() - start_time) * 1000 | |
| print(f" Storage operation: {'β ' if storage_result.success else 'β'} " | |
| f"(Time: {storage_time:.2f}ms)") | |
| if storage_result.success: | |
| # Test retrieval | |
| start_time = time.time() | |
| retrieved_data = await integration.retrieve_with_security(storage_result.storage_id) | |
| retrieval_time = (time.time() - start_time) * 1000 | |
| print(f" Retrieval operation: {'β ' if retrieved_data.get('security_valid') else 'β'} " | |
| f"(Time: {retrieval_time:.2f}ms)") | |
| # Get performance metrics | |
| metrics = await integration.get_performance_metrics() | |
| print(f" Cross-domain latency: {metrics['integration_metrics']['cross_domain_latency']:.2f}ms") | |
| print(f" Data throughput: {metrics['integration_metrics']['data_throughput']:,} ops/s") | |
| return storage_result.success | |
| async def test_service_connectivity(): | |
| """Test that services are running and responsive""" | |
| print("π‘ Testing Service Connectivity...") | |
| # Check if supervisor services are running | |
| try: | |
| import subprocess | |
| result = subprocess.run(['sudo', 'supervisorctl', 'status', 'commsops:'], | |
| capture_output=True, text=True, timeout=10) | |
| if 'RUNNING' in result.stdout: | |
| print(" β Supervisor services: RUNNING") | |
| # Parse service status | |
| lines = result.stdout.strip().split('\n') | |
| for line in lines: | |
| if 'commsops:' in line: | |
| service_name = line.split()[0] | |
| status = line.split()[1] | |
| print(f" {service_name}: {status}") | |
| return True | |
| else: | |
| print(" β Supervisor services: NOT RUNNING") | |
| return False | |
| except Exception as e: | |
| print(f" β Service check failed: {e}") | |
| return False | |
| async def main(): | |
| """Main verification routine""" | |
| print("π Phase 2 Deployment Verification") | |
| print("=" * 50) | |
| all_tests_passed = True | |
| # Test 1: Service connectivity | |
| connectivity_ok = await test_service_connectivity() | |
| all_tests_passed &= connectivity_ok | |
| print() | |
| # Test 2: Neuromorphic security | |
| if connectivity_ok: | |
| security_ok = await test_neuromorphic_security() | |
| all_tests_passed &= security_ok | |
| print() | |
| # Test 3: DataOps integration | |
| if connectivity_ok: | |
| integration_ok = await test_dataops_integration() | |
| all_tests_passed &= integration_ok | |
| print() | |
| # Final results | |
| print("π Verification Results:") | |
| print("=" * 50) | |
| print(f"Service Connectivity: {'β PASS' if connectivity_ok else 'β FAIL'}") | |
| if connectivity_ok: | |
| print(f"Neuromorphic Security: {'β PASS' if security_ok else 'β FAIL'}") | |
| print(f"DataOps Integration: {'β PASS' if integration_ok else 'β FAIL'}") | |
| print(f"\nOverall Status: {'π ALL TESTS PASSED' if all_tests_passed else 'β DEPLOYMENT ISSUES'}") | |
| if all_tests_passed: | |
| print("\nπ Phase 2 Integration is fully operational and production-ready!") | |
| print("Next steps:") | |
| print(" - Integrate with monitoring dashboard") | |
| print(" - Update alerting systems") | |
| print(" - Begin Phase 3 MLOps integration") | |
| else: | |
| print("\nβ οΈ Some tests failed. Check service logs and configuration.") | |
| return all_tests_passed | |
| if __name__ == "__main__": | |
| success = asyncio.run(main()) | |
| sys.exit(0 if success else 1) |