diff --git a/src/guidellm/utils/encoding.py b/src/guidellm/utils/encoding.py index 5e001c8ec..bcc296b56 100644 --- a/src/guidellm/utils/encoding.py +++ b/src/guidellm/utils/encoding.py @@ -431,7 +431,7 @@ def to_dict_pydantic(self, item: Any) -> Any: "*PYD*": True, "typ": item.__class__.__name__, "mod": item.__class__.__module__, - "dat": item.model_dump(mode="python"), + "dat": item.model_dump(mode="python", exclude_computed_fields=True), } def from_dict_pydantic(self, item: dict[str, Any]) -> Any: @@ -572,7 +572,9 @@ def to_sequence_pydantic(self, obj: BaseModel) -> str | bytes: """ class_name: str = obj.__class__.__name__ class_module: str = obj.__class__.__module__ - json_data = obj.__pydantic_serializer__.to_json(obj) + json_data = obj.__pydantic_serializer__.to_json( + obj, exclude_computed_fields=True + ) return class_name.encode() + b"|" + class_module.encode() + b"|" + json_data diff --git a/tests/unit/utils/test_encoding.py b/tests/unit/utils/test_encoding.py index 1cdf3689f..b5a7059a5 100644 --- a/tests/unit/utils/test_encoding.py +++ b/tests/unit/utils/test_encoding.py @@ -201,7 +201,6 @@ def test_encode_decode_pydantic(self, valid_instances, obj: Any): else: assert decoded == obj - @pytest.mark.xfail(reason="old and broken", run=False) @pytest.mark.smoke @pytest.mark.parametrize( "obj",