def coerce_ts(ts: Union[datetime, str, int, float]) -> datetime:
    """Coerce various forms of timestamp into datetime."""

    if isinstance(ts, datetime):
        return ts
    if isinstance(ts, str):
        return datetime.fromisoformat(ts)
    if isinstance(ts, (int, float)):
        return datetime.fromtimestamp(ts)

    raise ValueError(f"Cannot coerce to datetime: {ts}")
Coerce various forms of timestamp into datetime.
src/core/trulens/core/database/utils.py