write-fastdeploy-unittest

Generates CI-compliant pytest unit tests for FastDeploy source files.

3.7k|759|Updated Jun 27, 2022
One-click install
npx skills add https://github.com/PaddlePaddle/FastDeploy --skill write-fastdeploy-unittest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-fastdeploy-unittest
Source: https://github.com/PaddlePaddle/FastDeploy/tree/main/.claude/skills/write-fastdeploy-unittest
Command: npx skills add https://github.com/PaddlePaddle/FastDeploy --skill write-fastdeploy-unittest

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing unit tests for the FastDeploy inference toolkit requires following strict CI conventions: correct test classification (multi-GPU sequential vs single-GPU parallel), port variable usage, log isolation, resource cleanup, and an 80% diff coverage threshold. This Skill automates that process so contributors get compliant tests without memorizing the CI rules.

Core Features & Use Cases

  • Automatic Test Pattern Selection: Chooses among four patterns (pure logic, GPU kernel, offline inference, E2E serving) based on the code under test.
  • Coverage-Driven Test Generation: Accepts coverage report lines or incremental diff-coverage JSON and writes tests targeting the exact uncovered lines.
  • CI Convention Compliance: Enforces naming conventions, port environment variables, log isolation via FD_LOG_DIR, resource cleanup, and black/isort/flake8 style checks.
  • Use Case: Paste a coverage line like fastdeploy/model_executor/model_loader/default_loader.py 48 32 14 0 26% 37-38, 42 and the agent appends tests to the existing test file covering those missing branches.

Quick Start

Use the write-fastdeploy-unittest skill to add unit tests for fastdeploy/cache_manager/transfer_factory/file_store/file_store.py.

Frequently Asked Questions about write-fastdeploy-unittest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests for FastDeploy that pass CI?

Use pytest or unittest, place the file in the matching tests/ subdirectory, and follow the four test patterns: pure logic with mocks, GPU kernel tests with @pytest.mark.gpu, offline inference via the LLM API, or E2E serving with subprocess servers. Verify with coverage run and pre-commit style checks.

How to generate tests from a coverage report for uncovered lines?

Paste the coverage report line or incremental diff-coverage JSON directly into the request. The agent parses the violation_lines or missing line ranges, analyzes the source logic at those lines, and writes tests specifically targeting those uncovered branches.

Why is my FastDeploy test classified as multi-GPU sequential in CI?

Any test referencing port variables like FD_API_PORT or FD_ENGINE_QUEUE_PORT, or containing tensor_parallel_size patterns, is classified as multi-GPU and runs sequentially. This applies even to single-GPU service tests with tensor_parallel_size=1.

Does FastDeploy testing require a GPU machine?

Tests run on CI runners with 2x NVIDIA H20 GPUs. Pure logic tests need no GPU and mock external dependencies, while GPU kernel tests require a GPU and are marked with @pytest.mark.gpu so they skip on non-GPU platforms.

What coverage threshold do FastDeploy PRs need to meet?

Pull requests require 80% diff coverage, enforced with diff-cover using --fail-under=80. Hardware-dependent branches that cannot be mocked, such as NUMA topology or RDMA paths, are acceptable coverage gaps.

Should I create a new test file or append to an existing one?

Always search for an existing test file covering the same module first and append new test cases to it. Only create a new file when none exists, following the naming convention of test_<module>.py with parent prefixes for generic names.