Skip to main content

Milvus Dataset

Milvus Dataset is a versatile Python library for efficient management and processing of large-scale datasets. While optimized for seamless integration with Milvus vector database, it also serves as a powerful standalone dataset management tool. The library provides a simple yet powerful interface for creating, writing, reading, and managing datasets, particularly excelling in handling large-scale vector data and general-purpose data management tasks.

Key Features

  1. Flexible Storage Support

    • Local storage support
    • Object storage support (S3/MinIO)
    • Easy migration between different storage types
  2. Rich Data Type Support

    • Basic data types (INT64, VARCHAR, etc.)
    • Vector data types (FLOAT_VECTOR)
    • JSON fields
    • Sparse vectors
    • Binary vectors
  3. Dataset Management

    • Training and test set split support
    • Dataset metadata management
    • Dataset statistics and analytics
    • Schema definition and validation
  4. Integration Capabilities

    • Import to Milvus database
    • Upload to Hugging Face Hub
    • Seamless pandas DataFrame integration
    • Built-in nearest neighbor computation
    • Built-in mock data generation

Installation

pip install milvus-dataset

Quick Start Guide

1. Basic Configuration

from milvus_dataset import ConfigManager, StorageType

# Initialize local storage
ConfigManager().init_storage(
    root_path="./data/my-dataset",
    storage_type=StorageType.LOCAL,
)

# Initialize S3 storage
ConfigManager().init_storage(
    root_path="s3://bucket/path",
    storage_type=StorageType.S3,
    options={
        "aws_access_key_id": "your_key",
        "aws_secret_access_key": "your_secret",
        "endpoint_url": "your_endpoint"  # Optional, for MinIO
    }
)

2. Creating a Dataset

from pymilvus import CollectionSchema, DataType, FieldSchema
from milvus_dataset import load_dataset

# Define Schema
schema = CollectionSchema(
    fields=[
        FieldSchema("id", DataType.INT64, is_primary=True),
        FieldSchema("text", DataType.VARCHAR, max_length=65535),
        FieldSchema("embedding", DataType.FLOAT_VECTOR, dim=1024)
    ],
    description="Text vector dataset"
)

# Load dataset
dataset = load_dataset("my-dataset", schema=schema)

3. Writing Data

import pandas as pd
import numpy as np

# Prepare data
df = pd.DataFrame({
    "id": range(1000),
    "text": ["text_" + str(i) for i in range(1000)],
    "embedding": [np.random.rand(1024) for _ in range(1000)]
})

# Write to training set
with dataset["train"].get_writer(mode="append") as writer:
    writer.write(df)

4. Dataset Operations

# View dataset information
print(dataset.summary())

# Compute neighbors
dataset.compute_neighbors(
    vector_field_name="embedding",
    pk_field_name="id",
    top_k=100
)

# import to Milvus
dataset.to_milvus(
    milvus_config={
        "host": "localhost",
        "port": 19530
    },
    milvus_storage=StorageConfig(
        root_path="s3://bucket/path",
        storage_type=StorageType.S3,
        options={
            "aws_access_key_id": "your_key",
            "aws_secret_access_key": "your_secret",
            "endpoint_url": "your_endpoint"  # Optional, for MinIO
        }
    )

)

# Upload to Hugging Face
dataset.to_hf(repo_name="username/dataset-name")

Advanced Usage

Performance Optimization

  1. File Size Configuration

    with dataset["train"].get_writer(
        mode="append",
        target_file_size_mb=512,  # Adjust file size
        num_buffers=15,           # Adjust buffer number
        queue_size=30             # Adjust queue size
    ) as writer:
        writer.write(df)
    
  2. Batch Processing

    # Read in batches
    for batch in dataset["train"].read(mode="batch", batch_size=1000):
        process_batch(batch)
    

Storage Migration

# Move data from local to S3
dataset.to_storage(StorageConfig(
    storage_type=StorageType.S3,
    root_path="s3://bucket/path",
    options={...}
))

Common Issues and Solutions

  1. Storage Type Selection

    • Use local storage for development and testing
    • Use object storage for production environments
  2. Handling Large-Scale Data

    • Use batch writing
    • Set appropriate buffer size and queue size
    • Consider parallel processing
  3. Ensuring Data Quality

    • Define comprehensive schema
    • Enable schema validation
    • Regularly check dataset statistics
  4. Performance Optimization Tips

    • Set reasonable file size (target_file_size_mb)
    • Adjust buffer parameters (num_buffers, queue_size)
    • Process data in batches instead of one by one

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

Metadata

Release files for milvus-dataset 1.0.0.post42

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for milvus-dataset 1.0.0.post42
File Size Uploaded Provenance Actions
milvus_dataset-1.0.0.post42.tar.gz 45.4 kB Without provenance Details for milvus_dataset-1.0.0.post42.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for milvus-dataset 1.0.0.post42
File Interpreter ABI Platform Actions
milvus_dataset-1.0.0.post42-py3-none-any.whl Python 3 none any Details for milvus_dataset-1.0.0.post42-py3-none-any.whl

Total release size: 89.0 kB

Release files / milvus_dataset-1.0.0.post42.tar.gz

Download URL milvus_dataset-1.0.0.post42.tar.gz
Size 45.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b68001e8ea3afc1a95e544332025a74bb1534d40566ca6d0192a37a7d1ce1aa0
BLAKE2b-256 checksum
How to use checksums
326231e6cb38f35977da9f169b07ce5c273df9903e9f74c45d8d0389a8e9d3c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.22.3 CPython/3.13.4 Darwin/22.6.0

Release files / milvus_dataset-1.0.0.post42-py3-none-any.whl

Download URL milvus_dataset-1.0.0.post42-py3-none-any.whl
Size 43.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0623eed87a455e0284095df526a9599e94ca50a3b84966279142988d0060c8e1
BLAKE2b-256 checksum
How to use checksums
28e901bc18add57d403ab071dbdf564c3f49b754b2c3dca4b13e7a145f6d50e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.22.3 CPython/3.13.4 Darwin/22.6.0

Security for milvus-dataset 1.0.0.post42

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page