|
7 | 7 |
|
8 | 8 | # Files to exclude from ingestion (should match src/main.py) |
9 | 9 | EXCLUDED_INGESTION_FILES = {"warmup_ocr.pdf"} |
| 10 | +_RELOAD_MODULES = [ |
| 11 | + "api", |
| 12 | + "api.router", |
| 13 | + "api.connector_router", |
| 14 | + "app", |
| 15 | + "app.container", |
| 16 | + "app.factory", |
| 17 | + "app.lifespan", |
| 18 | + "app.routes", |
| 19 | + "app.routes.internal", |
| 20 | + "config.settings", |
| 21 | + "dependencies", |
| 22 | + "auth_middleware", |
| 23 | + "main", |
| 24 | + "services", |
| 25 | + "services.default_docs_service", |
| 26 | + "services.search_service", |
| 27 | + "services.startup_orchestrator", |
| 28 | + "utils.opensearch_init", |
| 29 | +] |
| 30 | +_RELOAD_PREFIXES = ("api.", "app.", "services.") |
| 31 | + |
| 32 | + |
| 33 | +def _purge_reloaded_modules() -> None: |
| 34 | + import sys |
| 35 | + |
| 36 | + for mod in list(sys.modules): |
| 37 | + if mod in _RELOAD_MODULES or mod.startswith(_RELOAD_PREFIXES): |
| 38 | + sys.modules.pop(mod, None) |
10 | 39 |
|
11 | 40 |
|
12 | 41 | async def wait_for_ready(client: httpx.AsyncClient, timeout_s: float = 30.0): |
@@ -48,28 +77,7 @@ async def test_startup_ingest_creates_task(disable_langflow_ingest: bool): |
48 | 77 | os.environ["GOOGLE_OAUTH_CLIENT_SECRET"] = "" |
49 | 78 |
|
50 | 79 | # Reload settings to pick up env for this test run |
51 | | - import sys |
52 | | - |
53 | | - for mod in [ |
54 | | - "api.router", |
55 | | - "api.connector_router", |
56 | | - "api", |
57 | | - "app.container", |
58 | | - "app.factory", |
59 | | - "app.lifespan", |
60 | | - "app.routes", |
61 | | - "app.routes.internal", |
62 | | - "config.settings", |
63 | | - "dependencies", |
64 | | - "auth_middleware", |
65 | | - "main", |
66 | | - "services", |
67 | | - "services.default_docs_service", |
68 | | - "services.search_service", |
69 | | - "services.startup_orchestrator", |
70 | | - "utils.opensearch_init", |
71 | | - ]: |
72 | | - sys.modules.pop(mod, None) |
| 80 | + _purge_reloaded_modules() |
73 | 81 |
|
74 | 82 | from config.settings import clients, get_index_name |
75 | 83 | from main import create_app |
|
0 commit comments