Skip to main content

SQLModel-like library for Milvus

Project description

PyMilvusModel

Inspired by SQLModel, PyMilvusModel:

is a library for interacting with Milvus databases from Python code, with Python objects.

and follows the same paradigm, using Python type annotations and powered by Pydantic

Installation

pip install milvusmodel.py

Example Usage

from typing import List, Optional
from typing_extensions import Annotated
from pymilvus import MilvusClient, DataType
from pymilvusmodel import MilvusIndexParam, MilvusField, MilvusModel


class ExampleModel(MilvusModel):
    indexes: list[MilvusIndexParam] = [
        MilvusIndexParam("vector", "IVF_FLAT", "vector_index", metric_type="COSINE", params={
            "nlist": 128
        })
    ]
    id: Annotated[
        Optional[int],
        MilvusField(name="id", dtype=DataType.INT64,
                    is_primary=True, auto_id=True)
    ] = None
    vector: Annotated[
        List[float],
        MilvusField(name="vector", dtype=DataType.FLOAT_VECTOR, dim=2)
    ]


MILVUS_CLIENT = MilvusClient("http://localhost:19530")
MilvusModel.metadata.create_all(MILVUS_CLIENT)
print(MILVUS_CLIENT.list_collections()) # ['ExampleModel']
ExampleModel.insert(ExampleModel(vector=[0, 1]))
print(ExampleModel.query(filter="id>=0")) # [ExampleModel(indexes=[<pymilvusmodel.index.MilvusIndexParam object at 0x105c825d0>], id=456328785400861845, vector=[0.0, 1.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 Distribution

milvusmodel_py-0.2.0b0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

milvusmodel_py-0.2.0b0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file milvusmodel_py-0.2.0b0.tar.gz.

File metadata

  • Download URL: milvusmodel_py-0.2.0b0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for milvusmodel_py-0.2.0b0.tar.gz
Algorithm Hash digest
SHA256 c546eaeb4946be2e2f98b94c5a4f8c69d0988e5929c4f0c0d1686c704fbb0dfa
MD5 0f95e235cf87868e0cd67923b15437da
BLAKE2b-256 59001e9d7e4f5d134215469f6c5ac8e4510560915b9b277f4ca0feb6758a9085

See more details on using hashes here.

Provenance

The following attestation bundles were made for milvusmodel_py-0.2.0b0.tar.gz:

Publisher: python-publish.yml on brianferri/PyMilvusModel

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

File details

Details for the file milvusmodel_py-0.2.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for milvusmodel_py-0.2.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 52f698a5c52f2344d2d9e8bf894bbd3669356380d0acc94a88bdaeeb056a1f37
MD5 d2e566f760c3a5534fc1d014c379db15
BLAKE2b-256 61c150d48d8d3c76f03bf3aec6dc3c754dde6c78c74d3c49250930474916d445

See more details on using hashes here.

Provenance

The following attestation bundles were made for milvusmodel_py-0.2.0b0-py3-none-any.whl:

Publisher: python-publish.yml on brianferri/PyMilvusModel

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