Can I disable tracking run inputs?

Yes, if you switch track_run_inputs to False.

# !pip install 'lamindb[jupyter]'
!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.context.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()
→ created Transform('6o6r4j6A'), started new Run('ofNCZ6oG') at 2024-11-07 12:45:10 UTC
! record with similar description exists! did you mean to load it?
uid version is_latest description key suffix type size hash n_objects n_observations _hash_type _accessor visibility _key_is_virtual storage_id transform_id run_id created_at created_by_id
id
1 uIXav6RtDh4E7xvj0000 None True My image None .jpg None 29358 r4tnqmKI_SjrkdLzpuWp4g None None md5 None 1 True 1 1 1 2024-11-07 12:45:12.389850+00:00 1
Artifact(uid='tiZ6ibFFxOaiPCN30000', is_latest=True, description='My csv', suffix='.csv', size=11, hash='z1LdF2qN4cN0M2sXrcW8aw', _hash_type='md5', visibility=1, _key_is_virtual=True, storage_id=1, transform_id=1, run_id=1, created_by_id=1, created_at=2024-11-07 12:45:12 UTC)

Call ln.track():

ln.track("Rx2s9aPTMQLY0000")
→ notebook imports: lamindb==0.76.15
→ created Transform('Rx2s9aPT'), started new Run('b5JyNrRx') at 2024-11-07 12:45:13 UTC

Don’t track artifact as run input

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

No run inputs are linked to the current notebook run:

ln.Run.get(id=ln.context.run.id).input_artifacts.all()
<QuerySet []>
Hide code cell content
assert len(ln.Run.get(id=ln.context.run.id).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 .open():

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

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

for input in ln.Run.get(id=ln.context.run.id).input_artifacts.all():
    print(input)
Artifact(uid='uIXav6RtDh4E7xvj0000', is_latest=True, description='My image', suffix='.jpg', size=29358, hash='r4tnqmKI_SjrkdLzpuWp4g', _hash_type='md5', visibility=1, _key_is_virtual=True, storage_id=1, transform_id=1, run_id=1, created_by_id=1, created_at=2024-11-07 12:45:12 UTC)
Hide code cell content
assert len(ln.Run.get(id=ln.context.run.id).input_artifacts.all()) == 1

Automatically track artifacts as run input

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

ln.settings.track_run_inputs = True
artifact = ln.Artifact.get(description="My csv")
artifact.load()
test
0 1
1 2
2 3
for input in ln.Run.get(id=ln.context.run.id).input_artifacts.all():
    print(input)
Artifact(uid='uIXav6RtDh4E7xvj0000', is_latest=True, description='My image', suffix='.jpg', size=29358, hash='r4tnqmKI_SjrkdLzpuWp4g', _hash_type='md5', visibility=1, _key_is_virtual=True, storage_id=1, transform_id=1, run_id=1, created_by_id=1, created_at=2024-11-07 12:45:12 UTC)
Artifact(uid='tiZ6ibFFxOaiPCN30000', is_latest=True, description='My csv', suffix='.csv', size=11, hash='z1LdF2qN4cN0M2sXrcW8aw', _hash_type='md5', visibility=1, _key_is_virtual=True, storage_id=1, transform_id=1, run_id=1, created_by_id=1, created_at=2024-11-07 12:45:12 UTC)
Hide code cell content
assert len(ln.Run.get(id=ln.context.run.id).input_artifacts.all()) == 2
Hide code cell content
!lamin delete --force test-run-inputs
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.7/x64/bin/lamin", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/rich_click/rich_command.py", line 367, in __call__
    return super().__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/rich_click/rich_command.py", line 152, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/lamin_cli/__main__.py", line 209, in delete
    return delete(instance, force=force)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/lamindb_setup/_delete.py", line 102, in delete
    n_objects = check_storage_is_empty(
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/lamindb_setup/core/upath.py", line 817, 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 - delete them prior to deleting the instance