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]: The to_dict() method in the schema does not completely convert an object to a json dict, datatype and function type are still an IntEnum class #2538

Open
1 task done
zhuwenxing opened this issue Jan 2, 2025 · 0 comments
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@zhuwenxing
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The to_dict() method in the schema does not completely convert an object to a json dict, datatype and function type are still an IntEnum class

Expected Behavior

DataType/FunctionType object can be represented as a dictionary

    def to_dict(self) -> dict:
        """Convert DataType to a plain dictionary.
        
        Returns:
            dict: A dictionary containing the name and value of the DataType.
        """
        return {
            "name": self.name,
            "value": self.value
        }
    
    @classmethod
    def from_dict(cls, d: dict) -> "DataType":
        """Create DataType from a dictionary.
        
        Args:
            d (dict): Dictionary containing DataType information.
                     Must have either 'value' or 'name' key.
        
        Returns:
            DataType: The corresponding DataType enum value.
        """
        if "value" in d:
            return cls(d["value"])
        return cls[d["name"].upper()]

Steps/Code To Reproduce behavior

No response

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0):
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

@zhuwenxing zhuwenxing added the kind/bug Something isn't working label Jan 2, 2025
@XuanYang-cn XuanYang-cn added this to the 2.5.3 milestone Jan 6, 2025
@XuanYang-cn XuanYang-cn self-assigned this Jan 6, 2025
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

2 participants