Skip to content

fix: Tool-Workflow Relationships#4980

Merged
shaohuzhang1 merged 1 commit intov2from
pr@v2@fix_resource_mapping
Mar 30, 2026
Merged

fix: Tool-Workflow Relationships#4980
shaohuzhang1 merged 1 commit intov2from
pr@v2@fix_resource_mapping

Conversation

@shaohuzhang1
Copy link
Copy Markdown
Contributor

fix: Tool-Workflow Relationships

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Mar 30, 2026

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
Copy Markdown

f2c-ci-robot bot commented Mar 30, 2026

[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

@shaohuzhang1 shaohuzhang1 merged commit 99d7a20 into v2 Mar 30, 2026
3 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_resource_mapping branch March 30, 2026 09:44
'tool-workflow-lib-node': lambda n: [n.get('properties').get('node_data').get('tool_lib_id')]
},
'MODEL': {'ai-chat-node': lambda n: [n.get('properties').get('node_data').get('model_id')],
'question-node': lambda n: [n.get('properties').get('node_data').get('model_id')],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The provided code snippet contains some stylistic improvements and comments that can enhance readability. However, without more context about its purpose and usage within a larger system, there are no substantial optimization suggestions. Here are a few changes you might consider:

  1. Consistency: Ensure consistent spacing around operators (=, or), commas, and other punctuation. This improves readability.

    async def anext_async(agen):
        '''Helper function to yield from gen if defined'''
        try:
            return await agen.__anext__()
        except StopAsyncIteration:
            yield None
            raise
    
    MODELS = {
        'ai-chat-node': lambda n: [n.get('properties').get('node_data').get('model_id')],
        'question-node': lambda n: [n.get('properties').get('node_data').get('model_id')],
    }
  2. Comments: Provide explanatory comments for complex or unusual logic blocks to improve maintainability.

    # Define helper function to yield from generator if it's defined
    async def anext_async(agen):
        """Helper function to yield from generator if it's defined"""
        try:
            return await agen.__anext__()
        except StopAsyncIteration:
            yield None
            raise
    
    MODELS = {
        'ai-chat-node': lambda n: [n.get('properties').get('node_data').get('model_id')],
        'question-node': lambda n: [n.get('properties').get('node_data').get('model_id')],
    }
    
    # Add support for MCP nodes in tool IDs
    NODE_TEMPLATES['NODE-TYPE'] = {  # Replace 'NODE-TYPE' with actual type key
        'mcp-tool-id': ('tool_workflows/multi_component_processor_tool.json'),
        ...
    }
  3. Code Structure: If certain sections of the code involve significant processing or data manipulations, they might benefit from being extracted into separate utility functions.

  4. Error Handling: Ensure proper error handling is implemented and documented.

    # Check if mcp_node exists before accessing properties
    if 'node_template_mcp_node' in obj_info[m]:
        node_template_mcp_node = obj_info[m]['node_template_mcp_node']
        node_type_mcp_tool_ids = [
            id_item['properties'].get('node_data').get('mcp_tool_id')
            for item in node_template_mcp_node['components']
            if item.get('node_type') == mtc.MCP_TOOL_TYPE 
        ]
    else:
        log.error("Missing 'node_template_mcp_node'")
        continue

These adjustments can help clarify the structure and intent of the code, making it easier to read and potentially improving performance or maintaining it over time.

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.

1 participant