Repository navigation
refactor(connectors): pass annotations to the constructor in every connector - #827
Merged
masquare merged 6 commits intoNov 20, 2026
Conversation
karhu
requested changes
Nov 20, 2026
karhu
left a comment
Contributor
There was a problem hiding this comment.
Receivers of annotation objects behave inconsistently across the stack, some copy the annotation objects, some don't. annotate(), add_annotations(), TimeFDataset(annotations=...) (this PR) and LabelSet(annotations=...) (#797) attach a copy. The Record, Source, Signal and Task constructors keep the object as given. Consequently we have two similar ways to annotate a record, but one breaks at write time:
shared = Annotation("condition", value="healthy")
# fails at write time: both records hold the same occurrence
ds.add_record(Record(sources=[...], annotations=[shared]))
ds.add_record(Record(sources=[...], annotations=[shared]))
# put_dataset -> TimeFValidationError: an occurrence of annotation
# 'condition' is attached in more than one place
# works: annotate() attaches a copy each time
ds.add_record(Record(sources=[...])).annotate(shared)
ds.add_record(Record(sources=[...])).annotate(shared)…nnector TimeFDataset takes annotations like the other owners. The connectors pass annotations=[...] when they build a dataset, a Record or a task, and call annotate() only for an owner that exists or when a task needs the returned occurrence.
…onstructor Record, Source, Signal and Task now copy each annotation passed as annotations=, as annotate() does. So one Annotation object can go to several owners, and the writer no longer rejects it as attached in more than one place. The reader, imports, edits and with_references keep the occurrences that already belong to the object.
…e stored ones The reader passed the stored annotations to each constructor, which copied them, and then put the stored tuple back. That copied every occurrence once per read for nothing. The reader now builds the entity without annotations, validates each stored annotation as construction does, and attaches it. Source gets _validate_annotation like Record and Signal for that.
…ot hold The Hub source now lives in source_url and source_revision of the dataset metadata, so the example does not repeat it as annotations.
masquare
force-pushed
the
refactor/annotations-at-construction
branch
from
November 20, 2026 15:42
8636cdf to
9addb4e
Compare
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.
Every connector now attaches annotations the same way: as an
annotations=[...]list when it builds the owner. This is the cleanup sweep on top of the stack, kept apart so the PRs below do not grow.What changes
TimeFDataset(metadata=..., annotations=[...]): the dataset takes annotations at construction like a Record, a Source, a Signal and a task. It attaches each one asannotate()does, in order.Where annotate() stays
The built datasets do not change.
Checks
make checkandmake test-connectorspass.