lamindb.core.LabelManager

class lamindb.core.LabelManager(host)

Bases: object

Label manager.

This allows to manage untyped labels ULabel and arbitrary typed labels (e.g., CellLine) and associate labels with features.

Methods

add(records, feature=None)

Add one or several labels and associate them with a feature.

Parameters:
  • records (Record | list[Record] | QuerySet) – Label records to add.

  • feature (Feature | None, default: None) – Feature under which to group the labels.

Return type:

None

add_from(data, transfer_logs=None)

Add labels from an artifact or collection to another artifact or collection.

Return type:

None

Examples

>>> artifact1 = ln.Artifact(pd.DataFrame(index=[0, 1])).save()
>>> artifact2 = ln.Artifact(pd.DataFrame(index=[2, 3])).save()
>>> ulabels = ln.ULabel.from_values(["Label1", "Label2"], field="name")
>>> ln.save(ulabels)
>>> labels = ln.ULabel.filter(name__icontains = "label").all()
>>> artifact1.ulabels.set(labels)
>>> artifact2.labels.add_from(artifact1)
get(feature, mute=False, flat_names=False)

Get labels given a feature.

Parameters:
  • feature (Feature) – Feature under which labels are grouped.

  • mute (bool, default: False) – Show no logging.

  • flat_names (bool, default: False) – Flatten list to names rather than returning records.

Return type:

QuerySet | dict[str, QuerySet] | list