Skip to content

Commit 682d79a

Browse files
committed
black line len 79
1 parent 2422b0c commit 682d79a

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

template/base/miner.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def set_weights(self):
201201
)
202202

203203
except Exception as e:
204-
bt.logging.error(f"Failed to set weights on chain with exception: { e }")
204+
bt.logging.error(
205+
f"Failed to set weights on chain with exception: { e }"
206+
)
205207

206208
bt.logging.info(f"Set weights: {chain_weights}")
207209

template/base/neuron.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ def __init__(self, config=None):
9191
self.check_registered()
9292

9393
# Each miner gets a unique identity (UID) in the network for differentiation.
94-
self.uid = self.metagraph.hotkeys.index(self.wallet.hotkey.ss58_address)
94+
self.uid = self.metagraph.hotkeys.index(
95+
self.wallet.hotkey.ss58_address
96+
)
9597
bt.logging.info(
9698
f"Running neuron on subnet: {self.config.netuid} with uid {self.uid} using network: {self.subtensor.chain_endpoint}"
9799
)

template/base/validator.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@ def serve_axon(self):
8484
pass
8585

8686
except Exception as e:
87-
bt.logging.error(f"Failed to create Axon initialize with exception: {e}")
87+
bt.logging.error(
88+
f"Failed to create Axon initialize with exception: {e}"
89+
)
8890
pass
8991

9092
async def concurrent_forward(self):
9193
coroutines = [
92-
self.forward() for _ in range(self.config.neuron.num_concurrent_forwards)
94+
self.forward()
95+
for _ in range(self.config.neuron.num_concurrent_forwards)
9396
]
9497
await asyncio.gather(*coroutines)
9598

@@ -148,7 +151,9 @@ def run(self):
148151
# In case of unforeseen errors, the validator will log the error and continue operations.
149152
except Exception as err:
150153
bt.logging.error("Error during validation", str(err))
151-
bt.logging.debug(print_exception(type(err), err, err.__traceback__))
154+
bt.logging.debug(
155+
print_exception(type(err), err, err.__traceback__)
156+
)
152157

153158
def run_in_background_thread(self):
154159
"""
@@ -268,7 +273,9 @@ def resync_metagraph(self):
268273
# If so, we need to add new hotkeys and moving averages.
269274
if len(self.hotkeys) < len(self.metagraph.hotkeys):
270275
# Update the size of the moving average scores.
271-
new_moving_average = torch.zeros((self.metagraph.n)).to(self.device)
276+
new_moving_average = torch.zeros((self.metagraph.n)).to(
277+
self.device
278+
)
272279
min_len = min(len(self.hotkeys), len(self.scores))
273280
new_moving_average[:min_len] = self.scores[:min_len]
274281
self.scores = new_moving_average

template/utils/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def add_args(cls, parser):
6363
# Netuid Arg: The netuid of the subnet to connect to.
6464
parser.add_argument("--netuid", type=int, help="Subnet netuid", default=1)
6565

66-
neuron_type = "validator" if "miner" not in cls.__name__.lower() else "miner"
66+
neuron_type = (
67+
"validator" if "miner" not in cls.__name__.lower() else "miner"
68+
)
6769

6870
parser.add_argument(
6971
"--neuron.name",

template/utils/uids.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def check_uid_availability(
2626
return True
2727

2828

29-
def get_random_uids(self, k: int, exclude: List[int] = None) -> torch.LongTensor:
29+
def get_random_uids(
30+
self, k: int, exclude: List[int] = None
31+
) -> torch.LongTensor:
3032
"""Returns k available random uids from the metagraph.
3133
Args:
3234
k (int): Number of uids to return.

template/validator/reward.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def get_rewards(
4949
- torch.FloatTensor: A tensor of rewards for the given query and responses.
5050
"""
5151
# Get all the reward results by iteratively calling your reward() function.
52-
return torch.FloatTensor([reward(query, response) for response in responses]).to(
53-
self.device
54-
)
52+
return torch.FloatTensor(
53+
[reward(query, response) for response in responses]
54+
).to(self.device)

tests/test_template_validator.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def test_dummy_responses(self):
6666

6767
responses = self.neuron.dendrite.query(
6868
# Send the query to miners in the network.
69-
axons=[self.neuron.metagraph.axons[uid] for uid in self.miner_uids],
69+
axons=[
70+
self.neuron.metagraph.axons[uid] for uid in self.miner_uids
71+
],
7072
# Construct a dummy query.
7173
synapse=Dummy(dummy_input=self.neuron.step),
7274
# All responses have the deserialize function called on them before returning.

0 commit comments

Comments
 (0)