Update build by processing changes using fine-grained dependencies.
Use fine-grained dependencies to update targets in other modules that may be affected by externally-visible changes in the changed modules.
This forms the core of the fine-grained incremental daemon mode. This module is not used at all by the 'classic' (non-daemon) incremental mode.
Here is some motivation for this mode:
Some terms:
Some program state is maintained across multiple build increments in memory:
Here's a summary of how a fine-grained incremental program update happens:
This is module is tested using end-to-end fine-grained incremental mode test cases (test-data/unit/fine-grained*.test).
Class | FineGrainedBuildManager |
No class docstring; 0/12 instance variable, 6/6 methods documented |
Function | calculate_active_triggers |
Determine activated triggers by comparing old and new symbol tables. |
Function | dedupe_modules |
Undocumented |
Function | delete_module |
Undocumented |
Function | ensure_deps_loaded |
Ensure that the dependencies on a module are loaded. |
Function | ensure_trees_loaded |
Ensure that the modules in initial and their deps have loaded trees. |
Function | find_relative_leaf_module |
Find a module in a list that directly imports no other module in the list. |
Function | find_symbol_tables_recursive |
Find all nested symbol tables. |
Function | find_targets_recursive |
Find names of all targets that need to reprocessed, given some triggers. |
Function | find_unloaded_deps |
Find all the deps of the nodes in initial that haven't had their tree loaded. |
Function | fix_fg_dependencies |
Populate the dependencies with stuff that build may have missed |
Function | get_module_to_path_map |
Undocumented |
Function | get_sources |
Undocumented |
Function | is_verbose |
Undocumented |
Function | lookup_target |
Look up a target by fully-qualified name. |
Function | propagate_changes_using_dependencies |
Transitively rechecks targets based on triggers and the dependency map. |
Function | refresh_suppressed_submodules |
Look for submodules that are now suppressed in target package. |
Function | replace_modules_with_new_variants |
Replace modules with newly builds versions. |
Function | reprocess_nodes |
Reprocess a set of nodes within a single module. |
Function | target_from_node |
Return the target name corresponding to a deferred node. |
Function | update_deps |
Undocumented |
Function | update_module_isolated |
Build a new version of one changed module only. |
Constant | INIT_SUFFIXES |
Undocumented |
Constant | MAX_ITER |
Undocumented |
Constant | SENSITIVE_INTERNAL_MODULES |
Undocumented |
Variable | BlockedUpdate |
Undocumented |
Variable | NormalUpdate |
Undocumented |
Variable | UpdateResult |
Undocumented |
Determine activated triggers by comparing old and new symbol tables.
For example, if only the signature of function m.f is different in the new symbol table, return {'<m.f>'}.
Parameters | |
manager:BuildManager | Undocumented |
old_snapshots:Dict[ | Undocumented |
new_modules:Dict[ | Undocumented |
Returns | |
Set[ | Undocumented |
Undocumented
Parameters | |
modules:List[ | Undocumented |
Returns | |
List[ | Undocumented |
Undocumented
Parameters | |
module_id:str | Undocumented |
path:str | Undocumented |
graph:Graph | Undocumented |
manager:BuildManager | Undocumented |
Ensure that the dependencies on a module are loaded.
Dependencies are loaded into the 'deps' dictionary.
This also requires loading dependencies from any parent modules, since dependencies will get stored with parent modules when a module doesn't exist.
Parameters | |
module:str | Undocumented |
deps:Dict[ | Undocumented |
graph:Dict[ | Undocumented |
Parameters | |
manager:BuildManager | Undocumented |
graph:Dict[ | Undocumented |
initial:Sequence[ | Undocumented |
Find a module in a list that directly imports no other module in the list.
If no such module exists, return the lexicographically first module from the list. Always return one of the items in the modules list.
Parameters | |
modules:List[ | Undocumented |
graph:Graph | Undocumented |
Returns | |
Tuple[ | Undocumented |
Find all nested symbol tables.
symbols: Root symbol table
Returns a dictionary from full name to corresponding symbol table.
Parameters | |
prefix:str | Undocumented |
symbols:SymbolTable | Undocumented |
Returns | |
Dict[ | Undocumented |
Find names of all targets that need to reprocessed, given some triggers.
Parameters | |
manager:BuildManager | Undocumented |
graph:Graph | Undocumented |
triggers:Set[ | Undocumented |
deps:Dict[ | Undocumented |
up_to_date_modules:Set[ | Undocumented |
Returns | |
Tuple[ | Undocumented |
Find all the deps of the nodes in initial that haven't had their tree loaded.
The key invariant here is that if a module is loaded, so are all of their dependencies. This means that when we encounter a loaded module, we don't need to explore its dependencies. (This invariant is slightly violated when dependencies are added, which can be handled by calling find_unloaded_deps directly on the new dependencies.)
Parameters | |
manager:BuildManager | Undocumented |
graph:Dict[ | Undocumented |
initial:Sequence[ | Undocumented |
Returns | |
List[ | Undocumented |
Parameters | |
manager:BuildManager | Undocumented |
deps:Dict[ | Undocumented |
Undocumented
Parameters | |
fscache:FileSystemCache | Undocumented |
modules:Dict[ | Undocumented |
changed_modules:List[ | Undocumented |
Returns | |
List[ | Undocumented |
Look up a target by fully-qualified name.
The first item in the return tuple is a list of deferred nodes that needs to be reprocessed. If the target represents a TypeInfo corresponding to a protocol, return it as a second item in the return tuple, otherwise None.
Parameters | |
manager:BuildManager | Undocumented |
target:str | Undocumented |
Returns | |
Tuple[ | Undocumented |
Transitively rechecks targets based on triggers and the dependency map.
Returns a list (module id, path) tuples representing modules that contain a target that needs to be reprocessed but that has not been parsed yet.
Processed targets should be appended to processed_targets (used in tests only, to test the order of processing targets).
Parameters | |
manager:BuildManager | Undocumented |
graph:Dict[ | Undocumented |
deps:Dict[ | Undocumented |
triggered:Set[ | Undocumented |
up_to_date_modules:Set[ | Undocumented |
targets_with_errors:Set[ | Undocumented |
processed_targets:List[ | Undocumented |
Returns | |
List[ | Undocumented |
Look for submodules that are now suppressed in target package.
If a submodule a.b gets added, we need to mark it as suppressed in modules that contain "from a import b". Previously we assumed that 'a.b' is not a module but a regular name.
This is only relevant when following imports normally.
Return a list of errors from refresh_file() if it was called. If the return value is None, we didn't call refresh_file().
Parameters | |
module:str | Undocumented |
path:Optional[ | Undocumented |
deps:Dict[ | Undocumented |
graph:Graph | Undocumented |
fscache:FileSystemCache | Undocumented |
refresh_file:Callable[ | Undocumented |
Returns | |
Optional[ | Undocumented |
Replace modules with newly builds versions.
Retain the identities of externally visible AST nodes in the old ASTs so that references to the affected modules from other modules will still be valid (unless something was deleted or replaced with an incompatible definition, in which case there will be dangling references that will be handled by propagate_changes_using_dependencies).
Parameters | |
manager:BuildManager | Undocumented |
graph:Dict[ | Undocumented |
old_modules:Dict[ | Undocumented |
new_modules:Dict[ | Undocumented |
Reprocess a set of nodes within a single module.
Return fired triggers.
Parameters | |
manager:BuildManager | Undocumented |
graph:Dict[ | Undocumented |
module_id:str | Undocumented |
nodeset:Set[ | Undocumented |
deps:Dict[ | Undocumented |
processed_targets:List[ | Undocumented |
Returns | |
Set[ | Undocumented |
Return the target name corresponding to a deferred node.
Returns the target name, or None if the node is not a valid target in the given module (for example, if it's actually defined in another module).
Parameters | |
module:str | Undocumented |
node:Union[ | Undocumented |
Returns | |
Optional[ | Undocumented |
Undocumented
Parameters | |
module_id:str | Undocumented |
nodes:List[ | Undocumented |
graph:Dict[ | Undocumented |
deps:Dict[ | Undocumented |
options:Options | Undocumented |
Build a new version of one changed module only.
Don't propagate changes to elsewhere in the program. Raise CompileError on encountering a blocking error.
module: Changed module (modified, created or deleted) path: Path of the changed module manager: Build manager graph: Build graph force_removed: If True, consider the module removed from the build even it the
file exists
Returns a named tuple describing the result (see above for details).
Parameters | |
module:str | Undocumented |
path:str | Undocumented |
manager:BuildManager | Undocumented |
previous_modules:Dict[ | Undocumented |
graph:Graph | Undocumented |
force_removed:bool | Undocumented |
Returns | |
UpdateResult | Undocumented |
Undocumented
Value |
|