latent.utils¶
Utility functions for hashing and dynamic imports.
Functions¶
import_string¶
Import a class or function from a dotted path.
Args: dotted_path: "module.submodule.ClassName"
Returns: The imported object
Raises: ImportError: If module cannot be imported AttributeError: If class/function cannot be found
stable_hash¶
Generate a stable MD5 hash for an object.
Handles: - Primitives (str, int, float, bool, None) - Dictionaries and Lists (recursively sorted) - Pandas DataFrames (content-based) - Pydantic Models - Other objects (via str representation)
Args: obj: Object to hash
Returns: Hex digest string
truncate_for_logging¶
Truncate/summarize a value for logging purposes.
Handles DataFrames, arrays, large collections, and long strings gracefully.
Args: value: Any value to summarize max_length: Maximum string length before truncation
Returns: A concise string representation