parent
f6afc40817
commit
135b02a812
@ -1,27 +1,65 @@
|
||||
import os
|
||||
import logging
|
||||
import warnings
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import concurrent.futures
|
||||
from dotenv import load_dotenv
|
||||
from loguru import logger
|
||||
from swarms.utils.disable_logging import disable_logging
|
||||
|
||||
|
||||
def bootup():
|
||||
"""Bootup swarms"""
|
||||
"""Initialize swarms environment and configuration
|
||||
|
||||
Handles environment setup, logging configuration, telemetry,
|
||||
and workspace initialization.
|
||||
"""
|
||||
try:
|
||||
logging.disable(logging.CRITICAL)
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
# Configure logging
|
||||
if (
|
||||
os.getenv("SWARMS_VERBOSE_GLOBAL", "False").lower()
|
||||
== "false"
|
||||
):
|
||||
logger.disable("")
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
# Silent wandb
|
||||
os.environ["WANDB_SILENT"] = "true"
|
||||
|
||||
# Auto set workspace directory
|
||||
# Configure workspace
|
||||
workspace_dir = os.path.join(os.getcwd(), "agent_workspace")
|
||||
if not os.path.exists(workspace_dir):
|
||||
os.makedirs(workspace_dir, exist_ok=True)
|
||||
os.makedirs(workspace_dir, exist_ok=True)
|
||||
os.environ["WORKSPACE_DIR"] = workspace_dir
|
||||
|
||||
# Suppress warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
# Use ThreadPoolExecutor to run disable_logging and auto_update concurrently
|
||||
with ThreadPoolExecutor(max_workers=1) as executor:
|
||||
executor.submit(disable_logging)
|
||||
# Run telemetry functions concurrently
|
||||
try:
|
||||
with concurrent.futures.ThreadPoolExecutor(
|
||||
max_workers=2
|
||||
) as executor:
|
||||
from swarms.telemetry.sentry_active import (
|
||||
activate_sentry,
|
||||
)
|
||||
|
||||
future_disable_logging = executor.submit(
|
||||
disable_logging
|
||||
)
|
||||
future_sentry = executor.submit(activate_sentry)
|
||||
|
||||
# Wait for completion and check for exceptions
|
||||
future_disable_logging.result()
|
||||
future_sentry.result()
|
||||
except Exception as e:
|
||||
logger.error(f"Error running telemetry functions: {e}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {str(e)}")
|
||||
logger.error(f"Error during bootup: {str(e)}")
|
||||
raise
|
||||
|
||||
|
||||
# Run bootup
|
||||
bootup()
|
||||
|
Loading…
Reference in new issue