-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ENG-8509: computed var dependency tracking for locally imported states #6035
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
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
|
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
Import dep tracking:
get_state