名称: pytest-ml-测试器 描述: 使用pytest进行机器学习特定测试的技能,包含数据、模型和预测的专用夹具。 允许使用的工具:
- 读取
- 写入
- Bash
- Glob
- Grep
pytest-ml-测试器
概述
使用pytest进行机器学习特定测试的技能,包含用于数据验证、模型加载、预测测试和机器学习管道验证的专用夹具。
功能
- 数据验证夹具
- 模型加载夹具
- 预测测试工具
- 性能回归测试
- 集成测试助手
- 机器学习代码覆盖率报告
- 使用Hypothesis进行基于属性的测试
- 参数化测试生成
目标流程
- 机器学习系统集成测试
- 模型评估与验证框架
- 数据收集与验证管道
工具与库
- pytest
- pytest-cov
- hypothesis
- great-expectations (可选)
输入模式
{
"type": "object",
"required": ["action"],
"properties": {
"action": {
"type": "string",
"enum": ["run", "generate", "coverage", "fixtures"],
"description": "要执行的测试操作"
},
"testConfig": {
"type": "object",
"properties": {
"testPath": { "type": "string" },
"markers": { "type": "array", "items": { "type": "string" } },
"verbose": { "type": "boolean" },
"failFast": { "type": "boolean" },
"parallel": { "type": "integer" }
}
},
"coverageConfig": {
"type": "object",
"properties": {
"sourcePath": { "type": "string" },
"minCoverage": { "type": "number" },
"reportFormat": { "type": "string", "enum": ["html", "xml", "term"] }
}
},
"generateConfig": {
"type": "object",
"properties": {
"testType": {
"type": "string",
"enum": ["data_validation", "model_inference", "performance", "integration"]
},
"targetPath": { "type": "string" },
"modelPath": { "type": "string" },
"dataPath": { "type": "string" }
}
},
"fixtureConfig": {
"type": "object",
"properties": {
"dataFixtures": { "type": "array" },
"modelFixtures": { "type": "array" },
"scope": { "type": "string", "enum": ["function", "class", "module", "session"] }
}
}
}
}
输出模式
{
"type": "object",
"required": ["status", "results"],
"properties": {
"status": {
"type": "string",
"enum": ["passed", "failed", "error"]
},
"results": {
"type": "object",
"properties": {
"totalTests": { "type": "integer" },
"passed": { "type": "integer" },
"failed": { "type": "integer" },
"skipped": { "type": "integer" },
"duration": { "type": "number" }
}
},
"failures": {
"type": "array",
"items": {
"type": "object",
"properties": {
"testName": { "type": "string" },
"error": { "type": "string" },
"traceback": { "type": "string" }
}
}
},
"coverage": {
"type": "object",
"properties": {
"percentage": { "type": "number" },
"reportPath": { "type": "string" },
"uncoveredLines": { "type": "object" }
}
},
"generatedTests": {
"type": "array",
"items": { "type": "string" }
}
}
}
使用示例
{
kind: 'skill',
title: '运行机器学习集成测试',
skill: {
name: 'pytest-ml-测试器',
context: {
action: 'run',
testConfig: {
testPath: 'tests/integration/',
markers: ['integration', 'model'],
verbose: true,
parallel: 4
},
coverageConfig: {
sourcePath: 'src/',
minCoverage: 80,
reportFormat: 'html'
}
}
}
}