fix: resolve CLI service imports and update blockchain documentation
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
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
- Add proper package imports for coordinator-api services - Fix 6 command modules to use app.services.* with clean path resolution - Remove brittle path hacks and user-specific fallbacks - Update blockchain-node README with operational status, API endpoints, and troubleshooting - Add blockchain section to main README with quick launch and CLI examples - Remove generated genesis.json from repository (should be ignored) These changes fix import errors in surveillance, ai-trading, ai-surveillance, advanced-analytics, regulatory, and enterprise-integration commands, and document the now-operational Brother Chain (blockchain node). Co-authored with sibling aitbc instance (coordination via Gitea).
This commit is contained in:
@@ -10,29 +10,15 @@ import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Import advanced analytics with robust path resolution
|
||||
# Ensure coordinator-api src is on path for app.services imports
|
||||
import os
|
||||
import sys
|
||||
|
||||
_services_path = os.environ.get('AITBC_SERVICES_PATH')
|
||||
if _services_path:
|
||||
if os.path.isdir(_services_path):
|
||||
if _services_path not in sys.path:
|
||||
sys.path.insert(0, _services_path)
|
||||
else:
|
||||
print(f"Warning: AITBC_SERVICES_PATH set but not a directory: {_services_path}", file=sys.stderr)
|
||||
else:
|
||||
_project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||
_computed_services = os.path.join(_project_root, 'apps', 'coordinator-api', 'src', 'app', 'services')
|
||||
if os.path.isdir(_computed_services) and _computed_services not in sys.path:
|
||||
sys.path.insert(0, _computed_services)
|
||||
else:
|
||||
_fallback = '/home/oib/windsurf/aitbc/apps/coordinator-api/src/app/services'
|
||||
if os.path.isdir(_fallback) and _fallback not in sys.path:
|
||||
sys.path.insert(0, _fallback)
|
||||
_src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'apps', 'coordinator-api', 'src'))
|
||||
if _src_path not in sys.path:
|
||||
sys.path.insert(0, _src_path)
|
||||
|
||||
try:
|
||||
from advanced_analytics import (
|
||||
from app.services.advanced_analytics import (
|
||||
start_analytics_monitoring, stop_analytics_monitoring, get_dashboard_data,
|
||||
create_analytics_alert, get_analytics_summary, advanced_analytics,
|
||||
MetricType, Timeframe
|
||||
@@ -43,8 +29,8 @@ except ImportError as e:
|
||||
|
||||
def _missing(*args, **kwargs):
|
||||
raise ImportError(
|
||||
f"Required service module 'advanced_analytics' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed or set AITBC_SERVICES_PATH."
|
||||
f"Required service module 'app.services.advanced_analytics' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed and the source directory is accessible."
|
||||
)
|
||||
start_analytics_monitoring = stop_analytics_monitoring = get_dashboard_data = _missing
|
||||
create_analytics_alert = get_analytics_summary = _missing
|
||||
|
||||
@@ -10,29 +10,15 @@ import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime
|
||||
|
||||
# Import AI surveillance system with robust path resolution
|
||||
# Ensure coordinator-api src is on path for app.services imports
|
||||
import os
|
||||
import sys
|
||||
|
||||
_services_path = os.environ.get('AITBC_SERVICES_PATH')
|
||||
if _services_path:
|
||||
if os.path.isdir(_services_path):
|
||||
if _services_path not in sys.path:
|
||||
sys.path.insert(0, _services_path)
|
||||
else:
|
||||
print(f"Warning: AITBC_SERVICES_PATH set but not a directory: {_services_path}", file=sys.stderr)
|
||||
else:
|
||||
_project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||
_computed_services = os.path.join(_project_root, 'apps', 'coordinator-api', 'src', 'app', 'services')
|
||||
if os.path.isdir(_computed_services) and _computed_services not in sys.path:
|
||||
sys.path.insert(0, _computed_services)
|
||||
else:
|
||||
_fallback = '/home/oib/windsurf/aitbc/apps/coordinator-api/src/app/services'
|
||||
if os.path.isdir(_fallback) and _fallback not in sys.path:
|
||||
sys.path.insert(0, _fallback)
|
||||
_src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'apps', 'coordinator-api', 'src'))
|
||||
if _src_path not in sys.path:
|
||||
sys.path.insert(0, _src_path)
|
||||
|
||||
try:
|
||||
from ai_surveillance import (
|
||||
from app.services.ai_surveillance import (
|
||||
start_ai_surveillance, stop_ai_surveillance, get_surveillance_summary,
|
||||
get_user_risk_profile, list_active_alerts, analyze_behavior_patterns,
|
||||
ai_surveillance, SurveillanceType, RiskLevel, AlertPriority
|
||||
@@ -43,8 +29,8 @@ except ImportError as e:
|
||||
|
||||
def _missing(*args, **kwargs):
|
||||
raise ImportError(
|
||||
f"Required service module 'ai_surveillance' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed or set AITBC_SERVICES_PATH."
|
||||
f"Required service module 'app.services.ai_surveillance' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed and the source directory is accessible."
|
||||
)
|
||||
start_ai_surveillance = stop_ai_surveillance = get_surveillance_summary = _missing
|
||||
get_user_risk_profile = list_active_alerts = analyze_behavior_patterns = _missing
|
||||
|
||||
@@ -10,29 +10,15 @@ import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Import AI trading engine with robust path resolution
|
||||
# Ensure coordinator-api src is on path for app.services imports
|
||||
import os
|
||||
import sys
|
||||
|
||||
_services_path = os.environ.get('AITBC_SERVICES_PATH')
|
||||
if _services_path:
|
||||
if os.path.isdir(_services_path):
|
||||
if _services_path not in sys.path:
|
||||
sys.path.insert(0, _services_path)
|
||||
else:
|
||||
print(f"Warning: AITBC_SERVICES_PATH set but not a directory: {_services_path}", file=sys.stderr)
|
||||
else:
|
||||
_project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||
_computed_services = os.path.join(_project_root, 'apps', 'coordinator-api', 'src', 'app', 'services')
|
||||
if os.path.isdir(_computed_services) and _computed_services not in sys.path:
|
||||
sys.path.insert(0, _computed_services)
|
||||
else:
|
||||
_fallback = '/home/oib/windsurf/aitbc/apps/coordinator-api/src/app/services'
|
||||
if os.path.isdir(_fallback) and _fallback not in sys.path:
|
||||
sys.path.insert(0, _fallback)
|
||||
_src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'apps', 'coordinator-api', 'src'))
|
||||
if _src_path not in sys.path:
|
||||
sys.path.insert(0, _src_path)
|
||||
|
||||
try:
|
||||
from ai_trading_engine import (
|
||||
from app.services.ai_trading_engine import (
|
||||
initialize_ai_engine, train_strategies, generate_trading_signals,
|
||||
get_engine_status, ai_trading_engine, TradingStrategy
|
||||
)
|
||||
@@ -42,8 +28,8 @@ except ImportError as e:
|
||||
|
||||
def _missing(*args, **kwargs):
|
||||
raise ImportError(
|
||||
f"Required service module 'ai_trading_engine' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed or set AITBC_SERVICES_PATH."
|
||||
f"Required service module 'app.services.ai_trading_engine' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed and the source directory is accessible."
|
||||
)
|
||||
initialize_ai_engine = train_strategies = generate_trading_signals = get_engine_status = _missing
|
||||
ai_trading_engine = None
|
||||
|
||||
@@ -10,41 +10,32 @@ import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime
|
||||
|
||||
# Import enterprise integration services using importlib to avoid naming conflicts
|
||||
import importlib.util
|
||||
# Ensure coordinator-api src is on path for app.services imports
|
||||
import os
|
||||
import sys
|
||||
_src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'apps', 'coordinator-api', 'src'))
|
||||
if _src_path not in sys.path:
|
||||
sys.path.insert(0, _src_path)
|
||||
|
||||
_services_path = os.environ.get('AITBC_SERVICES_PATH')
|
||||
if _services_path:
|
||||
base_dir = _services_path
|
||||
else:
|
||||
_project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||
base_dir = os.path.join(_project_root, 'apps', 'coordinator-api', 'src', 'app', 'services')
|
||||
if not os.path.isdir(base_dir):
|
||||
base_dir = '/home/oib/windsurf/aitbc/apps/coordinator-api/src/app/services'
|
||||
try:
|
||||
from app.services.enterprise_integration import (
|
||||
create_tenant, get_tenant_info, generate_api_key,
|
||||
register_integration, get_system_status, list_tenants,
|
||||
list_integrations
|
||||
)
|
||||
# Get EnterpriseAPIGateway if available
|
||||
import app.services.enterprise_integration as ei_module
|
||||
EnterpriseAPIGateway = getattr(ei_module, 'EnterpriseAPIGateway', None)
|
||||
_import_error = None
|
||||
except ImportError as e:
|
||||
_import_error = e
|
||||
|
||||
module_path = os.path.join(base_dir, 'enterprise_integration.py')
|
||||
if os.path.isfile(module_path):
|
||||
spec = importlib.util.spec_from_file_location("enterprise_integration_service", module_path)
|
||||
ei = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(ei)
|
||||
create_tenant = ei.create_tenant
|
||||
get_tenant_info = ei.get_tenant_info
|
||||
generate_api_key = ei.generate_api_key
|
||||
register_integration = ei.register_integration
|
||||
get_system_status = ei.get_system_status
|
||||
list_tenants = ei.list_tenants
|
||||
list_integrations = ei.list_integrations
|
||||
EnterpriseAPIGateway = getattr(ei, 'EnterpriseAPIGateway', None)
|
||||
else:
|
||||
# Provide stubs if module not found
|
||||
def _missing(*args, **kwargs):
|
||||
raise ImportError(
|
||||
f"Could not load enterprise_integration.py from {module_path}. "
|
||||
"Ensure coordinator-api services are available or set AITBC_SERVICES_PATH."
|
||||
f"Required service module 'app.services.enterprise_integration' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed and the source directory is accessible."
|
||||
)
|
||||
create_tenant = get_tenant_info = generate_api_key = _missing
|
||||
register_integration = get_system_status = list_tenants = list_integrations = _missing
|
||||
create_tenant = get_tenant_info = generate_api_key = register_integration = get_system_status = list_tenants = list_integrations = _missing
|
||||
EnterpriseAPIGateway = None
|
||||
|
||||
@click.group()
|
||||
|
||||
@@ -10,36 +10,17 @@ import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Import regulatory reporting system with robust path resolution
|
||||
# Ensure coordinator-api src is on path for app.services imports
|
||||
import os
|
||||
import sys
|
||||
|
||||
_services_path = os.environ.get('AITBC_SERVICES_PATH')
|
||||
if _services_path:
|
||||
if os.path.isdir(_services_path):
|
||||
if _services_path not in sys.path:
|
||||
sys.path.insert(0, _services_path)
|
||||
else:
|
||||
print(f"Warning: AITBC_SERVICES_PATH set but not a directory: {_services_path}", file=sys.stderr)
|
||||
else:
|
||||
_project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||
_computed_services = os.path.join(_project_root, 'apps', 'coordinator-api', 'src', 'app', 'services')
|
||||
if os.path.isdir(_computed_services) and _computed_services not in sys.path:
|
||||
sys.path.insert(0, _computed_services)
|
||||
else:
|
||||
_fallback = '/home/oib/windsurf/aitbc/apps/coordinator-api/src/app/services'
|
||||
if os.path.isdir(_fallback) and _fallback not in sys.path:
|
||||
sys.path.insert(0, _fallback)
|
||||
_src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'apps', 'coordinator-api', 'src'))
|
||||
if _src_path not in sys.path:
|
||||
sys.path.insert(0, _src_path)
|
||||
|
||||
try:
|
||||
from regulatory_reporting import (
|
||||
generate_sar as generate_sar_svc,
|
||||
generate_compliance_summary as generate_compliance_summary_svc,
|
||||
list_reports as list_reports_svc,
|
||||
regulatory_reporter,
|
||||
ReportType,
|
||||
ReportStatus,
|
||||
RegulatoryBody
|
||||
from app.services.regulatory_reporting import (
|
||||
generate_sar, generate_compliance_summary, list_reports,
|
||||
regulatory_reporter, ReportType, ReportStatus, RegulatoryBody
|
||||
)
|
||||
_import_error = None
|
||||
except ImportError as e:
|
||||
@@ -47,10 +28,10 @@ except ImportError as e:
|
||||
|
||||
def _missing(*args, **kwargs):
|
||||
raise ImportError(
|
||||
f"Required service module 'regulatory_reporting' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed or set AITBC_SERVICES_PATH."
|
||||
f"Required service module 'app.services.regulatory_reporting' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed and the source directory is accessible."
|
||||
)
|
||||
generate_sar_svc = generate_compliance_summary_svc = list_reports_svc = regulatory_reporter = _missing
|
||||
generate_sar = generate_compliance_summary = list_reports = regulatory_reporter = _missing
|
||||
|
||||
class ReportType:
|
||||
pass
|
||||
@@ -96,7 +77,7 @@ def generate_sar(ctx, user_id: str, activity_type: str, amount: float, descripti
|
||||
}
|
||||
|
||||
# Generate SAR
|
||||
result = asyncio.run(generate_sar_svc([activity]))
|
||||
result = asyncio.run(generate_sar([activity]))
|
||||
|
||||
click.echo(f"\n✅ SAR Report Generated Successfully!")
|
||||
click.echo(f"📋 Report ID: {result['report_id']}")
|
||||
@@ -129,7 +110,7 @@ def compliance_summary(ctx, period_start: str, period_end: str):
|
||||
click.echo(f"📈 Duration: {(end_date - start_date).days} days")
|
||||
|
||||
# Generate compliance summary
|
||||
result = asyncio.run(generate_compliance_summary_svc(
|
||||
result = asyncio.run(generate_compliance_summary(
|
||||
start_date.isoformat(),
|
||||
end_date.isoformat()
|
||||
))
|
||||
@@ -174,7 +155,7 @@ def list(ctx, report_type: str, status: str, limit: int):
|
||||
try:
|
||||
click.echo(f"📋 Regulatory Reports")
|
||||
|
||||
reports = list_reports_svc(report_type, status)
|
||||
reports = list_reports(report_type, status)
|
||||
|
||||
if not reports:
|
||||
click.echo(f"✅ No reports found")
|
||||
@@ -459,7 +440,7 @@ def test(ctx, period_start: str, period_end: str):
|
||||
|
||||
# Test SAR generation
|
||||
click.echo(f"\n📋 Test 1: SAR Generation")
|
||||
result = asyncio.run(generate_sar_svc([{
|
||||
result = asyncio.run(generate_sar([{
|
||||
"id": "test_sar_001",
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"user_id": "test_user_123",
|
||||
@@ -476,13 +457,13 @@ def test(ctx, period_start: str, period_end: str):
|
||||
|
||||
# Test compliance summary
|
||||
click.echo(f"\n📊 Test 2: Compliance Summary")
|
||||
compliance_result = asyncio.run(generate_compliance_summary_svc(period_start, period_end))
|
||||
compliance_result = asyncio.run(generate_compliance_summary(period_start, period_end))
|
||||
click.echo(f" ✅ Compliance Summary: {compliance_result['report_id']}")
|
||||
click.echo(f" 📈 Overall Score: {compliance_result['overall_score']:.1%}")
|
||||
|
||||
# Test report listing
|
||||
click.echo(f"\n📋 Test 3: Report Listing")
|
||||
reports = list_reports_svc()
|
||||
reports = list_reports()
|
||||
click.echo(f" ✅ Total Reports: {len(reports)}")
|
||||
|
||||
# Test export
|
||||
|
||||
@@ -10,33 +10,16 @@ import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Import surveillance system with robust path resolution
|
||||
# Ensure coordinator-api src is on path for app.services imports
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Determine services path: use AITBC_SERVICES_PATH if set, else compute relative to repo layout
|
||||
_services_path = os.environ.get('AITBC_SERVICES_PATH')
|
||||
if _services_path:
|
||||
if os.path.isdir(_services_path):
|
||||
if _services_path not in sys.path:
|
||||
sys.path.insert(0, _services_path)
|
||||
else:
|
||||
print(f"Warning: AITBC_SERVICES_PATH set but not a directory: {_services_path}", file=sys.stderr)
|
||||
else:
|
||||
# Compute project root relative to this file: cli/aitbc_cli/commands -> 3 levels up to project root
|
||||
_project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||
_computed_services = os.path.join(_project_root, 'apps', 'coordinator-api', 'src', 'app', 'services')
|
||||
if os.path.isdir(_computed_services) and _computed_services not in sys.path:
|
||||
sys.path.insert(0, _computed_services)
|
||||
else:
|
||||
# Fallback to known hardcoded path if it exists (for legacy deployments)
|
||||
_fallback = '/home/oib/windsurf/aitbc/apps/coordinator-api/src/app/services'
|
||||
if os.path.isdir(_fallback) and _fallback not in sys.path:
|
||||
sys.path.insert(0, _fallback)
|
||||
_src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'apps', 'coordinator-api', 'src'))
|
||||
if _src_path not in sys.path:
|
||||
sys.path.insert(0, _src_path)
|
||||
|
||||
try:
|
||||
from trading_surveillance import (
|
||||
start_surveillance, stop_surveillance, get_alerts,
|
||||
from app.services.trading_surveillance import (
|
||||
start_surveillance, stop_surveillance, get_alerts,
|
||||
get_surveillance_summary, AlertLevel
|
||||
)
|
||||
_import_error = None
|
||||
@@ -45,8 +28,8 @@ except ImportError as e:
|
||||
|
||||
def _missing(*args, **kwargs):
|
||||
raise ImportError(
|
||||
f"Required service module 'trading_surveillance' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed or set AITBC_SERVICES_PATH."
|
||||
f"Required service module 'app.services.trading_surveillance' could not be imported: {_import_error}. "
|
||||
"Ensure coordinator-api dependencies are installed and the source directory is accessible."
|
||||
)
|
||||
start_surveillance = stop_surveillance = get_alerts = get_surveillance_summary = _missing
|
||||
|
||||
@@ -237,7 +220,7 @@ def resolve(ctx, alert_id: str, resolution: str):
|
||||
click.echo(f"🔍 Resolving alert: {alert_id}")
|
||||
|
||||
# Import surveillance to access resolve function
|
||||
from trading_surveillance import surveillance
|
||||
from app.services.trading_surveillance import surveillance
|
||||
|
||||
success = surveillance.resolve_alert(alert_id, resolution)
|
||||
|
||||
@@ -263,7 +246,7 @@ def test(ctx, symbols: str, duration: int):
|
||||
click.echo(f"⏱️ Duration: {duration} seconds")
|
||||
|
||||
# Import test function
|
||||
from trading_surveillance import test_trading_surveillance
|
||||
from app.services.trading_surveillance import test_trading_surveillance
|
||||
|
||||
# Run test
|
||||
asyncio.run(test_trading_surveillance())
|
||||
@@ -289,7 +272,7 @@ def test(ctx, symbols: str, duration: int):
|
||||
def status(ctx):
|
||||
"""Show current surveillance status"""
|
||||
try:
|
||||
from trading_surveillance import surveillance
|
||||
from app.services.trading_surveillance import surveillance
|
||||
|
||||
click.echo(f"📊 Trading Surveillance Status")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user