Skip to content

Commit b5530b3

Browse files
author
Roman
committed
Merge branch 'staging' into fix/zyzniewski/unittests_warnings
# Conflicts: # tests/unit_tests/extrinsics/test_registration.py
2 parents bdbcbb0 + 53762f7 commit b5530b3

40 files changed

+820
-528
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
python -m venv .venv
4040
. .venv/bin/activate
4141
python -m pip install --upgrade uv
42-
uv pip install ruff
42+
uv pip install ruff==0.11.5
4343
4444
- save_cache:
4545
name: Save cached ruff venv

.github/workflows/e2e-subtensor-tests.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
test_files=$(find tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
4242
# keep it here for future debug
4343
# test_files=$(find tests/e2e_tests -type f -name "test*.py" | grep -E 'test_(incentive|commit_weights|set_weights)\.py$' | jq -R -s -c 'split("\n") | map(select(. != ""))')
44-
echo "::set-output name=test-files::$test_files"
44+
echo "test-files=$test_files" >> "$GITHUB_OUTPUT"
4545
shell: bash
4646

4747
pull-docker-image:
@@ -101,5 +101,26 @@ jobs:
101101
- name: Load Docker Image
102102
run: docker load -i subtensor-localnet.tar
103103

104-
- name: Run tests
105-
run: uv run pytest ${{ matrix.test-file }} -s
104+
# - name: Run tests
105+
# run: uv run pytest ${{ matrix.test-file }} -s
106+
107+
- name: Run tests with retry
108+
run: |
109+
set +e
110+
for i in 1 2; do
111+
echo "🔁 Attempt $i: Running tests"
112+
uv run pytest ${{ matrix.test-file }} -s
113+
status=$?
114+
if [ $status -eq 0 ]; then
115+
echo "✅ Tests passed on attempt $i"
116+
break
117+
else
118+
echo "❌ Tests failed on attempt $i"
119+
if [ $i -eq 2 ]; then
120+
echo "Tests failed after 2 attempts"
121+
exit 1
122+
fi
123+
echo "Retrying..."
124+
sleep 5
125+
fi
126+
done

bittensor/core/async_subtensor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ async def does_hotkey_exist(
753753
return_val = (
754754
False
755755
if result is None
756+
# not the default key (0x0)
756757
else result != "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM"
757758
)
758759
return return_val
@@ -3005,7 +3006,7 @@ async def wait_for_block(self, block: Optional[int] = None):
30053006

30063007
async def handler(block_data: dict):
30073008
logging.debug(
3008-
f'reached block {block_data["header"]["number"]}. Waiting for block {target_block}'
3009+
f"reached block {block_data['header']['number']}. Waiting for block {target_block}"
30093010
)
30103011
if block_data["header"]["number"] >= target_block:
30113012
return True

bittensor/core/axon.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ def verify_custom(synapse: MyCustomSynapse):
504504
)
505505

506506
param_class = first_param.annotation
507-
assert issubclass(
508-
param_class, Synapse
509-
), "The first argument of forward_fn must inherit from bittensor.Synapse"
507+
assert issubclass(param_class, Synapse), (
508+
"The first argument of forward_fn must inherit from bittensor.Synapse"
509+
)
510510
request_name = param_class.__name__
511511

512512
async def endpoint(*args, **kwargs):
@@ -580,19 +580,19 @@ async def endpoint(*args, **kwargs):
580580
blacklist_sig = Signature(
581581
expected_params, return_annotation=Tuple[bool, str]
582582
)
583-
assert (
584-
signature(blacklist_fn) == blacklist_sig
585-
), f"The blacklist_fn function must have the signature: blacklist( synapse: {request_name} ) -> tuple[bool, str]"
583+
assert signature(blacklist_fn) == blacklist_sig, (
584+
f"The blacklist_fn function must have the signature: blacklist( synapse: {request_name} ) -> tuple[bool, str]"
585+
)
586586
if priority_fn:
587587
priority_sig = Signature(expected_params, return_annotation=float)
588-
assert (
589-
signature(priority_fn) == priority_sig
590-
), f"The priority_fn function must have the signature: priority( synapse: {request_name} ) -> float"
588+
assert signature(priority_fn) == priority_sig, (
589+
f"The priority_fn function must have the signature: priority( synapse: {request_name} ) -> float"
590+
)
591591
if verify_fn:
592592
verify_sig = Signature(expected_params, return_annotation=None)
593-
assert (
594-
signature(verify_fn) == verify_sig
595-
), f"The verify_fn function must have the signature: verify( synapse: {request_name} ) -> None"
593+
assert signature(verify_fn) == verify_sig, (
594+
f"The verify_fn function must have the signature: verify( synapse: {request_name} ) -> None"
595+
)
596596

597597
# Store functions in appropriate attribute dictionaries
598598
self.forward_class_types[request_name] = param_class
@@ -747,9 +747,9 @@ def check_config(cls, config: "Config"):
747747
Raises:
748748
AssertionError: If the axon or external ports are not in range [1024, 65535]
749749
"""
750-
assert (
751-
1024 < config.axon.port < 65535
752-
), "Axon port must be in range [1024, 65535]"
750+
assert 1024 < config.axon.port < 65535, (
751+
"Axon port must be in range [1024, 65535]"
752+
)
753753

754754
assert config.axon.external_port is None or (
755755
1024 < config.axon.external_port < 65535

bittensor/core/extrinsics/asyncex/staking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async def add_stake_extrinsic(
127127
logging.info(
128128
f":satellite: [magenta]Safe Staking to:[/magenta] "
129129
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
130-
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
130+
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
131131
f"price limit: [green]{rate_with_tolerance}[/green], "
132132
f"original price: [green]{base_rate}[/green], "
133133
f"with partial stake: [green]{allow_partial_stake}[/green] "

bittensor/core/extrinsics/asyncex/start_call.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import TYPE_CHECKING
22

3-
from bittensor.utils import unlock_key
3+
from bittensor.utils import unlock_key, format_error_message
44
from bittensor.utils.btlogging import logging
55

66
if TYPE_CHECKING:
@@ -58,4 +58,4 @@ async def start_call_extrinsic(
5858
if await response.is_success:
5959
return True, "Success with `start_call` response."
6060

61-
return False, await response.error_message
61+
return False, format_error_message(await response.error_message)

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def unstake_extrinsic(
106106
logging.info(
107107
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
108108
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
109-
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
109+
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
110110
f"price limit: [green]{rate_with_tolerance}[/green], "
111111
f"original price: [green]{base_rate}[/green], "
112112
f"with partial unstake: [green]{allow_partial_stake}[/green] "

bittensor/core/extrinsics/staking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def add_stake_extrinsic(
115115
logging.info(
116116
f":satellite: [magenta]Safe Staking to:[/magenta] "
117117
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
118-
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
118+
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
119119
f"price limit: [green]{rate_with_tolerance}[/green], "
120120
f"original price: [green]{base_rate}[/green], "
121121
f"with partial stake: [green]{allow_partial_stake}[/green] "

bittensor/core/extrinsics/start_call.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import TYPE_CHECKING
22

3-
from bittensor.utils import unlock_key
3+
from bittensor.utils import unlock_key, format_error_message
44
from bittensor.utils.btlogging import logging
55

66
if TYPE_CHECKING:
@@ -59,4 +59,4 @@ def start_call_extrinsic(
5959
if response.is_success:
6060
return True, "Success with `start_call` response."
6161

62-
return False, response.error_message
62+
return False, format_error_message(response.error_message)

bittensor/core/extrinsics/unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def unstake_extrinsic(
103103
logging.info(
104104
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
105105
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
106-
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
106+
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
107107
f"price limit: [green]{rate_with_tolerance}[/green], "
108108
f"original price: [green]{base_rate}[/green], "
109109
f"with partial unstake: [green]{allow_partial_stake}[/green] "

0 commit comments

Comments
 (0)