-
Notifications
You must be signed in to change notification settings - Fork 15
annotations: adjustment to support multiple sample types #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
LeonardoRosaa
merged 17 commits into
main
from
leonardo-lig-8223-enable-annotation-page-for-videos
Dec 10, 2025
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b1942d6
support annotation with payload
LeonardoRosaa 4e14a9a
annotation: include dataset id for image
LeonardoRosaa 0f1ac89
Merge branch 'main' into leonardo-lig-8263-annotations-use-the-new-en…
LeonardoRosaa 006254c
work
LeonardoRosaa 2f0ff1c
Merge branch 'main' into leonardo-lig-8223-enable-annotation-page-for…
LeonardoRosaa a999f2c
extend to videos
LeonardoRosaa 11be2b4
removed sample_type from grid
LeonardoRosaa 8fd45a0
fixed sample type
LeonardoRosaa 13263a5
formatted files
LeonardoRosaa 4af597c
Merge branch 'main' into leonardo-lig-8223-enable-annotation-page-for…
LeonardoRosaa 230c29c
formatted files
LeonardoRosaa b50da8e
removed front-end changes
LeonardoRosaa 1de6af9
improved message and tests
LeonardoRosaa cbb39fb
renamed sample type to parent sample type
LeonardoRosaa b2eb035
Merge branch 'main' into leonardo-lig-8223-enable-annotation-page-for…
LeonardoRosaa 65810f0
use AnnotationWithPayloadView
LeonardoRosaa 6d60236
Merge branch 'main' into leonardo-lig-8223-enable-annotation-page-for…
LeonardoRosaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
22 changes: 22 additions & 0 deletions
22
lightly_studio/src/lightly_studio/resolvers/dataset_resolver/get_parent_dataset_id.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| """Retrieve the parent dataset ID for a given dataset ID.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from uuid import UUID | ||
|
|
||
| from sqlalchemy.orm import aliased | ||
| from sqlmodel import Session, col, select | ||
|
|
||
| from lightly_studio.models.dataset import DatasetTable | ||
|
|
||
| ParentDataset = aliased(DatasetTable) | ||
| ChildDataset = aliased(DatasetTable) | ||
|
|
||
|
|
||
| def get_parent_dataset_id(session: Session, dataset_id: UUID) -> DatasetTable | None: | ||
| """Retrieve the parent dataset for a given dataset ID.""" | ||
| return session.exec( | ||
| select(ParentDataset) | ||
| .join(ChildDataset, col(ChildDataset.parent_dataset_id) == col(ParentDataset.dataset_id)) | ||
| .where(ChildDataset.dataset_id == dataset_id) | ||
| ).one_or_none() |
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
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
46 changes: 46 additions & 0 deletions
46
lightly_studio/tests/resolvers/datasets_resolver/test_get_parent_dataset_id.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from sqlmodel import Session | ||
|
|
||
| from lightly_studio.resolvers import dataset_resolver | ||
| from tests.helpers_resolvers import ( | ||
| create_annotation, | ||
| create_annotation_label, | ||
| create_dataset, | ||
| create_image, | ||
| ) | ||
|
|
||
|
|
||
| def test_get_parent_dataset_id__from_parent_dataset(test_db: Session) -> None: | ||
| dataset = create_dataset(session=test_db) | ||
|
|
||
| image_1 = create_image( | ||
| session=test_db, | ||
| dataset_id=dataset.dataset_id, | ||
| file_path_abs="/path/to/sample2.png", | ||
| ) | ||
| car_label = create_annotation_label( | ||
| session=test_db, | ||
| annotation_label_name="car", | ||
| ) | ||
| annotation = create_annotation( | ||
| session=test_db, | ||
| sample_id=image_1.sample_id, | ||
| annotation_label_id=car_label.annotation_label_id, | ||
| dataset_id=dataset.dataset_id, | ||
| ) | ||
|
|
||
| parent_dataset = dataset_resolver.get_parent_dataset_id( | ||
| session=test_db, dataset_id=annotation.sample.dataset_id | ||
| ) | ||
| assert parent_dataset is not None | ||
| assert parent_dataset.dataset_id == dataset.dataset_id | ||
michal-lightly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def test_get_parent_dataset_id__from_root_dataset(test_db: Session) -> None: | ||
| dataset = create_dataset(session=test_db) | ||
|
|
||
| parent_dataset = dataset_resolver.get_parent_dataset_id( | ||
| session=test_db, dataset_id=dataset.dataset_id | ||
| ) | ||
| assert parent_dataset is None | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.