Reusable create_table() Utility for Consistent Table Styling#790
Reusable create_table() Utility for Consistent Table Styling#790thewhaleking merged 6 commits intoopentensor:stagingfrom
create_table() Utility for Consistent Table Styling#790Conversation
a8498e6 to
6046aa5
Compare
|
@thewhaleking please review this reusable table PR |
|
Hi @ibraheem-abe, this is another util from my end after success and error consistency. |
|
Thank you for your contribution This is a good idea - I would like to review this one in depth. Each existing table has been a result of multiple iterations and ideally we would like them to stay the same visually. Also I dont think we need these tests for the utility if the implementation is solid. |
|
@ibraheem-abe I removed the testing as it's not necessary |
|
Would also like @thewhaleking's eye on this |
Summary
This PR introduces a new
create_table()utility function that eliminates code duplication and ensures consistent table styling throughout the CLI. The function reduces repetitive table configuration code from 11+ lines down to 1-4 lines while maintaining full flexibility.Changes
New Utility Function
Added
create_table()tobittensor_cli/src/bittensor/utils.py:Refactored Locations
Updated three table creation sites in
bittensor_cli/src/commands/subnets/subnets.py:subnets_list()functionExamples
Pattern 1: Simple Table (Add Columns Later)
Before (11 lines):
After (2 lines):
Pattern 2: Table with Column Objects
Before (17 lines):
After (8 lines):
Pattern 3: Custom Overrides
Visual Examples
Here's how the tables look when rendered:
Manual Verification
Tested actual usage in the CLI commands:
Breaking Changes
None.
Files Changed
bittensor_cli/src/bittensor/utils.py- Addedcreate_table()functionbittensor_cli/src/commands/subnets/subnets.py- Refactored 3 table creationsbittensor_cli/src/commands/stake/bittensor_cli/src/commands/liquidity/bittensor_cli/src/commands/crowd/Contribution by Gittensor, learn more at https://gittensor.io/