pull/703/head
Kye Gomez 4 months ago committed by mike dupont
parent f6afc40817
commit 135b02a812

@ -20,7 +20,16 @@ logger = logging.getLogger(__name__)
from typing import Dict, Optional, Tuple from typing import Dict, Optional, Tuple
from uuid import UUID from uuid import UUID
BASE_URL = "http://0.0.0.0:8000/v1" # Set up logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler("api_tests.log"),
logging.StreamHandler(),
],
)
logger = logging.getLogger(__name__)
# Configuration # Configuration
@dataclass @dataclass
@ -136,9 +145,6 @@ class TestRunner:
logger.info(f"\nRunning test: {test_name}") logger.info(f"\nRunning test: {test_name}")
start_time = time.time() start_time = time.time()
<<<<<<< HEAD
=======
def create_test_user(session: TestSession) -> Tuple[bool, str]: def create_test_user(session: TestSession) -> Tuple[bool, str]:
"""Create a test user and store credentials in session.""" """Create a test user and store credentials in session."""
logger.info("Creating test user") logger.info("Creating test user")

@ -2422,22 +2422,15 @@ class Agent:
if self.llm is None: if self.llm is None:
raise TypeError("LLM object cannot be None") raise TypeError("LLM object cannot be None")
# Define common method names for LLM interfaces
method_names = ["run", "__call__", "generate", "invoke"]
for method_name in method_names:
if hasattr(self.llm, method_name):
try: try:
method = getattr(self.llm, method_name) out = self.llm.run(task, *args, **kwargs)
return method(task, *args, **kwargs)
except Exception as e:
raise RuntimeError(
f"Error calling {method_name}: {str(e)}"
)
raise AttributeError( return out
f"No suitable method found in the llm object. Expected one of: {method_names}" except AttributeError as e:
logger.error(
f"Error calling LLM: {e} You need a class with a run(task: str) method"
) )
raise e
def handle_sop_ops(self): def handle_sop_ops(self):
# If the user inputs a list of strings for the sop then join them and set the sop # If the user inputs a list of strings for the sop then join them and set the sop

@ -1,27 +1,65 @@
import os import os
import logging import logging
import warnings 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 from swarms.utils.disable_logging import disable_logging
def bootup(): def bootup():
"""Bootup swarms""" """Initialize swarms environment and configuration
Handles environment setup, logging configuration, telemetry,
and workspace initialization.
"""
try: try:
# Load environment variables
load_dotenv()
# Configure logging
if (
os.getenv("SWARMS_VERBOSE_GLOBAL", "False").lower()
== "false"
):
logger.disable("")
logging.disable(logging.CRITICAL) logging.disable(logging.CRITICAL)
# Silent wandb
os.environ["WANDB_SILENT"] = "true" os.environ["WANDB_SILENT"] = "true"
# Auto set workspace directory # Configure workspace
workspace_dir = os.path.join(os.getcwd(), "agent_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 os.environ["WORKSPACE_DIR"] = workspace_dir
# Suppress warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings("ignore", category=DeprecationWarning)
# Use ThreadPoolExecutor to run disable_logging and auto_update concurrently # Run telemetry functions concurrently
with ThreadPoolExecutor(max_workers=1) as executor: try:
executor.submit(disable_logging) 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: except Exception as e:
print(f"An error occurred: {str(e)}") logger.error(f"Error during bootup: {str(e)}")
raise raise
# Run bootup
bootup()

Loading…
Cancel
Save