-
Notifications
You must be signed in to change notification settings - Fork 848
Open
Description
Which component is this bug for?
Traceloop SDK
📜 Description
We recently turned on deprecation warnings for our app for another purpose, and began getting lots of warnings from Pydantic about Traceloop sdk calling the deprecated json method of Pydantic models. Presumably these models are arguments to workflows and tasks that we have set up.
.../miniconda3/envs/bb3.12/lib/python3.12/site-packages/traceloop/sdk/utils/json_encoder.py:21: PydanticDeprecatedSince20: The `json` method is deprecated; use `model_dump_json` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
return o.json()
👟 Reproduction steps
This contrived example raises the deprecation warning in question:
# make_warning.py
from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import task
from pydantic import BaseModel
Traceloop.init()
class SomeValue(BaseModel):
value: int
@task(name="add_numbers")
def add_numbers(a: SomeValue, b: SomeValue) -> SomeValue:
return SomeValue(value=a.value + b.value)
def main():
result = add_numbers(SomeValue(value=3), SomeValue(value=5))
print(f"Result: {result.value}")
if __name__ == "__main__":
main()This script assumes the presence of a Traceloop API token in the env.
Call the script with $ python -Wd make_warning.py
👍 Expected behavior
JSONEncoder should call model_dump_json() method of pydantic classes if present.
👎 Actual Behavior with Screenshots
Deprecation warning is raised
🤖 Python Version
3.12.11
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
Yes I am willing to submit a PR!
Metadata
Metadata
Assignees
Labels
No labels