Repository navigation
feat(format)!: annotate label sets like other entities and store them by id - #797
Merged
masquare merged 15 commits intoNov 20, 2026
Merged
Conversation
masquare
marked this pull request as ready for review
November 18, 2026 01:50
masquare
marked this pull request as ready for review
November 18, 2026 01:50
✅ CI checks passed
Updated for |
karhu
requested changes
Nov 18, 2026
karhu
approved these changes
Nov 18, 2026
masquare
force-pushed
the
feature/label-set-derived-name
branch
from
November 18, 2026 20:52
c6bf947 to
75ee6d6
Compare
masquare
force-pushed
the
feature/label-set-derived-name
branch
from
November 18, 2026 22:03
75ee6d6 to
ff9058a
Compare
masquare
force-pushed
the
feature/label-set-derived-name
branch
from
November 18, 2026 23:46
ff9058a to
f48f7da
Compare
masquare
force-pushed
the
feature/label-set-derived-name
branch
3 times, most recently
from
November 19, 2026 02:21
24f7c00 to
4647149
Compare
masquare
force-pushed
the
feature/label-set-derived-name
branch
from
November 19, 2026 05:19
4647149 to
4e50d54
Compare
masquare
force-pushed
the
feature/label-set-derived-name
branch
from
November 19, 2026 17:48
24f5461 to
4607c5d
Compare
karhu
requested changes
Nov 19, 2026
karhu
reviewed
Nov 20, 2026
… by id Remove LabelSet.name. A LabelSet is now an annotated object like a Record, Source, Signal, Task or the dataset: it has annotations and annotate(), and annotation(key) works on it. A ClassificationTask yields its label set in annotation_owners(), so the schema lists label set keys like any other keys. LabelSet(["a", "b"]) takes plain strings as labels without a description. Two label sets with the same labels (in any order, with the same descriptions) and the same multi_label are one set, and == says so. The dataset no longer keeps a label set registry. The writer stores each such set once, keeps the label order of the first set, keeps every distinct annotation occurrence of the equal sets, and does not change the caller's sets. label_sets is keyed by an integer label_set_id, tasks.label_set_id refers to it, and label set annotations are annotation_occurrences rows of a new LabelSet owner kind. The reader shares one set object for each id in a read. A copied task gets its own copy of its label set. The connectors that named their label sets attach the name as a name annotation: har_cot, sleep_cot, sleep_edfx, test_mean, hello_world and TSAQA. ARFBench stops deriving a name from its options. The control schema version stays 2. BREAKING CHANGE: LabelSet takes no name, so move it into annotations. Releases with classification tasks that were written before this change must be built again.
Follow the rename in the base change: a ClassificationTask yields its label set from annotatable_entities(), and the load plan reads it there.
The tests and the annotations docs read a label set's name annotation from its annotations, since annotation(key) is gone.
…_annotations A ClassificationTask yields its own annotations, then those of its label set, from walk_annotations(). The load plan reads a task's annotations through walk_annotations(), so it needs no separate label set handler, and annotatable_entities() is gone.
LabelSet(labels, ordered=True) makes the label order part of the identity of the set: the same labels in another order are a different set, and the stored set keeps its own order. By default a set is unordered, as before. label_sets gets an ordered column. ARFBench builds its option sets with ordered=True, because a model sees the options in their order.
Pass labels positionally and use plain strings where a label has no description. Labels with a description stay Label objects.
A task read loaded every stored label set and all their annotations, once for each read. It now loads the sets that its tasks name. The audit keeps the check for an annotation of a missing label set. The docs explain ordered label sets once.
…y the label set code - LabelSet(..., ordered=True) rejects a set or frozenset, because its order is not fixed. - assert_datasets_equal also compares label set annotations. - The format doc says which owners a full read checks. - Smaller cleanups in the label set field, a docstring and two tests.
Two label sets with the same labels and different annotations are two sets, and the writer stores each one with its own annotations. Sets with the same labels and the same annotations, in any order, are still stored once. The writer no longer merges the annotations of equal sets.
…lify the key The writer keeps the id of each label set object for the write, so a set that many tasks share is checked and keyed once. The row and the id are stored together. The key uses the frozen Label objects directly. A label set rejects a Python set also when it is not ordered, because the writer keeps the order of the first equal set and a Python set has no fixed order.
masquare
force-pushed
the
feature/label-set-derived-name
branch
from
November 20, 2026 07:25
4607c5d to
86e5933
Compare
Version 3 stores label sets by id, with their annotations. A reader of version 2 misreads it, and this reader misreads version 2, so both the written and the oldest readable version are 3.
karhu
approved these changes
Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A label set is now annotated like the other entities, and the control tables reference it by an integer id.
LabelSet.nameis gone. This builds on the owner walk in the PR below.What changes
LabelSetis a dataclass withlabels,multi_label,orderedandannotations, plusannotate(). That is the same contract as a Record, Source, Signal, Task and the dataset.LabelSet(["a", "b"])takes plain strings as labels without a description. UseLabel(name=..., description=...)where a label needs a description.ClassificationTask.walk_annotations()also yields the annotations of its label set, so the schema lists label set keys like any other keys.multi_labelandorderedare one set, and==says so. Annotations are not part of that identity, so equal sets with differentnameannotations merge into one stored set that keeps both annotations. ALabelSetis not hashable.LabelSet(labels, ordered=True)makes the label order part of the identity: the same labels in another order are a different set, and the stored set keeps its own order. Use it for ordinal labels or for options that a model sees in a fixed order. Sets are unordered by default. An ordered set rejects a Python set as its labels, because the order of a Python set is not fixed.label_setsgets anorderedcolumn.label_setsis keyed bylabel_set_id, andtasks.label_set_idrefers to it.annotation_occurrencesrows of the newLabelSetowner kind.nameannotation: har_cot, sleep_cot, sleep_edfx, test_mean, hello_world and TSAQA. ARFBench stops deriving a name from its options and builds its option sets withordered=True.Breaking changes
LabelSet(name=...)is gone. Move the name intoannotations, for exampleAnnotation("name", value="sleep_stage"), and read it fromlabel_set.annotations.label_set.namemust read thenameannotation instead.Where the logic is
types/label_sets.py: the newLabelSet.types/tasks.py: the label set as an owner, and the copy.format/control_writer.py:_LabelSetRows, the dedup and the ids.format/control_reader.py,format/control_schema.py: reading and the new owner kind.The rest is tests, docs and the connector updates. The connectors change in the same commit, because the type check fails otherwise.
Checks
make checkandmake test-connectorspass.verify()passes.