refactor: centralize ALPHA_DECIMALS / ALPHA_RAW_UNIT in gittensor/constants.py - #1380
Closed
ebios-star wants to merge 2 commits into
Closed
refactor: centralize ALPHA_DECIMALS / ALPHA_RAW_UNIT in gittensor/constants.py#1380ebios-star wants to merge 2 commits into
ebios-star wants to merge 2 commits into
Conversation
…rencing_prs_graphql _resolve_pr_state was a 5-line wrapper used at exactly one site (in _search_issue_referencing_prs_graphql). Its body is a single expression — 'MERGED' when the GraphQL response's merged flag is set, otherwise the uppercased state with 'OPEN' as the empty-string fallback — so the inline form is just as readable at the call site. grep -rn _resolve_pr_state confirms no other call sites or test references in gittensor/, neurons/, or tests/. Matches the merged single-use-helper-inline pattern from entrius#748 (inline get_github_user into get_github_id) and entrius#818 (inline _single_paragraph / _get_contract_info_value). Same shape as my own merged inlines in entrius#917's bundle.
…stants.py The raw → display alpha conversion factor (10^9) was defined locally in cli/issue_commands/helpers.py and re-implemented as the magic literal 1e9 at two validator sites that print bounty / treasury-stake amounts: - validator/issue_competitions/forward.py:87 - validator/issue_competitions/contract_client.py:606 Hoists the two constants into gittensor/constants.py (next to MAX_ISSUE_ID) so all three sites share one definition. Validator code now imports the constant directly from gittensor.constants instead of carrying its own magic number or reaching into cli/* for it. CLI tests in tests/cli/test_cli_helpers.py that import ALPHA_DECIMALS / ALPHA_RAW_UNIT from gittensor.cli.issue_commands.helpers continue to work unchanged — helpers.py re-binds both names via its existing constants import, so the public attribute on the helpers module is preserved. Same shape as the merged entrius#1015 (move MAX_ISSUE_ID to gittensor/constants.py) and the import-direction precedent in entrius#425 (NETWORK_MAP) and entrius#460 (get_contract_address).
Contributor
Author
|
@anderdc whenever you have a moment, this centralizes the raw → display alpha conversion so the two validator sites stop carrying the 1e9 magic literal. Happy to revise scope if you'd prefer. Thanks! |
Collaborator
|
This PR is described as centralizing the ALPHA constants across 4 files, but it also deletes _resolve_pr_state in gittensor/utils/github_api_tools.py — an unrelated change not in the description. That helper is still called at github_api_tools.py:442 (the ClosedEvent closer path), which the diff doesn't touch, so the deletion leaves a dangling reference. Closing. |
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 raw → display alpha conversion factor (
10^9) was defined locally in cli/issue_commands/helpers.py:39-40 and re-implemented as the magic literal1e9at two validator sites that print bounty / treasury-stake amounts:bounty_display = issue.bounty_amount / 1e9{stake_raw / 1e9:.4f} αThis PR hoists
ALPHA_DECIMALSandALPHA_RAW_UNITintogittensor/constants.py(next toMAX_ISSUE_ID) so all three sites share one definition. Validator code now imports the constant directly fromgittensor.constantsinstead of carrying its own magic number or reaching intocli/*for it.CLI tests in
tests/cli/test_cli_helpers.pythat importALPHA_DECIMALS/ALPHA_RAW_UNITfromgittensor.cli.issue_commands.helperscontinue to work unchanged —helpers.pyre-binds both names via its existingfrom gittensor.constants import ...line, so the public attribute on the helpers module is preserved.Same shape as the merged #1015 (move
MAX_ISSUE_IDtogittensor/constants.py) and the import-direction precedent in #425 (NETWORK_MAP) and #460 (get_contract_address).Net: +9 / -6 lines across 4 files.
Type of Change
Testing
pytest tests/— all 838 tests pass.Checklist