Skip to content

workflows

workflows

analyze_python_script

analyze_python_script(script: str) -> dict[str, Any]

Convenience API: Analyze Python script and return recommendations.

Tries to use the LangGraph workflow when available; falls back to the heuristic analyzer if LangGraph is not installed.

Source code in src/crew_dcs/integrations/agents/script_analyzer/workflows.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def analyze_python_script(script: str) -> dict[str, Any]:
    """Convenience API: Analyze Python script and return recommendations.

    Tries to use the LangGraph workflow when available; falls back to the
    heuristic analyzer if LangGraph is not installed.
    """
    try:
        from .script_analyzer_graph import run_workflow

        return run_workflow(script)
    except Exception:  # noqa: BLE001
        analyzer = DomoDataflowAnalyzer()
        result = analyzer.analyze(script)
        # Basic fallback structure for consistency
        return {
            "operations": [vars(op) for op in result.operations],
            "suggestions": [vars(s) for s in result.suggestions],
            "notes": result.notes,
            "recommendations": [
                {
                    "action_type": s.action_type,
                    "category": s.category,
                    "rationale": s.rationale,
                    "confidence": s.confidence,
                    "columns": s.columns,
                }
                for s in result.suggestions
            ],
        }