Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Workflow execution details execution status determination

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 10, 2025

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.

Details

Instructions 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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 10, 2025

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment


class NodeResult:
def __init__(self, node_variable: Dict, workflow_variable: Dict,
_write_context=write_context, _is_interrupt=is_interrupt):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided Python code seems generally well-written and follows Python best practices for encapsulation, functions, and error handling. Here are some minor corrections, optimizations, and improvements:

  1. Code Clarity:

    • Adding comments could clarify the purpose of each function.
  2. Function Naming:

    • handler can be renamed to something more descriptive like process_workflows.
  3. Loop Workflow Node Handling:

    • The get_loop_workflow_node function is good but it can be made a bit cleaner by reducing nesting levels.
  4. Workflow State Determination:

    • The logic in get_workflow_state looks correct, but it might benefit from additional logging or debugging information if needed.
  5. NodeResult Class:

    • The initialization method includes parameters that don't have default values yet.

Here's an optimized version of the code with these considerations:

@@ -105,13 +105,27 @@ def __init__(self, chat_info, knowledge_action_id):
         self.knowledge_action_id = knowledge_action_id

     def process_workflows(self, workflows):
+        # Initialize results list
         results = []
+        
         for workflow in workflows:
             state = get_workflow_state(workflow)
             updated_record = KnowledgeAction.objects.filter(id=self.knowledge_action_id).update(state=state,
                                                                                         run_time=time.time() -
                                                                                             workflow.context.get('start_time')
                                                                                              if workflow.context.get(
                                                                                                'start_time') is not None else 0)
-
-            records.append(record)

Additional Improvements:

  • Ensure that any used modules (like write_context, is_interrupt) are imported at the beginning of the file.
  • Validate input data types where applicable to prevent runtime errors.
  • Consider using asynchronous operations if necessary for performance reasons on large datasets.

These changes will make the code clearer, maintainable, and slightly more performant. If you need further assistance or optimizations beyond this scope, feel free to ask!

@shaohuzhang1 shaohuzhang1 merged commit 4e58d07 into v2 Dec 10, 2025
3 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow branch December 10, 2025 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants