trulens.core.schema.record¶
trulens.core.schema.record
¶
Serializable record-related classes.
Classes¶
RecordAppCallMethod
¶
Bases: SerialModel
Method information for the stacks inside RecordAppCall
.
RecordAppCall
¶
Bases: SerialModel
Info regarding each instrumented method call.
Attributes¶
call_id
class-attribute
instance-attribute
¶
call_id: CallID = Field(default_factory=new_call_id)
Unique identifier for this call.
This is shared across different instances of RecordAppCall if they refer to the same python method call. This may happen if multiple recorders capture the call in which case they will each have a different RecordAppCall but the call_id will be the same.
stack
instance-attribute
¶
stack: List[RecordAppCallMethod]
Call stack but only containing paths of instrumented apps/other objects.
rets
class-attribute
instance-attribute
¶
Returns of the instrumented method if successful.
Sometimes this is a dict, sometimes a sequence, and sometimes a base value.
error
class-attribute
instance-attribute
¶
Error message if call raised exception.
perf
class-attribute
instance-attribute
¶
Timestamps tracking entrance and exit of the instrumented method.
Functions¶
Record
¶
Bases: SerialModel
, Hashable
The record of a single main method call.
Note
This class will be renamed to Trace
in the future.
Attributes¶
cost
class-attribute
instance-attribute
¶
Costs associated with the record.
ts
class-attribute
instance-attribute
¶
Timestamp of last update.
This is usually set whenever a record is changed in any way.
main_input
class-attribute
instance-attribute
¶
The app's main input.
main_output
class-attribute
instance-attribute
¶
The app's main output if there was no error.
main_error
class-attribute
instance-attribute
¶
The app's main error if there was an error.
calls
class-attribute
instance-attribute
¶
calls: List[RecordAppCall] = []
The collection of calls recorded.
Note that these can be converted into a json structure with the same paths
as the app that generated this record via layout_calls_as_app
.
Invariant: calls are ordered by .perf.end_time
.
experimental_otel_spans
class-attribute
instance-attribute
¶
EXPERIMENTAL(otel_tracing): OTEL spans representation of this record.
This will be filled in only if the otel_tracing experimental feature is enabled.
feedback_and_future_results
class-attribute
instance-attribute
¶
feedback_and_future_results: Optional[
List[Tuple[FeedbackDefinition, Future[FeedbackResult]]]
] = Field(None, exclude=True)
Map of feedbacks to the futures for of their results.
These are only filled for records that were just produced. This will not
be filled in when read from database. Also, will not fill in when using
FeedbackMode.DEFERRED
.
feedback_results
class-attribute
instance-attribute
¶
feedback_results: Optional[List[Future[FeedbackResult]]] = (
Field(None, exclude=True)
)
Only the futures part of the above for backwards compatibility.
feedback_results_as_completed
property
¶
feedback_results_as_completed: Iterable[FeedbackResult]
Generate feedback results as they are completed.
Wraps feedback_results in as_completed.
Functions¶
wait_for_feedback_results
¶
wait_for_feedback_results(
feedback_timeout: Optional[float] = None,
) -> Dict[FeedbackDefinition, FeedbackResult]
Wait for feedback results to finish.
PARAMETER | DESCRIPTION |
---|---|
feedback_timeout |
Timeout in seconds for each feedback function. If
not given, will use the default timeout
|
RETURNS | DESCRIPTION |
---|---|
Dict[FeedbackDefinition, FeedbackResult]
|
A mapping of feedback functions to their results. |
get
¶
Get a value from the record using a path.
PARAMETER | DESCRIPTION |
---|---|
path |
Path to the value.
TYPE:
|
layout_calls_as_app
¶
layout_calls_as_app() -> Munch
Layout the calls in this record into the structure that follows that of the app that created this record.
This uses the paths stored in each RecordAppCall which are paths into the app.
Note: We cannot create a validated AppDefinition class (or subclass) object here as the layout of records differ in these ways:
-
Records do not include anything that is not an instrumented method hence have most of the structure of a app missing.
-
Records have RecordAppCall as their leafs where method definitions would be in the AppDefinition structure.