## lamindb.track

lamindb.track(transform=None, *, project=None, space=None, branch=None, plan=None, features=None, params=None, new_run=None, pypackages=None, key=None, path=None, source_code=None, kind=None, entrypoint=None, initiated_by_run=None, stream_tracking=None)

 Track a run of a notebook or script.

 Populates the global run "context" with "Transform" & "Run" objects
 and tracks the compute environment.

 Parameters:
| * **transform** ("str" | "Transform" | "None", default: "None") |
 -- A transform (stem) "uid" or object. If "None", auto-creates
 a "transform" with its "uid".

| * **project** ("str" | "Project" | "None", default: "None") -- A |
 project or its "name" or "uid" for labeling entities created
 during the run.

| * **space** ("str" | "Space" | "None", default: "None") -- A |
 restricted space or its "name" or "uid" in which to store
 entities created during the run. Default: the ""all"" space.
 Note that bionty entities ignore this setting and always get
 written to the ""all"" space. If you want to manually move
 entities to a different space, set the ".space" field (Manage
 access permissions).

| * **branch** ("str" | "Branch" | "None", default: "None") -- A |
 branch (or its "name" or "uid") on which to store records.

| * **plan** ("str" | "Artifact" | "None", default: "None") -- A |
 plan, typically an agent plan. Pass an artifact (or its "key"
 or "uid").

| * **features** ("dict" | "None", default: "None") -- A |
 dictionary of features & values to track for the run.

| * **params** ("dict" | "None", default: "None") -- A dictionary |
 of params & values to track for the run.

| * **new_run** ("bool" | "None", default: "None") -- If "False", |
 loads the latest run of transform (default notebook), if
 "True", creates new run (default non-notebook).

| * **pypackages** ("bool" | "None", default: "None") -- If "True" |
 or "None", infers Python packages used in a notebook.

| * **key** ("str" | "None", default: "None") -- Transform key. |

| * **path** ("str" | "Path" | "None", default: "None") -- |
 Filepath of a notebook or script.

| * **source_code** ("str" | "None", default: "None") -- Source |
 code.

 * **kind** ("Literal"["'pipeline'", "'notebook'", "'script'",
| "'function'"] | "None", default: "None") -- Transform kind. |

| * **entrypoint** ("str" | "None", default: "None") -- Optional |
 entrypoint name (e.g. function qualname) for the run.

| * **initiated_by_run** ("Run" | "None", default: "None") -- |
 Optional parent run that triggered this run.

| * **stream_tracking** ("bool" | "None", default: "None") -- If |
 set, override whether to capture stdout/stderr to run logs.
 Used by the flow/step decorator: flows get logs ("True"),
 steps do not ("False").

 Return type:
 "None"

 -[ Examples ]-

 To track the run of a notebook or script:

 import lamindb as ln

 ln.track()  # initiate a tracked notebook/script run

 # your code automatically tracks inputs & outputs

 ln.finish()  # mark run as finished, save execution report, source code & environment

 To ensure one version history across file renames:

 ln.track("Onv04I53OgtT")

 To track a project or an agent plan: pass a project/artifact to
 "ln.track()", for example:

 ln.track(project="My project", plan="./plans/curate-dataset-x.md")

 Note that you have to create a project or save the agent plan in
 case it they don't yet exist:

 # create a project in Python
 ln.Project(name="My project").save()

 # create a project with the CLI
 lamin create project "My project"

 # save an agent plan with the CLI
 lamin save /path/to/.cursor/plans/curate-dataset-x.plan.md
 lamin save /path/to/.claude/plans/curate-dataset-x.md

 To sync code with a git repo, see: Sync code with git.

 To track parameters and features, see: Track parameters & features.

 To browse more examples, see: Manage notebooks, scripts & workflows
 .