Skip to content

Commit

Permalink
Merge pull request #47 from zilliztech/add-partition-cli
Browse files Browse the repository at this point in the history
support partition cli
  • Loading branch information
nameczz authored Aug 22, 2023
2 parents daefc8c + 1725c10 commit 9e6205d
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
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))

0 comments on commit 9e6205d

Please sign in to comment.