chore: replace print() with proper logging; add jitter to automation
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (pull_request) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (pull_request) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (pull_request) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.11) (pull_request) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.12) (pull_request) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.13) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (pull_request) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (pull_request) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (pull_request) Has been cancelled
Security Scanning / Dependency Security Scan (pull_request) Has been cancelled
Security Scanning / Container Security Scan (pull_request) Has been cancelled
Security Scanning / OSSF Scorecard (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-cli (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-services (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (pull_request) Has been cancelled
AITBC CI/CD Pipeline / security-scan (pull_request) Has been cancelled
AITBC CI/CD Pipeline / build (pull_request) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (pull_request) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (pull_request) Has been cancelled
AITBC CI/CD Pipeline / performance-test (pull_request) Has been cancelled
AITBC CI/CD Pipeline / docs (pull_request) Has been cancelled
AITBC CI/CD Pipeline / release (pull_request) Has been cancelled
AITBC CI/CD Pipeline / notify (pull_request) Has been cancelled
AITBC CLI Level 1 Commands Test / test-summary (pull_request) Has been cancelled
Security Scanning / Security Summary Report (pull_request) Has been cancelled

- CLI commands: replace print with click.echo (ensures proper stdout handling)
- Coordinator API services: add logging import and logger; replace print with logger.info
- Automation scripts: claim-task.py, monitor-prs.py, qa-cycle.py now use logging and have random jitter at startup
- Also includes fix for name shadowing in regulatory.py (aliased service imports) which was pending

This addresses issue #23 (print statements) and improves error handling.

Note: Many bare except clauses (issue #20) remain; will be addressed separately.
This commit is contained in:
2026-03-15 19:01:56 +00:00
parent c390ba07c1
commit dc547a506a
23 changed files with 500 additions and 72 deletions

View File

@@ -591,28 +591,28 @@ def get_analytics_summary() -> Dict[str, Any]:
# Test function
async def test_advanced_analytics():
"""Test advanced analytics platform"""
print("📊 Testing Advanced Analytics Platform...")
logger.info("📊 Testing Advanced Analytics Platform...")
# Start monitoring
await start_analytics_monitoring(["BTC/USDT", "ETH/USDT"])
print("✅ Analytics monitoring started")
logger.info("✅ Analytics monitoring started")
# Let it run for a few seconds to generate data
await asyncio.sleep(5)
# Get dashboard data
dashboard = get_dashboard_data("BTC/USDT")
print(f"📈 Dashboard data: {len(dashboard)} fields")
logger.info(f"📈 Dashboard data: {len(dashboard)} fields")
# Get summary
summary = get_analytics_summary()
print(f"📊 Analytics summary: {summary}")
logger.info(f"📊 Analytics summary: {summary}")
# Stop monitoring
await stop_analytics_monitoring()
print("📊 Analytics monitoring stopped")
logger.info("📊 Analytics monitoring stopped")
print("🎉 Advanced Analytics test complete!")
logger.info("🎉 Advanced Analytics test complete!")
if __name__ == "__main__":
asyncio.run(test_advanced_analytics())

View File

@@ -695,32 +695,32 @@ def analyze_behavior_patterns(user_id: str = None) -> Dict[str, Any]:
# Test function
async def test_ai_surveillance():
"""Test AI surveillance system"""
print("🤖 Testing AI Surveillance System...")
logger.info("🤖 Testing AI Surveillance System...")
# Start surveillance
await start_ai_surveillance(["BTC/USDT", "ETH/USDT"])
print("✅ AI surveillance started")
logger.info("✅ AI surveillance started")
# Let it run for data collection
await asyncio.sleep(5)
# Get summary
summary = get_surveillance_summary()
print(f"📊 Surveillance summary: {summary}")
logger.info(f"📊 Surveillance summary: {summary}")
# Get alerts
alerts = list_active_alerts()
print(f"🚨 Active alerts: {len(alerts)}")
logger.info(f"🚨 Active alerts: {len(alerts)}")
# Analyze patterns
patterns = analyze_behavior_patterns()
print(f"🔍 Behavior patterns: {patterns}")
logger.info(f"🔍 Behavior patterns: {patterns}")
# Stop surveillance
await stop_ai_surveillance()
print("🔍 AI surveillance stopped")
logger.info("🔍 AI surveillance stopped")
print("🎉 AI Surveillance test complete!")
logger.info("🎉 AI Surveillance test complete!")
if __name__ == "__main__":
asyncio.run(test_ai_surveillance())

View File

@@ -609,27 +609,27 @@ def get_engine_status() -> Dict[str, Any]:
# Test function
async def test_ai_trading_engine():
"""Test AI trading engine"""
print("🤖 Testing AI Trading Engine...")
logger.info("🤖 Testing AI Trading Engine...")
# Initialize engine
await initialize_ai_engine()
# Train strategies
success = await train_strategies("BTC/USDT", 30)
print(f"✅ Training successful: {success}")
logger.info(f"✅ Training successful: {success}")
# Generate signals
signals = await generate_trading_signals("BTC/USDT")
print(f"📈 Generated {len(signals)} signals")
logger.info(f"📈 Generated {len(signals)} signals")
for signal in signals:
print(f" {signal['strategy']}: {signal['signal_type']} (confidence: {signal['confidence']:.2f})")
logger.info(f" {signal['strategy']}: {signal['signal_type']} (confidence: {signal['confidence']:.2f})")
# Get status
status = get_engine_status()
print(f"📊 Engine Status: {status}")
logger.info(f"📊 Engine Status: {status}")
print("🎉 AI Trading Engine test complete!")
logger.info("🎉 AI Trading Engine test complete!")
if __name__ == "__main__":
asyncio.run(test_ai_trading_engine())

View File

@@ -1,3 +1,5 @@
import logging
logger = logging.getLogger(__name__)
#!/usr/bin/env python3
"""
Bitcoin Wallet Integration for AITBC Exchange
@@ -146,4 +148,4 @@ def get_wallet_info() -> Dict[str, any]:
if __name__ == "__main__":
# Test the wallet integration
info = get_wallet_info()
print(json.dumps(info, indent=2))
logger.info(json.dumps(info, indent=2))

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import logging
import httpx
from collections import defaultdict, deque
from datetime import datetime
@@ -21,6 +22,8 @@ from ..schemas import (
JobState,
)
logger = logging.getLogger(__name__)
_STATUS_LABELS = {
JobState.queued: "Queued",
JobState.running: "Running",
@@ -81,7 +84,7 @@ class ExplorerService:
return BlockListResponse(items=items, next_offset=next_offset)
except Exception as e:
# Fallback to fake data if RPC is unavailable
print(f"Warning: Failed to fetch blocks from RPC: {e}, falling back to fake data")
logger.warning(f"Failed to fetch blocks from RPC: {e}, falling back to fake data")
statement = select(Job).order_by(Job.requested_at.desc())
jobs = self.session.execute(statement.offset(offset).limit(limit)).all()

View File

@@ -397,7 +397,7 @@ async def perform_aml_screening(user_id: str, user_data: Dict[str, Any]) -> Dict
# Test function
async def test_kyc_aml_integration():
"""Test KYC/AML integration"""
print("🧪 Testing KYC/AML Integration...")
logger.info("🧪 Testing KYC/AML Integration...")
# Test KYC submission
customer_data = {
@@ -408,17 +408,17 @@ async def test_kyc_aml_integration():
}
kyc_result = await submit_kyc_verification("user123", "chainalysis", customer_data)
print(f"✅ KYC Submitted: {kyc_result}")
logger.info(f"✅ KYC Submitted: {kyc_result}")
# Test KYC status check
kyc_status = await check_kyc_status(kyc_result["request_id"], "chainalysis")
print(f"📋 KYC Status: {kyc_status}")
logger.info(f"📋 KYC Status: {kyc_status}")
# Test AML screening
aml_result = await perform_aml_screening("user123", customer_data)
print(f"🔍 AML Screening: {aml_result}")
logger.info(f"🔍 AML Screening: {aml_result}")
print("🎉 KYC/AML integration test complete!")
logger.info("🎉 KYC/AML integration test complete!")
if __name__ == "__main__":
asyncio.run(test_kyc_aml_integration())

View File

@@ -1,3 +1,5 @@
import logging
logger = logging.getLogger(__name__)
"""
Python 3.13.5 Optimized Services for AITBC Coordinator API
@@ -313,19 +315,19 @@ class ServiceFactory:
async def demonstrate_optimized_services():
"""Demonstrate optimized services usage"""
print("🚀 Python 3.13.5 Optimized Services Demo")
print("=" * 50)
logger.info("🚀 Python 3.13.5 Optimized Services Demo")
logger.info("=" * 50)
# This would be used in actual application code
print("\n✅ Services ready for Python 3.13.5 deployment:")
print(" - OptimizedJobService with batch processing")
print(" - OptimizedMinerService with enhanced validation")
print(" - SecurityEnhancedService with improved hashing")
print(" - PerformanceMonitor with real-time metrics")
print(" - Generic base classes with type safety")
print(" - @override decorators for method safety")
print(" - Enhanced error messages for debugging")
print(" - 5-10% performance improvements")
logger.info("\n✅ Services ready for Python 3.13.5 deployment:")
logger.info(" - OptimizedJobService with batch processing")
logger.info(" - OptimizedMinerService with enhanced validation")
logger.info(" - SecurityEnhancedService with improved hashing")
logger.info(" - PerformanceMonitor with real-time metrics")
logger.info(" - Generic base classes with type safety")
logger.info(" - @override decorators for method safety")
logger.info(" - Enhanced error messages for debugging")
logger.info(" - 5-10% performance improvements")
if __name__ == "__main__":
asyncio.run(demonstrate_optimized_services())

View File

@@ -736,7 +736,7 @@ def list_reports(report_type: Optional[str] = None, status: Optional[str] = None
# Test function
async def test_regulatory_reporting():
"""Test regulatory reporting system"""
print("🧪 Testing Regulatory Reporting System...")
logger.info("🧪 Testing Regulatory Reporting System...")
# Test SAR generation
activities = [
@@ -755,20 +755,20 @@ async def test_regulatory_reporting():
]
sar_result = await generate_sar(activities)
print(f"✅ SAR Report Generated: {sar_result['report_id']}")
logger.info(f"✅ SAR Report Generated: {sar_result['report_id']}")
# Test compliance summary
compliance_result = await generate_compliance_summary(
"2026-01-01T00:00:00",
"2026-01-31T23:59:59"
)
print(f"✅ Compliance Summary Generated: {compliance_result['report_id']}")
logger.info(f"✅ Compliance Summary Generated: {compliance_result['report_id']}")
# List reports
reports = list_reports()
print(f"📋 Total Reports: {len(reports)}")
logger.info(f"📋 Total Reports: {len(reports)}")
print("🎉 Regulatory reporting test complete!")
logger.info("🎉 Regulatory reporting test complete!")
if __name__ == "__main__":
asyncio.run(test_regulatory_reporting())

View File

@@ -516,28 +516,28 @@ def get_surveillance_summary() -> Dict[str, Any]:
# Test function
async def test_trading_surveillance():
"""Test trading surveillance system"""
print("🧪 Testing Trading Surveillance System...")
logger.info("🧪 Testing Trading Surveillance System...")
# Start monitoring
await start_surveillance(["BTC/USDT", "ETH/USDT"])
print("✅ Surveillance started")
logger.info("✅ Surveillance started")
# Let it run for a few seconds to generate alerts
await asyncio.sleep(5)
# Get alerts
alerts = get_alerts()
print(f"🚨 Generated {alerts['total']} alerts")
logger.info(f"🚨 Generated {alerts['total']} alerts")
# Get summary
summary = get_surveillance_summary()
print(f"📊 Alert Summary: {summary}")
logger.info(f"📊 Alert Summary: {summary}")
# Stop monitoring
await stop_surveillance()
print("🔍 Surveillance stopped")
logger.info("🔍 Surveillance stopped")
print("🎉 Trading surveillance test complete!")
logger.info("🎉 Trading surveillance test complete!")
if __name__ == "__main__":
asyncio.run(test_trading_surveillance())