refactor: dedupe store_*_bulk executemany blocks into BaseRepository.execute_bulk#1548
Closed
ebios-star wants to merge 1 commit into
Closed
refactor: dedupe store_*_bulk executemany blocks into BaseRepository.execute_bulk#1548ebios-star wants to merge 1 commit into
ebios-star wants to merge 1 commit into
Conversation
…execute_bulk
The three Repository.store_*_bulk methods repeated the same
try/executemany/commit/rollback/return-count block verbatim, differing only
in the query, the entity name in the error log, and (for file changes) one
extra log detail. Centralize the pattern as BaseRepository.execute_bulk,
the executemany sibling of the existing execute_command helper.
Behavior is unchanged. store_file_changes_bulk keeps its lazy " | PRs: {...}"
error context via the optional error_detail_fn, evaluated only on failure.
set_miner_evaluation is intentionally left untouched: it returns bool, not a
row count, so folding it in would change its contract.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@anderdc @LandynDev whenever you have a moment — this is a small, behavior-preserving consolidation of the three |
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.
Summary
The three
Repository.store_*_bulkmethods each repeated the sametry / executemany / commit / rollback / return-countblock verbatim:gittensor/validator/storage/repository.py—store_pull_requests_bulk,store_issues_bulk,store_file_changes_bulkThe only things that varied per site were the query constant, the entity name in the error message, and — for file changes only — one extra
| PRs: {...}log detail. This PR centralizes the block asBaseRepository.execute_bulk(), theexecutemanysibling of the existingexecute_command()helper that already lives on the same base class. Each call site collapses from an 11-line block to a single delegating call.Behavior is unchanged. Return values (
len(values)on success,0on failure), commit/rollback semantics, and the exact error-log strings are all preserved.store_file_changes_bulkkept its| PRs: {...}context via the optionalerror_detail_fn, which — like the original — is only evaluated on the failure path, so the success path does no extra work.The one structurally-different sibling is intentionally left untouched, since folding it in would change behavior:
set_miner_evaluationruns the sameexecutemanyshape but returnsbool(True/False), not a row count, and builds its rows frommaster_repositories. Its contract differs, so it stays as-is.Related Issues
None.
Type of Change
Testing
Added
tests/validator/test_execute_bulk.pycovering the new helper directly: success returns the row count and commits,commit=Falseskips the commit, the failure path rolls back and returns0, anderror_detail_fnis invoked only on failure. The existingstore_*_bulkcall sites are mocked at the boundary in the current suite, so the helper's internals were previously uncovered.Full suite passes (
uv run pytest→ 956 passed).ruff check,ruff format --check, andpyrightare all clean. This is an internal validator/storage refactor with no CLI/output changes, so the CLI before/after evidence requirement does not apply.Checklist