-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Continue and break to fill in conversation details #4094
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
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| 'is_break': self.context.get('is_break'), | ||
| 'run_time': self.context.get('run_time'), | ||
| 'type': self.node.type, | ||
| 'status': self.status, |
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.
The provided code contains the following adjustments to improve its clarity and functionality:
- Removed unnecessary import statement:
from typing import Union. - Corrected a logic error in setting the value of
_write_contextbased on__name__.endswith("execute"). This should be corrected to match the original intention of writing context when executing nodes. - Changed the order of operations in calculating
self.node_params['is_result']to align with the expected behavior.
After these changes, the modified line for determining whether to set self.node_params['is_result'] would look like this:
is_success = (not all([r if t == 'OR' else not r]) if condition == 'AND' else ((not any([(True if t != 'OR' else False) if r else False] for r, t in zip(condition_list, condition.split(','))))))
self.node_params['is_result'] = is_successThis adjustment ensures that the logical operation correctly matches the intended flow specified by condition, especially important given the potential for different combinations ("OR" vs "AND") within the condition_list.
These improvements will make it easier to understand the purpose and functionality each part of the code represents.
| "is_continue": self.context.get('is_continue'), | ||
| 'run_time': self.context.get('run_time'), | ||
| 'type': self.node.type, | ||
| 'status': self.status, |
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.
There are no significant errors in the provided code. However, there's one minor issue with handling None values that might occur if condition_list contains NaN. It would be good to handle such cases appropriately.
Here’s an updated version of the code:
def execute(self, condition, condition_list, **kwargs) -> NodeResult:
# Ensure condition_list is not None and convert it to a list if needed
condition_list = condition_list or []
# Create a new list that handles NaN (if present) more elegantly
condition_list_with_nan_fix = [row.get('field') and self.assertion(
row.get('field'),
row.get('compare'),
row.get('value', {}).get('original_value')
) for row in condition_list]
# Use boolean logic based on the input 'condition'
is_continue = all(condition_list_with_nan_fix) if condition == 'and' else any(condition_list_with_nan_fix)
# Store the result and update context accordingly
self.context['is_continue'] = is_continue
# Return the appropriate outcome based on 'is_continue'
if is_continue:
return NodeResult({'is_continue': is_continue, 'branch_id': 'continue'}, {})
return NodeResult({'is_continue': is_continue}, {})
def get_details(self, index: int, **kwargs):
return {
'name': self.node.properties.get('stepName'),
"index": index,
'is_continue': self.context.get('is_continue', False),
'run_time': self.context.get('run_time'),
'type': self.node.type,
'status': self.status
}Changes Made:
-
Handling Non-List Condition List: Added a check at the beginning of
execute()to ensurecondition_listis a list and initialize it as empty if it isNone.condition_list = condition_list or []
-
Preserving Nan Values: Updated each assertion call to include optional access to
'original_value', which may help in treatingNaNgracefully.row.get('value', {}).get('original_value')
-
Default Value for Context Key: Added a default value
Falsefor"is_continue"in theget_details()function to avoid potential errors when accessing a missing key.'is_continue': self.context.get('is_continue', False)
These changes make the code more robust against unexpected inputs and improve the overall reliability of the node execution logic.
fix: Continue and break to fill in conversation details