Skip to content

Commit d6e9e24

Browse files
committed
Removed try:except
1 parent 0d7af81 commit d6e9e24

File tree

2 files changed

+33
-39
lines changed

2 files changed

+33
-39
lines changed

bittensor/core/async_subtensor.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -997,26 +997,23 @@ async def get_parents(
997997
parents [(proportion, parent)], and an error message (if applicable)
998998
"""
999999
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
1000-
try:
1001-
parents = await self.substrate.query(
1002-
module="SubtensorModule",
1003-
storage_function="ParentKeys",
1004-
params=[hotkey, netuid],
1005-
block_hash=block_hash,
1006-
reuse_block_hash=reuse_block,
1007-
)
1008-
if parents:
1009-
formatted_parents = []
1010-
for proportion, parent in parents.value:
1011-
# Convert U64 to int
1012-
formatted_child = decode_account_id(parent[0])
1013-
normalized_proportion = u64_normalized_float(proportion)
1014-
formatted_parents.append((normalized_proportion, formatted_child))
1015-
return True, formatted_parents, ""
1016-
else:
1017-
return True, [], ""
1018-
except SubstrateRequestException as e:
1019-
return False, [], format_error_message(e)
1000+
parents = await self.substrate.query(
1001+
module="SubtensorModule",
1002+
storage_function="ParentKeys",
1003+
params=[hotkey, netuid],
1004+
block_hash=block_hash,
1005+
reuse_block_hash=reuse_block,
1006+
)
1007+
if parents:
1008+
formatted_parents = []
1009+
for proportion, parent in parents.value:
1010+
# Convert U64 to int
1011+
formatted_child = decode_account_id(parent[0])
1012+
normalized_proportion = u64_normalized_float(proportion)
1013+
formatted_parents.append((normalized_proportion, formatted_child))
1014+
return True, formatted_parents, ""
1015+
else:
1016+
return True, [], ""
10201017

10211018
async def get_children(
10221019
self,

bittensor/core/subtensor.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -767,25 +767,22 @@ def get_parents(
767767
A tuple containing a boolean indicating success or failure, a list of formatted
768768
parents [(proportion, parent)], and an error message (if applicable)
769769
"""
770-
try:
771-
parents = self.substrate.query(
772-
module="SubtensorModule",
773-
storage_function="ParentKeys",
774-
params=[hotkey, netuid],
775-
block_hash=self.determine_block_hash(block),
776-
)
777-
if parents:
778-
formatted_parents = []
779-
for proportion, parent in parents.value:
780-
# Convert U64 to int
781-
formatted_child = decode_account_id(parent[0])
782-
normalized_proportion = u64_normalized_float(proportion)
783-
formatted_parents.append((normalized_proportion, formatted_child))
784-
return True, formatted_parents, ""
785-
else:
786-
return True, [], ""
787-
except SubstrateRequestException as e:
788-
return False, [], format_error_message(e)
770+
parents = self.substrate.query(
771+
module="SubtensorModule",
772+
storage_function="ParentKeys",
773+
params=[hotkey, netuid],
774+
block_hash=self.determine_block_hash(block),
775+
)
776+
if parents:
777+
formatted_parents = []
778+
for proportion, parent in parents.value:
779+
# Convert U64 to int
780+
formatted_child = decode_account_id(parent[0])
781+
normalized_proportion = u64_normalized_float(proportion)
782+
formatted_parents.append((normalized_proportion, formatted_child))
783+
return True, formatted_parents, ""
784+
else:
785+
return True, [], ""
789786

790787
def get_children(
791788
self, hotkey: str, netuid: int, block: Optional[int] = None

0 commit comments

Comments
 (0)