Skip to content

Instantly share code, notes, and snippets.

@ldorigo
Created February 27, 2024 08:08
Show Gist options
  • Save ldorigo/09f4ff14bc0e2d582d1cc6bff5b8ab30 to your computer and use it in GitHub Desktop.
Save ldorigo/09f4ff14bc0e2d582d1cc6bff5b8ab30 to your computer and use it in GitHub Desktop.
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