File size: 1,854 Bytes
d8d14f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import logging
import warnings
import concurrent.futures
from dotenv import load_dotenv
from loguru import logger
from swarms.utils.disable_logging import disable_logging


def bootup():
    """Initialize swarms environment and configuration

    Handles environment setup, logging configuration, telemetry,
    and workspace initialization.
    """
    try:
        # 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"

        # Configure workspace
        workspace_dir = os.path.join(os.getcwd(), "agent_workspace")
        os.makedirs(workspace_dir, exist_ok=True)
        os.environ["WORKSPACE_DIR"] = workspace_dir

        # Suppress warnings
        warnings.filterwarnings("ignore", category=DeprecationWarning)

        # 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:
        logger.error(f"Error during bootup: {str(e)}")
        raise


# Run bootup
bootup()