Repository navigation
BUG: skip blank lines when counting the loaded simulations - #1256
Open
pranjalbhatia710 wants to merge 1 commit into
Open
pranjalbhatia710 wants to merge 1 commit into
pranjalbhatia710 wants to merge 1 commit into
Conversation
set_num_of_loaded_sims counted every line of a .txt (JSONL) outputs log and every line after the header of a .csv one, blank lines included, while _read_log_file skips them. num_of_loaded_sims could then exceed len(outputs_log), and simulate_convergence returned without simulating because it took the extra count as simulations already run. Count only non-blank lines of a JSONL log, and count the rows of a CSV log with csv.DictReader, as _read_log_file does. Fixes RocketPy-Team#1255 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1256 +/- ##
========================================
Coverage 87.84% 87.84%
========================================
Files 130 130
Lines 18185 18185
========================================
Hits 15975 15975
Misses 2210 2210 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Pull request type
Checklist
ruff check,ruff format --check,pylinton the changed files)pytest tests -m slow --runslow) have passed locally (only the Monte Carlo unit and integration tests were run, see below)CHANGELOG.md— no action needed; an LLM workflow auto-updates it after mergeCurrent behavior
MonteCarlo.set_num_of_loaded_simscounts every line of a.txt(JSONL) outputs log, and every line after the header of a.csvone, blank lines included._read_log_file(and_checkpoint_rows) skip blank lines, so for a log containing one,num_of_loaded_simsis larger thanlen(outputs_log).simulate_convergenceuses that count as the number of simulations already run, so with the log from #1255 (2 rows, 2 blank lines,max_simulations=4) it reports "A total of 4 simulation results were loaded" and returns[]without simulating. A.csvlog with a blank line between two rows counts 3.New behavior
num_of_loaded_simsmatches the rows the readers return:line.strip(), the same test_read_log_fileuses).csv.DictReader, the reader_read_log_fileuses. It consumes the header and skips blank rows, so the manual "minus one for the header" goes away.New unit tests in
tests/unit/simulation/test_monte_carlo.py:test_set_num_of_loaded_sims_skips_blank_lines[jsonl|csv]: a log with two rows and blank lines giveslen(outputs_log) == num_of_loaded_sims == 2.test_simulate_convergence_runs_after_a_log_with_blank_lines: the reproduction fromnum_of_loaded_simscounts the blank lines of an outputs log #1255.simulate_convergencenow reachessimulate(a stub that raises) instead of returning early.All three fail on
develop(assert 4 == 2,DID NOT RAISE RuntimeError) and pass with the fix.Breaking change
Additional information
Tested on macOS arm64, Python 3.12.12:
pytest tests/unit/simulation/test_monte_carlo*.py tests/unit/simulation/test_append_lineage.py: 213 passed, 15 skipped, 1 failed. The failure (test_ellipses_reports_an_image_path_that_does_not_exist) is the optionalimageiodependency not being installed and is the same without this change.pytest tests/integration/simulation/test_monte_carlo.py: 6 passed, 5 skipped.Fixes #1255
This PR was prepared with AI assistance (Claude Code).
🤖 Generated with Claude Code