-
Notifications
You must be signed in to change notification settings - Fork 310
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
fix sync for map over lp in dynamic #3155
fix sync for map over lp in dynamic #3155
Conversation
Signed-off-by: Troy Chiu <[email protected]>
Code Review Agent Run Status
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3155 +/- ##
==========================================
- Coverage 78.58% 77.45% -1.14%
==========================================
Files 284 212 -72
Lines 25356 22027 -3329
Branches 2865 2864 -1
==========================================
- Hits 19926 17060 -2866
+ Misses 4650 4134 -516
- Partials 780 833 +53 ☔ View full report in Codecov by Sentry. |
Code Review Agent Run #df4fb4Actionable Suggestions - 2
Additional Suggestions - 1
Review Details
|
node_launch_plans[node.workflow_node.launchplan_ref] = self.client.get_launch_plan( | ||
node.workflow_node.launchplan_ref | ||
).spec | ||
self.find_launch_plan_for_node(node, node_launch_plans) |
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.
Consider adding error handling for find_launch_plan_for_node
to handle potential exceptions when fetching launch plans. The method may fail silently if there are issues accessing the launch plans.
Code suggestion
Check the AI-generated fix before applying
self.find_launch_plan_for_node(node, node_launch_plans) | |
try: | |
self.find_launch_plan_for_node(node, node_launch_plans) | |
except FlyteEntityNotExistException as e: | |
logger.warning(f"Failed to fetch launch plan for node {node.id}: {str(e)}") |
Code Review Run #df4fb4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
def find_launch_plan_for_node( | ||
self, node: Node, node_launch_plans: Dict[id_models, launch_plan_models.LaunchPlanSpec] | ||
): |
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.
Consider breaking down the find_launch_plan_for_node
method into smaller, more focused methods. The current implementation has multiple nested functions and complex branching logic which could be simplified for better maintainability. Consider extracting the branch node handling logic into a separate method.
Code suggestion
Check the AI-generated fix before applying
def find_launch_plan_for_node( | |
self, node: Node, node_launch_plans: Dict[id_models, launch_plan_models.LaunchPlanSpec] | |
): | |
def _handle_then_node( | |
self, child_then_node: Node, node_launch_plans: Dict[id_models, launch_plan_models.LaunchPlanSpec] | |
) -> None: | |
if child_then_node.branch_node: | |
self._handle_branch_node(child_then_node.branch_node, node_launch_plans) | |
elif child_then_node.workflow_node and child_then_node.workflow_node.launchplan_ref: | |
lp_ref = child_then_node.workflow_node.launchplan_ref | |
self.find_launch_plan(lp_ref, node_launch_plans) | |
def _handle_branch_node( | |
self, branch_node: BranchNode, node_launch_plans: Dict[id_models, launch_plan_models.LaunchPlanSpec] | |
) -> None: | |
if branch_node and branch_node.if_else: | |
branch = branch_node.if_else | |
if branch.case and branch.case.then_node: | |
self._handle_then_node(branch.case.then_node, node_launch_plans) | |
if branch.other: | |
for o in branch.other: | |
if o.then_node: | |
self._handle_then_node(o.then_node, node_launch_plans) | |
if branch.else_node: | |
if branch.else_node.branch_node: | |
self._handle_branch_node(branch.else_node.branch_node, node_launch_plans) | |
elif branch.else_node.workflow_node and branch.else_node.workflow_node.launchplan_ref: | |
lp_ref = branch.else_node.workflow_node.launchplan_ref | |
self.find_launch_plan(lp_ref, node_launch_plans) | |
def find_launch_plan_for_node( | |
self, node: Node, node_launch_plans: Dict[id_models, launch_plan_models.LaunchPlanSpec] | |
): |
Code Review Run #df4fb4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Why are the changes needed?
Currently if we call sync_node_execution on an execution contains map over lp in dynamic workflow, we'll get error like
because we didn't inspect launch plan inside an array node in dynamic case.
What changes were proposed in this pull request?
How was this patch tested?
tested with a dynamic workflow which contains map over launch plan and I was able to call sync_node_execution and get the correct data.
Check all the applicable boxes
Summary by Bito
This PR addresses a bug in sync_node_execution where launch plans within array nodes of dynamic workflows were causing KeyError exceptions. The implementation has been refactored to properly inspect and handle launch plans inside array nodes, with improved code organization through method separation and enhanced support for map operations over launch plans.Unit tests added: False
Estimated effort to review (1-5, lower is better): 1