From 574ec125ba54daf34493527f8c1ef4f515b749a1 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 25 May 2026 12:29:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20milvus=202.6.12=20?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/milvus/2.6.12/Dockerfile | 23 +++++++++++ frameworks/milvus/2.6.12/README.md | 46 ++++++++++++++++++++++ frameworks/milvus/2.6.12/build.conf | 4 ++ frameworks/milvus/2.6.12/test.sh | 61 +++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 frameworks/milvus/2.6.12/Dockerfile create mode 100644 frameworks/milvus/2.6.12/README.md create mode 100644 frameworks/milvus/2.6.12/build.conf create mode 100755 frameworks/milvus/2.6.12/test.sh diff --git a/frameworks/milvus/2.6.12/Dockerfile b/frameworks/milvus/2.6.12/Dockerfile new file mode 100644 index 00000000..ffe7cb3e --- /dev/null +++ b/frameworks/milvus/2.6.12/Dockerfile @@ -0,0 +1,23 @@ +FROM opencloudos/opencloudos9-minimal:latest + +LABEL maintainer="OpenCloudOS Community" +LABEL org.opencontainers.image.source="https://gitee.com/OpenCloudOS/ai-agent-container" +LABEL org.opencontainers.image.description="Milvus (pymilvus) 2.6.12 on OpenCloudOS 9" + +# 安装 Python 3.11 及基础依赖 +RUN dnf install -y \ + python3.11 \ + python3.11-pip \ + && dnf clean all \ + && rm -rf /var/cache/yum/* \ + && ln -sf /usr/bin/python3.11 /usr/bin/python3 + +# 安装 pymilvus +RUN pip3.11 install --no-cache-dir uv \ + && uv pip install --no-cache-dir \ + "pymilvus[milvus-lite]==2.6.12" \ + --system + +RUN echo $(date +"%Y-%m-%dT%H:%M:%S%z") > /opencloudos_build_date.txt + +CMD ["python3.11"] diff --git a/frameworks/milvus/2.6.12/README.md b/frameworks/milvus/2.6.12/README.md new file mode 100644 index 00000000..9e2d5865 --- /dev/null +++ b/frameworks/milvus/2.6.12/README.md @@ -0,0 +1,46 @@ +# Milvus (pymilvus) 2.6.12 on OpenCloudOS 9 + +## 基本信息 +- **框架版本**:v2.6.12 +- **基础镜像**:opencloudos/opencloudos9-minimal:latest +- **Python 版本**:3.11 +- **框架类型**:向量数据库(CPU) +- **CUDA 版本**:N/A(CPU 框架) + +## 构建 + +```bash +docker build -t oc9-milvus:2.6.12 frameworks/milvus/2.6.12/ +``` + +## 使用示例 + +```bash +# 验证 pymilvus 版本 +docker run --rm oc9-milvus:2.6.12 python3 -c "from pymilvus import __version__; print(__version__)" + +# 本地模式使用示例 +docker run --rm oc9-milvus:2.6.12 python3 -c " +from pymilvus import MilvusClient + +client = MilvusClient('./milvus_demo.db') +client.create_collection(collection_name='demo', dimension=4) +client.insert('demo', [{'id': 1, 'vector': [0.1, 0.2, 0.3, 0.4]}]) +results = client.query('demo', filter='id == 1', output_fields=['vector']) +print(results) +" +``` + +## 测试验证 + +```bash +bash test.sh oc9-milvus:2.6.12 +``` + +测试脚本会验证以下内容: +- pymilvus 模块正常导入且版本正确 +- MilvusClient 本地模式可正常创建 +- 集合增删改查操作正常 + +## 已知问题 +- 本地模式(MilvusClient + SQLite)仅适合开发测试,生产环境建议连接远程 Milvus 服务。 diff --git a/frameworks/milvus/2.6.12/build.conf b/frameworks/milvus/2.6.12/build.conf new file mode 100644 index 00000000..d0eb775a --- /dev/null +++ b/frameworks/milvus/2.6.12/build.conf @@ -0,0 +1,4 @@ +# milvus (pymilvus) 2.6.12 on OpenCloudOS 9 +IMAGE_NAME=oc9-milvus +IMAGE_TAG=2.6.12 +GPU_TEST=false diff --git a/frameworks/milvus/2.6.12/test.sh b/frameworks/milvus/2.6.12/test.sh new file mode 100755 index 00000000..de5ae617 --- /dev/null +++ b/frameworks/milvus/2.6.12/test.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -e + +IMAGE="${1:?ERROR: 缺少镜像参数。用法: bash test.sh }" + +VERSION="2.6.12" + +echo "=== Milvus (pymilvus) $VERSION 功能测试 ===" + +# 1. 验证 pymilvus 导入 +echo -n "检查 pymilvus import... " +docker run --rm "$IMAGE" python3 -c " +from pymilvus import __version__ +print('pymilvus version:', __version__) +assert __version__ == '$VERSION', f'Expected $VERSION, got {__version__}' +" && echo "✓ 通过" || { echo "✗ 失败"; exit 1; } + +# 2. 验证 MilvusClient 本地模式可创建 +echo -n "检查 MilvusClient 本地模式... " +docker run --rm "$IMAGE" python3 -c " +from pymilvus import MilvusClient +client = MilvusClient('./test_milvus.db') +print('MilvusClient 本地模式创建成功') +" && echo "✓ 通过" || { echo "✗ 失败"; exit 1; } + +# 3. 验证集合操作 +echo -n "检查集合增删改查... " +docker run --rm "$IMAGE" python3 -c " +from pymilvus import MilvusClient +import numpy as np + +client = MilvusClient('./test_milvus.db') + +# 创建集合 +if client.has_collection('test_collection'): + client.drop_collection('test_collection') + +client.create_collection( + collection_name='test_collection', + dimension=4, +) + +# 插入数据 +data = [ + {'id': 1, 'vector': [0.1, 0.2, 0.3, 0.4], 'text': 'hello'}, + {'id': 2, 'vector': [0.2, 0.3, 0.4, 0.5], 'text': 'world'}, +] +client.insert(collection_name='test_collection', data=data) + +# 查询数据 +results = client.query( + collection_name='test_collection', + filter='id == 1', + output_fields=['text'] +) +assert len(results) == 1 +assert results[0]['text'] == 'hello' +print('集合操作正常') +" && echo "✓ 通过" || { echo "✗ 失败"; exit 1; } + +echo "=== 所有测试通过 ===" -- Gitee