Skip to content

Include preselected samples in sampling results - #2255

Closed
lukas-lightly wants to merge 2 commits into
mainfrom
lukas-lig-10631-lightlystudio-sampling-add-preselected-tag-to-gui-2
Closed

lukas-lightly wants to merge 2 commits into
mainfrom
lukas-lig-10631-lightlystudio-sampling-add-preselected-tag-to-gui-2

Conversation

@lukas-lightly

@lukas-lightly lukas-lightly commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

This is consistent with LightlyOne.

How has it been tested?

Added tests.

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Summary by CodeRabbit

  • New Features

    • Continued sampling now includes preselected samples in the resulting tag before newly selected samples.
    • Reusing a preselected tag accumulates samples across runs while counting only newly selected samples toward the requested amount.
    • Sequence sampling now includes preselected frames in result tags.
    • A result tag is created even when all available samples are already preselected.
  • Documentation

    • Updated sampling documentation to clarify preselection behavior.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T13:55:26.997054Z 3d47241 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 64421615-1e1b-464c-b244-587f84db8a9a

📥 Commits

Reviewing files that changed from the base of the PR and between 3d47241 and b5a718d.

📒 Files selected for processing (5)
  • lightly_studio/docs/docs/concepts_and_tools/sampling.md
  • lightly_studio/src/lightly_studio/sampling/sample.py
  • lightly_studio/src/lightly_studio/sampling/sampling_via_db.py
  • lightly_studio/src/lightly_studio/sampling/sequence_sampling.py
  • lightly_studio/tests/sampling/test_sequence_sampling.py

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Sampling now includes preselected samples in result tags before newly selected samples. It also creates result tags when no additional samples are available. Documentation and tests reflect the updated standard and sequence sampling behavior.

Changes

Sampling accumulation

Layer / File(s) Summary
Result-tag accumulation
lightly_studio/src/lightly_studio/sampling/sampling_via_db.py, lightly_studio/docs/docs/concepts_and_tools/sampling.md
Standard sampling passes preselected samples to result-tag creation first. It creates a result tag when no additional samples are available.
Sequence result accumulation
lightly_studio/src/lightly_studio/sampling/sequence_sampling.py
Sequence sampling prepends preselected frame IDs to result tags. It also handles cases with no candidate sequences.
Sampling behavior validation
lightly_studio/src/lightly_studio/sampling/sample.py, lightly_studio/tests/sampling/*
Documentation and tests cover retained preselected samples, ordering, cumulative results, and inputs where all samples are preselected.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: horatiualmasan

Merge Risk: ⚪ Minimal · up to b5a71

The sampling accumulation changes are covered for normal and exhausted-input paths, with no current merge-blocking issue identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The changelog section is complete, but the change summary and testing sections are too brief. The description does not explain the behavior change, motivation, affected sampling behavior, dependencies… Expand the change summary with the new preselected-sample behavior, the LightlyOne alignment, affected sampling paths, and any issue or motivation. Describe the tests that were added or run, including reproduction instructions and relevant …
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preselected samples are included in sampling results.
Docstring Coverage ✅ Passed Docstring coverage is 82.61% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 6 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The changelog section is complete, but the change summary and testing sections are too brief. The description does not explain the behavior change, motivation, affected sampling behavior, dependencies, or how to reproduce the tests.

Resolution

Expand the change summary with the new preselected-sample behavior, the LightlyOne alignment, affected sampling paths, and any issue or motivation. Describe the tests that were added or run, including reproduction instructions and relevant test configuration. State whether dependencies are required.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lukas-lig-10631-lightlystudio-sampling-add-preselected-tag-to-gui-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d47241864

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +479 to +480
account. The preselected samples influence the strategy and appear before the newly
selected samples in the result. `n_samples_to_select` is the number of new samples to select.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include preselection in sequence sampling results

When diverse(..., selected_sequence_length=...) is used, this promise is false: sampling_via_database delegates to sequence_sampling.sampling_via_database_sequences, which still slices off selected_sequence_indices[:len(preselected_indices)] before creating the tag. Consequently a second sequence batch excludes all preselected frames, unlike regular sampling; include that prefix in the sequence result or document the exception explicitly.

Useful? React with 👍 / 👎.

Comment on lines +479 to +480
account. The preselected samples influence the strategy and appear before the newly
selected samples in the result. `n_samples_to_select` is the number of new samples to select.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid promising ordering that result tags discard

The persisted sampling result cannot expose the stated prefix order: sampling_helpers.create_result_tag calls add_sample_ids_to_tag_id, which constructs insertion rows from set(sample_ids), and SampleTagLinkTable has no ordering column. The new test only observes the transient argument before this order is discarded, so users querying the result tag cannot rely on preselected samples appearing first; describe them as included, or persist an explicit rank.

Useful? React with 👍 / 👎.

selected_sample_ids = [
input_sample_ids[index] for index in selected_indices[len(preselected_indices) :]
]
selected_sample_ids = [input_sample_ids[index] for index in selected_indices]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update public API docstrings for the inclusion behavior

This now includes preselected IDs in every regular result tag, but the public docstrings for Sampling.metadata_weighting, diverse, deduplicate, annotation_balancing, metadata_balancing, subpart_diversity, and multi_strategies still state that these samples are excluded unless the same tag name is reused. Those docstrings feed the linked API reference, leaving Python users with instructions that contradict the implemented behavior.

Useful? React with 👍 / 👎.

@lightly-fast-track-bot

lightly-fast-track-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

✅  Fast Track: all required checks passed — auto-approved.

Guardrail Result Message
frontend/complexity 0 file(s) checked.
backend/complexity 6 file(s) checked, no violations.
backend/coverage 3 file(s) checked at 90%.
[PASS] lightly_studio/src/lightly_studio/sampling/sample.py: no executable added lines
[PASS] lightly_studio/src/lightly_studio/sampling/sampling_via_db.py: 100.0%
[PASS] lightly_studio/src/lightly_studio/sampling/sequence_sampling.py: 100.0%
diff-size PR adds 131 line(s) (limit: 215).
frontend/coverage 0 file(s) checked.

View the guardrail run

To run the guardrails locally, from fast_track/ run make install once, then make run-guardrails (or GUARDRAILS=<name1>,<name2> make run-guardrails for some guardrails).

Reflects b5a718d.

@lukas-lightly
lukas-lightly force-pushed the lukas-lig-10631-lightlystudio-sampling-add-preselected-tag-to-gui-2 branch from 3d47241 to b5a718d Compare September 15, 2026 07:40
@lukas-lightly
lukas-lightly deleted the lukas-lig-10631-lightlystudio-sampling-add-preselected-tag-to-gui-2 branch September 15, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant