Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

valohai-migrate-metricsValohai 迁移指标

Agent Skill

valohai-migrate-metrics 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

371

周安装

15

GitHub Stars

公开资料未说明

下载量

116
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:valohai-migrate-metrics(Valohai 迁移指标)
来源仓库:https://github.com/valohai/valohai-skills
仓库路径:skills/valohai-migrate-metrics
安装命令:
npx skills add https://github.com/valohai/valohai-skills --skill valohai-migrate-metrics
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/valohai/valohai-skills --skill valohai-migrate-metrics

简介

valohai-migrate-metrics 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词、任务场景或来源线索快速定位候选结果。

  • 适用于研究检索类任务,提供指标迁移和分析支持。
  • 通过 npx skills add 命令从 GitHub 安装,需确认权限范围和维护状态。
  • 使用前建议检查是否会触发联网、命令执行或文件读写操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Valohai Metrics/Metadata Migration

Add metrics tracking to ML code so Valohai automatically captures, visualizes, and enables comparison across experiments. No special libraries required - just print JSON to stdout.

Philosophy

Valohai captures metrics by detecting JSON printed to stdout during execution. This is deliberately simple and framework-agnostic. No SDK imports, no decorators, no special API calls. Just print(json.dumps({...})).

Step-by-Step Instructions

1. Identify Metrics to Track

Scan the user's ML code for values worth tracking:

  • Training metrics: loss, accuracy, precision, recall, F1 score, AUC-ROC
  • Training dynamics: learning rate (if scheduled), gradient norm, batch processing time
  • Validation metrics: val_loss, val_accuracy, val_f1 (per epoch or interval)
  • Resource metrics: GPU utilization, memory usage, throughput (samples/sec)
  • Final results: best model score, total training time, convergence epoch
  • Custom KPIs: any domain-specific metric the user cares about

2. Add JSON Printing to Code

The core pattern is simple - print a JSON dictionary to stdout:

import json

# Log metrics at any point in your code
print(json.dumps({"accuracy": 0.92, "loss": 0.08}))

CRITICAL: Group all metrics from the same moment into a single json.dumps() call. Each print(json.dumps(...)) creates one metadata event with one timestamp. If you print metrics separately, Valohai treats them as disconnected events and they cannot be correlated.

# WRONG - 4 disconnected events, can't be correlated or plotted together
print(json.dumps({"inference_time_s": 0.45}))
print(json.dumps({"num_detections": 6}))
print(json.dumps({"confidence_threshold": 0.25}))
print(json.dumps({"iou_threshold": 0.7}))

# CORRECT - 1 event, all metrics linked together
print(json.dumps({
    "inference_time_s": 0.45,
    "num_detections": 6,
    "confidence_threshold": 0.25,
    "iou_threshold": 0.7,
}))

Same rule applies to training loops - one epoch = one json.dumps():

# WRONG
print(json.dumps({"epoch": epoch}))
print(json.dumps({"train_loss": train_loss}))
print(json.dumps({"val_accuracy": val_acc}))

# CORRECT
print(json.dumps({
    "epoch": epoch,
    "train_loss": train_loss,
    "val_accuracy": val_acc,
}))

Valohai automatically:

  • Captures every JSON line printed to stdout
  • Adds a UTC timestamp
  • Makes values searchable, sortable, and plottable
  • Enables real-time visualization during execution

3. Common Integration Patterns

Training Loop (Most Common)

import json

for epoch in range(epochs):
    train_loss = train_one_epoch(model, train_loader, optimizer)
    val_loss, val_acc = validate(model, val_loader)

    print(json.dumps({
        "epoch": epoch,
        "train_loss": train_loss,
        "val_loss": val_loss,
        "val_accuracy": val_acc,
    }))

Batch-Level Logging

import json

for epoch in range(epochs):
    for batch_idx, (data, target) in enumerate(train_loader):
        loss = train_step(model, data, target, optimizer)

        if batch_idx % 100 == 0:  # Log every N batches to stay under 50 events/sec
            print(json.dumps({
                "epoch": epoch,
                "batch": batch_idx,
                "loss": loss.item(),
            }))

Multiple Phases with Context

import json

# Training phase
for epoch in range(epochs):
    train_metrics = train_epoch(model, train_loader)
    print(json.dumps({
        "epoch": epoch,
        "phase": "training",
        "loss": train_metrics["loss"],
        "accuracy": train_metrics["accuracy"],
    }))

    # Validation phase
    val_metrics = validate(model, val_loader)
    print(json.dumps({
        "epoch": epoch,
        "phase": "validation",
        "loss": val_metrics["loss"],
        "accuracy": val_metrics["accuracy"],
    }))

Final Summary Metrics

import json

# After training completes
print(json.dumps({
    "best_val_accuracy": best_accuracy,
    "best_epoch": best_epoch,
    "total_training_time_seconds": elapsed,
    "final_train_loss": final_loss,
}))

