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.1b0.tar.gz (6.2 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.1b0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: milvusmodel_py-0.2.1b0.tar.gz
  • Upload date:
  • Size: 6.2 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.1b0.tar.gz
Algorithm Hash digest
SHA256 dfe5695560444f81e7b6a65bb0df9dde5242d411294a2dbb8d182dc6793fa59a
MD5 5c485a4d7f1ad30ef8d272f03162b559
BLAKE2b-256 68477516ca2bf2d6fd6b5b539798c205474908c7ff7742034030087784a6caa8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for milvusmodel_py-0.2.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 d56ec670609325b8069702d19b5ab5dbdd43fde10b60376b02b827ae4ab7a606
MD5 25c77b2c1d1a5a0e89143c7258b362ed
BLAKE2b-256 daae38509ed6af8173375b41437eb05ffca93b70f49269dcdba1d94c2768cfab

See more details on using hashes here.

Provenance

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