Track run inputs#

You may turn on run inputs tracking by setting lamindb.settings.track_run_inputs_upon_load to True: loaded files will be automatically added as the inputs of the current notebook run.

import lamindb as ln

ln.track()
✅ Loaded instance: testuser1/mydata
💬 Instance: testuser1/mydata
💬 User: testuser1
✅ Added: Transform(id='Rx2s9aPTMQLY', version='0', name='05-track-runin', type=notebook, title='Track run inputs', created_by_id='DzTjkKse', created_at=datetime.datetime(2023, 5, 30, 20, 26, 1))
✅ Added: Run(id='u695iqzI0921cr8HNZ0q', transform_id='Rx2s9aPTMQLY', transform_version='0', created_by_id='DzTjkKse', created_at=datetime.datetime(2023, 5, 30, 20, 26, 1))

Default behavior: don’t track file as run input#

file = ln.select(ln.File, suffix=".fcs").one()
adata = file.load()

No run inputs are linked to the current notebook run:

with ln.Session() as ss:
    assert len(ss.select(ln.Run, id=ln.context.run.id).one().inputs) == 0

Track file as run input#

You can see the fcs file is now being added to the run inputs:

with ln.Session() as ss:
    file = ss.select(ln.File, suffix=".fcs").one()
    adata = file.load(is_run_input=True)
    assert len(ss.select(ln.Run, id=ln.context.run.id).one().inputs) == 1
    print(ss.select(ln.Run, id=ln.context.run.id).one().inputs)
[[session open] File(id='AkgsTMzjY5kyiUtm6WXZ', name='example.fcs', suffix='.fcs', size=6785467, hash='KCEXRahJ-Ui9Y6nksQ8z1A', run_id='jjV8fShqtvG8ZEm63jgN', transform_id='ANW20Fr4eZgM', transform_version='0', storage_id='nmLvrDUj', created_at=datetime.datetime(2023, 5, 30, 20, 25, 57), created_by_id='DzTjkKse')]
Hide code cell content
# [Not for users] clean up for CI
with ln.Session() as ss:
    run = ss.select(ln.Run, id=ln.context.run.id).one()
    run.inputs = []
    ss.add(run)