Skip to content

fix(cli): add evaluation cache to miner score stub#1191

Merged
anderdc merged 1 commit into
entrius:testfrom
statxc:fix/miner-score-evaluation-cache-stub
May 14, 2026
Merged

fix(cli): add evaluation cache to miner score stub#1191
anderdc merged 1 commit into
entrius:testfrom
statxc:fix/miner-score-evaluation-cache-stub

Conversation

@statxc
Copy link
Copy Markdown
Contributor

@statxc statxc commented May 12, 2026

Summary

gitt miner score runs the validator scoring pipeline through _StubValidator, which avoids the real validator runtime dependencies. After #1040, get_rewards() always calls self.evaluation_cache.evict_many(penalized_uids), but the CLI stub did not define evaluation_cache.

This PR adds a lazy MinerEvaluationCache factory and wires it onto _StubValidator, matching the validator surface now required by get_rewards() while keeping CLI imports lightweight.

Changes

  • Add _new_evaluation_cache() to lazily construct MinerEvaluationCache.
  • Attach self.evaluation_cache in _StubValidator.__init__.
  • Add regression coverage that exercises the real oss_contributions -> get_rewards path instead of mocking oss_contributions away.

Testing

.venv/bin/python -m pytest tests/cli/test_miner_score.py tests/validator/test_validator_cache_fallback.py -q
.venv/bin/python -m pytest tests/cli -q
.venv/bin/python -m ruff check gittensor/cli/miner_commands/score.py tests/cli/test_miner_score.py tests/validator/test_validator_cache_fallback.py
.venv/bin/python -m ruff format --check gittensor/cli/miner_commands/score.py tests/cli/test_miner_score.py
.venv/bin/python -m compileall -q gittensor/cli/miner_commands/score.py tests/cli/test_miner_score.py
git diff --check
UV_CACHE_DIR=/tmp/uv-cache .venv/bin/python -m pre_commit run --files gittensor/cli/miner_commands/score.py tests/cli/test_miner_score.py

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 12, 2026
@anderdc anderdc added refactor Code restructuring without behavior change and removed bug Something isn't working labels May 14, 2026
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

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

Take the guard at the call site instead. In gittensor/validator/oss_contributions/reward.py:143, wrap the eviction in if penalized_uids: — the single-miner dev flow never produces penalized UIDs, so the attribute is never accessed and the stub stays minimal. Drop the _new_evaluation_cache factory and _StubValidator.evaluation_cache change from this PR. Keep the new test — that lower-mock shape (patching only evaluate_miners_pull_requests) is the right coverage gap to close.

@statxc statxc force-pushed the fix/miner-score-evaluation-cache-stub branch from b0a12a0 to 312d352 Compare May 14, 2026 03:08
@statxc
Copy link
Copy Markdown
Contributor Author

statxc commented May 14, 2026

Hi @anderdc how are you? I've solved this correctly. Thanks for reviewing.
Could you add bug label on this PR? In my opinion, this PR means bug fix too.

@statxc statxc force-pushed the fix/miner-score-evaluation-cache-stub branch from 312d352 to c77ae2d Compare May 14, 2026 03:22
@statxc statxc force-pushed the fix/miner-score-evaluation-cache-stub branch from c77ae2d to f7582a1 Compare May 14, 2026 09:24
@anderdc anderdc merged commit a1c1b82 into entrius:test May 14, 2026
3 checks passed
@statxc
Copy link
Copy Markdown
Contributor Author

statxc commented May 14, 2026

Thanks @anderdc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants