Skip to content

Add disable_graph Option / Feature Flag #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions src/codegen/sdk/codebase/codebase_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,35 +457,40 @@ def _process_diff_files(self, files_to_sync: Mapping[SyncType, list[Path]], incr
# Step 8: Add internal import resolution edges for new and updated files
if not skip_uncache:
uncache_all()
self._computing = True
try:
logger.info(f"> Computing import resolution edges for {counter[NodeType.IMPORT]} imports")
for node in to_resolve:
if node.node_type == NodeType.IMPORT:
node._remove_internal_edges(EdgeType.IMPORT_SYMBOL_RESOLUTION)
node.add_symbol_resolution_edge()
to_resolve.extend(node.symbol_usages)
if counter[NodeType.EXPORT] > 0:
logger.info(f"> Computing export dependencies for {counter[NodeType.EXPORT]} exports")

if self.config.feature_flags.disable_graph:
logger.warning("Graph generation is disabled. Skipping import and symbol resolution")
self._computing = False
else:
self._computing = True
try:
logger.info(f"> Computing import resolution edges for {counter[NodeType.IMPORT]} imports")
for node in to_resolve:
if node.node_type == NodeType.EXPORT:
node._remove_internal_edges(EdgeType.EXPORT)
node.compute_export_dependencies()
if node.node_type == NodeType.IMPORT:
node._remove_internal_edges(EdgeType.IMPORT_SYMBOL_RESOLUTION)
node.add_symbol_resolution_edge()
to_resolve.extend(node.symbol_usages)
if counter[NodeType.SYMBOL] > 0:
from codegen.sdk.core.interfaces.inherits import Inherits

logger.info("> Computing superclass dependencies")
for symbol in to_resolve:
if isinstance(symbol, Inherits):
symbol._remove_internal_edges(EdgeType.SUBCLASS)
symbol.compute_superclass_dependencies()

if not skip_uncache:
uncache_all()
self._compute_dependencies(to_resolve, incremental)
finally:
self._computing = False
if counter[NodeType.EXPORT] > 0:
logger.info(f"> Computing export dependencies for {counter[NodeType.EXPORT]} exports")
for node in to_resolve:
if node.node_type == NodeType.EXPORT:
node._remove_internal_edges(EdgeType.EXPORT)
node.compute_export_dependencies()
to_resolve.extend(node.symbol_usages)
if counter[NodeType.SYMBOL] > 0:
from codegen.sdk.core.interfaces.inherits import Inherits

logger.info("> Computing superclass dependencies")
for symbol in to_resolve:
if isinstance(symbol, Inherits):
symbol._remove_internal_edges(EdgeType.SUBCLASS)
symbol.compute_superclass_dependencies()

if not skip_uncache:
uncache_all()
self._compute_dependencies(to_resolve, incremental)
finally:
self._computing = False

def _compute_dependencies(self, to_update: list[Importable], incremental: bool):
seen = set()
Expand Down
1 change: 1 addition & 0 deletions src/codegen/sdk/codebase/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GSFeatureFlags(BaseModel):
full_range_index: bool = False
ignore_process_errors: bool = True # Ignore errors from dependency manager and language engine
import_resolution_overrides: dict[str, str] = {} # Override import resolution for specific modules
disable_graph: bool = False # Turn of graph generation entirely. Speeds up parsing but disables usages and dependencies


DefaultFlags = GSFeatureFlags(sync_enabled=False)
Expand Down