Skip to content

Fix switch_ts to reset state & clean up IRC when switching TS guesses#866

Merged
alongd merged 1 commit intomainfrom
ts_switch_bugs
Apr 13, 2026
Merged

Fix switch_ts to reset state & clean up IRC when switching TS guesses#866
alongd merged 1 commit intomainfrom
ts_switch_bugs

Conversation

@calvinp0
Copy link
Copy Markdown
Member

When a TS guess fails validation (e.g., NMD check), switch_ts picks the next guess but previously left stale state behind:

  1. IRC species from the invalidated guess were never cleaned up. delete_all_species_jobs('TS0') only deletes jobs under the TS0 label, but IRC species like IRC_TS0_1 are separate entries in running_jobs/species_dict/etc. These orphaned species
    continued running in parallel with the new guess, potentially interfering with job processing.
  2. job_types flags (freq, sp, opt) were never reset. After guess N's freq completed, job_types['freq'] = True carried over to guess N+1, causing the scheduler to skip re-running freq for the new geometry.
  3. convergence was never reset to None.
  4. The old line self.output[label]['geo'] = ... wrote to the wrong dict level (top-level keys instead of self.output[label]['paths']), making it dead code.
  5. Pending pipe batches from the old guess were never discarded.

Copy link
Copy Markdown

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

Fixes Scheduler.switch_ts() to properly reset state when a TS guess is invalidated, preventing stale jobs/flags from affecting the next TS guess.

Changes:

  • Clean up IRC species spawned from the invalidated TS guess (remove jobs, output, species entries, labels).
  • Reset per-label output[label]['job_types'] flags and convergence so the next guess re-runs the pipeline.
  • Discard pending pipe-batch entries for the invalidated TS label/directions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
arc/scheduler.py Adds TS-switch cleanup for IRC species, resets job state, and clears pending pipe batches.
arc/scheduler_test.py Adds a unit test intended to validate the cleanup/reset behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread arc/scheduler.py Outdated
Comment thread arc/scheduler_test.py Outdated
Comment thread arc/scheduler_test.py Outdated
Comment thread arc/scheduler_test.py Outdated
@calvinp0 calvinp0 requested a review from Copilot April 11, 2026 09:26
Copy link
Copy Markdown

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread arc/scheduler_test.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.30%. Comparing base (32a8ea1) to head (03fdcba).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #866      +/-   ##
==========================================
+ Coverage   60.11%   60.30%   +0.19%     
==========================================
  Files         102      102              
  Lines       31045    31073      +28     
  Branches     8087     8097      +10     
==========================================
+ Hits        18664    18740      +76     
+ Misses      10067     9994      -73     
- Partials     2314     2339      +25     
Flag Coverage Δ
functionaltests 60.30% <ø> (+0.19%) ⬆️
unittests 60.30% <ø> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copy link
Copy Markdown
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Looks good, but I think the addition should be inside delete_all_species_jobs()

@calvinp0
Copy link
Copy Markdown
Member Author

Looks good, but I think the addition should be inside delete_all_species_jobs()
@alongd I made the change, but also in an arc run found another TS bug, so I added it - so please be aware of this:
https://github.com/ReactionMechanismGenerator/ARC/pull/866/changes#diff-556ad66547f14f3f9a3915808a05b59151ee8216b817845d8d716577c0aeb5ebR3557

Copy link
Copy Markdown
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Thanks, added two comments

Comment thread arc/scheduler.py Outdated
Comment thread arc/scheduler.py Outdated
  When a TS guess fails validation (e.g., NMD check), switch_ts picks the next guess but previously left stale state behind:

  1. IRC species from the invalidated guess were never cleaned up. delete_all_species_jobs('TS0') only deletes jobs under the TS0 label, but IRC species like IRC_TS0_1 are separate entries in running_jobs/species_dict/etc. These orphaned species
  continued running in parallel with the new guess, potentially interfering with job processing.
  2. job_types flags (freq, sp, opt) were never reset. After guess N's freq completed, job_types['freq'] = True carried over to guess N+1, causing the scheduler to skip re-running freq for the new geometry.
  3. convergence was never reset to None.
  4. The old line self.output[label]['geo'] = ... wrote to the wrong dict level (top-level keys instead of self.output[label]['paths']), making it dead code.
  5. Pending pipe batches from the old guess were never discarded.
@calvinp0 calvinp0 requested a review from alongd April 13, 2026 15:08
@alongd alongd merged commit aac97f7 into main Apr 13, 2026
8 checks passed
@alongd alongd deleted the ts_switch_bugs branch April 13, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants