Skip to content

Add helper methods to eliminate duplicate null checks#47

Open
sarvanithin wants to merge 2 commits intowithmartian:mainfrom
sarvanithin:refactor/add-null-check-helpers
Open

Add helper methods to eliminate duplicate null checks#47
sarvanithin wants to merge 2 commits intowithmartian:mainfrom
sarvanithin:refactor/add-null-check-helpers

Conversation

@sarvanithin
Copy link
Contributor

  • Add _require_container() and _require_task() helper methods to CodeBaseEnv
  • Update SweBenchEnv to use helpers instead of duplicate if/raise patterns
  • Remove TODO comment about duplicate checks
  • Improves code reusability and maintainability

Both helpers raise RuntimeError with clear messages if state is invalid.

- Add _require_container() and _require_task() helper methods to CodeBaseEnv
- Update SweBenchEnv to use helpers instead of duplicate if/raise patterns
- Remove TODO comment about duplicate checks
- Improves code reusability and maintainability

Both helpers raise RuntimeError with clear messages if state is invalid.
Copy link
Contributor

@rsmith49 rsmith49 left a comment

Choose a reason for hiding this comment

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

Nice find, thanks @sarvanithin! Can you add the _require_container and _require_task checks to HarborEnv as well? Then I'll go ahead and merge 🙌

- Update _start_container() to use _require_task() helper
- Update _start_code_agent() to use both helpers
- Update _compute_reward() to use both helpers
- Update _parse_reward_file() to use _require_container() helper
- Consistent error handling across all environment implementations
@rsmith49
Copy link
Contributor

Looks like the changes conflict with some of the changes to HarborEnv - do you mind resolving those? Shouldn't be too much to fix

@sarvanithin
Copy link
Contributor Author

@rsmith49 Conflicts resolved! All 82 tests passing. Ready for review.
thanks!

@rsmith49
Copy link
Contributor

Looks like you accidentally included the state snapshot changes here as well - are you able to take that piece back out?

@sarvanithin sarvanithin force-pushed the refactor/add-null-check-helpers branch from 77c9a5c to 3609560 Compare January 26, 2026 22:56
@sarvanithin
Copy link
Contributor Author

Fixed both issues:

  1. Removed snapshot changes - those belong in PR Add environment state snapshotting for RL research #53
  2. Removed duplicate helper methods

This PR now only contains the original helper method changes. All 67 tests passing.

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