mlflow-python by terrylica/cc-skills
npx skills add https://github.com/terrylica/cc-skills --skill mlflow-python通过 Python API 实现统一的 MLflow 读写操作,并集成 QuantStats 以提供全面的交易指标。
ADR : 2025-12-12-mlflow-python-skill
注意 : 此技能使用 Pandas(MLflow API 需要它)。
mlflow-python路径会被 Polars 偏好钩子自动跳过。
能够做到 :
无法做到 :
MLflow 使用独立的环境变量存储凭据(不嵌入在 URI 中):
# 选项 1:mise + .env.local(推荐)
# 在技能目录下创建 .env.local 文件,内容如下:
MLFLOW_TRACKING_URI=http://mlflow.eonlabs.com:5000
MLFLOW_TRACKING_USERNAME=eonlabs
MLFLOW_TRACKING_PASSWORD=<password>
# 选项 2:直接设置环境变量
export MLFLOW_TRACKING_URI="http://mlflow.eonlabs.com:5000"
export MLFLOW_TRACKING_USERNAME="eonlabs"
export MLFLOW_TRACKING_PASSWORD="<password>"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
/usr/bin/env bash << 'SKILL_SCRIPT_EOF'
cd ${CLAUDE_PLUGIN_ROOT}/skills/mlflow-python
uv run scripts/query_experiments.py experiments
SKILL_SCRIPT_EOF
/usr/bin/env bash << 'SKILL_SCRIPT_EOF_2'
cd ${CLAUDE_PLUGIN_ROOT}/skills/mlflow-python
uv run scripts/log_backtest.py \
--experiment "crypto-backtests" \
--run-name "btc_momentum_v2" \
--returns path/to/returns.csv \
--params '{"strategy": "momentum", "timeframe": "1h"}'
SKILL_SCRIPT_EOF_2
uv run scripts/query_experiments.py experiments
uv run scripts/query_experiments.py runs \
--experiment "crypto-backtests" \
--filter "metrics.sharpe_ratio > 1.5" \
--order-by "metrics.sharpe_ratio DESC"
uv run scripts/create_experiment.py \
--name "crypto-backtests-2025" \
--description "Q1 2025 cryptocurrency trading strategy backtests"
uv run scripts/get_metric_history.py \
--run-id abc123 \
--metrics sharpe_ratio,cumulative_return
log_backtest.py 脚本通过 QuantStats 计算 70 多个指标,包括:
| 类别 | 指标 |
|---|---|
| 比率 | sharpe, sortino, calmar, omega, treynor |
| 回报 | cagr, total_return, avg_return, best, worst |
| 回撤 | max_drawdown, avg_drawdown, drawdown_days |
| 交易 | win_rate, profit_factor, payoff_ratio, consecutive_wins/losses |
| 风险 | volatility, var, cvar, ulcer_index, serenity_index |
| 高级 | kelly_criterion, recovery_factor, risk_of_ruin, information_ratio |
完整列表请参见 quantstats-metrics.md。
| 脚本 | 用途 |
|---|---|
log_backtest.py | 记录回测回报率及 QuantStats 指标 |
query_experiments.py | 搜索实验和运行记录(替代 CLI) |
create_experiment.py | 创建带有元数据的新实验 |
get_metric_history.py | 检索指标时间序列数据 |
此技能使用 mise 的 [env] 模式进行配置。默认值请参见 .mise.toml。
为凭据创建 .env.local 文件(已加入 gitignore):
MLFLOW_TRACKING_URI=http://mlflow.eonlabs.com:5000
MLFLOW_TRACKING_USERNAME=eonlabs
MLFLOW_TRACKING_PASSWORD=<password>
此技能替代了基于 CLI 的 mlflow-query 技能。主要区别:
| 功能 | mlflow-query(旧) | mlflow-python(新) |
|---|---|---|
| 记录指标 | 不支持 | mlflow.log_metrics() |
| 记录参数 | 不支持 | mlflow.log_params() |
| 查询运行记录 | CLI 文本解析 | DataFrame 输出 |
| 指标历史记录 | 仅变通方案 | 原生支持 |
| 身份验证模式 | 嵌入在 URI 中 | 独立的环境变量 |
详细映射请参见 migration-from-cli.md。
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 连接被拒绝 | MLflow 服务器未运行 | 验证 MLFLOW_TRACKING_URI 和服务器状态 |
| 身份验证失败 | 凭据错误 | 检查 .env 文件中的 MLFLOW_TRACKING_USERNAME 和 PASSWORD |
| 实验未找到 | 实验名称拼写错误 | 运行 query_experiments.py experiments 列出所有实验 |
| QuantStats 导入错误 | 缺少依赖项 | 在技能目录下运行 uv add quantstats |
| Pandas 导入警告 | 此技能预期会出现 | 忽略 - MLflow 需要 Pandas(已被钩子排除) |
| 运行创建失败 | 实验不存在 | 使用 create_experiment.py 先创建实验 |
| 指标历史记录为空 | 错误的 run_id 或指标名称 | 使用 query_experiments.py runs 验证 run_id |
| 回报率 CSV 解析错误 | 错误的日期格式或列 | 检查 CSV 是否包含日期索引和回报率列 |
每周安装次数
72
代码仓库
GitHub 星标数
24
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode67
codex64
gemini-cli64
cursor62
github-copilot62
claude-code62
Unified read/write MLflow operations via Python API with QuantStats integration for comprehensive trading metrics.
ADR : 2025-12-12-mlflow-python-skill
Note : This skill uses Pandas (MLflow API requires it). The
mlflow-pythonpath is auto-skipped by the Polars preference hook.
CAN Do :
CANNOT Do :
MLflow uses separate environment variables for credentials (NOT embedded in URI):
# Option 1: mise + .env.local (recommended)
# Create .env.local in skill directory with:
MLFLOW_TRACKING_URI=http://mlflow.eonlabs.com:5000
MLFLOW_TRACKING_USERNAME=eonlabs
MLFLOW_TRACKING_PASSWORD=<password>
# Option 2: Direct environment variables
export MLFLOW_TRACKING_URI="http://mlflow.eonlabs.com:5000"
export MLFLOW_TRACKING_USERNAME="eonlabs"
export MLFLOW_TRACKING_PASSWORD="<password>"
/usr/bin/env bash << 'SKILL_SCRIPT_EOF'
cd ${CLAUDE_PLUGIN_ROOT}/skills/mlflow-python
uv run scripts/query_experiments.py experiments
SKILL_SCRIPT_EOF
/usr/bin/env bash << 'SKILL_SCRIPT_EOF_2'
cd ${CLAUDE_PLUGIN_ROOT}/skills/mlflow-python
uv run scripts/log_backtest.py \
--experiment "crypto-backtests" \
--run-name "btc_momentum_v2" \
--returns path/to/returns.csv \
--params '{"strategy": "momentum", "timeframe": "1h"}'
SKILL_SCRIPT_EOF_2
uv run scripts/query_experiments.py experiments
uv run scripts/query_experiments.py runs \
--experiment "crypto-backtests" \
--filter "metrics.sharpe_ratio > 1.5" \
--order-by "metrics.sharpe_ratio DESC"
uv run scripts/create_experiment.py \
--name "crypto-backtests-2025" \
--description "Q1 2025 cryptocurrency trading strategy backtests"
uv run scripts/get_metric_history.py \
--run-id abc123 \
--metrics sharpe_ratio,cumulative_return
The log_backtest.py script calculates 70+ metrics via QuantStats, including:
| Category | Metrics |
|---|---|
| Ratios | sharpe, sortino, calmar, omega, treynor |
| Returns | cagr, total_return, avg_return, best, worst |
| Drawdown | max_drawdown, avg_drawdown, drawdown_days |
| Trade | win_rate, profit_factor, payoff_ratio, consecutive_wins/losses |
| Risk | volatility, var, cvar, ulcer_index, serenity_index |
| Advanced | kelly_criterion, recovery_factor, risk_of_ruin, information_ratio |
See quantstats-metrics.md for full list.
| Script | Purpose |
|---|---|
log_backtest.py | Log backtest returns with QuantStats metrics |
query_experiments.py | Search experiments and runs (replaces CLI) |
create_experiment.py | Create new experiment with metadata |
get_metric_history.py | Retrieve metric time-series data |
The skill uses mise [env] pattern for configuration. See .mise.toml for defaults.
Create .env.local (gitignored) for credentials:
MLFLOW_TRACKING_URI=http://mlflow.eonlabs.com:5000
MLFLOW_TRACKING_USERNAME=eonlabs
MLFLOW_TRACKING_PASSWORD=<password>
This skill replaces the CLI-based mlflow-query skill. Key differences:
| Feature | mlflow-query (old) | mlflow-python (new) |
|---|---|---|
| Log metrics | Not supported | mlflow.log_metrics() |
| Log params | Not supported | mlflow.log_params() |
| Query runs | CLI text parsing | DataFrame output |
| Metric history | Workaround only | Native support |
| Auth pattern | Embedded in URI | Separate env vars |
See migration-from-cli.md for detailed mapping.
| Issue | Cause | Solution |
|---|---|---|
| Connection refused | MLflow server not running | Verify MLFLOW_TRACKING_URI and server status |
| Authentication failed | Wrong credentials | Check MLFLOW_TRACKING_USERNAME and PASSWORD in .env |
| Experiment not found | Experiment name typo | Run query_experiments.py experiments to list all |
| QuantStats import error | Missing dependency | uv add quantstats in skill directory |
| Pandas import warning | Expected for this skill | Ignore - MLflow requires Pandas (hook-excluded) |
| Run creation fails | Experiment doesn't exist | Use create_experiment.py to create first |
Weekly Installs
72
Repository
GitHub Stars
24
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode67
codex64
gemini-cli64
cursor62
github-copilot62
claude-code62
专业SEO审计工具:全面网站诊断、技术SEO优化与页面分析指南
68,800 周安装
Capacitor 启动画面插件:iOS/Android 自定义启动页、动画与问题解决指南
175 周安装
Shopware 6 最佳实践指南:22类77条规则,助力电商插件开发与性能优化
177 周安装
ISO 27001信息安全经理:自动化ISMS实施与医疗合规风险评估工具
174 周安装
Matplotlib 最佳实践指南:Python 数据可视化、绘图技巧与图表优化
178 周安装
Ensembl 数据库查询与基因组分析指南 | 基因注释、序列检索、变异分析
178 周安装
头脑风暴助手 - 使用Gemini AI系统生成创意想法,支持SCAMPER、六顶思考帽等方法
176 周安装
| Metric history empty | Wrong run_id or metric name | Verify run_id with query_experiments.py runs |
| Returns CSV parse error | Wrong date format or columns | Check CSV has date index and returns column |