Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions python/valuecell/server/db/init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
from pathlib import Path
from typing import Optional

# Smart path handling: try import first, add path only if needed
# This allows running the script directly: uv run valuecell/server/db/init_db.py
try:
import valuecell # noqa: F401
except ImportError:
# If import fails, add the Python package root to sys.path
# Calculate path: init_db.py -> db -> server -> valuecell -> python (root)
_current_file = Path(__file__).resolve()
_python_root = _current_file.parent.parent.parent.parent
if str(_python_root) not in sys.path:
sys.path.insert(0, str(_python_root))

from sqlalchemy import inspect, text
from sqlalchemy.exc import SQLAlchemyError

Expand Down