fix: add smart sys.path fallback for init_db entrypoint#344
fix: add smart sys.path fallback for init_db entrypoint#344vcfgv merged 1 commit intoValueCell-ai:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses issues when the project directory path contains spaces (common on macOS in "Mobile Documents" directories). The changes add path quoting in launch.py and path handling logic in init_db.py to support direct script execution.
Key Changes:
- Added try-except import pattern in init_db.py to support running the script directly via
uv run - Added single quotes around all path variables in command strings to handle spaces
- Implemented manual .env file parsing to pass environment variables via subprocess instead of using
--env-fileflag
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| python/valuecell/server/db/init_db.py | Adds smart path handling to allow direct script execution by conditionally adding the Python package root to sys.path when imports fail |
| python/scripts/launch.py | Adds quotes to path variables and implements manual .env loading to avoid shell parsing issues with spaces in paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for the Pull Request. Could you please run |
Add smart path handling in init_db.py to resolve ModuleNotFoundError when project path contains spaces (e.g. 'Mobile Documents'). The script now: - Attempts to import valuecell first - Only adds project root to sys.path if import fails - Works both as standalone script and installed package This fix allows running: uv run valuecell/server/db/init_db.py from paths containing spaces without ModuleNotFoundError. Fixes: ModuleNotFoundError in init_db.py with space-containing paths
932ccb9 to
bd1b042
Compare
|
Hi @vcfgv, I've updated this PR to resolve merge conflicts with the latest main branch. Current changes:
What happened: Implementation: The PR is now ready for review. Thank you for your patience! |
|
I updated the title to better reflect the actual changes. Thanks for the contribution! |
1. Related Issue
NA
2. Type of Change
Type of Change: Bug Fix
3. Description
Fixes issues when project path contains spaces (e.g., "Mobile Documents" on macOS).
The changes are backward compatible:
4. Testing
5. Checklist