Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support partition cli #47

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions milvus_cli/Cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from Data import MilvusData
from User import MilvusUser
from Alias import MilvusAlias
from Partition import MilvusPartition
from pymilvus import __version__
from Types import ParameterException

Expand All @@ -29,3 +30,4 @@ class MilvusCli(object):
data = MilvusData()
user = MilvusUser()
alias = MilvusAlias()
partition = MilvusPartition()
1 change: 0 additions & 1 deletion milvus_cli/Partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def list_partition_names(self, collectionName, alias=None):
def load_partition(self, collectionName, partitionName, alias=None):
try:
target = self.describe_partition(collectionName, partitionName, alias)
print("---", target)
target.load()
return f"Load partition {partitionName} successfully!"
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions milvus_cli/scripts/milvus_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from data_cli import *
from user_cli import *
from alias_cli import *
from partition_cli import *


if __name__ == "__main__":
Expand Down
101 changes: 101 additions & 0 deletions milvus_cli/scripts/partition_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from helper_cli import create, getList, delete, show, load, release
import click


@create.command("partition")
@click.option("-c", "--collection-name", "collectionName", help="Collection name.")
@click.option("-p", "--partition", "partitionName", help="The name of partition.")
@click.option(
"-d",
"--description",
"description",
help="[Optional] - Partition description.",
default="",
)
@click.pass_obj
def create_partition(obj, collectionName, partitionName, description):
"""
Create partition.

Example:

milvus_cli > create partition -c car -p new_partition -d test_add_partition
"""
click.echo(
obj.partition.create_partition(collectionName, description, partitionName)
)
click.echo("Create partition successfully!")


@show.command("partition")
@click.option("-c", "--collection-name", "collectionName", help="Collection name.")
@click.option("-p", "--partition", "partitionName", help="The name of partition.")
@click.pass_obj
def describe_partition(obj, collectionName, partitionName):
"""
Describe partition.

Example:

milvus_cli > show partition -c car -p new_partition
"""
click.echo(obj.partition.describe_partition(collectionName, partitionName))


@getList.command("partitions")
@click.option("-c", "--collection-name", "collectionName", help="Collection name.")
@click.pass_obj
def list_partitions(obj, collectionName):
"""
List partitions.

Example:

milvus_cli > list partitions -c car
"""
click.echo(obj.partition.list_partition_names(collectionName))


@delete.command("partition")
@click.option("-c", "--collection-name", "collectionName", help="Collection name.")
@click.option("-p", "--partition", "partitionName", help="The name of partition.")
@click.pass_obj
def delete_partition(obj, collectionName, partitionName):
"""
Delete partition.

Example:

milvus_cli > delete partition -c car -p new_partition
"""
click.echo(obj.partition.delete_partition(collectionName, partitionName))


@load.command("partition")
@click.option("-c", "--collection-name", "collectionName", help="Collection name.")
@click.option("-p", "--partition", "partitionName", help="The name of partition.")
@click.pass_obj
def load_partition(obj, collectionName, partitionName):
"""
Load partition.

Example:

milvus_cli > load partition -c car -p new_partition
"""
click.echo(obj.partition.load_partition(collectionName, partitionName))


@release.command("partition")
@click.option("-c", "--collection-name", "collectionName", help="Collection name.")
@click.option("-p", "--partition", "partitionName", help="The name of partition.")
@click.pass_obj
def release_partition(obj, collectionName, partitionName):
"""
Release partition.

Example:

milvus_cli > release partition -c car -p new_partition
"""
click.echo(obj.partition.release_partition(collectionName, partitionName))