fix: isolate per-miner exceptions in OSS scoring loop - #996
Closed
plind-junior wants to merge 7 commits into
Closed
Conversation
Wrap the per-miner evaluate_miners_pull_requests call in try/except so a single miner's uncaught exception cannot abort the whole scoring round. Without this, any RecursionError / ValueError / etc. propagated through oss_contributions -> forward -> concurrent_forward -> the while-True at neurons/base/validator.py and silently killed the validator's daemon scoring thread, leaving the main thread to log "Validator running" indefinitely with no further forward passes. The crashed miner gets a MinerEvaluation with failed_reason set, so downstream skip-on-failure paths (cache, issue discovery, DB write) treat the miner as non-scoring this round without per-site awareness. Brings the OSS path to parity with issue_discovery/mirror_scan, which already isolates per-miner failures.
The repo doesn't ship pytest-asyncio in its dev extras, so @pytest.mark.asyncio silently warned-then-failed on CI. Switch to plain sync test functions that call asyncio.run(get_rewards(...)) — matches the rest of the test suite (no other test in this repo uses pytest-asyncio).
…tion-isolation # Conflicts: # gittensor/validator/oss_contributions/reward.py
…n' into fix/per-miner-exception-isolation
Collaborator
|
|
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
Wrap the per-miner
evaluate_miners_pull_requestscall ingittensor/validator/oss_contributions/reward.pyintry/except Exceptionso a single miner's uncaught exception cannot abort the whole scoring round.Without this, any unhandled exception (e.g.
RecursionErrorfrom #978,ValueErrorfrom #893, future schema-driftKeyError/AttributeError) propagates throughoss_contributions→forward→concurrent_forward→ thewhile Trueatneurons/base/validator.py:144-169. Theexcept Exceptionthere logs once andrun()returns. Becauserun()is the target of a daemon thread (base/validator.py:179), the scoring thread dies silently while the main thread keeps printingValidator running | uid X | ...every 30s — no further forward passes, no weight updates, until manual restart. After restart the validator re-fetches the same data and re-crashes on the same miner.The crashed miner now gets a
MinerEvaluation(uid=uid, hotkey=hotkey, failed_reason=...), so downstream skip-on-failure paths (MinerEvaluationCache.store_or_use_cached_evaluation,mirror_scan,repository.upsert_miner_evaluation) already treat the miner as non-scoring this round without any new per-site awareness.This is a safety net, not a substitute for fixing each specific exception class at source. It brings the OSS path to parity with
issue_discovery/mirror_scan.py:157-162, which already isolates per-miner failures.Related Issues
Closes #995
Related (independent vectors that fire this chain):
walk_nodein tree-sitter scoring can hit Python's recursion limit on deeply nested ASTs #978 —RecursionErrorfromtree_sitter_utils.walk_nodeon AST depth >1000ValueErrorfromMirrorClient._getresponse.json()not classified asMirrorRequestErrorType of Change
Testing
New
tests/validator/oss_contributions/test_reward.py:test_per_miner_exception_does_not_abort_round— boom on UID 3 (raisesRecursionError); asserts UIDs 1/2/4/5 are still scored, UID 3 carriesfailed_reason,get_rewardsreturns a normal(rewards, evaluations, cached_uids, penalized_uids)tuple.test_failed_reason_records_exception_class_and_message— asserts the substitutedMinerEvaluation.failed_reasonincludes both the exception class name and message, so post-hoc DB inspection can identify the vector that crashed a miner.Local verification:
Checklist
ruff check/ruff format --checkcleanException(notBaseException) soKeyboardInterrupt/SystemExitstill propagate