Skip to content

Commit 43a31f1

Browse files
committed
[bugf][bootup][WORKSPACE_DIR is discarded at import, so it never takes effect]
bootup() runs at 'import swarms' and assigned WORKSPACE_DIR unconditionally, then disable_logging() assigned it again with the relative string 'agent_workspace'. Either write alone discards whatever the caller exported. Default it only when unset, which is what bootup's own comment already claims ('Setup workspace dir only if needed' guarded the mkdir, not the assignment), and drop the stray assignment from disable_logging, which only reads the value.
1 parent f8e3fff commit 43a31f1

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

swarms/telemetry/bootup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ def bootup():
2121
# Silence wandb
2222
os.environ["WANDB_SILENT"] = "true"
2323

24-
# Setup workspace dir only if needed
25-
if not workspace_path.exists():
26-
workspace_path.mkdir(parents=True, exist_ok=True)
27-
os.environ["WORKSPACE_DIR"] = str(workspace_path)
24+
# Only default it. Assigning unconditionally discarded whatever the
25+
# caller had exported, so WORKSPACE_DIR never survived `import swarms`.
26+
if not os.getenv("WORKSPACE_DIR"):
27+
os.environ["WORKSPACE_DIR"] = str(workspace_path)
28+
Path(os.environ["WORKSPACE_DIR"]).mkdir(
29+
parents=True, exist_ok=True
30+
)
2831

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

swarms/utils/disable_logging.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ def disable_logging():
99
Disables logging for specific modules and sets up file and stream handlers.
1010
Runs in a separate thread to avoid blocking the main thread.
1111
"""
12-
os.environ["WORKSPACE_DIR"] = "agent_workspace"
13-
1412
warnings.filterwarnings("ignore", category=UserWarning)
1513

1614
# disable tensorflow warnings
@@ -46,7 +44,7 @@ def disable_logging():
4644
logging.getLogger().handlers = []
4745

4846
# Get the workspace directory from the environment variables
49-
workspace_dir = os.environ["WORKSPACE_DIR"]
47+
workspace_dir = os.getenv("WORKSPACE_DIR") or "agent_workspace"
5048

5149
# Check if the workspace directory exists, if not, create it
5250
if not os.path.exists(workspace_dir):

0 commit comments

Comments
 (0)