Skip to content

Commit a641141

Browse files
authored
Merge branch 'staging' into feat/thewhaleking/add-timestamp
2 parents b9561dd + 380c5a3 commit a641141

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

bittensor/core/dendrite.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,14 @@ def __del__(self):
877877
# ... some operations ...
878878
del dendrite # This will implicitly invoke the __del__ method and close the session.
879879
"""
880-
self.close_session()
880+
try:
881+
self.close_session()
882+
except RuntimeError:
883+
if self._session:
884+
logging.debug(
885+
"A Dendrite session was unable to be closed during garbage-collection of the Dendrite object. This "
886+
"usually indicates that you were not using the async context manager."
887+
)
881888

882889

883890
# For back-compatibility with torch

tests/e2e_tests/test_commit_weights.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall
267267
assert success is True
268268

269269
# Wait a few blocks
270-
await asyncio.sleep(2) # Wait for the txs to be included in the chain
270+
await asyncio.sleep(10) # Wait for the txs to be included in the chain
271271

272272
# Query the WeightCommits storage map for all three salts
273273
weight_commits = subtensor.query_module(

tests/e2e_tests/utils/chain_interactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async def wait_epoch(subtensor: "Subtensor", netuid: int = 1):
8181
q_tempo = [v for (k, v) in subtensor.query_map_subtensor("Tempo") if k == netuid]
8282
if len(q_tempo) == 0:
8383
raise Exception("could not determine tempo")
84-
tempo = q_tempo[0]
84+
tempo = q_tempo[0].value
8585
logging.info(f"tempo = {tempo}")
8686
await wait_interval(tempo, subtensor, netuid)
8787

tests/e2e_tests/utils/e2e_test_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,7 @@ def clone_or_update_templates(specific_commit=None):
7878
return install_dir + templates_repo
7979

8080

81-
def install_templates(install_dir):
82-
subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", "."])
83-
84-
8581
def uninstall_templates(install_dir):
86-
subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "bittensor", "-y"])
8782
# Delete everything in directory
8883
shutil.rmtree(install_dir)
8984

@@ -93,7 +88,6 @@ def __init__(self):
9388
self.dir = clone_or_update_templates()
9489

9590
def __enter__(self):
96-
install_templates(self.dir)
9791
return self
9892

9993
def __exit__(self, exc_type, exc_value, traceback):

tests/unit_tests/test_dendrite.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ def test_close(setup_dendrite, setup_axon):
8383
assert setup_dendrite._session is None
8484

8585

86+
def test_garbage_collection(setup_dendrite):
87+
del setup_dendrite # should not raise an error
88+
89+
90+
@pytest.mark.asyncio
91+
async def test_async_garbage_collection(setup_dendrite, setup_axon):
92+
async with setup_dendrite as dendrite:
93+
assert (await dendrite.session) is not None
94+
del setup_dendrite # should not raise error
95+
96+
8697
@pytest.mark.asyncio
8798
async def test_aclose(setup_dendrite, setup_axon):
8899
axon = setup_axon

0 commit comments

Comments
 (0)