ENG-8509: computed var dependency tracking for locally imported states#6035
Merged
adhami3310 merged 4 commits intomainfrom Dec 11, 2025
Merged
ENG-8509: computed var dependency tracking for locally imported states#6035adhami3310 merged 4 commits intomainfrom
adhami3310 merged 4 commits intomainfrom
Conversation
Import dep tracking: * all forms of function-local imports should be usable in `get_state` * get deps from get_state through chained attributes
CodSpeed Performance ReportMerging #6035 will not alter performanceComparing Summary
|
Contributor
Greptile OverviewGreptile SummaryThis PR enhances the dependency tracking system to support function-local imports when using Key Changes
Test CoverageThe PR includes comprehensive test coverage for:
The implementation correctly handles the complexity of Python's import bytecode while maintaining backward compatibility. Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User as User Code (async function)
participant DT as DependencyTracker
participant Bytecode as Python Bytecode
participant Imports as importlib/sys.modules
participant State as BaseState
User->>DT: __post_init__()
DT->>DT: Initialize tracked_locals with self
DT->>DT: _populate_dependencies()
loop For each bytecode instruction
DT->>Bytecode: Get instruction
alt IMPORT_NAME
Bytecode->>DT: instruction.argval = module name
DT->>Imports: importlib.import_module(module)
Imports-->>DT: Module loaded
DT->>DT: Track module in tracked_locals
else IMPORT_FROM
Bytecode->>DT: instruction.argval = imported name
DT->>Imports: Get attribute from module
Imports-->>DT: Return imported object
DT->>DT: Track imported object in tracked_locals
else LOAD_FAST (tracked local)
Bytecode->>DT: Load tracked local to stack
DT->>DT: Set top_of_stack, status=GETTING_ATTR
else LOAD_ATTR on get_state
Bytecode->>DT: Call get_state
DT->>DT: Set status=GETTING_STATE
DT->>DT: Resolve state class from tracked_locals
else END_SEND (await complete)
Bytecode->>DT: Await finished
DT->>DT: Set status=GETTING_STATE_POST_AWAIT
DT->>DT: Track state instance
else LOAD_ATTR on state
Bytecode->>DT: Access state.attribute
DT->>State: Get attribute
State-->>DT: Attribute info
DT->>DT: Record dependency
else LOAD_FAST_LOAD_FAST
Bytecode->>DT: Load multiple values (equality check)
DT->>DT: Track rightmost value as top_of_stack
end
end
DT-->>User: Dependencies collected
|
adhami3310
approved these changes
Dec 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Import dep tracking:
get_state