Skip to content

Commit b4fc2bd

Browse files
committed
Surface ray parallel processing up to sdk
Signed-off-by: Rahul Krishna <rkrsn@ibm.com>
1 parent 1e8988b commit b4fc2bd

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

cldk/analysis/python/codeanalyzer/codeanalyzer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(
113113
cache_dir: Union[str, Path, None] = None,
114114
target_files: List[str] | None = None,
115115
use_codeql: bool = True,
116+
use_ray: bool = False,
116117
) -> None:
117118
"""Initialize the Python code analyzer and run analysis.
118119
@@ -145,6 +146,10 @@ def __init__(
145146
use_codeql: If ``True`` (default), uses CodeQL to enhance call
146147
graph resolution beyond what Jedi provides. Set to ``False``
147148
for faster analysis without CodeQL.
149+
use_ray: If ``True``, enables Ray-based parallel processing for
150+
analysis. Recommended for very large projects where Jedi/CodeQL
151+
analysis would otherwise be slow. Requires Ray to be installed.
152+
Defaults to ``False``.
148153
149154
Raises:
150155
ValueError: If ``project_dir`` is ``None``.
@@ -164,6 +169,7 @@ def __init__(
164169
self.eager_analysis = eager_analysis
165170
self.target_files = target_files
166171
self.use_codeql = use_codeql
172+
self.use_ray = use_ray
167173

168174
# codeanalyzer-python owns all caching. CLDK forwards these paths
169175
# verbatim; when cache_dir is None the backend defaults it to
@@ -212,7 +218,7 @@ def _run_analyzer(self) -> PyApplication:
212218
output=self.analysis_json_path,
213219
format=OutputFormat.JSON,
214220
using_codeql=self.use_codeql,
215-
using_ray=False,
221+
using_ray=self.use_ray,
216222
rebuild_analysis=self.eager_analysis,
217223
skip_tests=True,
218224
file_name=target_file,

cldk/analysis/python/python_analysis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def __init__(
106106
target_files: List[str] | None,
107107
eager_analysis: bool,
108108
use_codeql: bool = True,
109+
use_ray: bool = False,
109110
) -> None:
110111
"""Initialize the Python analysis facade.
111112
@@ -140,6 +141,10 @@ def __init__(
140141
resolution with CodeQL analysis for more complete and accurate
141142
call edges. Set to ``False`` for faster analysis using only
142143
Jedi, at the cost of potentially missing some call relationships.
144+
use_ray: If ``True``, enables Ray-based parallel processing for
145+
analysis. Recommended for very large projects where sequential
146+
Jedi/CodeQL analysis would be slow. Requires Ray to be installed.
147+
Defaults to ``False``.
143148
144149
Raises:
145150
ValueError: If ``project_dir`` is ``None``. Python analysis requires
@@ -165,6 +170,7 @@ def __init__(
165170
cache_dir=cache_dir,
166171
target_files=target_files,
167172
use_codeql=use_codeql,
173+
use_ray=use_ray,
168174
)
169175

170176
# -----[ treesitter passthrough ]-----

cldk/core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def analysis(
107107
analysis_json_path: str | Path = None,
108108
cache_dir: str | Path | None = None,
109109
use_codeql: bool = True,
110+
use_ray: bool = False,
110111
) -> JavaAnalysis | PythonAnalysis | CAnalysis:
111112
"""Initialize and return a language-specific analysis facade.
112113
@@ -158,6 +159,11 @@ def analysis(
158159
Jedi-based call graph resolution with CodeQL analysis for more
159160
complete call edges. Set to ``False`` for faster analysis using
160161
only Jedi. Ignored for Java and C.
162+
use_ray: **Python only.** If ``True``, enables Ray-based parallel
163+
processing for analysis. Recommended for very large projects
164+
where sequential Jedi/CodeQL analysis would be slow. Requires
165+
Ray to be installed. Defaults to ``False``. Ignored for Java
166+
and C.
161167
162168
Returns:
163169
A language-specific analysis facade instance:
@@ -224,6 +230,7 @@ def analysis(
224230
target_files=target_files,
225231
eager_analysis=eager,
226232
use_codeql=use_codeql,
233+
use_ray=use_ray,
227234
)
228235
elif self.language == "c":
229236
return CAnalysis(project_dir=project_path)

0 commit comments

Comments
 (0)