Spaces:
Sleeping
Sleeping
Christophe Bourgoin
Claude
commited on
Commit
·
f90fc86
1
Parent(s):
d978a2c
Fix: Create PROFILE_DIR at module import time
Browse filesThis fixes the database initialization error on Hugging Face Spaces
by ensuring the ~/.agentic-content-generation directory is created
when src/profile.py is imported, before any database operations.
Changes:
- Added PROFILE_DIR.mkdir() at module level in src/profile.py
- Simplified main.py (directory now created at import)
- Fixes error: "Failed to create database engine"
The directory is now guaranteed to exist before DatabaseSessionService
tries to create the SQLite database.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- main.py +1 -2
- src/__pycache__/__init__.cpython-312.pyc +0 -0
- src/__pycache__/tools.cpython-312.pyc +0 -0
- src/profile.py +3 -0
main.py
CHANGED
|
@@ -68,8 +68,7 @@ async def run_content_generation(topic: str, preferences: dict = None, session_i
|
|
| 68 |
)
|
| 69 |
|
| 70 |
# Initialize persistent session service
|
| 71 |
-
#
|
| 72 |
-
PROFILE_DIR.mkdir(parents=True, exist_ok=True)
|
| 73 |
db_path = PROFILE_DIR / "sessions.db"
|
| 74 |
db_url = f"sqlite:///{db_path}"
|
| 75 |
session_service = DatabaseSessionService(db_url=db_url)
|
|
|
|
| 68 |
)
|
| 69 |
|
| 70 |
# Initialize persistent session service
|
| 71 |
+
# Note: PROFILE_DIR is created at module import in src/profile.py
|
|
|
|
| 72 |
db_path = PROFILE_DIR / "sessions.db"
|
| 73 |
db_url = f"sqlite:///{db_path}"
|
| 74 |
session_service = DatabaseSessionService(db_url=db_url)
|
src/__pycache__/__init__.cpython-312.pyc
CHANGED
|
Binary files a/src/__pycache__/__init__.cpython-312.pyc and b/src/__pycache__/__init__.cpython-312.pyc differ
|
|
|
src/__pycache__/tools.cpython-312.pyc
CHANGED
|
Binary files a/src/__pycache__/tools.cpython-312.pyc and b/src/__pycache__/tools.cpython-312.pyc differ
|
|
|
src/profile.py
CHANGED
|
@@ -266,6 +266,9 @@ DEFAULT_PROFILE = UserProfile()
|
|
| 266 |
PROFILE_DIR = Path.home() / ".agentic-content-generation"
|
| 267 |
PROFILE_PATH = PROFILE_DIR / "profile.yaml"
|
| 268 |
|
|
|
|
|
|
|
|
|
|
| 269 |
|
| 270 |
def load_profile_from_yaml(path: Path) -> UserProfile:
|
| 271 |
"""Load user profile from YAML file.
|
|
|
|
| 266 |
PROFILE_DIR = Path.home() / ".agentic-content-generation"
|
| 267 |
PROFILE_PATH = PROFILE_DIR / "profile.yaml"
|
| 268 |
|
| 269 |
+
# Ensure directory exists (critical for HF Spaces and first-time setup)
|
| 270 |
+
PROFILE_DIR.mkdir(parents=True, exist_ok=True)
|
| 271 |
+
|
| 272 |
|
| 273 |
def load_profile_from_yaml(path: Path) -> UserProfile:
|
| 274 |
"""Load user profile from YAML file.
|