AgentSkillsCN

python-dev

当用户请求运行 pytest、安装依赖、激活虚拟环境、执行 Python 脚本,或就 TheRock、mlse-tools、dnn-benchmarking 项目的 Python 开发、虚拟环境、pip 工具、测试流程展开讨论时,可调用此技能。

SKILL.md
--- frontmatter
name: python-dev
description: Use this skill when the user asks to run pytest, install requirements, activate venv, run python scripts, or discusses Python development, virtual environments, pip, or testing for TheRock, mlse-tools, or dnn-benchmarking projects.
version: 1.0.0

Python Development Patterns

Virtual Environment Locations

ProjectVenv Path
TheRock (main)/home/AMD/sareeder/TheRock/.venv
therock-consumption/home/AMD/sareeder/therock-consumption/.venv
therock-miopen-plugin/home/AMD/sareeder/therock-miopen-plugin-move/.venv
dnn-benchmarking/home/AMD/sareeder/dnn-benchmarking/.venv
mlse-toolsNone (use system Python)
rocm-librariesNone (C++ project)

Running Python Commands

Always activate venv or use venv's Python directly:

Option 1: Inline activation

bash
source /home/AMD/sareeder/TheRock/.venv/bin/activate && python3 script.py

Option 2: Direct path

bash
/home/AMD/sareeder/TheRock/.venv/bin/python3 script.py

Option 3: For pip

bash
/home/AMD/sareeder/TheRock/.venv/bin/pip install -r requirements.txt

pytest Patterns

TheRock

bash
source /home/AMD/sareeder/TheRock/.venv/bin/activate
pytest /home/AMD/sareeder/TheRock/tests/

dnn-benchmarking

bash
cd /home/AMD/sareeder/dnn-benchmarking
source .venv/bin/activate
pytest -m "not gpu"              # Non-GPU tests only
pytest                            # All tests (requires hipDNN)
pytest --cov=dnn_benchmarking    # With coverage
pytest -k "test_name"            # Filter by name

Environment Variables

For hipDNN/ROCm Python work:

bash
export THEROCK_DIST_DIR=/home/AMD/sareeder/TheRock/build/dist/rocm
export HIPDNN_PLUGIN_DIR=<build>/lib/hipdnn_plugins/engines
export LD_LIBRARY_PATH=$THEROCK_DIST_DIR/lib:$LD_LIBRARY_PATH

Creating New Venv

When setting up a worktree or project:

bash
cd <project-path>
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt  # If exists
pip install -e .  # If pyproject.toml exists (editable install)

Worktree Venv Isolation

CRITICAL: Each worktree must have its own .venv. Never share venvs between worktrees.

If entering a worktree without .venv, create one:

bash
cd /home/AMD/sareeder/therock-consumption
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt