Skip to content

Conversation

@wangxingjun778
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wangxingjun778, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the robustness of the AutoSkills framework by introducing a comprehensive suite of unit tests for its DAG execution capabilities. It ensures that data and outputs from upstream skills are correctly and reliably propagated to downstream skills, covering various execution patterns and edge conditions. Additionally, a minor but important fix improves the sanitization of skill IDs for environment variables, preventing potential issues with special characters.

Highlights

  • Enhanced Environment Variable Sanitization: The logic for sanitizing skill IDs into safe environment variable keys has been extended to handle additional special characters, specifically '@' and '/', ensuring broader compatibility for upstream skill references.
  • Comprehensive Unit Tests for Skill DAG Data Flow: A new, extensive unit test module has been added to validate the upstream-downstream data passing mechanism within the Skill Directed Acyclic Graph (DAG) executor. This includes tests for sequential and parallel skill execution, output file propagation, and various edge cases.
  • Removal of Empty Test Initialization File: An empty 'init.py' file within the 'tests/skills' directory has been removed, tidying up the test suite structure.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • ms_agent/skill/auto_skills.py
    • Modified the _build_execution_input function to include '@' and '/' in the dep_id sanitization process when creating safe_key environment variables for upstream outputs.
  • tests/skills/init.py
    • Removed the empty __init__.py file.
  • tests/skills/test_dag_upstream_downstream.py
    • Added a new unit test file to validate the DAGExecutor's upstream-downstream data passing.
    • Includes tests for direct data flow, full pipeline execution, mixed parallel and sequential DAGs, and edge cases.
    • Verifies correct environment variable injection (UPSTREAM_OUTPUTS, UPSTREAM_<SAFE_KEY>_STDOUT) and output file propagation.
    • Ensures proper handling of skill failures and special characters in skill IDs.
Activity
  • The pull request was created by wangxingjun778 to add unit tests for upstream-downstream tasks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive suite of unit tests for the skill DAG's upstream-downstream data passing, which is an excellent addition for ensuring the robustness of skill chaining. It also includes a necessary fix to properly sanitize special characters in skill IDs for environment variable creation. My feedback focuses on enhancing the new test file by improving test coverage for the sanitization logic and increasing type safety for better maintainability.

import tempfile
import unittest
from pathlib import Path
from typing import Dict, List, Optional
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve type safety in this file, please import Coroutine which is used as a type hint in the run_async helper function.

Suggested change
from typing import Dict, List, Optional
from typing import Coroutine, Dict, List, Optional

# Helpers
# ---------------------------------------------------------------------------

def run_async(coro):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better type safety and readability, please add a type hint for the coro parameter.

Suggested change
def run_async(coro):
def run_async(coro: Coroutine):

executor = self.executor

async def mock_execute_single(
skill_id, dag, execution_input=None, query=''):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, please add type hints to the parameters of this inner function.

                skill_id: str, dag: Dict, execution_input: Optional[ExecutionInput] = None, query: str = ''

executor = self.executor

async def mock_execute_single(
skill_id, dag, execution_input=None, query=''):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, please add type hints to the parameters of this inner function.

                skill_id: str, dag: Dict, execution_input: Optional[ExecutionInput] = None, query: str = ''

}

async def mock_execute_single(
skill_id, dag, execution_input=None, query=''):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, please add type hints to the parameters of this inner function.

                skill_id: str, dag: Dict, execution_input: Optional[ExecutionInput] = None, query: str = ''

Comment on lines +850 to +876
def test_safe_key_special_characters(self):
"""Skill IDs with @, -, . are sanitized in env var names."""
special_skill = create_mock_skill(
'my-tool.v2@latest', 'MyTool', 'Tool with special chars',
self.skills_dir / 'my_tool')
self.skills['my-tool.v2@latest'] = special_skill

dep_skill = create_mock_skill(
'consumer@latest', 'Consumer', 'Depends on special',
self.skills_dir / 'consumer')
self.skills['consumer@latest'] = dep_skill

self.executor._outputs['my-tool.v2@latest'] = ExecutionOutput(
stdout='special output\n', stderr='', exit_code=0, duration_ms=10)

dag = {
'my-tool.v2@latest': [],
'consumer@latest': ['my-tool.v2@latest'],
}
exec_input = self.executor._build_execution_input(
'consumer@latest', dag)

# Safe key: my-tool.v2@latest -> MY_TOOL_V2_LATEST
expected_key = 'UPSTREAM_MY_TOOL_V2_LATEST_STDOUT'
self.assertIn(expected_key, exec_input.env_vars,
f'{expected_key} should be in env_vars, '
f'got keys: {list(exec_input.env_vars.keys())}')
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The fix in auto_skills.py adds sanitization for / characters in skill IDs, but this test only covers @, -, and .. To ensure full test coverage for the change, please update this test to include a skill ID with a / character.

    def test_safe_key_special_characters(self):
        """Skill IDs with @, -, ., and / are sanitized in env var names."""
        skill_id = 'my-org/my-tool.v2@latest'
        special_skill = create_mock_skill(
            skill_id, 'MyTool', 'Tool with special chars',
            self.skills_dir / 'my_tool')
        self.skills[skill_id] = special_skill

        dep_skill = create_mock_skill(
            'consumer@latest', 'Consumer', 'Depends on special',
            self.skills_dir / 'consumer')
        self.skills['consumer@latest'] = dep_skill

        self.executor._outputs[skill_id] = ExecutionOutput(
            stdout='special output\n', stderr='', exit_code=0, duration_ms=10)

        dag = {
            skill_id: [],
            'consumer@latest': [skill_id],
        }
        exec_input = self.executor._build_execution_input(
            'consumer@latest', dag)

        # Safe key: my-org/my-tool.v2@latest -> MY_ORG_MY_TOOL_V2_LATEST
        expected_key = 'UPSTREAM_MY_ORG_MY_TOOL_V2_LATEST_STDOUT'
        self.assertIn(expected_key, exec_input.env_vars,
                       f'{expected_key} should be in env_vars, '
                       f'got keys: {list(exec_input.env_vars.keys())}')

@wangxingjun778 wangxingjun778 merged commit ee905cf into modelscope:main Feb 9, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants