Created
February 27, 2024 08:08
-
-
Save ldorigo/09f4ff14bc0e2d582d1cc6bff5b8ab30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Run(BaseRunV2): | |
"""Run schema for the V2 API in the Tracer.""" | |
execution_order: int | |
child_execution_order: int | |
child_runs: List[Run] = Field(default_factory=list) | |
tags: Optional[List[str]] = Field(default_factory=list) | |
events: List[Dict[str, Any]] = Field(default_factory=list) | |
trace_id: Optional[UUID] = None | |
dotted_order: Optional[str] = None | |
@root_validator(pre=True) | |
def assign_name(cls, values: dict) -> dict: | |
"""Assign name to the run.""" | |
if values.get("name") is None: | |
if "name" in values["serialized"]: | |
values["name"] = values["serialized"]["name"] | |
elif "id" in values["serialized"]: | |
values["name"] = values["serialized"]["id"][-1] | |
if values.get("events") is None: | |
values["events"] = [] | |
return values | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment