|
12 | 12 |
|
13 | 13 | import uvicorn |
14 | 14 |
|
15 | | -from aideator.paths import ( |
| 15 | +# Ensure the project root is in sys.path for module imports (api, db, engine, etc.) |
| 16 | +_ROOT = str(Path(__file__).resolve().parents[1]) |
| 17 | +if _ROOT not in sys.path: |
| 18 | + sys.path.insert(0, _ROOT) |
| 19 | + |
| 20 | +# Critical check: verify if 'api' is accessible |
| 21 | +try: |
| 22 | + import api |
| 23 | + # If api has no __path__, it's a module, not a package |
| 24 | + if not hasattr(api, "__path__"): |
| 25 | + # This is the conflict! |
| 26 | + if (Path.cwd() / "api").exists(): |
| 27 | + sys.path.insert(0, str(Path.cwd())) |
| 28 | + import importlib |
| 29 | + importlib.reload(api) |
| 30 | +except ImportError: |
| 31 | + if (Path.cwd() / "api").exists(): |
| 32 | + sys.path.insert(0, str(Path.cwd())) |
| 33 | + |
| 34 | +from aideator.paths import ( # noqa: E402 |
16 | 35 | ensure_dir, |
17 | 36 | get_all_paths, |
18 | 37 | get_default_config_path, |
19 | 38 | resolve_path, |
20 | 39 | ) |
21 | | -from aideator.rebuild_docs import rebuild_docs |
22 | | -from aideator.search.registry import get_search_provider |
23 | | -from api.config import load_settings, settings |
24 | | -from db.ideas import Idea, save_idea |
25 | | -from db.runs import Run, save_run |
26 | | -from engine.orchestrator import execute_run |
| 40 | +from aideator.rebuild_docs import rebuild_docs # noqa: E402 |
| 41 | +from aideator.search.registry import get_search_provider # noqa: E402 |
| 42 | +from api.config import load_settings, settings # noqa: E402 |
| 43 | +from db.ideas import Idea, save_idea # noqa: E402 |
| 44 | +from db.runs import Run, save_run # noqa: E402 |
| 45 | +from engine.orchestrator import execute_run # noqa: E402 |
27 | 46 |
|
28 | 47 |
|
29 | 48 | def run_server( |
|
0 commit comments