Skip to content

Fix exposure count on repeat observation.#1400

Open
wtgee wants to merge 1 commit intodevelopfrom
fix-observation-count
Open

Fix exposure count on repeat observation.#1400
wtgee wants to merge 1 commit intodevelopfrom
fix-observation-count

Conversation

@wtgee
Copy link
Member

@wtgee wtgee commented Feb 20, 2026

When sticking with the same Observation, don't reset the image count.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the dispatch scheduler’s selection logic to keep using the existing current_observation instance when reselecting the same target, preventing observation progress (exposure count) from being reset during repeat scheduling.

Changes:

  • Introduces keep_current flow to avoid reassigning self.current_observation when the top-ranked observation is the current one.
  • Recomputes and compares the current observation’s score from the current evaluation round before deciding to keep it.
  • Updates how self.current_observation.merit is set when keeping vs switching observations.

Comment on lines +133 to +135
else:
# Update merit even if keeping current observation
self.current_observation.merit = top_obs_score
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

When keep_current is True because the current observation outscored top_obs_score, self.current_observation.merit is updated to top_obs_score (the other observation’s score). This makes current_observation.merit inconsistent with the chosen observation; it should be set to the current observation’s computed score for this cycle (e.g., current_obs_score).

Copilot uses AI. Check for mistakes.
Comment on lines +128 to +132
# Set the current observation
# Only update if we're not keeping the current observation to avoid resetting exposure count
if not keep_current:
self.current_observation = self.observations[top_obs_name]
self.current_observation.merit = top_obs_score
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

This change is specifically meant to prevent exposure counts from being reset when the scheduler keeps the same observation (especially when read_file=True rebuilds self.observations). There are scheduler tests, but none appear to assert that current_observation.exposure_list / current_exp_num is preserved across a re-evaluation that keeps the same observation. Adding a focused test would prevent regressions here.

Copilot uses AI. Check for mistakes.
Comment on lines +124 to +126
if current_obs_score >= top_obs_score:
best_obs.insert(0, (self.current_observation, current_obs_score))
keep_current = True
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

best_obs is documented/tests expect tuples of (obs_name: str, score: float), but this branch inserts (self.current_observation, current_obs_score), changing the type of the first element (and also duplicating the current observation entry in best_obs when show_all=True). Use self.current_observation.name (and consider reordering/removing the existing entry rather than inserting a duplicate).

Copilot uses AI. Check for mistakes.
@wtgee wtgee force-pushed the fix-observation-count branch from 6857e1b to 3da0d00 Compare February 21, 2026 00:04
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.33%. Comparing base (c3983c9) to head (3da0d00).

Files with missing lines Patch % Lines
src/panoptes/pocs/scheduler/dispatch.py 78.94% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1400   +/-   ##
========================================
  Coverage    64.33%   64.33%           
========================================
  Files          104      104           
  Lines         9532     9541    +9     
  Branches       845      848    +3     
========================================
+ Hits          6132     6138    +6     
- Misses        3254     3256    +2     
- Partials       146      147    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants