Skip to content

Fix off-by-one progress bar bugs#8201

Merged
ricardoV94 merged 3 commits into
pymc-devs:mainfrom
jessegrabowski:smc-progress-fix
Mar 17, 2026
Merged

Fix off-by-one progress bar bugs#8201
ricardoV94 merged 3 commits into
pymc-devs:mainfrom
jessegrabowski:smc-progress-fix

Conversation

@jessegrabowski
Copy link
Copy Markdown
Member

Progress bar is currently off by one when it completes, and @ricardoV94 is bullying me about it. The issue was we added a -1 factor to the total at some point when we shouldn't have. This caused the samplers to stop at n-1 / n (for which I was bullied). In the case of SMC sampling, it caused the progressbar maximum to be 0, so progress immediately stopped and no timing info is given.

I also re-wrote the test_manager tests. They weren't testing anything, just type checks and deterministic code paths. I added some tests that would have caught these off-by-one bugs.

I also simplified the is_last logic. Previously it was trying to calculate the remaining steps then advancing by that much, then doing a cleanup step. Now we just directly set the total completed to the expected total. This should be 100% bulletproof against embarrassing off-by-one bugs.

@jessegrabowski jessegrabowski added bug SMC Sequential Monte Carlo labels Mar 17, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Mar 17, 2026

Documentation build overview

📚 pymc | 🛠️ Build #31841862 | 📁 Comparing cab545a against latest (f89e6c8)


🔍 Preview build

Show files changed (2 files in total): 📝 2 modified | ➕ 0 added | ➖ 0 deleted
File Status
glossary.html 📝 modified
_modules/pymc/smc/sampling.html 📝 modified

@jessegrabowski
Copy link
Copy Markdown
Member Author

Failures look unrelated?

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.46%. Comparing base (f89e6c8) to head (cab545a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pymc/progress_bar/marimo_progress.py 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8201      +/-   ##
==========================================
- Coverage   91.49%   91.46%   -0.04%     
==========================================
  Files         124      124              
  Lines       19868    19865       -3     
==========================================
- Hits        18179    18170       -9     
- Misses       1689     1695       +6     
Files with missing lines Coverage Δ
pymc/progress_bar/progress.py 93.37% <100.00%> (-3.96%) ⬇️
pymc/progress_bar/rich_progress.py 98.85% <100.00%> (-0.03%) ⬇️
pymc/smc/parallel.py 66.99% <100.00%> (+0.32%) ⬆️
pymc/smc/sampling.py 96.55% <100.00%> (ø)
pymc/progress_bar/marimo_progress.py 17.77% <0.00%> (+0.38%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@fonnesbeck fonnesbeck left a comment

Choose a reason for hiding this comment

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

LGTM. Let's merge this first and I can rebase #8184 from it.

I was getting the same failures for #8184 and they magically disappeared one day.

@ricardoV94 ricardoV94 changed the base branch from v6 to main March 17, 2026 10:04
@ricardoV94
Copy link
Copy Markdown
Member

ricardoV94 commented Mar 17, 2026

The failures was due to patches on main that are not in V3 yet. I changed the branch of both PRs to main (@fonnesbeck 's a few days ago, which is how they "magically" went away)

@fonnesbeck
Copy link
Copy Markdown
Member

Magic!

@ricardoV94
Copy link
Copy Markdown
Member

ricardoV94 commented Mar 17, 2026

It's hanging in the Check for changes job

@ricardoV94 ricardoV94 merged commit 6c48a0b into pymc-devs:main Mar 17, 2026
43 checks passed
@ricardoV94
Copy link
Copy Markdown
Member

@fonnesbeck merged

@jessegrabowski
Copy link
Copy Markdown
Member Author

jessegrabowski commented Mar 17, 2026

Magic!

Any sufficiently advanced Ricardo PR is indistinguishable from magic

ricardoV94 pushed a commit to ricardoV94/pymc that referenced this pull request Mar 17, 2026
* Fix off-by-one progress bug

* Simplify is_last logic

* Add marimo tests for off-by-one bug
@fonnesbeck fonnesbeck mentioned this pull request Mar 18, 2026
9 tasks
zaxtax pushed a commit to zaxtax/pymc that referenced this pull request Mar 21, 2026
* Fix off-by-one progress bug

* Simplify is_last logic

* Add marimo tests for off-by-one bug
ricardoV94 pushed a commit to ricardoV94/pymc that referenced this pull request Mar 23, 2026
* Fix off-by-one progress bug

* Simplify is_last logic

* Add marimo tests for off-by-one bug
ricardoV94 pushed a commit to ricardoV94/pymc that referenced this pull request Mar 23, 2026
* Fix off-by-one progress bug

* Simplify is_last logic

* Add marimo tests for off-by-one bug
ricardoV94 pushed a commit that referenced this pull request Mar 23, 2026
* Fix off-by-one progress bug

* Simplify is_last logic

* Add marimo tests for off-by-one bug
@ricardoV94 ricardoV94 mentioned this pull request Mar 27, 2026
@ricardoV94 ricardoV94 mentioned this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug samplers SMC Sequential Monte Carlo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants