Skip to main content

Python wrapper for Birdwatcher - Milvus debug and diagnostic tool

Project description

PyBirdwatcher

Python wrapper for Birdwatcher - a debug and diagnostic tool for Milvus 2.0+.

Installation

pip install pybirdwatcher

The package includes pre-compiled binaries for:

  • Linux (amd64, arm64)
  • macOS (amd64, arm64)
  • Windows (amd64)

Quick Start

from pybirdwatcher import Birdwatcher

# Using context manager (recommended)
with Birdwatcher.connect("localhost:2379") as bw:
    # List sessions
    for session in bw.sessions:
        print(f"{session.server_name}: {session.address}")

    # List collections
    for collection in bw.collections:
        print(f"{collection.name}: {len(collection.fields)} fields")

Pythonic API

Sessions

from pybirdwatcher import Birdwatcher

with Birdwatcher.connect("localhost:2379") as bw:
    # Property access
    sessions = bw.sessions

    # Get coordinators only
    coords = bw.get_coordinators()

    # Get specific node types
    querynodes = bw.get_nodes("querynode")
    datanodes = bw.get_nodes("datanode")

    for s in sessions:
        print(f"ID: {s.server_id}")
        print(f"Name: {s.server_name}")
        print(f"Address: {s.address}")
        print(f"Version: {s.version}")
        print(f"Is Coordinator: {s.is_coordinator}")

Collections

from pybirdwatcher import Birdwatcher, CollectionState

with Birdwatcher.connect("localhost:2379") as bw:
    # List all collections
    collections = bw.collections

    # Filter by database ID
    collections = bw.list_collections(db_id=1)

    # Get specific collection
    coll = bw.get_collection(name="my_collection")

    if coll:
        print(f"ID: {coll.id}")
        print(f"Name: {coll.name}")
        print(f"State: {coll.state}")
        print(f"Shards: {coll.num_shards}")

        # Access fields
        for field in coll.fields:
            print(f"  Field: {field.name} ({field.data_type})")

        # Get primary key field
        pk = coll.pk_field
        print(f"PK Field: {pk.name}")

        # Get vector fields
        for vf in coll.vector_fields:
            print(f"Vector: {vf.name}")

Segments

from pybirdwatcher import Birdwatcher, SegmentState, SegmentLevel

with Birdwatcher.connect("localhost:2379") as bw:
    # List all segments
    segments = bw.segments

    # Filter by collection
    segments = bw.list_segments(collection_id=123)

    # Filter by state (using enum or string)
    flushed = bw.list_segments(state=SegmentState.FLUSHED)
    growing = bw.list_segments(state="Growing")

    # Filter by level
    l0_segments = bw.list_segments(level=SegmentLevel.L0)

    # Get small segments (low fill ratio)
    small = bw.get_small_segments(collection_id=123, threshold=0.2)

    for seg in segments:
        print(f"ID: {seg.id}")
        print(f"State: {seg.state}")
        print(f"Level: {seg.level}")
        print(f"Rows: {seg.num_rows}/{seg.max_rows}")
        print(f"Fill Ratio: {seg.fill_ratio:.2%}")
        print(f"Is Small: {seg.is_small}")

Statistics

from pybirdwatcher import Birdwatcher

with Birdwatcher.connect("localhost:2379") as bw:
    # Get segment statistics
    stats = bw.get_segment_stats(collection_id=123)
    print(f"Total segments: {stats['total']}")
    print(f"Healthy segments: {stats['healthy_segments']}")
    print(f"Small segments: {stats['small_segments']}")
    print(f"Total rows: {stats['total_rows']}")
    print(f"By state: {stats['by_state']}")
    print(f"By level: {stats['by_level']}")

    # Get cluster summary
    summary = bw.get_cluster_summary()
    print(f"Components: {summary['total_components']}")
    print(f"Collections: {summary['total_collections']}")

Other Resources

with Birdwatcher.connect("localhost:2379") as bw:
    # Databases
    databases = bw.databases

    # Partitions
    partitions = bw.list_partitions(collection_id=123)

    # Indexes
    indexes = bw.list_indexes(collection_id=123)

    # Replicas
    replicas = bw.list_replicas(collection_id=123)

    # Checkpoints
    checkpoints = bw.list_checkpoints(collection_id=123)

    # Health check
    health = bw.healthz()

Raw Commands

with Birdwatcher.connect("localhost:2379") as bw:
    # Run any birdwatcher command
    output = bw.run("show channel-watch")

    # Get JSON output
    data = bw.run("show session", json_output=True)

Data Models

All data is returned as Python dataclasses with proper typing:

from pybirdwatcher import (
    Session,
    Collection,
    Segment,
    SegmentState,
    SegmentLevel,
    CollectionState,
    DataType,
    FieldSchema,
)

# Enums for filtering
SegmentState.FLUSHED
SegmentState.GROWING
SegmentState.DROPPED

SegmentLevel.L0
SegmentLevel.L1
SegmentLevel.L2

CollectionState.COLLECTION_CREATED

DataType.FLOAT_VECTOR
DataType.INT64

Building from Source

cd python

# Build binary for current platform
./scripts/build_binary.sh

# Build for all platforms
./scripts/build_all_platforms.sh

# Build wheel
pip install build
python -m build

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pybirdwatcher-0.1.0-py3-none-manylinux_2_17_x86_64.whl (24.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

pybirdwatcher-0.1.0-py3-none-manylinux_2_17_aarch64.whl (21.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

pybirdwatcher-0.1.0-py3-none-macosx_11_0_arm64.whl (22.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

pybirdwatcher-0.1.0-py3-none-macosx_10_9_x86_64.whl (24.2 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file pybirdwatcher-0.1.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pybirdwatcher-0.1.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8ce00c93ad19d3235479a79d530f131d98e7917351c2e9baefdfec129cd013f0
MD5 f44e84b7a0edf7196f38d655e745093b
BLAKE2b-256 1627e29a7f842a92cc08778542a656178f41dd35dbae74316cbba4bb5dc16579

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybirdwatcher-0.1.0-py3-none-manylinux_2_17_x86_64.whl:

Publisher: build-wheels.yml on zhuwenxing/birdwatcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybirdwatcher-0.1.0-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pybirdwatcher-0.1.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 692de42d4a7dfd0b7e8f72c8b9d73455a95d11948723983a8e7da8de46d057d5
MD5 b9540c1b8557a184632c025baba7521a
BLAKE2b-256 f640a638ced978d27eb8caba24253d01c40ca09a945b027d17ec5b043550475c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybirdwatcher-0.1.0-py3-none-manylinux_2_17_aarch64.whl:

Publisher: build-wheels.yml on zhuwenxing/birdwatcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybirdwatcher-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pybirdwatcher-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db921b56e34a25cb396d78b1a9ed63ae0ce7bce0bc0532ed36270a57f4d93066
MD5 d7807f682a53f7c069905b8f9378b7a8
BLAKE2b-256 87905fc7e89ba46f5acba7efbce42064ee0e057337b74c1aed5a18f450c6452f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybirdwatcher-0.1.0-py3-none-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on zhuwenxing/birdwatcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybirdwatcher-0.1.0-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pybirdwatcher-0.1.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 30977029f630d2deaeeeb9e3065ec32acd770aa84604773d8dde85559133d9ac
MD5 a3fbc1dd6ccf25d6a60ab487bdd47780
BLAKE2b-256 d93a568254a769a54837997a6e5e0f52f39c90715e9621c8bf0c7a95ee98a9d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybirdwatcher-0.1.0-py3-none-macosx_10_9_x86_64.whl:

Publisher: build-wheels.yml on zhuwenxing/birdwatcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page