Can I disable tracking run inputs?

Yes, if you switch track_run_inputs to False.

Setup

!lamin init --storage test-run-inputs
Hide code cell output
馃挕 connected lamindb: testuser1/test-run-inputs
import lamindb as ln
馃挕 connected lamindb: testuser1/test-run-inputs

Some test artifacts:

ln.track(transform=ln.Transform(name="Dummpy pipeline"))
ln.Artifact(ln.core.datasets.file_jpg_paradisi05(), description="My image").save()
ln.Artifact(ln.core.datasets.file_mini_csv(), description="My csv").save()
馃挕 saved: Transform(uid='L1IPEXkwE7TG', name='Dummpy pipeline', type='pipeline', created_by_id=1, updated_at='2024-05-25 15:26:14 UTC')
馃挕 saved: Run(uid='XkN19vlLrwz9VCbxZMBA', transform_id=1, created_by_id=1)
Artifact(uid='yqkcgLmfsWCwElK2cNWw', description='My csv', suffix='.csv', size=11, hash='z1LdF2qN4cN0M2sXrcW8aw', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, transform_id=1, run_id=1, updated_at='2024-05-25 15:26:15 UTC')

Call ln.track():

ln.settings.transform.stem_uid = "Rx2s9aPTMQLY"
ln.settings.transform.version = "1"
ln.track()
馃挕 notebook imports: lamindb==0.72.1
馃挕 saved: Transform(uid='Rx2s9aPTMQLY5zKv', version='1', name='Can I disable tracking run inputs?', key='track-run-inputs', type='notebook', created_by_id=1, updated_at='2024-05-25 15:26:16 UTC')
馃挕 saved: Run(uid='ozxhJc8arI3zxlYVO8WI', transform_id=2, created_by_id=1)
Run(uid='ozxhJc8arI3zxlYVO8WI', started_at='2024-05-25 15:26:16 UTC', is_consecutive=True, transform_id=2, created_by_id=1)

Don鈥檛 track artifact as run input

ln.settings.track_run_inputs = False
artifact = ln.Artifact.filter(description="My image").one()
artifact.cache()
PosixUPath('/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/qXA3FDlGhDdO15XSk89x.jpg')

No run inputs are linked to the current notebook run:

ln.Run.filter(id=ln.core.run_context.run.id).one().input_artifacts.all()
<QuerySet []>
Hide code cell content
assert len(ln.Run.filter(id=ln.core.run_context.run.id).one().input_artifacts.all()) == 0

Manually track artifact as run input

Let us manually track an artifact by passing is_run_input to either .cache(), .load() or .backed():

artifact.cache(is_run_input=True)
PosixUPath('/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/qXA3FDlGhDdO15XSk89x.jpg')

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

for input in ln.Run.filter(id=ln.core.run_context.run.id).one().input_artifacts.all():
    print(input)
Artifact(uid='qXA3FDlGhDdO15XSk89x', description='My image', suffix='.jpg', size=29358, hash='r4tnqmKI_SjrkdLzpuWp4g', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, transform_id=1, run_id=1, updated_at='2024-05-25 15:26:15 UTC')
Hide code cell content
assert len(ln.Run.filter(id=ln.core.run_context.run.id).one().input_artifacts.all()) == 1

Automatically track artifacts as run input

If you switch the following setting, and call to .load(), .cache() and .backed() will track the artifact as run input.

ln.settings.track_run_inputs = True
artifact = ln.Artifact.filter(description="My csv").one()
artifact.load()
test
0 1
1 2
2 3
for input in ln.Run.filter(id=ln.core.run_context.run.id).one().input_artifacts.all():
    print(input)
Artifact(uid='qXA3FDlGhDdO15XSk89x', description='My image', suffix='.jpg', size=29358, hash='r4tnqmKI_SjrkdLzpuWp4g', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, transform_id=1, run_id=1, updated_at='2024-05-25 15:26:15 UTC')
Artifact(uid='yqkcgLmfsWCwElK2cNWw', description='My csv', suffix='.csv', size=11, hash='z1LdF2qN4cN0M2sXrcW8aw', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, transform_id=1, run_id=1, updated_at='2024-05-25 15:26:15 UTC')
Hide code cell content
assert len(ln.Run.filter(id=ln.core.run_context.run.id).one().input_artifacts.all()) == 2
Hide code cell content
!lamin delete --force test-run-inputs
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.9/x64/bin/lamin", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/rich_click/rich_command.py", line 367, in __call__
    return super().__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/rich_click/rich_command.py", line 152, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/lamin_cli/__main__.py", line 103, in delete
    return delete(instance, force=force)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/lamindb_setup/_delete.py", line 98, in delete
    n_objects = check_storage_is_empty(
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/lamindb_setup/core/upath.py", line 798, in check_storage_is_empty
    raise InstanceNotEmpty(message)
lamindb_setup.core.upath.InstanceNotEmpty: Storage /home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb contains 2 objects ('_is_initialized' ignored) - delete them prior to deleting the instance
['/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/_is_initialized', '/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/qXA3FDlGhDdO15XSk89x.jpg', '/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/yqkcgLmfsWCwElK2cNWw.csv']