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

[Bug]: FieldSchema.construct_from_dict() not support params max_length and dim #2046

Open
1 task done
james-gone opened this issue Apr 18, 2024 · 0 comments
Open
1 task done
Labels
kind/bug Something isn't working

Comments

@james-gone
Copy link

james-gone commented Apr 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When dict has max_length or dim
{'name': 'error_message', 'type': <DataType.VARCHAR: 21>, 'max_length': 1024}
a_dict={'name': 'error_msg_vector', 'type': <DataType.FLOAT_VECTOR: 101>, 'dim': 768}
When I new FieldSchema.construct_from_dict(a_dict), got

TypeError: pymilvus.orm.schema.FieldSchema() got multiple values for keyword argument 'max_length'

and

pymilvus.exceptions.MilvusException: <MilvusException: (code=65535, message=dimension is not defined in field type params, check type param dim for vector field)>

Expected Behavior

When I new FieldSchema.construct_from_dict(a_dict) no error.

Steps/Code To Reproduce behavior

fields_dict = [
    {'name': 'error_message', 'type': <DataType.VARCHAR: 21>, 'max_length': 1024},
    {'name': 'error_msg_vector', 'type': <DataType.FLOAT_VECTOR: 101>, 'dim': 768}
]
fields = []
for f_dict in fields_dict:
    fields.append(FieldSchema.construct_from_dict(f_dict))

Environment details

pymilvus==2.4.0

Anything else?

add below code at pymilvus/orm/schema.py can fix it.
within def construct_from_dict(cls, raw: Dict):

371         if raw.get("max_length") is not None:
372             kwargs["max_length"] = raw.get("max_length")
373         if raw.get("dim") is not None:
374             kwargs["dim"] = raw.get("dim")
pymilvus orm schema py-construct_from_dict
@james-gone james-gone added the kind/bug Something isn't working label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant