Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Remove legacy Pydantic references #1945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bittensor/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def body_hash(self) -> str:

if required_hash_fields:
instance_fields = self.model_dump()
# Preserve backward compatibility in which fields will added in .dict() order
# Preserve backward compatibility in which fields will added in .model_dump() order
# instead of the order one from `self.required_hash_fields`
required_hash_fields = [
field for field in instance_fields if field in required_hash_fields
Expand All @@ -715,7 +715,7 @@ def body_hash(self) -> str:
required_hash_fields = self.__class__.required_hash_fields

if required_hash_fields:
instance_fields = instance_fields or self.dict()
instance_fields = instance_fields or self.model_dump()
for field in required_hash_fields:
hashes.append(bittensor.utils.hash(str(instance_fields[field])))

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class SynapseHTTPClient(TestClient):
def post_synapse(self, synapse: Synapse):
return self.post(
f"/{synapse.__class__.__name__}",
json=synapse.dict(),
json=synapse.model_dump(),
headers={"computed_body_hash": synapse.body_hash},
)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_dendrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async def test_dendrite__call__success_response(
input_synapse = SynapseDummy(input=1)
expected_synapse = SynapseDummy(
**(
input_synapse.dict()
input_synapse.model_dump()
| dict(
output=2,
axon=TerminalInfo(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_body_hash_override():

def test_default_instance_fields_dict_consistency():
synapse_instance = bittensor.Synapse()
assert synapse_instance.dict() == {
assert synapse_instance.model_dump() == {
"name": "Synapse",
"timeout": 12.0,
"total_size": 0,
Expand Down