alibaba / GraphScope

🔨 🍇 💻 🚀 GraphScope: A One-Stop Large-Scale Graph Computing System from Alibaba | 一站式图计算系统
https://graphscope.io
Apache License 2.0
3.27k stars 442 forks source link

[BUG] Interactive Python SDK fails to validate Model's json with Pydantic > 2.8.2 #4279

Open zhanglei1949 opened 1 week ago

zhanglei1949 commented 1 week ago
python3 basic_example.py

Output

The response of add_vertex:
 Result: Status: 0, message: OK, value: {'message': 'Vertex data is successfully inserted'}
exception:  1 validation error for ModelProperty
name
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/client/session.py", line 398, in get_vertex
    api_response = self._vertex_api.get_vertex_with_http_info(
  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/validate_call_decorator.py", line 60, in wrapper_function
    return validate_call_wrapper(*args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 96, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/api/graph_service_vertex_management_api.py", line 802, in get_vertex_with_http_info
    return self.api_client.response_deserialize(
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/api_client.py", line 315, in response_deserialize
    return_data = self.deserialize(response_text, response_type)
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/api_client.py", line 391, in deserialize
    return self.__deserialize(data, response_type)
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/api_client.py", line 430, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/api_client.py", line 732, in __deserialize_model
    return klass.from_dict(data)
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/models/vertex_data.py", line 95, in from_dict
    "values": [ModelProperty.from_dict(_item) for _item in obj.get("values")] if obj.get("values") is not None else None
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/models/vertex_data.py", line 95, in <listcomp>
    "values": [ModelProperty.from_dict(_item) for _item in obj.get("values")] if obj.get("values") is not None else None
  File "/home/runner/.local/lib/python3.10/site-packages/gs_interactive/models/model_property.py", line 90, in from_dict
    _obj = cls.model_validate({
  File "/home/runner/.local/lib/python3.10/site-packages/pydantic/main.py", line 596, in model_validate
    return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for ModelProperty
name
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type

The warnings maybe helpful for debugging.

/home/runner/.local/lib/python3.10/site-packages/google/protobuf/runtime_version.py:112: UserWarning: Protobuf gencode version 5.27.2 is older than the runtime version 5.28.2 at results.proto. Please avoid checked-in Protobuf gencode that can be obsolete.
  warnings.warn(
/home/runner/.local/lib/python3.10/site-packages/google/protobuf/runtime_version.py:112: UserWarning: Protobuf gencode version 5.27.2 is older than the runtime version 5.28.2 at common.proto. Please avoid checked-in Protobuf gencode that can be obsolete.
  warnings.warn(
/home/runner/.local/lib/python3.10/site-packages/google/protobuf/runtime_version.py:112: UserWarning: Protobuf gencode version 5.27.2 is older than the runtime version 5.28.2 at expr.proto. Please avoid checked-in Protobuf gencode that can be obsolete.
  warnings.warn(
/home/runner/.local/lib/python3.10/site-packages/google/protobuf/runtime_version.py:112: UserWarning: Protobuf gencode version 5.27.2 is older than the runtime version 5.28.2 at type.proto. Please avoid checked-in Protobuf gencode that can be obsolete.
  warnings.warn(
/home/runner/.local/lib/python3.10/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:                                                                                                                                                     [163/1892]
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `PrimitiveType` but got `StringType` with value `StringType(string=StringT...'LongText', 'VarChar']))` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `TemporalType` but got `StringType` with value `StringType(string=StringT...'LongText', 'VarChar']))` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
/home/runner/.local/lib/python3.10/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `PrimitiveType` but got `StringType` with value `StringType(string=StringT...'LongText', 'VarChar']))` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `TemporalType` but got `StringType` with value `StringType(string=StringT...'LongText', 'VarChar']))` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
/home/runner/.local/lib/python3.10/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
/home/runner/.local/lib/python3.10/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  PydanticSerializationUnexpectedValue: Expected `PrimitiveType` but got `StringType` with value `StringType(string=StringT...'LongText', 'VarChar']))` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `TemporalType` but got `StringType` with value `StringType(string=StringT...'LongText', 'VarChar']))` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['Primitive...ngType', 'TemporalType']` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
/home/runner/.local/lib/python3.10/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  Expected `list[str]` but got `_LiteralGenericAlias` with value `typing.Literal['FixedChar', 'LongText', 'VarChar']` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
zhanglei1949 commented 1 week ago

The current adhoc fix is restrict the version of Pydantic <= 2.8.2

zhanglei1949 commented 6 days ago

It seems that the failure is due to the server error on API list_jos. However, we still need to resolve the warnings from pydantic > 2.8.2