Refactor CLI command imports to be more robust (issue #21) #26
@@ -9,13 +9,9 @@ import asyncio
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
from aitbc_cli.imports import ensure_coordinator_api_imports
|
||||
|
||||
# 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)
|
||||
ensure_coordinator_api_imports()
|
||||
|
||||
try:
|
||||
from app.services.advanced_analytics import (
|
||||
|
||||
@@ -9,13 +9,9 @@ import asyncio
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime
|
||||
from aitbc_cli.imports import ensure_coordinator_api_imports
|
||||
|
||||
# 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)
|
||||
ensure_coordinator_api_imports()
|
||||
|
||||
try:
|
||||
from app.services.ai_surveillance import (
|
||||
|
||||
@@ -9,13 +9,9 @@ import asyncio
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
from aitbc_cli.imports import ensure_coordinator_api_imports
|
||||
|
||||
# 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)
|
||||
ensure_coordinator_api_imports()
|
||||
|
||||
try:
|
||||
from app.services.ai_trading_engine import (
|
||||
|
||||
@@ -9,13 +9,9 @@ import asyncio
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime
|
||||
from aitbc_cli.imports import ensure_coordinator_api_imports
|
||||
|
||||
# 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)
|
||||
ensure_coordinator_api_imports()
|
||||
|
||||
try:
|
||||
from app.services.enterprise_integration import (
|
||||
|
||||
@@ -9,13 +9,9 @@ import asyncio
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
from aitbc_cli.imports import ensure_coordinator_api_imports
|
||||
|
||||
# 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)
|
||||
ensure_coordinator_api_imports()
|
||||
|
||||
try:
|
||||
from app.services.regulatory_reporting import (
|
||||
|
||||
@@ -9,13 +9,9 @@ import asyncio
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
from aitbc_cli.imports import ensure_coordinator_api_imports
|
||||
|
||||
# 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)
|
||||
ensure_coordinator_api_imports()
|
||||
|
||||
try:
|
||||
from app.services.trading_surveillance import (
|
||||
|
||||
10
cli/aitbc_cli/imports.py
Normal file
10
cli/aitbc_cli/imports.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""Import setup for AITBC CLI to access coordinator-api services."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
def ensure_coordinator_api_imports():
|
||||
"""Ensure coordinator-api src directory is on sys.path."""
|
||||
_src_path = Path(__file__).resolve().parent.parent.parent / 'apps' / 'coordinator-api' / 'src'
|
||||
if str(_src_path) not in sys.path:
|
||||
sys.path.insert(0, str(_src_path))
|
||||
Reference in New Issue
Block a user