diff --git a/.gitignore b/.gitignore index f9c49b6..e11e427 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,43 @@ ``` -# Compiled Python files -*.pyc +# Python __pycache__/ +*.pyc +*.pyo +*.pyd -# Generated images -*.png +# Testing +.pytest_cache/ +.coverage +coverage/ +htmlcov/ -# Logs and temporary files +# Logs *.log -*.tmp + +# Environment +.env +.env.local +*.env.* + +# Dependencies +.venv/ +venv/ +virtualenv/ +pip-log.txt +pip-delete-this-directory.txt + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Build +build/ +dist/ +*.egg-info/ ``` \ No newline at end of file diff --git a/charts/latency_leaderboard.png b/charts/latency_leaderboard.png new file mode 100644 index 0000000..1ba3776 Binary files /dev/null and b/charts/latency_leaderboard.png differ diff --git a/charts/performance_radar.png b/charts/performance_radar.png new file mode 100644 index 0000000..013cdd8 Binary files /dev/null and b/charts/performance_radar.png differ diff --git a/tests/__pycache__/safety_gating.cpython-312.pyc b/tests/__pycache__/safety_gating.cpython-312.pyc index 98ae85a..a61139d 100644 Binary files a/tests/__pycache__/safety_gating.cpython-312.pyc and b/tests/__pycache__/safety_gating.cpython-312.pyc differ diff --git a/tests/__pycache__/system_metrics.cpython-312.pyc b/tests/__pycache__/system_metrics.cpython-312.pyc index d043e4f..043efe9 100644 Binary files a/tests/__pycache__/system_metrics.cpython-312.pyc and b/tests/__pycache__/system_metrics.cpython-312.pyc differ diff --git a/tests/integration/test_basic_coverage.py b/tests/integration/test_basic_coverage.py index fbd93cf..b910c8f 100644 --- a/tests/integration/test_basic_coverage.py +++ b/tests/integration/test_basic_coverage.py @@ -1,4 +1,4 @@ -import pytest +import pytest import sys import os diff --git a/tests/integration/test_full_coverage.py b/tests/integration/test_full_coverage.py index e698c07..3d32895 100644 --- a/tests/integration/test_full_coverage.py +++ b/tests/integration/test_full_coverage.py @@ -1,4 +1,4 @@ -import pytest +import pytest import sys import os sys.path.append('phase3_automation_phase4_cognitive/scripts') diff --git a/tests/monitoring_test.py b/tests/monitoring_test.py index 04bb3f9..4cdd2a4 100644 --- a/tests/monitoring_test.py +++ b/tests/monitoring_test.py @@ -1,38 +1,40 @@ -import sys -sys.path.append('scripts') -from production_logger import ProductionLogger -from metrics_exporter import metrics_exporter - -print("=== PRODUCTION MONITORING TEST ===") - -# Initialize monitoring -logger = ProductionLogger() -logger.log_system_event("monitoring_test", {"status": "initialized"}) - -# Start metrics server in background -import threading -def start_metrics(): - metrics_exporter.start_metrics_server() +import sys +import os -metrics_thread = threading.Thread(target=start_metrics, daemon=True) -metrics_thread.start() +# Add tests directory to path for imports +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) -# Simulate activity -logger.log_detection_event("yes", 0.996, 3.64, "neutral", 0.015) -metrics_exporter.record_kws_latency(3.64) -metrics_exporter.record_wakeword_detection('yes') - -logger.log_safety_event("shutdown", "blocked", "safety_mode_active") -metrics_exporter.record_safety_block() - -print("✅ Production monitoring systems: OPERATIONAL") -print("📈 Metrics available at: http://localhost:8000") -print("📝 Logs writing to: logs/edgetinyml_*.log") -print("Press Ctrl+C to stop...") - -try: - while True: - import time - time.sleep(1) -except KeyboardInterrupt: - print("Monitoring test completed") +from production_logger import ProductionLogger +from system_metrics import metrics_exporter + +def run_monitoring_test(): + """Run production monitoring test""" + print("=== PRODUCTION MONITORING TEST ===") + + # Initialize monitoring + logger = ProductionLogger() + logger.log_system_event("monitoring_test", {"status": "initialized"}) + + # Start metrics server in background + import threading + def start_metrics(): + metrics_exporter.start_metrics_server() + + metrics_thread = threading.Thread(target=start_metrics, daemon=True) + metrics_thread.start() + + # Simulate activity + logger.log_detection_event("yes", 0.996, 3.64, "neutral", 0.015) + metrics_exporter.record_kws_latency(3.64) + metrics_exporter.record_wakeword_detection('yes') + + logger.log_safety_event("shutdown", "blocked", "safety_mode_active") + metrics_exporter.record_safety_block() + + print("✅ Production monitoring systems: OPERATIONAL") + print("📈 Metrics available at: http://localhost:8000") + print("📝 Logs writing to: logs/edgetinyml_*.log") + print("Test completed successfully!") + +if __name__ == "__main__": + run_monitoring_test() diff --git a/tests/perf/kws_advanced_optimization.py b/tests/perf/kws_advanced_optimization.py index 2375f99..f42c24f 100644 --- a/tests/perf/kws_advanced_optimization.py +++ b/tests/perf/kws_advanced_optimization.py @@ -1,4 +1,4 @@ -import time +import time import numpy as np import tensorflow as tf import os diff --git a/tests/perf/kws_detailed_analysis.py b/tests/perf/kws_detailed_analysis.py index 14fc121..6acd214 100644 --- a/tests/perf/kws_detailed_analysis.py +++ b/tests/perf/kws_detailed_analysis.py @@ -1,4 +1,4 @@ -import time +import time import numpy as np import tensorflow as tf diff --git a/tests/perf/kws_optimized_bench.py b/tests/perf/kws_optimized_bench.py index 4f62cb2..e1c352d 100644 --- a/tests/perf/kws_optimized_bench.py +++ b/tests/perf/kws_optimized_bench.py @@ -1,4 +1,4 @@ -import tensorflow as tf +import tensorflow as tf import time import os diff --git a/tests/perf/windows_optimized_bench.py b/tests/perf/windows_optimized_bench.py index 9391f7c..503ff10 100644 --- a/tests/perf/windows_optimized_bench.py +++ b/tests/perf/windows_optimized_bench.py @@ -1,4 +1,4 @@ -import tensorflow as tf +import tensorflow as tf import time import numpy as np diff --git a/tests/resilience/flood_test.py b/tests/resilience/flood_test.py index 7b4b921..f51a298 100644 --- a/tests/resilience/flood_test.py +++ b/tests/resilience/flood_test.py @@ -1,4 +1,4 @@ -import threading +import threading import time import random from concurrent.futures import ThreadPoolExecutor diff --git a/tests/resilience/time_warp_test.py b/tests/resilience/time_warp_test.py index b4d5831..41f0cc2 100644 --- a/tests/resilience/time_warp_test.py +++ b/tests/resilience/time_warp_test.py @@ -1,6 +1,12 @@ # tests/resilience/time_warp_test.py import time import datetime +import sys +import os + +# Add parent tests directory to path for imports +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + from system_metrics import ProductionLogger def test_time_changes(): diff --git a/tests/safety_gating.py b/tests/safety_gating.py index 7f59a74..f2b010b 100644 --- a/tests/safety_gating.py +++ b/tests/safety_gating.py @@ -1,4 +1,4 @@ -import time +import time class SafetyGatingSystem: def __init__(self): diff --git a/tests/security/command_injection_mass_test.py b/tests/security/command_injection_mass_test.py index 7b8395c..86ba14a 100644 --- a/tests/security/command_injection_mass_test.py +++ b/tests/security/command_injection_mass_test.py @@ -1,4 +1,10 @@ -import time +import time +import sys +import os + +# Add parent tests directory to path for imports +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + from safety_gating import SafetyGatingSystem def test_destructive_commands(): diff --git a/tests/security/file_corruption_test.py b/tests/security/file_corruption_test.py index 6057f28..fba5bc3 100644 --- a/tests/security/file_corruption_test.py +++ b/tests/security/file_corruption_test.py @@ -1,4 +1,4 @@ -import os +import os import shutil import time diff --git a/tests/security/security_validation.py b/tests/security/security_validation.py index 9862991..92f1ab6 100644 --- a/tests/security/security_validation.py +++ b/tests/security/security_validation.py @@ -1,4 +1,4 @@ -import sys +import sys import os sys.path.append('phase3_automation_phase4_cognitive/scripts') diff --git a/tests/security/test_safety_gating.py b/tests/security/test_safety_gating.py index 695081d..520f008 100644 --- a/tests/security/test_safety_gating.py +++ b/tests/security/test_safety_gating.py @@ -1,4 +1,4 @@ -import pytest +import pytest import os import sys sys.path.append('phase3_automation_phase4_cognitive/scripts') diff --git a/tests/stress/cpu_saturation_test.py b/tests/stress/cpu_saturation_test.py index 1ca4d25..76e293d 100644 --- a/tests/stress/cpu_saturation_test.py +++ b/tests/stress/cpu_saturation_test.py @@ -1,4 +1,4 @@ -import psutil +import psutil import threading import time import numpy as np diff --git a/tests/stress/disk_io_test.py b/tests/stress/disk_io_test.py index 25b0a69..2afcee7 100644 --- a/tests/stress/disk_io_test.py +++ b/tests/stress/disk_io_test.py @@ -1,4 +1,4 @@ -import threading +import threading import time import json import os @@ -35,6 +35,8 @@ def disk_writer(stop_event): def run_disk_io_test(duration_minutes=1): # Reduced duration print("🚨 STARTING DISK I/O OVERLOAD TEST") + import sys + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from system_metrics import ProductionLogger stop_event = threading.Event() diff --git a/tests/stress/memory_starvation_test.py b/tests/stress/memory_starvation_test.py index 6284867..e2a551b 100644 --- a/tests/stress/memory_starvation_test.py +++ b/tests/stress/memory_starvation_test.py @@ -1,4 +1,4 @@ -import psutil +import psutil import time import numpy as np diff --git a/tests/system_metrics.py b/tests/system_metrics.py index a098b73..9aa29d6 100644 --- a/tests/system_metrics.py +++ b/tests/system_metrics.py @@ -1,9 +1,28 @@ -import psutil +import psutil import time import json import os from datetime import datetime -from prometheus_client import start_http_server, Histogram, Counter, Gauge + +# Graceful prometheus_client handling +try: + from prometheus_client import start_http_server, Histogram, Counter, Gauge + HAS_PROMETHEUS = True +except ImportError: + HAS_PROMETHEUS = False + # Mock classes for when prometheus is not installed + class Histogram: + def __init__(self, *args, **kwargs): pass + def labels(self, **kwargs): return self + def observe(self, value): pass + class Counter: + def __init__(self, *args, **kwargs): pass + def labels(self, **kwargs): return self + def inc(self, value=1): pass + class Gauge: + def __init__(self, *args, **kwargs): pass + def set(self, value): pass + def start_http_server(port): pass class ProductionLogger: def __init__(self, log_dir="../logs"):