INNER CODE UNIT · Python
get_dynamic_executor_urls
pgalko/BambooAI · web_app/app.py:146
def get_dynamic_executor_urls(user_id: str) -> dict:
"""Get dynamic executor URLs for a specific user"""
if GLOBAL_EXECUTION_MODE == 'local':
return None # no executor: the kernel runs in a subprocess here
if DIRECT_EXECUTOR_URL:
return _executor_urls(DIRECT_EXECUTOR_URL) # one executor, named in .env, no orchestrator
if container_orchestrator is None:
logger.error("EXECUTION_MODE=api needs EXECUTOR_API_BASE_URL in this edition (no orchestrator is installed)")
return None
try:
user_compute_tier = get_user_compute_tier(user_id)
container_info = container_orchestrator.get_or_create_container(user_id, user_compute_tier)
if container_info["status"] == "ready":
base_url = f"http://{container_info['ip']}:{container_info['port']}"
return {
'EXECUTOR_API_BASE_URL': base_url,