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='39WywGqKptfncxwa', name='Dummpy pipeline', type='pipeline', created_by_id=1, updated_at='2024-06-19 23:05:47 UTC')
💡 saved: Run(uid='QRIdLFwPJBJW9K7nXFI7', transform_id=1, created_by_id=1)
Artifact(uid='Ge9BcSKAOGbhWj3slzxS', description='My csv', suffix='.csv', type='dataset', 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-06-19 23:05:48 UTC')

Call ln.track():

ln.settings.transform.stem_uid = "Rx2s9aPTMQLY"
ln.settings.transform.version = "1"
ln.track()
💡 notebook imports: lamindb==0.74.0
💡 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-06-19 23:05:48 UTC')
💡 saved: Run(uid='my7OmbmUbrdLjjsTMh88', transform_id=2, created_by_id=1)
Run(uid='my7OmbmUbrdLjjsTMh88', started_at='2024-06-19 23:05:48 UTC', is_consecutive=True, transform_id=2, created_by_id=1)

Don’t 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/6m7d1kjc30Hp4dpmssa5.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/6m7d1kjc30Hp4dpmssa5.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='6m7d1kjc30Hp4dpmssa5', description='My image', suffix='.jpg', type='dataset', 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-06-19 23:05:48 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='6m7d1kjc30Hp4dpmssa5', description='My image', suffix='.jpg', type='dataset', 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-06-19 23:05:48 UTC')
Artifact(uid='Ge9BcSKAOGbhWj3slzxS', description='My csv', suffix='.csv', type='dataset', 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-06-19 23:05:48 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 779, 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/6m7d1kjc30Hp4dpmssa5.jpg', '/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/Ge9BcSKAOGbhWj3slzxS.csv', '/home/runner/work/lamindb/lamindb/docs/faq/test-run-inputs/.lamindb/_is_initialized']