# scripts/run_nested_scan.py # debug script # { # "name": "Run NestedInsight Scan", # "type": "python", # "request": "launch", # "program": "${workspaceFolder}/scripts/run_nested_scan.py", # "cwd": "${workspaceFolder}", # "console": "integratedTerminal", # "justMyCode": true, # "env": { # "AIOPS_CONFIG_FILE": "${workspaceFolder}/config.yaml", # "ROOT_DIR": "${workspaceFolder}/aiops", # "PYTHONPATH": "${workspaceFolder}", # "PYTHONUNBUFFERED": "1", # } # } import asyncio import logging from dependency_injector import providers from aiops.infra.deps.aiops_deps import Dependencies logging.basicConfig(level=logging.DEBUG) deps = Dependencies() deps.jira_client.override(providers.Object(None)) deps.lark_client.override(providers.Object(None)) guardian = deps.service_guardian() nested = guardian.nested_insight_service async def main(): """Run scan and wait for all active analysis tasks to complete. In the new stateless design: - scan() processes windows in WATCHING state and launches analyses - Active analyses are tracked in nested._active_analyses set - We poll until all active analyses complete """ logging.info("Starting nested insight scan...") await nested.scan() # Wait for all active analyses to complete logging.info(f"Waiting for {nested.active_analyses_count} active analysis tasks...") while nested.active_analyses_count > 0: logging.info(f"{nested.active_analyses_count} tasks still running...") await asyncio.sleep(10) logging.info("All analysis tasks completed!") if __name__ == "__main__": asyncio.run(main())