Fix environment_setup directory creation from PR #433
- Remove dependency on workspace_dirs module - Use direct Path().mkdir() for directory creation - Configure development directories correctly (lib/workspace/...) - Skip directory creation in production mode
This commit is contained in:
@@ -7,21 +7,21 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Dict, Any
|
from typing import List, Dict, Any
|
||||||
|
|
||||||
from services.workspace_dirs import ensure_global_operational_dirs
|
|
||||||
|
|
||||||
|
|
||||||
class EnvironmentSetup:
|
class EnvironmentSetup:
|
||||||
"""Manages environment setup for ALwrity backend."""
|
"""Manages environment setup for ALwrity backend."""
|
||||||
|
|
||||||
def __init__(self, production_mode: bool = False):
|
def __init__(self, production_mode: bool = False):
|
||||||
self.production_mode = production_mode
|
self.production_mode = production_mode
|
||||||
# Use safer directory paths that don't conflict with deployment platforms
|
|
||||||
if production_mode:
|
if production_mode:
|
||||||
# In production, only create operational directories
|
self.required_directories = []
|
||||||
self.required_directories = ["logs", "temp"]
|
|
||||||
else:
|
else:
|
||||||
# In development, only create operational directories
|
self.required_directories = [
|
||||||
self.required_directories = ["logs", "temp"]
|
"lib/workspace/alwrity_content",
|
||||||
|
"lib/workspace/alwrity_web_research",
|
||||||
|
"lib/workspace/alwrity_prompts",
|
||||||
|
"lib/workspace/alwrity_config"
|
||||||
|
]
|
||||||
|
|
||||||
def setup_directories(self) -> bool:
|
def setup_directories(self) -> bool:
|
||||||
"""Create necessary directories for ALwrity."""
|
"""Create necessary directories for ALwrity."""
|
||||||
@@ -36,15 +36,15 @@ class EnvironmentSetup:
|
|||||||
print(" ⚠️ Skipping directory creation in production mode")
|
print(" ⚠️ Skipping directory creation in production mode")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
for directory in self.required_directories:
|
||||||
ensure_global_operational_dirs(self.required_directories)
|
try:
|
||||||
if verbose:
|
Path(directory).mkdir(parents=True, exist_ok=True)
|
||||||
for directory in self.required_directories:
|
if verbose:
|
||||||
print(f" ✅ Created: {directory}")
|
print(f" ✅ Created: {directory}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f" ❌ Failed to create operational directories: {e}")
|
print(f" ❌ Failed to create {directory}: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print("✅ All directories created successfully")
|
print("✅ All directories created successfully")
|
||||||
|
|||||||
Reference in New Issue
Block a user