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.1.1b0.tar.gz (5.4 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.1.1b0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for milvusmodel_py-0.1.1b0.tar.gz
Algorithm Hash digest
SHA256 33b0406a0bd7d258b606627c2768cacdf3ed760e6bd6c4602d1751531bb6476c
MD5 68e3605132c32865b84f7e9eb301b7ab
BLAKE2b-256 07ac7f8d9af56fadc5652aa3a3d655decf299014539fc89fb8db6180906d211c

See more details on using hashes here.

Provenance

The following attestation bundles were made for milvusmodel_py-0.1.1b0.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.1.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for milvusmodel_py-0.1.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d2f85c95ad2306678028f378d57ee54fa1a51ef88cbaa08bba769b89bd1c6dd
MD5 574fc031a2cf386f8c7d291dc54bdcc1
BLAKE2b-256 781420d9b03686af5d70a4565f5e583bc841bb8c6f450553e9271c8587d245c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for milvusmodel_py-0.1.1b0-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