lamindb.tracked

lamindb.tracked(uid=None)

Mark a function as tracked with this decorator.

You will be able to see inputs, outputs, and parameters of the function in the data lineage graph.

Guide: Track notebooks, scripts & functions

Added in version 1.1.0: This is still in beta and will be refined in future releases.

Parameters:

uid (str | None, default: None) – Persist the uid to identify this transform across renames.

Return type:

Callable[[Callable[[ParamSpec(P, bound= None)], TypeVar(R)]], Callable[[ParamSpec(P, bound= None)], TypeVar(R)]]

Example:

import lamindb as ln

@ln.tracked()
def subset_dataframe(
    input_artifact_key: str,  # all arguments tracked as parameters of the function run
    output_artifact_key: str,
    subset_rows: int = 2,
    subset_cols: int = 2,
) -> None:
    artifact = ln.Artifact.get(key=input_artifact_key)
    df = artifact.load()  # auto-tracked as input
    new_df = df.iloc[:subset_rows, :subset_cols]
    ln.Artifact.from_df(new_df, key=output_artifact_key).save()  # auto-tracked as output