Skip to content

Commit e6c1f36

Browse files
authored
Merge pull request #2599 from opentensor/feat/roman/refactor
Make code as beautiful as it has never been before
2 parents 9d2d8ce + e75a0fc commit e6c1f36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+430
-932
lines changed

bittensor/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# The MIT License (MIT)
2-
# Copyright © 2024 Opentensor Foundation
3-
#
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5-
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
6-
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7-
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8-
#
9-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
10-
# the Software.
11-
#
12-
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13-
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14-
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16-
# DEALINGS IN THE SOFTWARE.
17-
181
import warnings
192

203
from .core.settings import __version__, version_split, DEFAULTS, DEFAULT_NETWORK

bittensor/__main__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# The MIT License (MIT)
2-
# Copyright © 2024 Opentensor Foundation
3-
#
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5-
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
6-
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7-
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8-
#
9-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
10-
# the Software.
11-
#
12-
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13-
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14-
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16-
# DEALINGS IN THE SOFTWARE.
17-
181
import os
192
import subprocess
203
import sys

bittensor/core/axon.py

Lines changed: 90 additions & 61 deletions
Large diffs are not rendered by default.

bittensor/core/chain_data/axon_info.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# The MIT License (MIT)
2-
# Copyright © 2024 Opentensor Foundation
3-
#
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5-
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
6-
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7-
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8-
#
9-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
10-
# the Software.
11-
#
12-
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13-
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14-
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16-
# DEALINGS IN THE SOFTWARE.
17-
181
"""
192
This module defines the `AxonInfo` class, a data structure used to represent information about an axon endpoint
203
in the bittensor network.
@@ -105,7 +88,8 @@ def from_string(cls, json_string: str) -> "AxonInfo":
10588
json_string (str): The JSON string representation of the AxonInfo object.
10689
10790
Returns:
108-
AxonInfo: An instance of AxonInfo created from the JSON string. If decoding fails, returns a default `AxonInfo` object with default values.
91+
AxonInfo: An instance of AxonInfo created from the JSON string. If decoding fails, returns a default
92+
`AxonInfo` object with default values.
10993
11094
Raises:
11195
json.JSONDecodeError: If there is an error in decoding the JSON string.

bittensor/core/chain_data/neuron_info.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ def from_weights_bonds_and_neuron_lite(
8282
8383
Args:
8484
neuron_lite (NeuronInfoLite): A lite version of the neuron containing basic attributes.
85-
weights_as_dict (dict[int, list[tuple[int, int]]]): A dictionary where the key is the UID and the value is a list of weight tuples associated with the neuron.
86-
bonds_as_dict (dict[int, list[tuple[int, int]]]): A dictionary where the key is the UID and the value is a list of bond tuples associated with the neuron.
85+
weights_as_dict (dict[int, list[tuple[int, int]]]): A dictionary where the key is the UID and the value is
86+
a list of weight tuples associated with the neuron.
87+
bonds_as_dict (dict[int, list[tuple[int, int]]]): A dictionary where the key is the UID and the value is a
88+
list of bond tuples associated with the neuron.
8789
8890
Returns:
8991
NeuronInfo: An instance of NeuronInfo populated with the provided weights and bonds.

bittensor/core/chain_data/subnet_hyperparameters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ def from_vec_u8(cls, vec_u8: bytes) -> Optional["SubnetHyperparameters"]:
7272
"""
7373
Create a `SubnetHyperparameters` instance from a vector of bytes.
7474
75-
This method decodes the given vector of bytes using the `bt_decode` module and creates a new instance of `SubnetHyperparameters` with the decoded values.
75+
This method decodes the given vector of bytes using the `bt_decode` module and creates a new instance of
76+
`SubnetHyperparameters` with the decoded values.
7677
7778
Args:
7879
vec_u8 (bytes): A vector of bytes to decode into `SubnetHyperparameters`.
7980
8081
Returns:
81-
Optional[SubnetHyperparameters]: An instance of `SubnetHyperparameters` if decoding is successful, None otherwise.
82+
Optional[SubnetHyperparameters]: An instance of `SubnetHyperparameters` if decoding is successful, None
83+
otherwise.
8284
"""
8385
decoded = bt_decode.SubnetHyperparameters.decode(vec_u8)
8486
return SubnetHyperparameters(

bittensor/core/config.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# The MIT License (MIT)
2-
# Copyright © 2024 Opentensor Foundation
3-
#
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5-
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
6-
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7-
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8-
#
9-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
10-
# the Software.
11-
#
12-
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13-
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14-
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16-
# DEALINGS IN THE SOFTWARE.
17-
181
"""Implementation of the config class, which manages the configuration of different Bittensor modules."""
192

203
import argparse
@@ -42,7 +25,8 @@ class Config(DefaultMunch):
4225
parser (argparse.ArgumentParser): Command line parser object.
4326
strict (bool): If ``true``, the command line arguments are strictly parsed.
4427
args (list of str): Command line arguments.
45-
default (Optional[Any]): Default value for the Config. Defaults to ``None``. This default will be returned for attributes that are undefined.
28+
default (Optional[Any]): Default value for the Config. Defaults to ``None``. This default will be returned for
29+
attributes that are undefined.
4630
4731
Returns:
4832
config (bittensor.core.config.Config): Nested config object created from parser arguments.

0 commit comments

Comments
 (0)