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.1b1.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.1b1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: milvusmodel_py-0.1.1b1.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.1b1.tar.gz
Algorithm Hash digest
SHA256 db57d1c35f90c682caffd31aa2cabeb69c34c893d4c0614771639b944d23483c
MD5 55380e1dafd17de437dcd58707b70eab
BLAKE2b-256 5daad12217abdbe262f3300db647ce3dea1188e29fc0689e66fdcc9686e313e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for milvusmodel_py-0.1.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a01c6c56ae8b550e6f633bf258922f7bd5d86666b0bd40444a161c5d3755d9a
MD5 2dcc5c1ef8bcad90130d416671ce12d9
BLAKE2b-256 6255b2f843b8342c88d932df3a2b88c5d2be9cc7f364786401cf37d1063b3270

See more details on using hashes here.

Provenance

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