CodebaseConfig object which is used to configure more advanced behaviors of the graph construction process.
These flags are helpful for debugging problematic repos, optimizing Codegen’s performance, or testing unreleased or experimental (potentially backwards-breaking) features.
These configuration options are defined in src/codegen/configs/models/codebase.py.
Usage
You can customize the behavior of the graph construction process when initializing a Codebase by passing aCodebaseConfig object with the desired configuration flags.
Table of Contents
- debug
- verify-graph
- track-graph
- method-usages
- sync-enabled
- full-range-index
- ignore-process-errors
- disable-graph
- disable-file-parse
- exp-lazy-graph
- generics
- import-resolution-paths
- import-resolution-overrides
- py-resolve-syspath
- ts-dependency-manager
- ts-language-engine
- v8-ts-engine
- unpacking-assignment-partial-removal
Configuration Flags
Flag: debug
Default: False
Enables verbose logging for debugging purposes. In its current form, it enables:
- Verbose logging when adding nodes to the graph
- Verbose logging during initial file parsing
- Additional assertions on graph creation
- Additional (costly) debug metrics on codebase construction
- etc.
Flag: verify_graph
Default: False
Adds assertions for graph state during reset resync. Used to test and debug graph desyncs after a codebase reset.
Runs post_reset_validation after a reset resync.
This is an internal debug flag.
Flag: track_graph
Default: False
Keeps a copy of the original graph before a resync. Used in conjunction with verify_graph to test and debug graph desyncs.
Original graph is saved as ctx.old_graph.
This is an internal debug flag.
Flag: method_usages
Default: True
Enables and disables resolving method usages.
Example Codebase:
method_usages on:
method_usages off:
Flag: sync_enabled
Default: False
Enables or disables graph sync during codebase.commit.
Implementation-specific details on sync graph can be found here.
sync_enabled on:
sync_enabled disabled:
Flag: full_range_index
Default: False
By default, Codebase maintains an internal range-to-node index for fast lookups. (i.e. bytes 120 to 130 maps to node X).
For optimization purposes, this only applies to nodes defined and handled by parser.py.
Enabling full_range_index will create an additional index that maps all tree-sitter ranges to nodes.
This can be useful for debugging or when you need to build any applications that require a full range-to-node index (i.e. a codebase tree lookup).
Flag: ignore_process_errors
Default: True
Controls whether to ignore errors that occur during external process execution (such as dependency manager or language engine).
Disabling ignore_process_errors would make Graph-sitter fail on errors that would otherwise be logged then ignored.
Flag: disable_graph
Default: False
Disables the graph construction process. Any operations that require the graph will no longer work. (In other words, this turns off import resolution and usage/dependency resolution)
Functions that operate purely on AST such as getting and editing parameters or modifying function and class definitions will still work.
For codemods that do not require the graph (aka only AST/Syntax-level changes), disabling graph parse could yield a 30%-40% decrease in parse time and memory usage!
Flag: disable_file_parse
Default: False
Disables ALL parsing, including file and graph parsing. This essentially treats all codebases as the “UNSUPPORTED” language mode.
Nearly all functions except for editing primitives like codebase.get_file and file.edit will no longer work.
This flag is useful for any usages of Graph-sitter that do NOT require any AST/CST/Graph parsing. (i.e. using Graph-sitter purely as a file editing harness)If this is your use case, this could decrease parse and memory usage by 95%.
Flag: exp_lazy_graph
Default: False
This experimental flag pushes the graph creation back until the graph is needed. This is an experimental feature and may have some unintended consequences.
Example Codemod:
This may have a very slight performance boost. Use at your own risk!
Flag: generics
Default: True
Enables and disables generic type resolution.
Example Codebase:
generics on:
generics off:
Generic resolution is still largely WIP and experimental, and may not work in all cases. In some rare circumstances, disabling generics may result in a significant performance boost.
Flag: import_resolution_paths
Default: []
Controls alternative paths to resolve imports from.
Example Codebase:
Flag: import_resolution_overrides
Default: {}
Controls import path overrides during import resolution.
Example
from a.b.c import d with the override a/b -> foo/bar will internally resolve the import as from foo.bar.c import d.
Flag: py_resolve_syspath
Default: False
Enables and disables resolution of imports from sys.path.
Flag: allow_external
Default: False
Enables resolving imports, files, modules, and directories from outside of the repo path.
Flag: ts_dependency_manager
Default: False
Enables Codegen’s internal dependency installer for TypeScript. This will modify package.json and install the bare minimum set of installable dependencies.
More documentation on TypeScript dependency manager can be found here
Flag: ts_language_engine
Default: False
Enables using the TypeScript compiler to extract information from the codebase. Enables commands such as inferred_return_type.
Flag: v8_ts_engine
Default: False
This feature flag requires
ts_language_engine to be enabled as well.inferred_return_type.
The V8 implementation (as opposed to the default external-process based implementation) is less stable, but provides the entire TypeScript API to be used from within Codegen.
Flag: unpacking_assignment_partial_removal
Default: False
Enables smarter removal of unpacking assignments.
Example Codebase:
unpacking_assignment_partial_removal on:
unpacking_assignment_partial_removal off: