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
Show 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('PEfzuAE2'), started new Run('2eAYCJLh') at 2024-10-11 09:32:58 UTC
Artifact(uid='detBkxE9CSKfuZQA0000', 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-10-11 09:32:59 UTC)
Call ln.track()
:
ln.track("Rx2s9aPTMQLY0000")
→ notebook imports: lamindb==0.76.12
→ created Transform('Rx2s9aPT'), started new Run('qNDpvYxm') at 2024-10-11 09:32:59 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/izuLFBszceb559Tb0000.jpg')
No run inputs are linked to the current notebook run:
ln.Run.get(id=ln.context.run.id).input_artifacts.all()
<QuerySet []>
Show 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/izuLFBszceb559Tb0000.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='izuLFBszceb559Tb0000', 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-10-11 09:32:59 UTC)
Show 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='izuLFBszceb559Tb0000', 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-10-11 09:32:59 UTC)
Artifact(uid='detBkxE9CSKfuZQA0000', 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-10-11 09:32:59 UTC)
Show code cell content
assert len(ln.Run.get(id=ln.context.run.id).input_artifacts.all()) == 2
Show code cell content
!lamin delete --force test-run-inputs
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.10/x64/bin/lamin", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/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.10/x64/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/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.10/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.10/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.10/x64/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/lamin_cli/__main__.py", line 203, in delete
return delete(instance, force=force)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/lamindb_setup/_delete.py", line 102, in delete
n_objects = check_storage_is_empty(
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/lamindb_setup/core/upath.py", line 776, 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