本文へ移動
cccskills
無料GitHub で公開日本語紹介

hamilton-observability

Hamiltonのデータフロー実行をUIとSDKで記録し、処理履歴や依存関係、失敗箇所、実行時間を確認して、開発時のデバッグや本番監視に役立てます。

原文原文の説明を見る

Hamilton UI and SDK patterns for tracking, monitoring, and debugging dataflows. Use for observability, lineage tracking, and production monitoring.

apache/hamiltonスター 2,621(GitHub 2,621 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 失敗した実行の原因を調べたいとき
  • 開発と本番の実行を比較したいとき
  • データの来歴を追跡したいとき
  • 本番パイプラインを監視したいとき

日本語での紹介

できること

Hamilton UIとSDKを使い、Hamiltonのデータフロー(DAG)の実行履歴を記録・確認する方法を扱います。実行ごとの入力、出力、処理時間を一覧し、ノード単位で依存関係や中間値、エラー内容を調べられます。失敗した処理の原因を探したり、複数回の実行を比較して処理時間や結果の違いを確認したりする際に役立ちます。タグでチームや環境、モデルのバージョンなどを整理し、データの来歴や本番環境での実行頻度、成功率、性能の推移を追う方法も紹介します。SDKから実行履歴を取得する方法や、通知設定、MLflow・Airflowとの連携例も含まれます。

こんなときに便利

Hamiltonで構築したデータ処理の失敗箇所を調べたいときや、開発環境と本番環境の処理を比較したいときに向いています。複数のパイプラインにまたがるデータの流れを確認したい場合や、処理時間の変化を継続的に把握したいチームにも役立ちます。

使い方の例

  • 「失敗した実行で、どのノードが原因か確認したい」
  • 「開発と本番の実行時間を比較して」
  • 「モデルのバージョン別にデータの流れを追いたい」

注意点

Hamilton UIとSDKの導入が必要です。UIの例ではローカルサーバーを起動し、SDKではプロジェクトIDやユーザー名を設定します。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md11.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

<!-- SPDX-License-Identifier: Apache-2.0 -->

Hamilton Observability & UI

This skill covers the Hamilton UI, SDK, and observability patterns for tracking and monitoring your dataflows in development and production.

What is Hamilton UI?

Hamilton UI is a web-based dashboard for:

  • Tracking DAG executions - See every run with inputs, outputs, and timing
  • Visualizing dataflows - Interactive DAG visualization
  • Debugging failures - Inspect errors and intermediate values
  • Lineage tracking - Understand data provenance
  • Performance monitoring - Identify bottlenecks
  • Team collaboration - Share DAGs and results

Quick Start

1. Install Hamilton with UI Support

pip install "apache-hamilton[sdk,ui]"

2. Start the Hamilton UI

# Start the UI server locally
hamilton ui

# UI will be available at http://localhost:8241

3. Add Tracking to Your Code

"""Add HamiltonTracker to your driver."""

from hamilton_sdk import adapters
from hamilton import driver

# Create tracker
tracker = adapters.HamiltonTracker(
    project_id=1,  # Your project ID from UI
    username="your.email@example.com",
    dag_name="my_pipeline",
    tags={"environment": "dev", "team": "data-science"},
)

# Build driver with tracker
dr = (
    driver.Builder()
    .with_config(your_config)
    .with_modules(*your_modules)
    .with_adapters(tracker)
    .build()
)

# Execute as normal - runs are automatically tracked!
results = dr.execute(["final_output"], inputs={"data_path": "data.csv"})

4. View in UI

Open http://localhost:8241 and see:

  • Your DAG visualization
  • Execution history
  • Node-level timing
  • Input/output values

HamiltonTracker Features

Basic Tracking

"""Minimal tracking setup."""

from hamilton_sdk import adapters

tracker = adapters.HamiltonTracker(
    project_id=1, username="user@example.com", dag_name="etl_pipeline"
)

# Attach to driver
dr = driver.Builder().with_adapters(tracker).build()

Advanced Tracking with Tags

"""Use tags for filtering and organization."""

tracker = adapters.HamiltonTracker(
    project_id=1,
    username="user@example.com",
    dag_name="ml_training",
    tags={
        "environment": "production",
        "model_version": "v2.1",
        "team": "ml-platform",
        "experiment_id": "exp_123",
    },
)

# Tags appear in UI for filtering and search

Async Tracking

"""Track async workflows."""

from hamilton import async_driver
from hamilton_sdk import adapters

tracker = adapters.AsyncHamiltonTracker(
    project_id=1, username="user@example.com", dag_name="async_rag_pipeline"
)

dr = await async_driver.Builder().with_modules(async_module).with_adapters(tracker).build()

result = await dr.execute(["llm_response"], inputs={"query": "test"})

Project Organization

Creating Projects

Projects group related DAGs together:

# Create project via UI
# 1. Open http://localhost:8241
# 2. Click "New Project"
# 3. Name it (e.g., "Customer Analytics")
# 4. Get the project_id

# Or via API
import requests
response = requests.post(
    "http://localhost:8241/api/v1/projects",
    json={"name": "Customer Analytics", "description": "Customer data pipelines"}
)
project_id = response.json()['id']

Organizing by Team

"""Organize DAGs by team and environment."""

# Team A - Development
tracker_team_a_dev = adapters.HamiltonTracker(
    project_id=1,  # "Team A Analytics" project
    username="user@example.com",
    dag_name="user_segmentation",
    tags={"team": "team-a", "env": "dev"},
)

# Team A - Production
tracker_team_a_prod = adapters.HamiltonTracker(
    project_id=1,
    username="user@example.com",
    dag_name="user_segmentation",
    tags={"team": "team-a", "env": "prod"},
)

# Team B - Different project
tracker_team_b = adapters.HamiltonTracker(
    project_id=2,  # "Team B ML" project
    username="user@example.com",
    dag_name="recommendation_model",
    tags={"team": "team-b", "env": "dev"},
)

Debugging with Hamilton UI

Inspecting Failed Runs

When a DAG fails, the UI shows:

  1. Which node failed - Visual highlighting
  2. Error message - Full stack trace
  3. Inputs to failed node - Inspect what caused the failure
  4. Successful nodes - What completed before failure
  5. Timing - Where time was spent before failure
"""DAG fails at 'processed_data' node."""
# In UI:
# - Navigate to failed run
# - Click on red 'processed_data' node
# - See error: "ValueError: Cannot convert string to float"
# - Inspect inputs: raw_data contains 'N/A' strings
# - Fix data cleaning logic

Comparing Runs

Compare two DAG runs side-by-side:

  • Input differences
  • Timing changes
  • Output value changes
  • Code changes
"""Compare dev vs prod performance."""
# Run 1: Development (10 seconds)
# Run 2: Production (45 seconds)

# In UI:
# - Select both runs
# - Click "Compare"
# - See: 'feature_engineering' node is 8x slower in prod
# - Reason: Prod has 10x more data
# - Solution: Add caching or parallelize

Node-Level Inspection

Drill into any node to see:

  • Execution time
  • Input values
  • Output values (if stored)
  • Error details (if failed)
  • Code version

Lineage Tracking

Understanding Data Provenance

Hamilton UI automatically tracks:

  • Upstream dependencies - What data contributed to this result?
  • Downstream impact - What depends on this node?
  • Cross-DAG lineage - Track data between different pipelines
"""Track lineage across training and inference."""

# Training pipeline
training_tracker = adapters.HamiltonTracker(
    project_id=1,
    username="user@example.com",
    dag_name="model_training",
    tags={"stage": "training", "model_version": "v2.1"},
)

# Inference pipeline (same project)
inference_tracker = adapters.HamiltonTracker(
    project_id=1,
    username="user@example.com",
    dag_name="model_inference",
    tags={"stage": "inference", "model_version": "v2.1"},
)

# In UI: Filter by model_version="v2.1" to see both pipelines

Production Monitoring

Key Metrics to Track

"""Track production metrics."""

tracker = adapters.HamiltonTracker(
    project_id=1,
    username="service@example.com",
    dag_name="production_etl",
    tags={
        "environment": "production",
        "service": "data-pipeline",
        "version": os.getenv("SERVICE_VERSION", "unknown"),
        "host": os.getenv("HOSTNAME", "unknown"),
    },
)

# Monitor in UI:
# - Execution frequency (runs per hour)
# - Success rate (failures per day)
# - Execution time trends
# - Node-level performance

Alerting on Failures

"""Set up failure notifications."""
# Hamilton UI can send alerts on:
# - DAG failures
# - Slow executions (> threshold)
# - Specific node failures

# Configure in UI:
# 1. Go to Project Settings
# 2. Set up webhook or email alerts
# 3. Define alert conditions

Performance Monitoring

Track performance over time:

"""Monitor performance degradation."""
# Week 1: Average execution time = 5 minutes
# Week 2: Average execution time = 8 minutes
# Week 3: Average execution time = 12 minutes

# In UI:
# - View execution time chart
# - Identify 'data_processing' node is slowing down
# - Root cause: Data volume increased 3x
# - Solution: Add partitioning or switch to Spark

Integration with Other Tools

MLflow Integration

"""Track both Hamilton and MLflow."""

from hamilton_sdk import adapters
import mlflow

hamilton_tracker = adapters.HamiltonTracker(
    project_id=1, username="user@example.com", dag_name="ml_training"
)

# Use both adapters
dr = driver.Builder().with_adapters(hamilton_tracker, mlflow_tracker).build()

# Results tracked in both Hamilton UI and MLflow

Airflow Integration

"""Track Hamilton DAGs in Airflow tasks."""

from airflow import DAG
from airflow.operators.python import PythonOperator
from hamilton_sdk import adapters


def run_hamilton_pipeline(**context):
    """Execute Hamilton with tracking."""
    tracker = adapters.HamiltonTracker(
        project_id=1,
        username="airflow@example.com",
        dag_name="airflow_etl",
        tags={
            "airflow_dag": context["dag"].dag_id,
            "airflow_run": context["run_id"],
            "task": context["task_instance"].task_id,
        },
    )

    dr = driver.Builder().with_modules(my_module).with_adapters(tracker).build()

    return dr.execute(["output"], inputs=context["params"])


with DAG("my_dag", schedule_interval="@daily") as dag:
    task = PythonOperator(task_id="hamilton_pipeline", python_callable=run_hamilton_pipeline)

SDK Advanced Usage

Querying Runs Programmatically

"""Query Hamilton UI via SDK."""

from hamilton_sdk import client

# Connect to Hamilton UI
hc = client.HamiltonClient(base_url="http://localhost:8241", username="user@example.com")

# Get recent runs
runs = hc.get_runs(project_id=1, dag_name="my_pipeline", limit=10)

for run in runs:
    print(f"Run {run.id}: {run.status} in {run.duration}s")

# Get specific run details
run_detail = hc.get_run(run_id=runs[0].id)
print(f"Inputs: {run_detail.inputs}")
print(f"Outputs: {run_detail.outputs}")

Custom Metadata

"""Add custom metadata to runs."""

tracker = adapters.HamiltonTracker(
    project_id=1,
    username="user@example.com",
    dag_name="my_pipeline",
    tags={
        "git_commit": subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip(),
        "git_branch": subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
        .decode()
        .strip(),
        "dataset_version": "v2024.01",
        "experiment_name": "baseline_v2",
    },
)

# All metadata searchable in UI

Best Practices

  1. Use descriptive dag_names - Make them searchable (e.g., "user_segmentation_daily" not "pipeline_1")
  2. Tag consistently - Use standard keys (environment, team, version)
  3. Track production - Always enable tracking in production
  4. Monitor trends - Set up dashboards for key metrics
  5. Clean up old runs - Archive or delete runs after retention period
  6. Use projects - Organize by team/domain, not by environment
  7. Document tags - Create team standard for tag keys and values

Troubleshooting

UI Not Showing Runs

# Check UI is running
curl http://localhost:8241/api/v1/ping

# Check tracker configuration
tracker = adapters.HamiltonTracker(
    project_id=1,  # Does this project exist?
    username="user@example.com",  # Is this user registered?
    dag_name="my_pipeline",
    api_url="http://localhost:8241"  # Override if UI is on different host
)

Slow UI Performance

"""Optimize tracking for large DAGs."""

tracker = adapters.HamiltonTracker(
    project_id=1,
    username="user@example.com",
    dag_name="large_pipeline",
    # Don't capture large outputs
    capture_data_statistics=False,  # Skip stats collection
    # Or be selective about what to capture
)

Additional Resources

  • For core Hamilton patterns, use /hamilton-core
  • For scaling patterns, use /hamilton-scale
  • Hamilton UI docs: hamilton.apache.org/concepts/ui
  • Hamilton SDK docs: github.com/apache/hamilton/tree/main/ui/sdk

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

hamilton-core

無料概要あり

PythonのHamiltonでデータ処理のDAGを組み立て、実行・テスト・デバッグするためのスキルです。関数やデコレーターで処理の依存関係を表し、既存コードの分割や可視化も進められます。

  • データ加工処理をDAGに整理したいとき
  • 既存スクリプトを関数に分割したいとき
  • Hamiltonの関数をテストしたいとき
apache/hamilton2,6212026年10月28日 更新

hamilton-dev-workflow

無料概要あり

Hamiltonの新しいデータフローを、DOT図の設計から構造検証、ノード単位のテスト駆動実装まで順序立てて作る手順を案内します。

  • 新しいHamiltonの処理フローを設計したいとき
  • 実装前にDAGの依存関係を検証したいとき
  • 処理をノードごとにテストしたいとき
apache/hamilton2,6212026年10月28日 更新

hamilton-integrations

無料概要あり

Hamiltonのデータ処理フローをAirflowやFastAPIなどに組み込み、定期実行、予測API、ダッシュボード、ノートブックで活用する方法を扱います。

  • Airflowで処理を定期実行したいとき
  • Hamiltonを予測APIに組み込みたいとき
  • Streamlitで分析結果を表示したいとき
apache/hamilton2,6212026年10月28日 更新

hamilton-llm

無料概要あり

HamiltonでRAGや埋め込み、ベクトルデータベース、プロンプトを組み合わせたLLMワークフローを設計し、並列実行やキャッシュ、構造化出力を使う実装パターンを学べます。

  • 文書検索型のAI回答を作りたいとき
  • プロンプトを部品ごとに管理したいとき
  • 複数のLLM処理を並行したいとき
apache/hamilton2,6212026年10月28日 更新

hamilton-mcp

無料概要あり

HamiltonのMCPツールを使い、データ処理のひな形作成からDAGの検証・可視化・実行までを会話の中で進め、構造上の誤りを直しながらパイプラインを組み立てます。

  • 新しいHamiltonパイプラインを作りたいとき
  • 実行前にDAGの依存関係を確認したいとき
  • 処理構造を図で把握したいとき
apache/hamilton2,6212026年10月28日 更新

hamilton-scale

無料概要あり

Hamiltonの処理を規模や負荷に応じて高速化するため、非同期I/Oやマルチスレッド、Spark・Ray・Daskによる並列化とキャッシュの使い分けを学べます。

  • 複数のAPI処理を並列化したいとき
  • 大規模データを分散処理したいとき
  • 重い計算の繰り返しを減らしたいとき
apache/hamilton2,6212026年10月28日 更新

apache のスキルをすべて見る

このスキルの問題を報告する