4. Framework-Specific Examples

PyTorch

import json
import time

for epoch in range(args.epochs):
    model.train()
    running_loss = 0.0
    correct = 0
    total = 0

    for batch_idx, (inputs, targets) in enumerate(train_loader):
        inputs, targets = inputs.to(device), targets.to(device)
        optimizer.zero_grad()
        outputs = model(inputs)
        loss = criterion(outputs, targets)
        loss.backward()
        optimizer.step()

        running_loss += loss.item()
        _, predicted = outputs.max(1)
        total += targets.size(0)
        correct += predicted.eq(targets).sum().item()

    train_loss = running_loss / len(train_loader)
    train_acc = correct / total

    # Validation
    model.eval()
    val_loss, val_acc = evaluate(model, val_loader, criterion, device)

    print(json.dumps({
        "epoch": epoch,
        "train_loss": round(train_loss, 4),
        "train_accuracy": round(train_acc, 4),
        "val_loss": round(val_loss, 4),
        "val_accuracy": round(val_acc, 4),
        "learning_rate": optimizer.param_groups[0]["lr"],
    }))

TensorFlow/Keras (Custom Callback)

import json
import tensorflow as tf

class ValohaiMetricsCallback(tf.keras.callbacks.Callback):
    def on_epoch_end(self, epoch, logs=None):
        if logs:
            metrics = {"epoch": epoch}
            metrics.update({k: round(float(v), 4) for k, v in logs.items()})
            print(json.dumps(metrics))

model.fit(
    x_train, y_train,
    epochs=args.epochs,
    batch_size=args.batch_size,
    validation_data=(x_val, y_val),
    callbacks=[ValohaiMetricsCallback()],
)

scikit-learn

import json
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score

model.fit(X_train, y_train)
y_pred = model.predict(X_test)

print(json.dumps({
    "accuracy": round(accuracy_score(y_test, y_pred), 4),
    "precision": round(precision_score(y_test, y_pred, average="weighted"), 4),
    "recall": round(recall_score(y_test, y_pred, average="weighted"), 4),
    "f1_score": round(f1_score(y_test, y_pred, average="weighted"), 4),
}))

XGBoost / LightGBM

import json

def valohai_callback(env):
    """Custom callback to log metrics to Valohai."""
    # Collect all metrics into one event per iteration
    metrics = {"iteration": env.iteration}
    for item in env.evaluation_result_list:
        metrics[item[0]] = round(item[1], 4)
    print(json.dumps(metrics))

model = xgb.train(
    params, dtrain,
    num_boost_round=100,
    evals=[(dtrain, "train"), (dval, "val")],
    callbacks=[valohai_callback],
)

5. What Valohai Does With Metrics

  • Execution table: Sort and filter executions by any metric value
  • Time-series charts: Plot metrics over epochs/steps, updated in real-time during training
  • Multi-execution comparison: Overlay metrics from multiple runs on the same chart
  • CSV/JSON export: Download metric data for external analysis
  • Pipeline conditions: Use metrics to control pipeline flow (e.g., stop if accuracy > threshold)

Best Practices

  1. One event = one json.dumps() - all metrics from the same moment MUST be in a single print. Separate prints create disconnected events that can't be correlated
  2. Log progressively throughout training, not just final results - enables real-time monitoring
  3. Use consistent metric names across experiments for meaningful comparison
  4. Include a step/epoch counter as a metric for proper time-series alignment
  5. Round floating-point values to 4-6 decimal places to keep logs readable
  6. Print to stdout (not stderr) - Valohai only captures JSON from stdout
  7. Ensure valid JSON - use json.dumps() rather than manual string formatting
  8. Add context fields like phase: "training" or phase: "validation" to distinguish metrics
  9. Log at reasonable intervals - every epoch is good; every batch may be too noisy unless filtered
  10. Stay under 50 events/second - Valohai enforces a rate limit of 500 JSON events per 10 seconds (50/s). Exceeding this triggers a warning and events will be dropped silently. If logging per-batch metrics, add a frequency filter (e.g., every N batches) to stay well under this limit

Edge Cases

  • Non-JSON stdout lines are ignored by Valohai (treated as regular log output)
  • Multiple JSON prints per line: only the first valid JSON object is captured
  • Nested JSON objects are flattened for display in the UI
  • String values in metrics are supported (e.g., "best_model": "epoch_42")
  • Boolean values are supported
  • Metrics can be used in pipeline edge conditions: metadata.accuracy >= 0.9
  • If using print() with frameworks that also print to stdout, the JSON lines are still correctly identified
  • Rate limit: More than 500 JSON events per 10 seconds triggers More than 50.0 events per second are being written to stdout; some are ignored. — dropped events are lost permanently. Use batch-level filtering (if batch_idx % N == 0) to control output rate

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.63%
按下载量换算42

Claude

27.1%
按下载量换算31

Cursor

19.52%
按下载量换算23

Gemini CLI

9.14%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills