Skip to content

Commit

Permalink
Import/type fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking committed Jan 10, 2025
1 parent 46a1468 commit 5913108
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
15 changes: 9 additions & 6 deletions tests/e2e_tests/test_commit_reveal_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ async def test_commit_and_reveal_weights_cr3(local_chain):
# Change the tempo of the subnet from default 360
# Since this is in normal blocks, this is necessary
tempo_set = 10
assert sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_tempo",
call_params={"netuid": netuid, "tempo": tempo_set},
return_error_message=True,
assert (
sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_tempo",
call_params={"netuid": netuid, "tempo": tempo_set},
return_error_message=True,
)[0]
is True
)
tempo = subtensor.get_subnet_hyperparameters(netuid=netuid).tempo
assert tempo_set == tempo
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_set_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from bittensor.core.subtensor import Subtensor
from bittensor.utils.balance import Balance
from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit
from bittensor.core.extrinsics import utils
from tests.e2e_tests.utils.chain_interactions import (
add_stake,
register_subnet,
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e_tests/utils/chain_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bittensor import Wallet
from bittensor.core.subtensor import Subtensor
from bittensor.utils.balance import Balance
from substrateinterface import SubstrateInterface
from bittensor.utils.substrate_interface import SubstrateInterface, ExtrinsicReceipt


def sudo_set_hyperparameter_bool(
Expand Down Expand Up @@ -153,15 +153,15 @@ async def wait_interval(
and the provided tempo, then enters a loop where it periodically checks
the current block number until the next tempo interval starts.
"""
current_block = subtensor.get_current_block()
current_block = await subtensor.async_subtensor.get_current_block()
next_tempo_block_start = next_tempo(current_block, tempo, netuid)
last_reported = None

while current_block < next_tempo_block_start:
await asyncio.sleep(
1
) # Wait for 1 second before checking the block number again
current_block = subtensor.get_current_block()
current_block = await subtensor.async_subtensor.get_current_block()
if last_reported is None or current_block - last_reported >= reporting_interval:
last_reported = current_block
print(
Expand All @@ -179,7 +179,7 @@ def sudo_set_admin_utils(
call_function: str,
call_params: dict,
return_error_message: bool = False,
) -> Union[bool, tuple[bool, Optional[str]]]:
) -> tuple[bool, str]:
"""
Wraps the call in sudo to set hyperparameter values using AdminUtils.
Expand Down Expand Up @@ -207,7 +207,7 @@ def sudo_set_admin_utils(
extrinsic = substrate.create_signed_extrinsic(
call=sudo_call, keypair=wallet.coldkey
)
response = substrate.submit_extrinsic(
response: "ExtrinsicReceipt" = substrate.submit_extrinsic(
extrinsic,
wait_for_inclusion=True,
wait_for_finalization=True,
Expand All @@ -216,7 +216,7 @@ def sudo_set_admin_utils(
if return_error_message:
return response.is_success, response.error_message

return response.is_success
return response.is_success, ""


async def root_set_subtensor_hyperparameter_values(
Expand All @@ -225,7 +225,7 @@ async def root_set_subtensor_hyperparameter_values(
call_function: str,
call_params: dict,
return_error_message: bool = False,
) -> Union[bool, tuple[bool, Optional[str]]]:
) -> tuple[bool, str]:
"""
Sets liquid alpha values using AdminUtils. Mimics setting hyperparams
"""
Expand All @@ -236,7 +236,7 @@ async def root_set_subtensor_hyperparameter_values(
)
extrinsic = substrate.create_signed_extrinsic(call=call, keypair=wallet.coldkey)

response = substrate.submit_extrinsic(
response: "ExtrinsicReceipt" = substrate.submit_extrinsic(
extrinsic,
wait_for_inclusion=True,
wait_for_finalization=True,
Expand All @@ -245,4 +245,4 @@ async def root_set_subtensor_hyperparameter_values(
if return_error_message:
return response.is_success, response.error_message

return response.is_success
return response.is_success, ""

0 comments on commit 5913108

Please sign in to comment.