lamindb.core.Context¶
- class lamindb.core.Context¶
- Bases: - object- Run context. - Enables convenient data lineage tracking by managing a transform & run upon - track()&- finish().- Guide: Track notebooks, scripts & functions - Examples - Is typically used via the global - contextobject via- ln.track()and- ln.finish():- >>> import lamindb as ln >>> ln.track() >>> # do things >>> ln.finish() - Attributes¶- property description: str | None¶
- descriptionargument for- context.transform.
 - property uid: str | None¶
- uidargument for- context.transform.
 - property version: str | None¶
- versionargument for- context.transform.
 - Methods¶- finish(ignore_non_consecutive=None)¶
- Finish a tracked run. - writes a timestamp: - run.finished_at
- saves the source code: - transform.source_code
- saves a run report: - run.report
 - When called in the last cell of a notebook: - prompts to save the notebook in your editor right before 
- prompts for user input if not consecutively executed 
 - Parameters:
- ignore_non_consecutive ( - None|- bool, default:- None) – Whether to ignore if a notebook was non-consecutively executed.
- Return type:
- None
 - Examples - >>> import lamindb as ln >>> ln.track() >>> # do things while tracking data lineage >>> ln.finish() - See also - lamin save script.pyor- lamin save notebook.ipynb→ docs
 - track(transform=None, *, project=None, params=None, new_run=None, path=None)¶
- Track a global run of your Python session. - sets - transform&- runby creating or loading- Transform&- Runrecords
- saves Python environment as a - requirements.txtfile:- run.environment
 - If - sync_git_repois set, checks whether a script-like transform exists in a git repository and links it.- Parameters:
- transform ( - str|- Transform|- None, default:- None) – A transform- uidor record. If- None, creates a- uid.
- project ( - str|- None, default:- None) – A project- nameor- uidfor labeling entities created during the run.
- params ( - dict|- None, default:- None) – A dictionary of parameters 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).
- path ( - str|- None, default:- None) – Filepath of notebook or script. Only needed if it can’t be automatically detected.
 
- Return type:
- None
 - Examples - To track the run of a notebook or script, call: - >>> ln.track() - If you want to ensure a single version history across renames of the notebook or script, pass the auto-generated - uidthat you’ll find in the logs:- >>> ln.track("Onv04I53OgtT0000") # example uid, the last four characters encode the version of the transform