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

fix load collection #1293

Merged
merged 1 commit into from
Feb 9, 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
72 changes: 15 additions & 57 deletions examples/resource_group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pymilvus import utility, connections
from pymilvus import utility, connections, DEFAULT_RESOURCE_GROUP
from example import *
from role_and_privilege import *

_HOST = '127.0.0.1'
_PORT = '19530'
Expand All @@ -11,10 +10,6 @@
_ID_FIELD_NAME = 'id_field'
_VECTOR_FIELD_NAME = 'float_vector_field'

_USER = "user"
_PASSWD = "123456"
_ROLE = "role"

# Vector parameters
_DIM = 128

Expand All @@ -25,37 +20,6 @@ def create_connection(user, passwd):
connections.connect(alias=_CONNECTION_NAME,host=_HOST, port=_PORT, user=user, password=passwd)
print(f"\nList connections:")
print(connections.list_connections())

def create_rbac_user():
create_credential(_USER, _PASSWD, _CONNECTION_NAME)
role = Role(_ROLE, using=_CONNECTION_NAME)
print(f"create role, role_name: {_ROLE}")
role.create()
print(f"add user")
role.add_user(_USER)
print(f"grant privilege")
role.grant("Global", "*", "CreateResourceGroup")
role.grant("Global", "*", "DropResourceGroup")
role.grant("Global", "*", "DescribeResourceGroup")
role.grant("Global", "*", "ListResourceGroups")
role.grant("Global", "*", "TransferNode")
role.grant("Global", "*", "TransferReplica")
print(f"list grants")
print(role.list_grants())

def remove_rbac_user():
create_connection("root", "123456")
role = Role(_ROLE, using=_CONNECTION_NAME)
print(f"remove user")
role.remove_user(_USER)
role.revoke("Global", "*", "CreateResourceGroup")
role.revoke("Global", "*", "DropResourceGroup")
role.revoke("Global", "*", "DescribeResourceGroup")
role.revoke("Global", "*", "ListResourceGroups")
role.revoke("Global", "*", "TransferNode")
role.revoke("Global", "*", "TransferReplica")
role.drop()
drop_credential(_USER, _CONNECTION_NAME)


def create_resource_group(name):
Expand Down Expand Up @@ -89,42 +53,36 @@ def transfer_replica(source, target, collection_name, num_replica):
utility.transfer_replica(
source, target, collection_name, num_replica, using=_CONNECTION_NAME)

def load_collection_for_transfer():
def run():
create_connection("root", "123456")
coll = create_collection(_COLLECTION_NAME, _ID_FIELD_NAME, _VECTOR_FIELD_NAME)
vectors = insert(coll, 10000, _DIM)
coll.flush()
create_index(coll, _VECTOR_FIELD_NAME)
load_collection(coll)

def run():
create_connection("root", "123456")
# create_rbac_user()
# create_connection(_USER, _PASSWD)
# load_collection_for_transfer()

create_resource_group("rg")
list_resource_groups()
describe_resource_group("rg")
transfer_node("__default_resource_group", "rg", 1)
describe_resource_group("__default_resource_group")
transfer_node(DEFAULT_RESOURCE_GROUP, "rg", 1)
describe_resource_group(DEFAULT_RESOURCE_GROUP)
describe_resource_group("rg")
release_collection(coll)
coll.load(_resource_groups=["rg"])
print("load finish")

transfer_node("rg", "__default_resource_group", 1)
describe_resource_group("__default_resource_group")
transfer_node("rg", DEFAULT_RESOURCE_GROUP, 1)
describe_resource_group(DEFAULT_RESOURCE_GROUP)
describe_resource_group("rg")


describe_resource_group("__default_resource_group")
describe_resource_group(DEFAULT_RESOURCE_GROUP)
describe_resource_group("rg")
# transfer_replica("__default_resource_group", "rg", _COLLECTION_NAME, 1)
describe_resource_group("__default_resource_group")
transfer_replica("rg", DEFAULT_RESOURCE_GROUP, _COLLECTION_NAME, 1)
describe_resource_group(DEFAULT_RESOURCE_GROUP)
describe_resource_group("rg")

drop_resource_group("rg")

# release_collection(coll)
# drop_collection(_COLLECTION_NAME)
# remove_rbac_user()
release_collection(coll)
drop_collection(_COLLECTION_NAME)

if __name__ == "__main__":
run()
2 changes: 1 addition & 1 deletion pymilvus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
)

from .orm import utility
from .orm.default_config import DefaultConfig, ENV_CONNECTION_CONF
from .orm.default_config import DefaultConfig, ENV_CONNECTION_CONF, DEFAULT_RESOURCE_GROUP

from .orm.search import SearchResult, Hits, Hit
from .orm.schema import FieldSchema, CollectionSchema
Expand Down
2 changes: 1 addition & 1 deletion pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def drop_partition(self, collection_name, partition_name, timeout=None):
raise MilvusException(response.error_code, response.reason)

@retry_on_rpc_failure()
def has_partition(self, collection_name, partition_name, timeout=None):
def has_partition(self, collection_name, partition_name, timeout=None, **kwargs):
check_pass_param(collection_name=collection_name, partition_name=partition_name)
request = Prepare.has_partition_request(collection_name, partition_name)
rf = self._stub.HasPartition.future(request, timeout=timeout)
Expand Down